From 28b24b72bc7a531349bfb1b380262a665aa67b15 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 16 Jun 2025 22:41:15 +0100 Subject: [PATCH] LibWeb: Don't resolve flow-relative values for `float` too early This allows `getComputedStyle()` to return the correct value if `float` is set to `inline-start` or `inline-end` --- Libraries/LibWeb/CSS/StyleComputer.cpp | 13 ----------- .../LibWeb/Layout/BlockFormattingContext.cpp | 5 ++-- .../css/css-box/parsing/float-computed.txt | 10 ++++++++ .../css/css-box/parsing/float-computed.html | 23 +++++++++++++++++++ 4 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-box/parsing/float-computed.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-box/parsing/float-computed.html diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 87b0e9d38e7..aa6a414f7f2 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -975,19 +975,6 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i return; } - if (property_id == CSS::PropertyID::Float) { - auto keyword = value.to_keyword(); - - // FIXME: Honor writing-mode, direction and text-orientation. - if (keyword == Keyword::InlineStart) { - set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(Keyword::Left)); - return; - } else if (keyword == Keyword::InlineEnd) { - set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(Keyword::Right)); - return; - } - } - if (property_is_shorthand(property_id)) { // ShorthandStyleValue was handled already, as were unresolved shorthands. // That means the only values we should see are the CSS-wide keywords, or the guaranteed-invalid value. diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 05b18c5b7a8..a081a01690c 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -1164,9 +1164,10 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer }; // Next, float to the left and/or right - if (box.computed_values().float_() == CSS::Float::Left) { + // FIXME: Honor writing-mode, direction and text-orientation. + if (box.computed_values().float_() == CSS::Float::Left || box.computed_values().float_() == CSS::Float::InlineStart) { float_box(FloatSide::Left, m_left_floats); - } else if (box.computed_values().float_() == CSS::Float::Right) { + } else if (box.computed_values().float_() == CSS::Float::Right || box.computed_values().float_() == CSS::Float::InlineEnd) { float_box(FloatSide::Right, m_right_floats); } diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-box/parsing/float-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-box/parsing/float-computed.txt new file mode 100644 index 00000000000..57215528d18 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-box/parsing/float-computed.txt @@ -0,0 +1,10 @@ +Harness status: OK + +Found 5 tests + +5 Pass +Pass Property float value 'none' +Pass Property float value 'left' +Pass Property float value 'right' +Pass Property float value 'inline-start' +Pass Property float value 'inline-end' \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-box/parsing/float-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-box/parsing/float-computed.html new file mode 100644 index 00000000000..914ea956a1c --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-box/parsing/float-computed.html @@ -0,0 +1,23 @@ + + + + +CSS basic box model: getComputedStyle().float + + + + + + + +
+ + +