commit 8a183125a82f2c1c1eb4cf2dce05c52f124d2719
parent 807658efa8c0c99e018d2b8c0fc456be20448dd6
Author: Botond Ballo <botond@mozilla.com>
Date: Thu, 13 Nov 2025 04:59:03 +0000
Bug 1730749 - Store the 'should flatten' flag on StickyScrollContainer. r=mstange
This allows the code that checks the flag to avoid needing the
sticky display item.
Differential Revision: https://phabricator.services.mozilla.com/D254146
Diffstat:
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/layout/generic/StickyScrollContainer.h b/layout/generic/StickyScrollContainer.h
@@ -85,6 +85,11 @@ class StickyScrollContainer final {
*/
void MarkFramesForReflow();
+ void SetShouldFlatten(bool aShouldFlatten) {
+ mShouldFlatten = aShouldFlatten;
+ }
+ bool ShouldFlattenAway() const { return mShouldFlatten; }
+
explicit StickyScrollContainer(ScrollContainerFrame* aScrollContainerFrame);
private:
@@ -100,6 +105,7 @@ class StickyScrollContainer final {
ScrollContainerFrame* const mScrollContainerFrame;
DepthOrderedFrameList mFrames;
nsPoint mScrollPosition;
+ bool mShouldFlatten = false;
};
} // namespace mozilla
diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp
@@ -3904,9 +3904,18 @@ void nsIFrame::BuildDisplayListForStackingContext(
aBuilder->CurrentActiveScrolledRoot(),
clipState.IsClippedToDisplayPort());
- auto* ssc = StickyScrollContainer::GetOrCreateForFrame(this);
- const bool shouldFlatten =
- !ssc || !ssc->ScrollContainer()->IsMaybeAsynchronouslyScrolled();
+ bool shouldFlatten = true;
+
+ StickyScrollContainer* stickyScrollContainer =
+ StickyScrollContainer::GetOrCreateForFrame(this);
+ if (stickyScrollContainer) {
+ if (stickyScrollContainer->ScrollContainer()
+ ->IsMaybeAsynchronouslyScrolled()) {
+ shouldFlatten = false;
+ }
+ stickyScrollContainer->SetShouldFlatten(shouldFlatten);
+ }
+
stickyItem->SetShouldFlatten(shouldFlatten);
resultList.AppendToTop(stickyItem);