8000 [CSS-Typed-OM] Stop treating grid-row-start / grid-column-start / gri… · WebKit/WebKit@a0f88ce · GitHub
[go: up one dir, main page]

Skip to content

Commit a0f88ce

Browse files
committed
[CSS-Typed-OM] Stop treating grid-row-start / grid-column-start / grid-row-end / grid-column-end as list properties
https://bugs.webkit.org/show_bug.cgi?id=250044 Reviewed by Matt Woodrow. Stop treating grid-row-start / grid-column-start / grid-row-end / grid-column-end as list properties in the CSS Typed OM API. Our logic currently treats those as list properties because the CSS Parser (consumeGridLine) generates a CSSValueList to represent them. Specification: - https://w3c.github.io/csswg-drafts/css-grid/#typedef-grid-row-start-grid-line * LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/grid-start-end-expected.txt: * Source/WebCore/css/typedom/CSSStyleValueFactory.cpp: (WebCore::mayConvertCSSValueListToSingleValue): (WebCore::CSSStyleValueFactory::reifyValue): Canonical link: https://commits.webkit.org/258764@main
1 parent ef8d414 commit a0f88ce

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/grid-start-end-expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PASS Setting 'grid-row-start' to a number: calc(2 + 3) throws TypeError
3131
PASS Setting 'grid-row-start' to a transform: translate(50%, 50%) throws TypeError
3232
PASS Setting 'grid-row-start' to a transform: perspective(10em) throws TypeError
3333
PASS Setting 'grid-row-start' 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
34-
FAIL 'grid-row-start' does not support '3' assert_class_string: Unsupported value must be a CSSStyleValue and not one of its subclasses expected "[object CSSStyleValue]" but got "[object CSSUnitValue]"
34+
PASS 'grid-row-start' does not support '3'
3535
PASS 'grid-row-start' does not support 'span 2'
3636
PASS 'grid-row-start' does not support '5 somegridarea span'
3737
PASS Can set 'grid-row-end' to CSS-wide keywords: initial
@@ -66,7 +66,7 @@ PASS Setting 'grid-row-end' to a number: calc(2 + 3) throws TypeError
6666
PASS Setting 'grid-row-end' to a transform: translate(50%, 50%) throws TypeError
6767
PASS Setting 'grid-row-end' to a transform: perspective(10em) throws TypeError
6868
PASS Setting 'grid-row-end' 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
69-
FAIL 'grid-row-end' does not support '3' assert_class_string: Unsupported value must be a CSSStyleValue and not one of its subclasses expected "[object CSSStyleValue]" but got "[object CSSUnitValue]"
69+
PASS 'grid-row-end' does not support '3'
7070
PASS 'grid-row-end' does not support 'span 2'
7171
PASS 'grid-row-end' does not support '5 somegridarea span'
7272
PASS Can set 'grid-column-start' to CSS-wide keywords: initial
@@ -101,7 +101,7 @@ PASS Setting 'grid-column-start' to a number: calc(2 + 3) throws TypeError
101101
PASS Setting 'grid-column-start' to a transform: translate(50%, 50%) throws TypeError
102102
PASS Setting 'grid-column-start' to a transform: perspective(10em) throws TypeError
103103
PASS Setting 'grid-column-start' 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
104-
FAIL 'grid-column-start' does not support '3' assert_class_string: Unsupported value must be a CSSStyleValue and not one of its subclasses expected "[object CSSStyleValue]" but got "[object CSSUnitValue]"
104+
PASS 'grid-column-start' does not support '3'
105105
PASS 'grid-column-start' does not support 'span 2'
106106
PASS 'grid-column-start' does not support '5 somegridarea span'
107107
PASS Can set 'grid-column-end' to CSS-wide keywords: initial
@@ -136,7 +136,7 @@ PASS Setting 'grid-column-end' to a number: calc(2 + 3) throws TypeError
136136
PASS Setting 'grid-column-end' to a transform: translate(50%, 50%) throws TypeError
137137
PASS Setting 'grid-column-end' to a transform: perspective(10em) throws TypeError
138138
PASS Setting 'grid-column-end' 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
139-
FAIL 'grid-column-end' does not support '3' assert_class_string: Unsupported value must be a CSSStyleValue and not one of its subclasses expected "[object CSSStyleValue]" but got "[object CSSUnitValue]"
139+
PASS 'grid-column-end' does not support '3'
140140
PASS 'grid-column-end' does not support 'span 2'
141141
PASS 'grid-column-end' does not support '5 somegridarea span'
142142

Source/WebCore/css/typedom/CSSStyleValueFactory.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ ExceptionOr<Vector<Ref<CSSStyleValue>>> CSSStyleValueFactory::parseStyleValue(co
163163
return results;
164164
}
165165

166+
static bool mayConvertCSSValueListToSingleValue(std::optional<CSSPropertyID> propertyID)
167+
{
168+
if (!propertyID)
169+
return true;
170+
171+
// Even though the CSS Parser uses a CSSValueList to represent these, they are not
172+
// really lists and CSS-Typed-OM does not expect them to treat them as such.
173+
return *propertyID != CSSPropertyGridRowStart
174+
&& *propertyID != CSSPropertyGridRowEnd
175+
&& *propertyID != CSSPropertyGridColumnStart
176+
&& *propertyID != CSSPropertyGridColumnEnd;
177+
}
178+
166179
ExceptionOr<Ref<CSSStyleValue>> CSSStyleValueFactory::reifyValue(Ref<CSSValue> cssValue, std::optional<CSSPropertyID> propertyID, Document* document)
167180
{
168181
if (is<CSSPrimitiveValue>(cssValue)) {
@@ -303,7 +316,7 @@ ExceptionOr<Ref<CSSStyleValue>> CSSStyleValueFactory::reifyValue(Ref<CSSValue> c
303316
auto valueList = downcast<CSSValueList>(cssValue.ptr());
304317
if (!valueList->length())
305318
return Exception { TypeError, "The CSSValueList should not be empty."_s };
306-
if (valueList->length() == 1 || (propertyID && CSSProperty::isListValuedProperty(*propertyID)))
319+
if ((valueList->length() == 1 && mayConvertCSSValueListToSingleValue(propertyID)) || (propertyID && CSSProperty::isListValuedProperty(*propertyID)))
307320
return reifyValue(*valueList->begin(), propertyID, document);
308321
}
309322

0 commit comments

Comments
 (0)
0