[tbb-commits] [tor-browser] 265/311: Bug 1736069 - Unconditionally create nsDisplayStickyPosition items r=tnikkel a=dmeehan
gitolite role
git at cupani.torproject.org
Tue Apr 26 15:31:05 UTC 2022
This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.
commit d8d3ed7215b641eb2d5af77082c3398946606a5a
Author: Miko Mynttinen <mikokm at gmail.com>
AuthorDate: Thu Mar 24 17:40:32 2022 +0000
Bug 1736069 - Unconditionally create nsDisplayStickyPosition items r=tnikkel a=dmeehan
Differential Revision: https://phabricator.services.mozilla.com/D141925
---
layout/generic/nsIFrame.cpp | 28 ++++++++++++++++----------
layout/painting/RetainedDisplayListBuilder.cpp | 4 +++-
layout/painting/nsDisplayList.h | 14 ++++++++++++-
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp
index be46eba2110bc..c2c4d31eb218c 100644
--- a/layout/generic/nsIFrame.cpp
+++ b/layout/generic/nsIFrame.cpp
@@ -3349,15 +3349,7 @@ void nsIFrame::BuildDisplayListForStackingContext(
aBuilder->EnterSVGEffectsContents(this, &hoistedScrollInfoItemsStorage);
}
- bool useStickyPosition = false;
- if (disp->mPosition == StylePositionProperty::Sticky) {
- StickyScrollContainer* stickyScrollContainer =
- StickyScrollContainer::GetStickyScrollContainerForFrame(this);
- if (stickyScrollContainer &&
- stickyScrollContainer->ScrollFrame()->IsMaybeAsynchronouslyScrolled()) {
- useStickyPosition = true;
- }
- }
+ bool useStickyPosition = disp->mPosition == StylePositionProperty::Sticky;
bool useFixedPosition =
disp->mPosition == StylePositionProperty::Fixed &&
@@ -3837,11 +3829,25 @@ void nsIFrame::BuildDisplayListForStackingContext(
// descendants).
const ActiveScrolledRoot* stickyASR = ActiveScrolledRoot::PickAncestor(
containerItemASR, aBuilder->CurrentActiveScrolledRoot());
- resultList.AppendNewToTop<nsDisplayStickyPosition>(
+
+ auto* stickyItem = MakeDisplayItem<nsDisplayStickyPosition>(
aBuilder, this, &resultList, stickyASR,
aBuilder->CurrentActiveScrolledRoot(),
clipState.IsClippedToDisplayPort());
- ct.TrackContainer(resultList.GetTop());
+
+ bool shouldFlatten = true;
+
+ StickyScrollContainer* stickyScrollContainer =
+ StickyScrollContainer::GetStickyScrollContainerForFrame(this);
+ if (stickyScrollContainer &&
+ stickyScrollContainer->ScrollFrame()->IsMaybeAsynchronouslyScrolled()) {
+ shouldFlatten = false;
+ }
+
+ stickyItem->SetShouldFlatten(shouldFlatten);
+
+ resultList.AppendToTop(stickyItem);
+ ct.TrackContainer(stickyItem);
// If the sticky element is inside a filter, annotate the scroll frame that
// scrolls the filter as having out-of-flow content inside a filter (this
diff --git a/layout/painting/RetainedDisplayListBuilder.cpp b/layout/painting/RetainedDisplayListBuilder.cpp
index 2af75e88f207c..1bd2b49b25a6b 100644
--- a/layout/painting/RetainedDisplayListBuilder.cpp
+++ b/layout/painting/RetainedDisplayListBuilder.cpp
@@ -596,10 +596,12 @@ class MergeState {
return true;
}
- if (type == DisplayItemType::TYPE_SUBDOCUMENT) {
+ if (type == DisplayItemType::TYPE_SUBDOCUMENT ||
+ type == DisplayItemType::TYPE_STICKY_POSITION) {
// nsDisplaySubDocument::mShouldFlatten can change without an invalidation
// (and is the reason we unconditionally build the subdocument item), so
// always use the new one to make sure we get the right value.
+ // Same for |nsDisplayStickyPosition::mShouldFlatten|.
return true;
}
diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h
index b41bb874c1f04..fab406241272f 100644
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -5532,7 +5532,8 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
const nsDisplayStickyPosition& aOther)
: nsDisplayOwnLayer(aBuilder, aOther),
mContainerASR(aOther.mContainerASR),
- mClippedToDisplayPort(aOther.mClippedToDisplayPort) {
+ mClippedToDisplayPort(aOther.mClippedToDisplayPort),
+ mShouldFlatten(false) {
MOZ_COUNT_CTOR(nsDisplayStickyPosition);
}
@@ -5564,6 +5565,14 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
bool CanMoveAsync() override { return true; }
+ void SetShouldFlatten(bool aShouldFlatten) {
+ mShouldFlatten = aShouldFlatten;
+ }
+
+ bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) final {
+ return mShouldFlatten;
+ }
+
private:
NS_DISPLAY_ALLOW_CLONING()
@@ -5590,6 +5599,9 @@ class nsDisplayStickyPosition : public nsDisplayOwnLayer {
// checkerboarded. Note that the sticky item will still be subject to the
// scrollport clip.
bool mClippedToDisplayPort;
+
+ // True if this item should be flattened away.
+ bool mShouldFlatten;
};
class nsDisplayFixedPosition : public nsDisplayOwnLayer {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the tbb-commits
mailing list