commit 26f80e88b6a2f8578f1f42f18b44233e9e1bfd6a
parent 97ef6bc71f79bce9f26f1076f8df1667a07a577f
Author: Botond Ballo <botond@mozilla.com>
Date: Thu, 13 Nov 2025 04:59:04 +0000
Bug 1730749 - Always retain ASRs. r=mstange,layout-reviewers,emilio
We need to retain sticky ASRs for:
- looking up the ASR from the frame
- sharing the ASR between continuations of a sticky element
We need to retain scroll ASRs for consistency (if we retain
sticky ASRs but not scroll ASRs, the retained sticky ASRs will
point to stale scroll ASR parents).
Differential Revision: https://phabricator.services.mozilla.com/D264156
Diffstat:
2 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp
@@ -169,26 +169,21 @@ void InitializeHitTestInfo(nsDisplayListBuilder* aBuilder,
/* static */
already_AddRefed<ActiveScrolledRoot> ActiveScrolledRoot::CreateASRForFrame(
const ActiveScrolledRoot* aParent,
- ScrollContainerFrame* aScrollContainerFrame, bool aIsRetained) {
- RefPtr<ActiveScrolledRoot> asr;
- if (aIsRetained) {
- asr = aScrollContainerFrame->GetProperty(ActiveScrolledRootCache());
- }
+ ScrollContainerFrame* aScrollContainerFrame) {
+ RefPtr<ActiveScrolledRoot> asr =
+ aScrollContainerFrame->GetProperty(ActiveScrolledRootCache());
if (!asr) {
asr = new ActiveScrolledRoot();
- if (aIsRetained) {
- RefPtr<ActiveScrolledRoot> ref = asr;
- aScrollContainerFrame->SetProperty(ActiveScrolledRootCache(),
- ref.forget().take());
- }
+ RefPtr<ActiveScrolledRoot> ref = asr;
+ aScrollContainerFrame->SetProperty(ActiveScrolledRootCache(),
+ ref.forget().take());
}
asr->mParent = aParent;
asr->mFrame = aScrollContainerFrame;
asr->mKind = ASRKind::Scroll;
asr->mDepth = aParent ? aParent->mDepth + 1 : 1;
- asr->mRetained = aIsRetained;
return asr.forget();
}
@@ -196,28 +191,22 @@ already_AddRefed<ActiveScrolledRoot> ActiveScrolledRoot::CreateASRForFrame(
/* static */
already_AddRefed<ActiveScrolledRoot>
ActiveScrolledRoot::CreateASRForStickyFrame(const ActiveScrolledRoot* aParent,
- nsIFrame* aStickyFrame,
- bool aIsRetained) {
- RefPtr<ActiveScrolledRoot> asr;
- if (aIsRetained) {
- asr = aStickyFrame->GetProperty(StickyActiveScrolledRootCache());
- }
+ nsIFrame* aStickyFrame) {
+ RefPtr<ActiveScrolledRoot> asr =
+ aStickyFrame->GetProperty(StickyActiveScrolledRootCache());
if (!asr) {
asr = new ActiveScrolledRoot();
- if (aIsRetained) {
- RefPtr<ActiveScrolledRoot> ref = asr;
- aStickyFrame->SetProperty(StickyActiveScrolledRootCache(),
- ref.forget().take());
- }
+ RefPtr<ActiveScrolledRoot> ref = asr;
+ aStickyFrame->SetProperty(StickyActiveScrolledRootCache(),
+ ref.forget().take());
}
asr->mParent = aParent;
asr->mFrame = aStickyFrame;
asr->mKind = ASRKind::Sticky;
asr->mDepth = aParent ? aParent->mDepth + 1 : 1;
- asr->mRetained = aIsRetained;
return asr.forget();
}
@@ -311,7 +300,7 @@ ScrollableLayerGuid::ViewID ActiveScrolledRoot::ComputeViewId() const {
}
ActiveScrolledRoot::~ActiveScrolledRoot() {
- if (mFrame && mRetained) {
+ if (mFrame) {
mFrame->RemoveProperty(mKind == ASRKind::Sticky
? StickyActiveScrolledRootCache()
: ActiveScrolledRootCache());
@@ -1500,16 +1489,16 @@ void nsDisplayListBuilder::MarkPreserve3DFramesForDisplayList(
ActiveScrolledRoot* nsDisplayListBuilder::AllocateActiveScrolledRoot(
const ActiveScrolledRoot* aParent,
ScrollContainerFrame* aScrollContainerFrame) {
- RefPtr<ActiveScrolledRoot> asr = ActiveScrolledRoot::CreateASRForFrame(
- aParent, aScrollContainerFrame, IsRetainingDisplayList());
+ RefPtr<ActiveScrolledRoot> asr =
+ ActiveScrolledRoot::CreateASRForFrame(aParent, aScrollContainerFrame);
mActiveScrolledRoots.AppendElement(asr);
return asr;
}
ActiveScrolledRoot* nsDisplayListBuilder::AllocateActiveScrolledRootForSticky(
const ActiveScrolledRoot* aParent, nsIFrame* aStickyFrame) {
- RefPtr<ActiveScrolledRoot> asr = ActiveScrolledRoot::CreateASRForStickyFrame(
- aParent, aStickyFrame, IsRetainingDisplayList());
+ RefPtr<ActiveScrolledRoot> asr =
+ ActiveScrolledRoot::CreateASRForStickyFrame(aParent, aStickyFrame);
mActiveScrolledRoots.AppendElement(asr);
return asr;
}
diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h
@@ -187,10 +187,9 @@ struct ActiveScrolledRoot {
// TODO: Just have one function with an extra ASRKind parameter
static already_AddRefed<ActiveScrolledRoot> CreateASRForFrame(
const ActiveScrolledRoot* aParent,
- ScrollContainerFrame* aScrollContainerFrame, bool aIsRetained);
+ ScrollContainerFrame* aScrollContainerFrame);
static already_AddRefed<ActiveScrolledRoot> CreateASRForStickyFrame(
- const ActiveScrolledRoot* aParent, nsIFrame* aStickyFrame,
- bool aIsRetained);
+ const ActiveScrolledRoot* aParent, nsIFrame* aStickyFrame);
static const ActiveScrolledRoot* PickAncestor(
const ActiveScrolledRoot* aOne, const ActiveScrolledRoot* aTwo) {
@@ -249,7 +248,7 @@ struct ActiveScrolledRoot {
NS_INLINE_DECL_REFCOUNTING(ActiveScrolledRoot)
private:
- ActiveScrolledRoot() : mDepth(0), mRetained(false) {}
+ ActiveScrolledRoot() : mDepth(0) {}
~ActiveScrolledRoot();
@@ -278,7 +277,6 @@ struct ActiveScrolledRoot {
mutable Maybe<layers::ScrollableLayerGuid::ViewID> mViewId;
uint32_t mDepth;
- bool mRetained;
};
enum class nsDisplayListBuilderMode : uint8_t {