From 48f56cad088e3ba5a6ba55bfa2a7ccfb9750c18a Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Wed, 25 Jun 2025 05:55:10 +0100 Subject: [PATCH] LibWeb: Handle non-numeric `font-weight` values in keyframes Previously, using `font-weight` with a keyword or `calc()` value inside a keyframe rule would cause a crash. --- Libraries/LibWeb/Layout/Node.cpp | 2 +- ...ing-index-keyframe-font-weight-dynamic.txt | 7 ++++ ...ng-index-keyframe-font-weight-dynamic.html | 34 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.html diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index 48c7ef3cb29..401845917b0 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -386,7 +386,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style) // That's why it has to be set before everything else. computed_values.set_font_list(computed_style.computed_font_list()); computed_values.set_font_size(computed_style.font_size()); - computed_values.set_font_weight(round_to(computed_style.property(CSS::PropertyID::FontWeight).as_number().number())); + computed_values.set_font_weight(computed_style.property(CSS::PropertyID::FontWeight).to_font_weight()); computed_values.set_font_kerning(computed_style.font_kerning()); computed_values.set_line_height(computed_style.line_height()); diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.txt new file mode 100644 index 00000000000..a73490ced9c --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Fail +Fail Initially, the sibling-index() is 3 for #target +Fail Removing a preceding sibling of #target reduces the sibling-index() \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.html new file mode 100644 index 00000000000..f26c5c301b9 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/tree-counting/sibling-index-keyframe-font-weight-dynamic.html @@ -0,0 +1,34 @@ + +CSS Values and Units Test: sibling-index() changing font-weight during @keyframes animation + + + + +
+
+
+
+
+