commit ba75c753ec99f324d372141fa9c02de0e45d8469
parent fd25face9d31224ecfeb785d9931843e34f7360b
Author: Timothy Nikkel <tnikkel@gmail.com>
Date: Fri, 14 Nov 2025 04:15:57 +0000
Bug 1995759. Note on the presshell and root presshell if CSS anchor pos has been seen. r=layout-reviewers,layout-anchor-positioning-reviewers,dshin,jwatt
See the other patch in this bug for the explanation why we need this.
This intentionally does not ever try to turn off this bool as that would be more complicated.
We need to track it in the root pres shell because we paint from the root presshell. (We paint menupopups from the menupopup frames instead of the root frame, but I think this setup will work fine for that case too.) We use the bool on non-root presshells to avoid walking to the root if it's already been set.
Differential Revision: https://phabricator.services.mozilla.com/D269697
Diffstat:
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp
@@ -728,7 +728,8 @@ PresShell::PresShell(Document* aDocument)
mInitializedWithKeyPressEventDispatchingBlacklist(false),
mHasTriedFastUnsuppress(false),
mProcessingReflowCommands(false),
- mPendingDidDoReflow(false) {
+ mPendingDidDoReflow(false),
+ mHasSeenAnchorPos(false) {
MOZ_LOG(gLog, LogLevel::Debug, ("PresShell::PresShell this=%p", this));
MOZ_ASSERT(aDocument);
diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h
@@ -762,6 +762,7 @@ class PresShell final : public nsStubDocumentObserver,
inline void AddAnchorPosPositioned(nsIFrame* aFrame) {
if (!mAnchorPosPositioned.Contains(aFrame)) {
+ MarkHasSeenAnchorPos();
mAnchorPosPositioned.AppendElement(aFrame);
}
}
@@ -779,6 +780,18 @@ class PresShell final : public nsStubDocumentObserver,
return mAnchorPosPositioned;
}
+ bool HasSeenAnchorPos() const { return mHasSeenAnchorPos; }
+
+ void MarkHasSeenAnchorPos() {
+ if (mHasSeenAnchorPos) {
+ return;
+ }
+ mHasSeenAnchorPos = true;
+ if (auto* rootPS = GetRootPresShell()) {
+ rootPS->mHasSeenAnchorPos = true;
+ }
+ }
+
#ifdef MOZ_REFLOW_PERF
void DumpReflows();
void CountReflows(const char* aName, nsIFrame* aFrame);
@@ -3490,6 +3503,11 @@ class PresShell final : public nsStubDocumentObserver,
bool mProcessingReflowCommands : 1;
bool mPendingDidDoReflow : 1;
+ // Whether CSS anchor positioning has ever been seen in this presshell.
+ // Additionally this will also be set to true on a root presshell if anchor
+ // positioning has ever been seen in any descendant presshell.
+ bool mHasSeenAnchorPos : 1;
+
// The last TimeStamp when the keyup event did not exit fullscreen because it
// was consumed.
TimeStamp mLastConsumedEscapeKeyUpForFullscreen;