Truly independent web browser
LibWeb: Wrap non-integer Typed OM numbers for <integer> in CSSMathSum
Andreas Klingc14554969850
diff --git a/Libraries/LibWeb/CSS/CSSUnitValue.cpp b/Libraries/LibWeb/CSS/CSSUnitValue.cppindex aeff7eec692..dbb6e6539c7 100644--- a/Libraries/LibWeb/CSS/CSSUnitValue.cpp+++ b/Libraries/LibWeb/CSS/CSSUnitValue.cpp@@ -397,6 +397,10 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_intif (property_accepts_type(property.id(), ValueType::Integer)) {auto integer = round_to_nearest_integer(number.value());+ // NB: A number that is not an integer does not match <integer>, so it's wrapped in a CSSMathSum, like+ // a value outside of the accepted range. It then gets rounded when computed.+ if (static_cast<double>(integer) != number.value())+ return wrap_in_math_sum(number);if (property_accepts_integer(property.id(), integer))return IntegerStyleValue::create(integer);return wrap_in_math_sum(number);diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/column-count.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/column-count.txtindex e8e94c1f13b..01953952c2c 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/column-count.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/column-count.txt@@ -2,8 +2,8 @@ Harness status: OKFound 32 tests-30 Pass-2 Fail+31 Pass+1 FailPass Can set 'column-count' to CSS-wide keywords: initialPass Can set 'column-count' to CSS-wide keywords: inheritPass Can set 'column-count' to CSS-wide keywords: unset@@ -12,7 +12,7 @@ Pass Can set 'column-count' to var() references: var(--A)Pass Can set 'column-count' to the 'auto' keyword: autoPass Can set 'column-count' to a number: 0Pass Can set 'column-count' to a number: -3.14-Fail Can set 'column-count' to a number: 3.14+Pass Can set 'column-count' to a number: 3.14Fail Can set 'column-count' to a number: calc(2 + 3)Pass Setting 'column-count' to a length: 0px throws TypeErrorPass Setting 'column-count' to a length: -3.14em throws TypeErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/order.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/order.txtindex 9416817398d..55d50ef4a5a 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/order.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/order.txt@@ -2,16 +2,16 @@ Harness status: OKFound 31 tests-28 Pass-3 Fail+30 Pass+1 FailPass Can set 'order' to CSS-wide keywords: initialPass Can set 'order' to CSS-wide keywords: inheritPass Can set 'order' to CSS-wide keywords: unsetPass Can set 'order' to CSS-wide keywords: revertPass Can set 'order' to var() references: var(--A)Pass Can set 'order' to a number: 0-Fail Can set 'order' to a number: -3.14-Fail Can set 'order' to a number: 3.14+Pass Can set 'order' to a number: -3.14+Pass Can set 'order' to a number: 3.14Fail Can set 'order' to a number: calc(2 + 3)Pass Setting 'order' to a length: 0px throws TypeErrorPass Setting 'order' to a length: -3.14em throws TypeErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/orphans.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/orphans.txtindex 131c25c513a..643b80a299e 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/orphans.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/orphans.txt@@ -2,8 +2,8 @@ Harness status: OKFound 31 tests-29 Pass-2 Fail+30 Pass+1 FailPass Can set 'orphans' to CSS-wide keywords: initialPass Can set 'orphans' to CSS-wide keywords: inheritPass Can set 'orphans' to CSS-wide keywords: unset@@ -11,7 +11,7 @@ Pass Can set 'orphans' to CSS-wide keywords: revertPass Can set 'orphans' to var() references: var(--A)Pass Can set 'orphans' to a number: 0Pass Can set 'orphans' to a number: -3.14-Fail Can set 'orphans' to a number: 3.14+Pass Can set 'orphans' to a number: 3.14Fail Can set 'orphans' to a number: calc(2 + 3)Pass Setting 'orphans' to a length: 0px throws TypeErrorPass Setting 'orphans' to a length: -3.14em throws TypeErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/widows.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/widows.txtindex 11aa4f62635..48d9d09629c 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/widows.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/widows.txt@@ -2,8 +2,8 @@ Harness status: OKFound 31 tests-29 Pass-2 Fail+30 Pass+1 FailPass Can set 'widows' to CSS-wide keywords: initialPass Can set 'widows' to CSS-wide keywords: inheritPass Can set 'widows' to CSS-wide keywords: unset@@ -11,7 +11,7 @@ Pass Can set 'widows' to CSS-wide keywords: revertPass Can set 'widows' to var() references: var(--A)Pass Can set 'widows' to a number: 0Pass Can set 'widows' to a number: -3.14-Fail Can set 'widows' to a number: 3.14+Pass Can set 'widows' to a number: 3.14Fail Can set 'widows' to a number: calc(2 + 3)Pass Setting 'widows' to a length: 0px throws TypeErrorPass Setting 'widows' to a length: -3.14em throws TypeErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/z-index.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/z-index.txtindex 8158e6bbf35..79cb86a18eb 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/z-index.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/z-index.txt@@ -2,8 +2,8 @@ Harness status: OKFound 32 tests-29 Pass-3 Fail+31 Pass+1 FailPass Can set 'z-index' to CSS-wide keywords: initialPass Can set 'z-index' to CSS-wide keywords: inheritPass Can set 'z-index' to CSS-wide keywords: unset@@ -11,8 +11,8 @@ Pass Can set 'z-index' to CSS-wide keywords: revertPass Can set 'z-index' to var() references: var(--A)Pass Can set 'z-index' to the 'auto' keyword: autoPass Can set 'z-index' to a number: 0-Fail Can set 'z-index' to a number: -3.14-Fail Can set 'z-index' to a number: 3.14+Pass Can set 'z-index' to a number: -3.14+Pass Can set 'z-index' to a number: 3.14Fail Can set 'z-index' to a number: calc(2 + 3)Pass Setting 'z-index' to a length: 0px throws TypeErrorPass Setting 'z-index' to a length: -3.14em throws TypeError