Skip to content

Commit 7d96fba

Browse files
AtkinsSJgmta
authored andcommitted
LibWeb/CSS: Parse list values as lists in CSSStyleValue parsing
1 parent 07d77e8 commit 7d96fba

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Libraries/LibWeb/CSS/CSSStyleValue.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <LibWeb/CSS/Parser/Parser.h>
1111
#include <LibWeb/CSS/PropertyNameAndID.h>
1212
#include <LibWeb/CSS/StyleValues/StyleValue.h>
13+
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
1314
#include <LibWeb/WebIDL/ExceptionOr.h>
1415

1516
namespace Web::CSS {
@@ -85,11 +86,14 @@ WebIDL::ExceptionOr<Variant<GC::Ref<CSSStyleValue>, GC::RootVector<GC::Ref<CSSSt
8586
if (!whole_value)
8687
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Failed to parse '{}' as a value for '{}' property", css_text, property->name())) };
8788

88-
// FIXME: 4. Subdivide into iterations whole value, according to property, and let values be the result.
89+
// 4. Subdivide into iterations whole value, according to property, and let values be the result.
90+
auto values = whole_value->subdivide_into_iterations(property.value());
8991

9092
// 5. For each value in values, replace it with the result of reifying value for property.
9193
GC::RootVector<GC::Ref<CSSStyleValue>> reified_values { vm.heap() };
92-
reified_values.append(whole_value->reify(*vm.current_realm(), property->name()));
94+
for (auto const& value : values) {
95+
reified_values.append(value->reify(*vm.current_realm(), property->name()));
96+
}
9397

9498
// 6. If parseMultiple is false, return values[0]. Otherwise, return values.
9599
// FIXME: We need to somehow store the source css_text on the returned CSSStyleValue.

Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-objects/parseAll.txt

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

33
Found 5 tests
44

5-
4 Pass
6-
1 Fail
5+
5 Pass
76
Pass CSSStyleValue.parseAll() with a valid property returns a list with a single CSSStyleValue
87
Pass CSSStyleValue.parseAll() is not case sensitive
9-
Fail CSSStyleValue.parseAll() with a valid list-valued property returns a list with a single CSSStyleValue
8+
Pass CSSStyleValue.parseAll() with a valid list-valued property returns a list with a single CSSStyleValue
109
Pass CSSStyleValue.parseAll() with a valid shorthand property returns a CSSStyleValue
1110
Pass CSSStyleValue.parseAll() with a valid custom property returns a list with a single CSSStyleValue

0 commit comments

Comments
 (0)