Skip to content

Truly independent web browser

LibWeb: Reify computed zero letter spacing as normal

Andreas Kling3e3ce549ed3b
diff --git a/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp b/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp
index 9a1d42681a5..5e73c35eb7b 100644
--- a/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp
+++ b/Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp
@@ -16,6 +16,8 @@
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/CSS/StyleSheetState.h>
+#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
+#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
#include <LibWeb/CSS/Zoom.h>
@@ -352,6 +354,10 @@ RefPtr<StyleValue const> StylePropertyMapReadOnly::get_style_value(Source& sourc
auto value = computed_values->computed_style_value(property_id);
if (!value)
return nullptr;
+ // INTEROP: Computed style maps expose zero letter-spacing as normal, matching the legacy CSSOM
+ // resolved value.
+ if (property_id == PropertyID::LetterSpacing && value->is_length() && value->as_length().raw_value() == 0)
+ return KeywordStyleValue::create(Keyword::Normal);
return unscaled_by_zoom(property_id, value.release_nonnull(), computed_values->effective_zoom());
};
return value_for_property(value_for_property, property.id());
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/letter-spacing.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/letter-spacing.txt
index 091e3f60c98..dc158e64429 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/letter-spacing.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/letter-spacing.txt
@@ -2,18 +2,17 @@ Harness status: OK
Found 32 tests
-29 Pass
-3 Fail
+32 Pass
Pass Can set 'letter-spacing' to CSS-wide keywords: initial
Pass Can set 'letter-spacing' to CSS-wide keywords: inherit
Pass Can set 'letter-spacing' to CSS-wide keywords: unset
Pass Can set 'letter-spacing' to CSS-wide keywords: revert
Pass Can set 'letter-spacing' to var() references: var(--A)
-Fail Can set 'letter-spacing' to the 'normal' keyword: normal
-Fail Can set 'letter-spacing' to a length: 0px
+Pass Can set 'letter-spacing' to the 'normal' keyword: normal
+Pass Can set 'letter-spacing' to a length: 0px
Pass Can set 'letter-spacing' to a length: -3.14em
Pass Can set 'letter-spacing' to a length: 3.14cm
-Fail Can set 'letter-spacing' to a length: calc(0px + 0em)
+Pass Can set 'letter-spacing' to a length: calc(0px + 0em)
Pass Can set 'letter-spacing' to a percent: 0%
Pass Can set 'letter-spacing' to a percent: -3.14%
Pass Can set 'letter-spacing' to a percent: 3.14%