commit 29f0c3cd54d66cefd2a7899060b02a7c603b01eb parent 2f990aab82f1973c1168a56b6c51fc229d1604f3 Author: Botond Ballo <botond@mozilla.com> Date: Tue, 25 Nov 2025 04:50:45 +0000 Bug 2001862 - Introduce ActiveScrolledRoot::LowestCommonAncestor. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D273758 Diffstat:
| M | layout/painting/nsDisplayList.h | | | 24 | ++++++++++++++++++++++++ |
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h @@ -199,6 +199,30 @@ struct ActiveScrolledRoot { return Depth(aOne) <= Depth(aTwo) ? aOne : aTwo; } + static const ActiveScrolledRoot* LowestCommonAncestor( + const ActiveScrolledRoot* aOne, const ActiveScrolledRoot* aTwo) { + uint32_t depth1 = Depth(aOne); + uint32_t depth2 = Depth(aTwo); + if (depth1 > depth2) { + for (uint32_t i = 0; i < (depth1 - depth2); ++i) { + MOZ_ASSERT(aOne); + aOne = aOne->mParent; + } + } else if (depth1 < depth2) { + for (uint32_t i = 0; i < (depth2 - depth1); ++i) { + MOZ_ASSERT(aTwo); + aTwo = aTwo->mParent; + } + } + while (aOne != aTwo) { + MOZ_ASSERT(aOne); + MOZ_ASSERT(aTwo); + aOne = aOne->mParent; + aTwo = aTwo->mParent; + } + return aOne; + } + static const ActiveScrolledRoot* PickDescendant( const ActiveScrolledRoot* aOne, const ActiveScrolledRoot* aTwo) { MOZ_ASSERT(IsAncestor(aOne, aTwo) || IsAncestor(aTwo, aOne));