From 5d9fe8f9ea4c5553ef7a25c39520f5ef4e52b26b Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Sat, 25 Jan 2020 10:25:16 +0000 Subject: [PATCH] Bug 1594451 - Propagate sticky position info to HitTestingNode. r=botond Differential Revision: https://phabricator.services.mozilla.com/D60065 --HG-- extra : moz-landing-system : lando --- gfx/layers/LayerMetricsWrapper.h | 25 +++++++++++++++++++ gfx/layers/apz/src/APZCTreeManager.cpp | 10 ++++++++ gfx/layers/apz/src/HitTestingTreeNode.cpp | 22 ++++++++++++++++ gfx/layers/apz/src/HitTestingTreeNode.h | 12 +++++++++ gfx/layers/wr/WebRenderScrollDataWrapper.h | 29 ++++++++++++++++++++++ 5 files changed, 98 insertions(+) diff --git a/gfx/layers/LayerMetricsWrapper.h b/gfx/layers/LayerMetricsWrapper.h index 08ef29d997ab..585df97e2446 100644 --- a/gfx/layers/LayerMetricsWrapper.h +++ b/gfx/layers/LayerMetricsWrapper.h @@ -411,6 +411,7 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { ScrollableLayerGuid::ViewID GetFixedPositionScrollContainerId() const { MOZ_ASSERT(IsValid()); + // TODO: Restrict this only for AtBottomLayer. return mLayer->GetFixedPositionScrollContainerId(); } @@ -420,6 +421,30 @@ class MOZ_STACK_CLASS LayerMetricsWrapper final { return mLayer->GetFixedPositionSides(); } + bool GetIsStickyPosition() const { + MOZ_ASSERT(IsValid()); + + return mLayer->GetIsStickyPosition(); + } + + ScrollableLayerGuid::ViewID GetStickyScrollContainerId() const { + MOZ_ASSERT(IsValid()); + + // TODO: Restrict this only for AtBottomLayer. + return mLayer->GetStickyScrollContainerId(); + } + + const LayerRectAbsolute& GetStickyScrollRangeOuter() const { + MOZ_ASSERT(IsValid()); + + return mLayer->GetStickyScrollRangeOuter(); + } + const LayerRectAbsolute& GetStickyScrollRangeInner() const { + MOZ_ASSERT(IsValid()); + + return mLayer->GetStickyScrollRangeInner(); + } + Maybe GetZoomAnimationId() const { MOZ_ASSERT(IsValid()); // This function is only really needed for template-compatibility with diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index bd639b1151d6..251d738dde3f 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1058,6 +1058,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId(), aLayer.GetFixedPositionSides(), aLayer.GetFixedPositionAnimationId()); + if (aLayer.GetIsStickyPosition()) { + node->SetStickyPosData(aLayer.GetStickyScrollContainerId(), + aLayer.GetStickyScrollRangeOuter(), + aLayer.GetStickyScrollRangeInner()); + } return node; } @@ -1284,6 +1289,11 @@ HitTestingTreeNode* APZCTreeManager::PrepareNodeForLayer( node->SetFixedPosData(aLayer.GetFixedPositionScrollContainerId(), aLayer.GetFixedPositionSides(), aLayer.GetFixedPositionAnimationId()); + if (aLayer.GetIsStickyPosition()) { + node->SetStickyPosData(aLayer.GetStickyScrollContainerId(), + aLayer.GetStickyScrollRangeOuter(), + aLayer.GetStickyScrollRangeInner()); + } return node; } diff --git a/gfx/layers/apz/src/HitTestingTreeNode.cpp b/gfx/layers/apz/src/HitTestingTreeNode.cpp index a0d5aa7a8645..89f33d0e3d37 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.cpp +++ b/gfx/layers/apz/src/HitTestingTreeNode.cpp @@ -30,6 +30,7 @@ HitTestingTreeNode::HitTestingTreeNode(AsyncPanZoomController* aApzc, mLockCount(0), mLayersId(aLayersId), mFixedPosTarget(ScrollableLayerGuid::NULL_SCROLL_ID), + mStickyPosTarget(ScrollableLayerGuid::NULL_SCROLL_ID), mIsBackfaceHidden(false), mIsAsyncZoomContainer(false), mOverride(EventRegionsOverride::NoOverride) { @@ -163,6 +164,27 @@ void HitTestingTreeNode::SetPrevSibling(HitTestingTreeNode* aSibling) { } } +void HitTestingTreeNode::SetStickyPosData( + ScrollableLayerGuid::ViewID aStickyPosTarget, + const LayerRectAbsolute& aScrollRangeOuter, + const LayerRectAbsolute& aScrollRangeInner) { + mStickyPosTarget = aStickyPosTarget; + mStickyScrollRangeOuter = aScrollRangeOuter; + mStickyScrollRangeInner = aScrollRangeInner; +} + +ScrollableLayerGuid::ViewID HitTestingTreeNode::GetStickyPosTarget() const { + return mStickyPosTarget; +} + +const LayerRectAbsolute& HitTestingTreeNode::GetStickyScrollRangeOuter() const { + return mStickyScrollRangeOuter; +} + +const LayerRectAbsolute& HitTestingTreeNode::GetStickyScrollRangeInner() const { + return mStickyScrollRangeInner; +} + void HitTestingTreeNode::MakeRoot() { mParent = nullptr; diff --git a/gfx/layers/apz/src/HitTestingTreeNode.h b/gfx/layers/apz/src/HitTestingTreeNode.h index 0acaf42bf220..9ad0bf3bdb04 100644 --- a/gfx/layers/apz/src/HitTestingTreeNode.h +++ b/gfx/layers/apz/src/HitTestingTreeNode.h @@ -132,6 +132,14 @@ class HitTestingTreeNode { SideBits GetFixedPosSides() const; Maybe GetFixedPositionAnimationId() const; + /* Sticky pos info */ + void SetStickyPosData(ScrollableLayerGuid::ViewID aStickyPosTarget, + const LayerRectAbsolute& aScrollRangeOuter, + const LayerRectAbsolute& aScrollRangeInner); + ScrollableLayerGuid::ViewID GetStickyPosTarget() const; + const LayerRectAbsolute& GetStickyScrollRangeOuter() const; + const LayerRectAbsolute& GetStickyScrollRangeInner() const; + /* Convert |aPoint| into the LayerPixel space for the layer corresponding to * this node. |aTransform| is the complete (content + async) transform for * this node. */ @@ -193,6 +201,10 @@ class HitTestingTreeNode { ScrollableLayerGuid::ViewID mFixedPosTarget; SideBits mFixedPosSides; + ScrollableLayerGuid::ViewID mStickyPosTarget; + LayerRectAbsolute mStickyScrollRangeOuter; + LayerRectAbsolute mStickyScrollRangeInner; + /* Let {L,M} be the {layer, scrollable metrics} pair that this node * corresponds to in the layer tree. mEventRegions contains the event regions * from L, in the case where event-regions are enabled. If event-regions are diff --git a/gfx/layers/wr/WebRenderScrollDataWrapper.h b/gfx/layers/wr/WebRenderScrollDataWrapper.h index 547fb23ee555..d4b1e55da59b 100644 --- a/gfx/layers/wr/WebRenderScrollDataWrapper.h +++ b/gfx/layers/wr/WebRenderScrollDataWrapper.h @@ -374,6 +374,35 @@ class MOZ_STACK_CLASS WebRenderScrollDataWrapper final { return mLayer->GetFixedPositionSides(); } + bool GetIsStickyPosition() const { + MOZ_ASSERT(IsValid()); + + // TODO: Bug 1610731 Implement this for WebRender. + return false; + } + + ScrollableLayerGuid::ViewID GetStickyScrollContainerId() const { + MOZ_ASSERT(IsValid()); + + // TODO: Bug 1610731 Implement this for WebRender. + return ScrollableLayerGuid::NULL_SCROLL_ID; + } + + const LayerRectAbsolute& GetStickyScrollRangeOuter() const { + MOZ_ASSERT(IsValid()); + static const LayerRectAbsolute dummy; + + // TODO: Bug 1610731 Implement this for WebRender. + return dummy; + } + const LayerRectAbsolute& GetStickyScrollRangeInner() const { + MOZ_ASSERT(IsValid()); + static const LayerRectAbsolute dummy; + + // TODO: Bug 1610731 Implement this for WebRender. + return dummy; + } + Maybe GetZoomAnimationId() const { MOZ_ASSERT(IsValid()); return mLayer->GetZoomAnimationId();