LibWeb/CSS: Subdivide into iterations when reading from StylePropertyMap

This commit is contained in:
Sam Atkins 2025-11-04 13:42:31 +00:00
parent 7292714592
commit 1bcc489310
Notes: github-actions[bot] 2025-11-06 10:35:43 +00:00
9 changed files with 28 additions and 30 deletions

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/StylePropertyMapReadOnlyPrototype.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/CSSStyleValue.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/PropertyNameAndID.h>
#include <LibWeb/DOM/Document.h>
@ -61,8 +62,8 @@ WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, Empty>> StylePropertyMapRead
// 4. If props[property] exists, subdivide into iterations props[property], then reify the first item of the result and return it.
if (auto property_value = get_style_value(props, property.value())) {
// FIXME: Subdivide into iterations, and only reify/return the first.
return property_value->reify(realm(), property->name());
auto iterations = property_value->subdivide_into_iterations(property.value());
return iterations.first()->reify(realm(), property->name());
}
// 5. Otherwise, return undefined.
@ -85,8 +86,11 @@ WebIDL::ExceptionOr<Vector<GC::Ref<CSSStyleValue>>> StylePropertyMapReadOnly::ge
// 4. If props[property] exists, subdivide into iterations props[property], then reify each item of the result, and return the list.
if (auto property_value = get_style_value(props, property.value())) {
// FIXME: Subdivide into iterations.
return Vector { property_value->reify(realm(), property->name()) };
auto iterations = property_value->subdivide_into_iterations(property.value());
GC::RootVector<GC::Ref<CSSStyleValue>> results { heap() };
for (auto const& style_value : iterations)
results.append(style_value->reify(realm(), property->name()));
return results;
}
// 5. Otherwise, return an empty list.

View file

@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
5 Pass
1 Fail
6 Pass
Pass Getting a custom property not in the computed style returns undefined
Pass Getting a valid property from computed style returns the correct entry
Pass Getting a valid custom property from computed style returns the correct entry
Fail Getting a list-valued property from computed style returns only the first value
Pass Getting a list-valued property from computed style returns only the first value
Pass Computed StylePropertyMap.get is not case-sensitive
Pass Computed StylePropertyMap.get reflects updates in inline style

View file

@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
5 Pass
1 Fail
6 Pass
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
Pass StylePropertyMap.getAll is case-insensitive
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

View file

@ -2,12 +2,11 @@ Harness status: OK
Found 7 tests
6 Pass
1 Fail
7 Pass
Pass Getting a custom property not in the CSS rule returns undefined
Pass Getting a valid property not in the CSS rule returns undefined
Pass Getting a valid property from CSS rule returns the correct entry
Pass Getting a valid custom property from CSS rule returns the correct entry
Fail Getting a list-valued property from CSS rule returns only the first value
Pass Getting a list-valued property from CSS rule returns only the first value
Pass Declared StylePropertyMap.get is not case-sensitive
Pass Declared StylePropertyMap.get reflects changes in the CSS rule

View file

@ -2,12 +2,11 @@ Harness status: OK
Found 7 tests
6 Pass
1 Fail
7 Pass
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
Pass Calling StylePropertyMap.getAll with a property not in the property model returns an empty list
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
Pass StylePropertyMap.getAll is case-insensitive
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 14 tests
11 Pass
3 Fail
13 Pass
1 Fail
Pass Setting a StylePropertyMap with an unsupported property name throws TypeError
Pass Setting a StylePropertyMap with an null property name throws TypeError
Pass Setting a StylePropertyMap with a descriptor throws TypeError
@ -14,7 +14,7 @@ Pass Setting a non list-valued property with list-valued string throws TypeError
Pass Setting a list-valued property with a CSSUnparsedValue and other values throws TypeError
Pass Setting a list-valued property with a var ref() and other values throws TypeError
Pass Setting a property with CSSStyleValue or String updates its value
Fail Setting a list-valued property with CSSStyleValue or String updates its values
Pass Setting a list-valued property with CSSStyleValue or String updates its values
Fail Setting a list-valued property with a list-valued string updates its value
Pass Setting a custom property with CSSStyleValue or String updates its value
Fail StylePropertyMap.set is case-insensitive
Pass StylePropertyMap.set is case-insensitive

View file

@ -2,12 +2,11 @@ Harness status: OK
Found 7 tests
6 Pass
1 Fail
7 Pass
Pass Getting a custom property not in the inline style returns undefined
Pass Getting a valid property not in the inline style returns undefined
Pass Getting a valid property from inline style returns the correct entry
Pass Getting a valid custom property from inline style returns the correct entry
Fail Getting a list-valued property from inline style returns only the first value
Pass Getting a list-valued property from inline style returns only the first value
Pass Declared StylePropertyMap.get is not case-sensitive
Pass Declared StylePropertyMap.get reflects changes in the inline style

View file

@ -2,12 +2,11 @@ Harness status: OK
Found 7 tests
6 Pass
1 Fail
7 Pass
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
Pass Calling StylePropertyMap.getAll with a property not in the property model returns an empty list
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
Pass StylePropertyMap.getAll is case-insensitive
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 14 tests
11 Pass
3 Fail
13 Pass
1 Fail
Pass Setting a StylePropertyMap with an unsupported property name throws TypeError
Pass Setting a StylePropertyMap with an null property name throws TypeError
Pass Setting a StylePropertyMap with a descriptor throws TypeError
@ -14,7 +14,7 @@ Pass Setting a non list-valued property with list-valued string throws TypeError
Pass Setting a list-valued property with a CSSUnparsedValue and other values throws TypeError
Pass Setting a list-valued property with a var ref() and other values throws TypeError
Pass Setting a property with CSSStyleValue or String updates its value
Fail Setting a list-valued property with CSSStyleValue or String updates its values
Pass Setting a list-valued property with CSSStyleValue or String updates its values
Fail Setting a list-valued property with a list-valued string updates its value
Pass Setting a custom property with CSSStyleValue or String updates its value
Fail StylePropertyMap.set is case-insensitive
Pass StylePropertyMap.set is case-insensitive