Skip to content

Commit 1bcc489

Browse files
committed
LibWeb/CSS: Subdivide into iterations when reading from StylePropertyMap
1 parent 7292714 commit 1bcc489

File tree

9 files changed

+28
-30
lines changed

9 files changed

+28
-30
lines changed

Libraries/LibWeb/CSS/StylePropertyMapReadOnly.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <LibWeb/Bindings/Intrinsics.h>
99
#include <LibWeb/Bindings/StylePropertyMapReadOnlyPrototype.h>
1010
#include <LibWeb/CSS/CSSStyleDeclaration.h>
11+
#include <LibWeb/CSS/CSSStyleValue.h>
1112
#include <LibWeb/CSS/ComputedProperties.h>
1213
#include <LibWeb/CSS/PropertyNameAndID.h>
1314
#include <LibWeb/DOM/Document.h>
@@ -61,8 +62,8 @@ WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, Empty>> StylePropertyMapRead
6162

6263
// 4. If props[property] exists, subdivide into iterations props[property], then reify the first item of the result and return it.
6364
if (auto property_value = get_style_value(props, property.value())) {
64-
// FIXME: Subdivide into iterations, and only reify/return the first.
65-
return property_value->reify(realm(), property->name());
65+
auto iterations = property_value->subdivide_into_iterations(property.value());
66+
return iterations.first()->reify(realm(), property->name());
6667
}
6768

6869
// 5. Otherwise, return undefined.
@@ -85,8 +86,11 @@ WebIDL::ExceptionOr<Vector<GC::Ref<CSSStyleValue>>> StylePropertyMapReadOnly::ge
8586

8687
// 4. If props[property] exists, subdivide into iterations props[property], then reify each item of the result, and return the list.
8788
if (auto property_value = get_style_value(props, property.value())) {
88-
// FIXME: Subdivide into iterations.
89-
return Vector { property_value->reify(realm(), property->name()) };
89+
auto iterations = property_value->subdivide_into_iterations(property.value());
90+
GC::RootVector<GC::Ref<CSSStyleValue>> results { heap() };
91+
for (auto const& style_value : iterations)
92+
results.append(style_value->reify(realm(), property->name()));
93+
return results;
9094
}
9195

9296
// 5. Otherwise, return an empty list.

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/computed/get.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ Harness status: OK
22

33
Found 6 tests
44

5-
5 Pass
6-
1 Fail
5+
6 Pass
76
Pass Getting a custom property not in the computed style returns undefined
87
Pass Getting a valid property from computed style returns the correct entry
98
Pass Getting a valid custom property from computed style returns the correct entry
10-
Fail Getting a list-valued property from computed style returns only the first value
9+
Pass Getting a list-valued property from computed style returns only the first value
1110
Pass Computed StylePropertyMap.get is not case-sensitive
1211
Pass Computed StylePropertyMap.get reflects updates in inline style

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/computed/getAll.tentative.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ Harness status: OK
22

33
Found 6 tests
44

5-
5 Pass
6-
1 Fail
5+
6 Pass
76
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
87
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
98
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
109
Pass StylePropertyMap.getAll is case-insensitive
1110
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
12-
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
11+
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/declared/get.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Harness status: OK
22

33
Found 7 tests
44

5-
6 Pass
6-
1 Fail
5+
7 Pass
76
Pass Getting a custom property not in the CSS rule returns undefined
87
Pass Getting a valid property not in the CSS rule returns undefined
98
Pass Getting a valid property from CSS rule returns the correct entry
109
Pass Getting a valid custom property from CSS rule returns the correct entry
11-
Fail Getting a list-valued property from CSS rule returns only the first value
10+
Pass Getting a list-valued property from CSS rule returns only the first value
1211
Pass Declared StylePropertyMap.get is not case-sensitive
1312
Pass Declared StylePropertyMap.get reflects changes in the CSS rule

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/declared/getAll.tentative.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Harness status: OK
22

33
Found 7 tests
44

5-
6 Pass
6-
1 Fail
5+
7 Pass
76
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
87
Pass Calling StylePropertyMap.getAll with a property not in the property model returns an empty list
98
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
109
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
1110
Pass StylePropertyMap.getAll is case-insensitive
1211
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
13-
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
12+
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/declared/set.tentative.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Harness status: OK
22

33
Found 14 tests
44

5-
11 Pass
6-
3 Fail
5+
13 Pass
6+
1 Fail
77
Pass Setting a StylePropertyMap with an unsupported property name throws TypeError
88
Pass Setting a StylePropertyMap with an null property name throws TypeError
99
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
1414
Pass Setting a list-valued property with a CSSUnparsedValue and other values throws TypeError
1515
Pass Setting a list-valued property with a var ref() and other values throws TypeError
1616
Pass Setting a property with CSSStyleValue or String updates its value
17-
Fail Setting a list-valued property with CSSStyleValue or String updates its values
17+
Pass Setting a list-valued property with CSSStyleValue or String updates its values
1818
Fail Setting a list-valued property with a list-valued string updates its value
1919
Pass Setting a custom property with CSSStyleValue or String updates its value
20-
Fail StylePropertyMap.set is case-insensitive
20+
Pass StylePropertyMap.set is case-insensitive

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/get.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Harness status: OK
22

33
Found 7 tests
44

5-
6 Pass
6-
1 Fail
5+
7 Pass
76
Pass Getting a custom property not in the inline style returns undefined
87
Pass Getting a valid property not in the inline style returns undefined
98
Pass Getting a valid property from inline style returns the correct entry
109
Pass Getting a valid custom property from inline style returns the correct entry
11-
Fail Getting a list-valued property from inline style returns only the first value
10+
Pass Getting a list-valued property from inline style returns only the first value
1211
Pass Declared StylePropertyMap.get is not case-sensitive
1312
Pass Declared StylePropertyMap.get reflects changes in the inline style

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/getAll.tentative.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ Harness status: OK
22

33
Found 7 tests
44

5-
6 Pass
6-
1 Fail
5+
7 Pass
76
Pass Calling StylePropertyMap.getAll with an unsupported property throws a TypeError
87
Pass Calling StylePropertyMap.getAll with a property not in the property model returns an empty list
98
Pass Calling StylePropertyMap.getAll with a custom property not in the property model returns an empty list
109
Pass Calling StylePropertyMap.getAll with a valid property returns a single element list with the correct entry
1110
Pass StylePropertyMap.getAll is case-insensitive
1211
Pass Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry
13-
Fail Calling StylePropertyMap.getAll with a list-valued property returns all the values
12+
Pass Calling StylePropertyMap.getAll with a list-valued property returns all the values

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/inline/set.tentative.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Harness status: OK
22

33
Found 14 tests
44

5-
11 Pass
6-
3 Fail
5+
13 Pass
6+
1 Fail
77
Pass Setting a StylePropertyMap with an unsupported property name throws TypeError
88
Pass Setting a StylePropertyMap with an null property name throws TypeError
99
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
1414
Pass Setting a list-valued property with a CSSUnparsedValue and other values throws TypeError
1515
Pass Setting a list-valued property with a var ref() and other values throws TypeError
1616
Pass Setting a property with CSSStyleValue or String updates its value
17-
Fail Setting a list-valued property with CSSStyleValue or String updates its values
17+
Pass Setting a list-valued property with CSSStyleValue or String updates its values
1818
Fail Setting a list-valued property with a list-valued string updates its value
1919
Pass Setting a custom property with CSSStyleValue or String updates its value
20-
Fail StylePropertyMap.set is case-insensitive
20+
Pass StylePropertyMap.set is case-insensitive

0 commit comments

Comments
 (0)