commit e552e7599f7a19ff234390c32b52f8a64f38cc5f
parent b63f6bdd581f7b07696a01d03b0a1d7f9390d944
Author: Botond Ballo <botond@mozilla.com>
Date: Thu, 13 Nov 2025 04:59:02 +0000
Bug 1730749 - Add a static version of nsDisplayStickyPosition::ShouldGetStickyAnimationId() for use without a display item instance. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D254142
Diffstat:
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp
@@ -5355,16 +5355,21 @@ bool nsDisplayOwnLayer::IsStickyPositionLayer() const {
return GetType() == DisplayItemType::TYPE_STICKY_POSITION;
}
-bool nsDisplayOwnLayer::HasDynamicToolbar() const {
- if (!mFrame->PresContext()->IsRootContentDocumentCrossProcess()) {
+/* static */
+bool nsDisplayOwnLayer::HasDynamicToolbar(nsIFrame* aFrame) {
+ if (!aFrame->PresContext()->IsRootContentDocumentCrossProcess()) {
return false;
}
- return mFrame->PresContext()->HasDynamicToolbar() ||
+ return aFrame->PresContext()->HasDynamicToolbar() ||
// For tests on Android, this pref is set to simulate the dynamic
// toolbar
StaticPrefs::apz_fixed_margin_override_enabled();
}
+bool nsDisplayOwnLayer::HasDynamicToolbar() const {
+ return HasDynamicToolbar(mFrame);
+}
+
bool nsDisplayOwnLayer::CreateWebRenderCommands(
wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources,
const StackingContextHelper& aSc, RenderRootStateManager* aManager,
@@ -6115,8 +6120,17 @@ bool nsDisplayStickyPosition::UpdateScrollData(
return ret;
}
+bool nsDisplayStickyPosition::ShouldGetStickyAnimationId(
+ nsIFrame* aStickyFrame) {
+ // Also implies being in the cross-process RCD.
+ // The animation id is how we translate the layer by the dynamic toolbar
+ // offset. It's not needed for regular sticky positioning, that's handled
+ // by WebRender without an animation id.
+ return nsDisplayOwnLayer::HasDynamicToolbar(aStickyFrame);
+}
+
bool nsDisplayStickyPosition::ShouldGetStickyAnimationId() const {
- return HasDynamicToolbar(); // also implies being in the cross-process RCD
+ return ShouldGetStickyAnimationId(mFrame);
}
nsDisplayScrollInfoLayer::nsDisplayScrollInfoLayer(
diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h
@@ -5638,6 +5638,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList {
bool IsZoomingLayer() const;
bool IsFixedPositionLayer() const;
bool IsStickyPositionLayer() const;
+ static bool HasDynamicToolbar(nsIFrame* aFrame);
bool HasDynamicToolbar() const;
virtual bool ShouldGetFixedAnimationId() { return false; }
@@ -5768,6 +5769,7 @@ class nsDisplayStickyPosition final : public nsDisplayOwnLayer {
return mShouldFlatten;
}
+ static bool ShouldGetStickyAnimationId(nsIFrame* aStickyFrame);
bool ShouldGetStickyAnimationId() const;
private: