Bug 1384616 - Save APZ-relevant data from fixed-pos items in the WR scroll data for layers-free transactions. r?jrmuizel
MozReview-Commit-ID: HAFnrCVM9pZ
--- a/gfx/layers/wr/WebRenderScrollData.h
+++ b/gfx/layers/wr/WebRenderScrollData.h
@@ -69,16 +69,17 @@ public:
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
void SetReferentId(uint64_t aReferentId) { mReferentId = Some(aReferentId); }
Maybe<uint64_t> GetReferentId() const { return mReferentId; }
EventRegionsOverride GetEventRegionsOverride() const { return mEventRegionsOverride; }
const ScrollThumbData& GetScrollThumbData() const { return mScrollThumbData; }
const uint64_t& GetScrollbarAnimationId() const { return mScrollbarAnimationId; }
FrameMetrics::ViewID GetScrollbarTargetContainerId() const { return mScrollbarTargetContainerId; }
bool IsScrollbarContainer() const { return mIsScrollbarContainer; }
+ void SetFixedPositionScrollContainerId(FrameMetrics::ViewID aId) { mFixedPosScrollContainerId = aId; }
FrameMetrics::ViewID GetFixedPositionScrollContainerId() const { return mFixedPosScrollContainerId; }
void Dump(const WebRenderScrollData& aOwner) const;
friend struct IPC::ParamTraits<WebRenderLayerScrollData>;
private:
// The number of descendants this layer has (not including the layer itself).
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2082,23 +2082,30 @@ nsLayoutUtils::SetFixedPositionLayerData
} else {
anchor.y = anchorRect.YMost();
}
} else if (position->mOffset.GetTopUnit() != eStyleUnit_Auto) {
sides |= eSideBitsTop;
}
}
+ ViewID id = ScrollIdForRootScrollFrame(aPresContext);
+ aLayer->SetFixedPositionData(id, anchor, sides);
+}
+
+FrameMetrics::ViewID
+nsLayoutUtils::ScrollIdForRootScrollFrame(nsPresContext* aPresContext)
+{
ViewID id = FrameMetrics::NULL_SCROLL_ID;
if (nsIFrame* rootScrollFrame = aPresContext->PresShell()->GetRootScrollFrame()) {
if (nsIContent* content = rootScrollFrame->GetContent()) {
id = FindOrCreateIDFor(content);
}
}
- aLayer->SetFixedPositionData(id, anchor, sides);
+ return id;
}
bool
nsLayoutUtils::ViewportHasDisplayPort(nsPresContext* aPresContext)
{
nsIFrame* rootScrollFrame =
aPresContext->PresShell()->GetRootScrollFrame();
return rootScrollFrame &&
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -568,16 +568,22 @@ public:
*/
static void SetFixedPositionLayerData(Layer* aLayer, const nsIFrame* aViewportFrame,
const nsRect& aAnchorRect,
const nsIFrame* aFixedPosFrame,
nsPresContext* aPresContext,
const ContainerLayerParameters& aContainerParameters);
/**
+ * Get the scroll id for the root scrollframe of the presshell of the given
+ * prescontext. Returns NULL_SCROLL_ID if it couldn't be found.
+ */
+ static FrameMetrics::ViewID ScrollIdForRootScrollFrame(nsPresContext* aPresContext);
+
+ /**
* Return true if aPresContext's viewport has a displayport.
*/
static bool ViewportHasDisplayPort(nsPresContext* aPresContext);
/**
* Return true if aFrame is a fixed-pos frame and is a child of a viewport
* which has a displayport. These frames get special treatment from the compositor.
* aDisplayPort, if non-null, is set to the display port rectangle (relative to
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6683,16 +6683,28 @@ bool nsDisplayFixedPosition::TryMerge(ns
if (other->mFrame != mFrame)
return false;
if (aItem->GetClipChain() != GetClipChain())
return false;
MergeFromTrackingMergedFrames(other);
return true;
}
+bool
+nsDisplayFixedPosition::UpdateScrollData(mozilla::layers::WebRenderScrollData* aData,
+ mozilla::layers::WebRenderLayerScrollData* aLayerData)
+{
+ if (aLayerData) {
+ FrameMetrics::ViewID id = nsLayoutUtils::ScrollIdForRootScrollFrame(
+ Frame()->PresContext());
+ aLayerData->SetFixedPositionScrollContainerId(id);
+ }
+ return true;
+}
+
TableType
GetTableTypeFromFrame(nsIFrame* aFrame)
{
if (aFrame->IsTableFrame()) {
return TableType::TABLE;
}
if (aFrame->IsTableColFrame()) {
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -4292,16 +4292,19 @@ public:
virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) override { return mIsFixedBackground; }
virtual uint32_t GetPerFrameKey() override { return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); }
AnimatedGeometryRoot* AnimatedGeometryRootForScrollMetadata() const override {
return mAnimatedGeometryRootForScrollMetadata;
}
+ virtual bool UpdateScrollData(mozilla::layers::WebRenderScrollData* aData,
+ mozilla::layers::WebRenderLayerScrollData* aLayerData) override;
+
protected:
// For background-attachment:fixed
nsDisplayFixedPosition(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList, uint32_t aIndex);
void Init(nsDisplayListBuilder* aBuilder);
AnimatedGeometryRoot* mAnimatedGeometryRootForScrollMetadata;
uint32_t mIndex;