commit e1c6518b466283bc3523f557988a968eb42b1b9b
parent 8614bf2a9ac69a52f070a91e747ecaf6710c60c4
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Fri, 3 Oct 2025 11:33:41 +0000
Bug 1986711 - More explicitly disable menupopup frame hypothetical position. r=layout-reviewers,dshin
Menupopups don't get positioned using the usual rules, so they don't
need to compute their hypothetical position even when open.
Long term we should do this for all top layer frames but I don't want to
change behavior in this patch.
Differential Revision: https://phabricator.services.mozilla.com/D267289
Diffstat:
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -993,17 +993,31 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
nscoord availISize = logicalCBSize.ISize(wm);
ReflowInput::InitFlags initFlags;
- if (aFlags.contains(AbsPosReflowFlag::IsGridContainerCB)) {
- // When a grid container generates the abs.pos. CB for a *child* then
- // the static position is determined via CSS Box Alignment within the
- // abs.pos. CB (a grid area, i.e. a piece of the grid). In this scenario,
- // due to the multiple coordinate spaces in play, we use a convenience
- // flag to simply have the child's ReflowInput give it a static position
- // at its abs.pos. CB origin, and then we'll align & offset it from there.
- nsIFrame* placeholder = aKidFrame->GetPlaceholderFrame();
- if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
- initFlags += ReflowInput::InitFlag::StaticPosIsCBOrigin;
+ const bool staticPosIsCBOrigin = [&] {
+ if (aFlags.contains(AbsPosReflowFlag::IsGridContainerCB)) {
+ // When a grid container generates the abs.pos. CB for a *child* then
+ // the static position is determined via CSS Box Alignment within the
+ // abs.pos. CB (a grid area, i.e. a piece of the grid). In this scenario,
+ // due to the multiple coordinate spaces in play, we use a convenience
+ // flag to simply have the child's ReflowInput give it a static position
+ // at its abs.pos. CB origin, and then we'll align & offset it from there.
+ nsIFrame* placeholder = aKidFrame->GetPlaceholderFrame();
+ if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
+ return true;
+ }
+ }
+ if (aKidFrame->IsMenuPopupFrame()) {
+ // Popups never use their static pos.
+ return true;
}
+ // TODO(emilio): Either reparent the top layer placeholder frames to the
+ // viewport, or return true here for top layer frames more generally (not
+ // only menupopups), see https://github.com/w3c/csswg-drafts/issues/8040.
+ return false;
+ }();
+
+ if (staticPosIsCBOrigin) {
+ initFlags += ReflowInput::InitFlag::StaticPosIsCBOrigin;
}
const bool kidFrameMaySplit =