From b4a768cfc7c4c4fdef5c6454aeb4a124f303d40d Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 25 Mar 2025 10:41:59 +0100 Subject: [PATCH] layout: Ensure compatible positioning context during flexbox block content sizing calculation (#36123) Sometimes column Flexbox needs to do an early layout pass to determine the preferred block content size of flex items. Previously the absolutely positioned children created during this pass were discarded, but now they are cached to be possibly used during the final layout phase of the flex item. Since they are not thrown away, it is necessary that the `PositioningContext` used to collect them is compatible with their final `PositioningContext`. Fixes #36121. Signed-off-by: Martin Robinson --- components/layout_2020/flexbox/layout.rs | 13 ++++++++----- tests/wpt/meta/MANIFEST.json | 7 +++++++ .../css-flexbox/mixed-containing-blocks-crash.html | 13 +++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 tests/wpt/tests/css/css-flexbox/mixed-containing-blocks-crash.html diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs index 880847617f6..f71f5da6915 100644 --- a/components/layout_2020/flexbox/layout.rs +++ b/components/layout_2020/flexbox/layout.rs @@ -2619,11 +2619,14 @@ impl FlexItemBox { auto_cross_size_stretches_to_container_size: bool, intrinsic_sizing_mode: IntrinsicSizingMode, ) -> Au { - let mut positioning_context = PositioningContext::new_for_subtree( - flex_context - .positioning_context - .collects_for_nearest_positioned_ancestor(), - ); + let mut positioning_context = PositioningContext::new_for_style(self.style()) + .unwrap_or_else(|| { + PositioningContext::new_for_subtree( + flex_context + .positioning_context + .collects_for_nearest_positioned_ancestor(), + ) + }); let style = self.independent_formatting_context.style(); match &self.independent_formatting_context.contents { diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 117f1af832b..522021d0a9c 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -2599,6 +2599,13 @@ {} ] ], + "mixed-containing-blocks-crash.html": [ + "f8a38e057d32e8bb8d7e143d867ca6364210ba38", + [ + null, + {} + ] + ], "negative-available-size-crash.html": [ "837fdaeba9ef8baeb4f2bad281bb13551d6d8ff9", [ diff --git a/tests/wpt/tests/css/css-flexbox/mixed-containing-blocks-crash.html b/tests/wpt/tests/css/css-flexbox/mixed-containing-blocks-crash.html new file mode 100644 index 00000000000..f8a38e057d3 --- /dev/null +++ b/tests/wpt/tests/css/css-flexbox/mixed-containing-blocks-crash.html @@ -0,0 +1,13 @@ + +CSS Flexbox: Mixed containing blocks + + + + + + +
+
Three
fixed
+
+ +