From 0a6793c89b342c41eef61599bb0dea430383d428 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Mon, 30 Dec 2024 07:42:14 +1100 Subject: [PATCH] LibWeb: Check if types have a present and nonzero percentage value Co-authored-by: Chase Knowlden Co-authored-by: "tanner.drake" --- Libraries/LibWeb/CSS/CSSNumericType.cpp | 2 +- .../css/css-values/reference/all-green.html | 1 + .../css-values/max-unitless-zero-invalid.html | 33 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Ref/expected/wpt-import/css/css-values/reference/all-green.html create mode 100644 Tests/LibWeb/Ref/input/wpt-import/css/css-values/max-unitless-zero-invalid.html diff --git a/Libraries/LibWeb/CSS/CSSNumericType.cpp b/Libraries/LibWeb/CSS/CSSNumericType.cpp index 30ff18c5ce3..9080b3d3948 100644 --- a/Libraries/LibWeb/CSS/CSSNumericType.cpp +++ b/Libraries/LibWeb/CSS/CSSNumericType.cpp @@ -154,7 +154,7 @@ Optional CSSNumericType::added_to(CSSNumericType const& other) c } // If type1 and/or type2 contain "percent" with a non-zero value, // and type1 and/or type2 contain a key other than "percent" with a non-zero value - if ((type1.exponent(BaseType::Percent) != 0 || type2.exponent(BaseType::Percent) != 0) + if (((type1.exponent(BaseType::Percent).has_value() && type1.exponent(BaseType::Percent) != 0) || (type2.exponent(BaseType::Percent).has_value() && type2.exponent(BaseType::Percent) != 0)) && (type1.contains_a_key_other_than_percent_with_a_non_zero_value() || type2.contains_a_key_other_than_percent_with_a_non_zero_value())) { // For each base type other than "percent" hint: for (auto hint_int = 0; hint_int < to_underlying(BaseType::__Count); ++hint_int) { diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-values/reference/all-green.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-values/reference/all-green.html new file mode 100644 index 00000000000..454b71944ee --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-values/reference/all-green.html @@ -0,0 +1 @@ + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-values/max-unitless-zero-invalid.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-values/max-unitless-zero-invalid.html new file mode 100644 index 00000000000..70ca710b4a1 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-values/max-unitless-zero-invalid.html @@ -0,0 +1,33 @@ + + + + + CSS Values and Units Test: min() with unitless 0 + + + + + + + + + + + +
+ + +