diff --git a/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 778690e81e7..7bdf1623fbf 100644 --- a/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -20,12 +20,12 @@ namespace Web::Layout { CSSPixels FlexFormattingContext::get_pixel_width(Box const& box, CSS::Size const& size) const { - return calculate_inner_width(box, containing_block_width_as_available_size(box), size); + return calculate_inner_width(box, m_available_space->width, size); } CSSPixels FlexFormattingContext::get_pixel_height(Box const& box, CSS::Size const& size) const { - return calculate_inner_height(box, containing_block_height_as_available_size(box), size); + return calculate_inner_height(box, m_available_space->height, size); } FlexFormattingContext::FlexFormattingContext(LayoutState& state, LayoutMode layout_mode, Box const& flex_container, FormattingContext* parent) @@ -51,6 +51,8 @@ void FlexFormattingContext::run(AvailableSpace const& available_space) { // This implements https://www.w3.org/TR/css-flexbox-1/#layout-algorithm + m_available_space = available_space; + // 1. Generate anonymous flex items generate_anonymous_flex_items(); diff --git a/Libraries/LibWeb/Layout/FlexFormattingContext.h b/Libraries/LibWeb/Layout/FlexFormattingContext.h index ef3cd331ef4..a9ad1aff3e3 100644 --- a/Libraries/LibWeb/Layout/FlexFormattingContext.h +++ b/Libraries/LibWeb/Layout/FlexFormattingContext.h @@ -235,6 +235,7 @@ private: AvailableSpace space; }; Optional m_available_space_for_items; + Optional m_available_space; }; } diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp index 9875c19a5bd..1e65532aa5e 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1655,34 +1655,6 @@ CSSPixels FormattingContext::containing_block_height_for(NodeWithStyleAndBoxMode VERIFY_NOT_REACHED(); } -AvailableSize FormattingContext::containing_block_width_as_available_size(NodeWithStyleAndBoxModelMetrics const& node) const -{ - auto const& used_values = m_state.get(node); - switch (used_values.width_constraint) { - case SizeConstraint::MinContent: - return AvailableSize::make_min_content(); - case SizeConstraint::MaxContent: - return AvailableSize::make_max_content(); - case SizeConstraint::None: - return AvailableSize::make_definite(used_values.containing_block_used_values()->content_width()); - } - VERIFY_NOT_REACHED(); -} - -AvailableSize FormattingContext::containing_block_height_as_available_size(NodeWithStyleAndBoxModelMetrics const& node) const -{ - auto const& used_values = m_state.get(node); - switch (used_values.height_constraint) { - case SizeConstraint::MinContent: - return AvailableSize::make_min_content(); - case SizeConstraint::MaxContent: - return AvailableSize::make_max_content(); - case SizeConstraint::None: - return AvailableSize::make_definite(used_values.containing_block_used_values()->content_height()); - } - VERIFY_NOT_REACHED(); -} - // https://drafts.csswg.org/css-sizing-3/#stretch-fit-size CSSPixels FormattingContext::calculate_stretch_fit_width(Box const& box, AvailableSize const& available_width) const { diff --git a/Libraries/LibWeb/Layout/FormattingContext.h b/Libraries/LibWeb/Layout/FormattingContext.h index a2f8f6a819d..3a3a5c4b4a2 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.h +++ b/Libraries/LibWeb/Layout/FormattingContext.h @@ -101,9 +101,6 @@ public: [[nodiscard]] CSSPixels containing_block_width_for(NodeWithStyleAndBoxModelMetrics const&) const; [[nodiscard]] CSSPixels containing_block_height_for(NodeWithStyleAndBoxModelMetrics const&) const; - [[nodiscard]] AvailableSize containing_block_width_as_available_size(NodeWithStyleAndBoxModelMetrics const&) const; - [[nodiscard]] AvailableSize containing_block_height_as_available_size(NodeWithStyleAndBoxModelMetrics const&) const; - [[nodiscard]] CSSPixels calculate_stretch_fit_width(Box const&, AvailableSize const&) const; [[nodiscard]] CSSPixels calculate_stretch_fit_height(Box const&, AvailableSize const&) const; diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/flex-minimum-height-flex-items-012.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/flex-minimum-height-flex-items-012.txt index 2c802d91a99..b56c9d0bdab 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/flex-minimum-height-flex-items-012.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/flex-minimum-height-flex-items-012.txt @@ -6,6 +6,6 @@ Rerun Found 1 tests -1 Fail +1 Pass Details -Result Test Name MessageFail .flexbox 1 \ No newline at end of file +Result Test Name MessagePass .flexbox 1 \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size-quirks.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size-quirks.txt index 23311727b6a..d7b16be70d3 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size-quirks.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size-quirks.txt @@ -6,12 +6,11 @@ Rerun Found 8 tests -7 Pass -1 Fail +8 Pass Details Result Test Name MessagePass .flexbox 1 Pass .flexbox 2 -Fail .flexbox 3 +Pass .flexbox 3 Pass .flexbox 4 Pass .flexbox 5 Pass .flexbox 6 diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size.txt index 23311727b6a..d7b16be70d3 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/percentage-size.txt @@ -6,12 +6,11 @@ Rerun Found 8 tests -7 Pass -1 Fail +8 Pass Details Result Test Name MessagePass .flexbox 1 Pass .flexbox 2 -Fail .flexbox 3 +Pass .flexbox 3 Pass .flexbox 4 Pass .flexbox 5 Pass .flexbox 6