Skip to content

Truly independent web browser

LibWeb: Preserve unitless zero for numeric properties

Andreas Klingbfa02c82a641
diff --git a/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp
index 54f8d5e73e8..b9ecf03bba6 100644
--- a/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp
+++ b/Libraries/LibWeb/CSS/StyleValues/NumberStyleValue.cpp
@@ -27,7 +27,9 @@ GC::Ref<CSSStyleValue> NumberStyleValue::reify(Utf16FlyString const& associated_
// FIXME: Do this for registered custom properties.
if (auto property_id = property_id_from_string(associated_property); property_id.has_value()
&& property_id != PropertyID::Custom
- && property_accepts_type(*property_id, ValueType::Length)) {
+ && property_accepts_type(*property_id, ValueType::Length)
+ && !property_accepts_type(*property_id, ValueType::Number)
+ && !property_accepts_type(*property_id, ValueType::Integer)) {
return CSSUnitValue::create(0, "px"_utf16_fly_string);
}
}
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt
index 55f17285b42..286d41780be 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 32 tests
-30 Pass
-2 Fail
+32 Pass
Pass Can set 'line-height' to CSS-wide keywords: initial
Pass Can set 'line-height' to CSS-wide keywords: inherit
Pass Can set 'line-height' to CSS-wide keywords: unset
@@ -14,8 +13,8 @@ Pass Can set 'line-height' to a length: 0px
Pass Can set 'line-height' to a length: -3.14em
Pass Can set 'line-height' to a length: 3.14cm
Pass Can set 'line-height' to a length: calc(0px + 0em)
-Fail Can set 'line-height' to a number: 0
-Fail Can set 'line-height' to a number: -3.14
+Pass Can set 'line-height' to a number: 0
+Pass Can set 'line-height' to a number: -3.14
Pass Can set 'line-height' to a number: 3.14
Pass Can set 'line-height' to a number: calc(2 + 3)
Pass Can set 'line-height' to a percent: 0%
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
index d4bb56bc398..0f10ce8127b 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/tab-size.txt
@@ -2,15 +2,14 @@ Harness status: OK
Found 31 tests
-29 Pass
-2 Fail
+31 Pass
Pass Can set 'tab-size' to CSS-wide keywords: initial
Pass Can set 'tab-size' to CSS-wide keywords: inherit
Pass Can set 'tab-size' to CSS-wide keywords: unset
Pass Can set 'tab-size' to CSS-wide keywords: revert
Pass Can set 'tab-size' to var() references: var(--A)
-Fail Can set 'tab-size' to a number: 0
-Fail Can set 'tab-size' to a number: -3.14
+Pass Can set 'tab-size' to a number: 0
+Pass Can set 'tab-size' to a number: -3.14
Pass Can set 'tab-size' to a number: 3.14
Pass Can set 'tab-size' to a number: calc(2 + 3)
Pass Can set 'tab-size' to a length: 0px