Skip to content

Truly independent web browser

LibWeb: Preserve compound Typed OM property values

Andreas Kling76a99a7dc745
diff --git a/Documentation/CSSGeneratedFiles.md b/Documentation/CSSGeneratedFiles.md
index f8179de8f01..e6a3996c638 100644
--- a/Documentation/CSSGeneratedFiles.md
+++ b/Documentation/CSSGeneratedFiles.md
@@ -35,6 +35,7 @@ Each property will have some set of these fields on it:
| `positional-value-list-shorthand` | No | `false` | Boolean. Whether this property is a "positional value list shorthand". See below. | `bool property_is_positional_value_list_shorthand(PropertyID)` |
| `quirks` | No | `[]` | Array of strings. Some properties have special behavior in "quirks mode", which are listed here. See below. | |
| `requires-computation` | Yes | | String. When a property's value needs to be run through the computation process. See below. | `bool property_requires_computation_with_inherited_value(PropertyID)`<br/>`bool property_requires_computation_with_initial_value(PropertyID)`<br/>`bool property_requires_computation_with_cascaded_value(PropertyID)` |
+| `typed-om-multiplicity` | No | Nothing | String. Overrides `multiplicity` for Typed OM. See `multiplicity` below. | `bool property_is_single_valued(PropertyID)`<br/>`bool property_is_list_valued(PropertyID)` |
| `valid-identifiers` | No | `[]` | Array of strings. Which keywords the property accepts. See below. | `bool property_accepts_keyword(PropertyID, Keyword)` |
| `valid-types` | No | `[]` | Array of strings. Which value types the property accepts. See below. | `bool property_accepts_type(PropertyID, ValueType)` |
| `needs-layout-for-getcomputedstyle` | No | `false` | Boolean. Whether this property requires up-to-date layout before it could be queried by getComputedStyle() | `bool property_needs_layout_for_getcomputedstyle(PropertyID)` |
@@ -81,6 +82,9 @@ commas; `counter-increment` doesn't have commas but also is a list of counters t
Lists can also be [coordinating list properties](https://drafts.csswg.org/css-values-4/#linked-properties), in which
case they are marked as `coordinating-list` instead of `list`.
+Typed OM divides the values of list-valued properties into iterations. Some properties are stored as lists internally
+even though Typed OM treats their value as a single item. Set `typed-om-multiplicity` to `"single"` for those.
+
### `positional-value-list-shorthand`
Some shorthand properties work differently to normal in that mapping of provided values to longhands isn't necessarily
1-to-1 and instead depends on the number of values provided, for example `margin`, `border-width`, `gap`, etc.
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index bad464dd471..49065b1a472 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -529,6 +529,7 @@
"needs-layout-node-for-resolved-value": true,
"__comment": "FIXME: List `filter-value-list` as a valid-type once it's generically supported.",
"multiplicity": "list",
+ "typed-om-multiplicity": "single",
"requires-computation": "cascaded-value",
"valid-identifiers": [
"none"
@@ -1887,6 +1888,7 @@
"inherited": false,
"initial": "none",
"multiplicity": "list",
+ "typed-om-multiplicity": "single",
"requires-computation": "never",
"valid-types": [
"custom-ident ![none,and,not,or]"
@@ -2321,6 +2323,7 @@
"needs-layout-node-for-resolved-value": true,
"__comment": "FIXME: List `filter-value-list` as a valid-type once it's generically supported.",
"multiplicity": "list",
+ "typed-om-multiplicity": "single",
"requires-computation": "cascaded-value",
"valid-identifiers": [
"none"
@@ -4563,6 +4566,7 @@
"inherited": true,
"initial": "auto",
"multiplicity": "list",
+ "typed-om-multiplicity": "single",
"requires-computation": "never",
"valid-types": [
"string"
@@ -5643,6 +5647,7 @@
"inherited": false,
"initial": "all",
"multiplicity": "coordinating-list",
+ "typed-om-multiplicity": "single",
"requires-computation": "never",
"valid-types": [
"custom-ident ![none]"
@@ -5895,6 +5900,7 @@
"inherited": false,
"initial": "auto",
"multiplicity": "list",
+ "typed-om-multiplicity": "single",
"requires-computation": "never",
"valid-types": [
"custom-ident ![all,auto,contents,none,scroll-position,will-change]"
diff --git a/Libraries/LibWeb/CSS/StylePropertyMap.cpp b/Libraries/LibWeb/CSS/StylePropertyMap.cpp
index a3a4729894d..3f796e56bae 100644
--- a/Libraries/LibWeb/CSS/StylePropertyMap.cpp
+++ b/Libraries/LibWeb/CSS/StylePropertyMap.cpp
@@ -53,16 +53,6 @@ static bool any_have_non_matching_associated_property(Utf16FlyString const& prop
});
}
-static NonnullRefPtr<StyleValueList> style_value_list_for_property(StyleValueVector&& values, PropertyID property_id)
-{
- if (first_is_one_of(property_id, PropertyID::BackdropFilter, PropertyID::Filter))
- return StyleValueList::create(move(values), StyleValueList::Separator::Space, StyleValueList::Collapsible::No);
-
- // FIXME: Determine which other properties need a space instead of a comma, or to disable collapsibility.
- // Move this into Properties.json?
- return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
-}
-
// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation
static WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> create_an_internal_representation(JS::VM& vm, PropertyNameAndID const& property, Variant<GC::Ref<CSSStyleValue>, Utf16String> const& value)
{
@@ -273,7 +263,7 @@ WebIDL::ExceptionOr<void> StylePropertyMap::set(Utf16FlyString property_name, Re
if (values_to_set.size() == 1 && !should_wrap_value_in_list(property.value(), values_to_set.first())) {
TRY(props.set_property_style_value(property.value(), values_to_set.take_first()));
} else {
- TRY(props.set_property_style_value(property.value(), style_value_list_for_property(move(values_to_set), property->id())));
+ TRY(props.set_property_style_value(property.value(), StyleValueList::create(move(values_to_set), StyleValueList::Separator::Comma)));
}
return {};
@@ -347,7 +337,7 @@ WebIDL::ExceptionOr<void> StylePropertyMap::append(Utf16FlyString property_name,
// 11. Append the entries of temp values to props[property].
// NB: StyleValues are immutable, so we create a new one instead.
- return props.set_property_style_value(property.value(), style_value_list_for_property(move(value_list), property->id()));
+ return props.set_property_style_value(property.value(), StyleValueList::create(move(value_list), StyleValueList::Separator::Comma));
}
// https://drafts.css-houdini.org/css-typed-om-1/#dom-stylepropertymap-delete
diff --git a/Meta/Generators/generate_libweb_css_property_id.py b/Meta/Generators/generate_libweb_css_property_id.py
index 73c30b8d7f3..4480bf289fa 100755
--- a/Meta/Generators/generate_libweb_css_property_id.py
+++ b/Meta/Generators/generate_libweb_css_property_id.py
@@ -622,7 +622,7 @@ bool property_is_list_valued(PropertyID property_id)
""")
for name, value in properties.items():
- multiplicity = value.get("multiplicity")
+ multiplicity = value.get("typed-om-multiplicity", value.get("multiplicity"))
if multiplicity is not None and multiplicity != "single":
if multiplicity not in ("list", "coordinating-list"):
print(
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/backdrop-filter.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/backdrop-filter.txt
index 0ab06cf7fd8..66f2a1cd149 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/backdrop-filter.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/backdrop-filter.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 34 tests
-33 Pass
-1 Fail
+34 Pass
Pass Can set 'backdrop-filter' to CSS-wide keywords: initial
Pass Can set 'backdrop-filter' to CSS-wide keywords: inherit
Pass Can set 'backdrop-filter' to CSS-wide keywords: unset
@@ -37,4 +36,4 @@ Pass Setting 'backdrop-filter' to a transform: translate(50%, 50%) throws TypeEr
Pass Setting 'backdrop-filter' to a transform: perspective(10em) throws TypeError
Pass Setting 'backdrop-filter' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
Pass 'filter' does not support 'blur(2px)'
-Fail 'filter' does not support 'url(filters.svg) blur(4px) saturate(150%)'
\ No newline at end of file
+Pass 'filter' does not support 'url(filters.svg) blur(4px) saturate(150%)'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/container-name.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/container-name.txt
index 2edb795fc6e..debe954ced7 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/container-name.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/container-name.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 39 tests
-38 Pass
-1 Fail
+39 Pass
Pass Can set 'container-name' to CSS-wide keywords: initial
Pass Can set 'container-name' to CSS-wide keywords: inherit
Pass Can set 'container-name' to CSS-wide keywords: unset
@@ -38,7 +37,7 @@ Pass Setting 'container-name' to a number: calc(2 + 3) throws TypeError
Pass Setting 'container-name' to a transform: translate(50%, 50%) throws TypeError
Pass Setting 'container-name' to a transform: perspective(10em) throws TypeError
Pass Setting 'container-name' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
-Fail 'container-name' does not support 'name1 name2'
+Pass 'container-name' does not support 'name1 name2'
Pass Setting 'container-name' to the 'and' keyword: and throws TypeError
Pass Setting 'container-name' to the 'not' keyword: not throws TypeError
Pass Setting 'container-name' to the 'or' keyword: or throws TypeError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/filter.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/filter.txt
index 54a379ee8ca..8db8cc76c09 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/filter.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/filter.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 34 tests
-33 Pass
-1 Fail
+34 Pass
Pass Can set 'filter' to CSS-wide keywords: initial
Pass Can set 'filter' to CSS-wide keywords: inherit
Pass Can set 'filter' to CSS-wide keywords: unset
@@ -37,4 +36,4 @@ Pass Setting 'filter' to a transform: translate(50%, 50%) throws TypeError
Pass Setting 'filter' to a transform: perspective(10em) throws TypeError
Pass Setting 'filter' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
Pass 'filter' does not support 'blur(2px)'
-Fail 'filter' does not support 'url(filters.svg) blur(4px) saturate(150%)'
\ No newline at end of file
+Pass 'filter' does not support 'url(filters.svg) blur(4px) saturate(150%)'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/quotes.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/quotes.txt
index 61024989bb0..e1130b30b1e 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/quotes.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/quotes.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 33 tests
-32 Pass
-1 Fail
+33 Pass
Pass Can set 'quotes' to CSS-wide keywords: initial
Pass Can set 'quotes' to CSS-wide keywords: inherit
Pass Can set 'quotes' to CSS-wide keywords: unset
@@ -36,4 +35,4 @@ Pass Setting 'quotes' to a number: calc(2 + 3) throws TypeError
Pass Setting 'quotes' to a transform: translate(50%, 50%) throws TypeError
Pass Setting 'quotes' to a transform: perspective(10em) throws TypeError
Pass Setting 'quotes' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
-Fail 'quotes' does not support '"<<" ">>" "<" ">"'
\ No newline at end of file
+Pass 'quotes' does not support '"<<" ">>" "<" ">"'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transition-property.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transition-property.txt
index 5dd3731dde7..cf4dd522a49 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transition-property.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/transition-property.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 35 tests
-32 Pass
-3 Fail
+33 Pass
+2 Fail
Pass Can set 'transition-property' to CSS-wide keywords: initial
Pass Can set 'transition-property' to CSS-wide keywords: inherit
Pass Can set 'transition-property' to CSS-wide keywords: unset
@@ -37,5 +37,5 @@ Pass Setting 'transition-property' to a transform: translate(50%, 50%) throws Ty
Pass Setting 'transition-property' to a transform: perspective(10em) throws TypeError
Pass Setting 'transition-property' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
Fail 'transition-property' does not support 'width'
-Fail 'transition-property' does not support 'width, height'
+Pass 'transition-property' does not support 'width, height'
Fail 'transition-property' does not support 'all'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/will-change.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/will-change.txt
index cfbba47d07c..55076b50d13 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/will-change.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/will-change.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 34 tests
-32 Pass
-2 Fail
+33 Pass
+1 Fail
Pass Can set 'will-change' to CSS-wide keywords: initial
Pass Can set 'will-change' to CSS-wide keywords: inherit
Pass Can set 'will-change' to CSS-wide keywords: unset
@@ -37,4 +37,4 @@ Pass Setting 'will-change' to a transform: translate(50%, 50%) throws TypeError
Pass Setting 'will-change' to a transform: perspective(10em) throws TypeError
Pass Setting 'will-change' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError
Fail 'will-change' does not support 'scroll-position'
-Fail 'will-change' does not support 'contents, foo, scroll-position'
\ No newline at end of file
+Pass 'will-change' does not support 'contents, foo, scroll-position'
\ No newline at end of file