commit 6f18d6dcac6c058e0f7674dadf4c4ab826db2b8c
parent 034bb37a04d060747f4ce05090b045f107ea26b7
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Wed, 26 Nov 2025 14:17:40 +0000
Bug 2002497 - Keep track of fallback non-layout-dependent margins. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin
When committing a fallback style, make sure to keep track of potential
non-layout-dependent margins that we used to reflow our kid, so that we
can keep returning the right thing from GetUsedMargin() without having
to re-resolve the fallback style or keep it around.
This fixes the issue described in
https://phabricator.services.mozilla.com/D270310#9482100
Differential Revision: https://phabricator.services.mozilla.com/D274110
Diffstat:
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -1005,7 +1005,19 @@ struct MOZ_STACK_CLASS MOZ_RAII AutoFallbackStyleSetter {
});
}
- void CommitCurrentFallback() { mOldCacheState = OldCacheState{None{}}; }
+ void CommitCurrentFallback() {
+ mOldCacheState = OldCacheState{None{}};
+ // If we have a non-layout dependent margin / paddings, which are different
+ // from our original style, we need to make sure to commit it into the frame
+ // property so that it doesn't get lost after returning from reflow.
+ nsMargin margin;
+ if (mOldStyle &&
+ !mOldStyle->StyleMargin()->MarginEquals(*mFrame->StyleMargin()) &&
+ mFrame->StyleMargin()->GetMargin(margin)) {
+ mFrame->SetOrUpdateDeletableProperty(nsIFrame::UsedMarginProperty(),
+ margin);
+ }
+ }
private:
nsIFrame* const mFrame;