Skip to content

Commit

Permalink
[view-transitions] auto is disallowed on view-transition-name
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267619
rdar://121094366

Reviewed by Anne van Kesteren.

Adopt the resolution from: w3c/csswg-drafts#9639

Add a custom parsing function since the auto-generated function does not support custom-ident restrictions.

* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/parsing/view-transition-name-invalid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/parsing/view-transition-name-invalid.html:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeViewTransitionName):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.h:

Canonical link: https://commits.webkit.org/273118@main
  • Loading branch information
nt1m committed Jan 17, 2024
1 parent b65f4ed commit 3586fe0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

PASS e.style['view-transition-name'] = "auto" should not set the property value
PASS e.style['view-transition-name'] = "default" should not set the property value
PASS e.style['view-transition-name'] = "none none" should not set the property value
PASS e.style['view-transition-name'] = "\"none\"" should not set the property value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</head>
<body>
<script>
test_invalid_value("view-transition-name", "auto"); // `auto` is excluded.
test_invalid_value("view-transition-name", "default"); // `default` isn't allowed by the `<custom-ident>` syntax.
test_invalid_value("view-transition-name", "none none");
test_invalid_value("view-transition-name", `"none"`);
Expand Down
5 changes: 3 additions & 2 deletions Source/WebCore/css/CSSProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -9251,7 +9251,9 @@
"view-transition-name": {
"codegen-properties": {
"converter": "ViewTransitionName",
"parser-grammar": "none | <custom-ident>",
"parser-function": "consumeViewTransitionName",
"parser-grammar-unused": "none | <custom-ident>",
"parser-grammar-unused-reason": "Needs support for applying restrictions to <custom-ident>. The <custom-ident> production used here excludes the keyword auto.",
"settings-flag": "viewTransitionsEnabled"
},
"specification": {
Expand Down Expand Up @@ -9407,7 +9409,6 @@
"parser-function-requires-context": true,
"parser-grammar-unused": "[ <integer [0,inf]> && <symbol> ]#",
"parser-grammar-unused-reason": "Needs support for '&&' groups"

},
"specification": {
"category": "css-counter-styles",
Expand Down
9 changes: 9 additions & 0 deletions Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8445,6 +8445,15 @@ RefPtr<CSSValue> consumeOffsetRotate(CSSParserTokenRange& range, CSSParserMode m
return CSSOffsetRotateValue::create(WTFMove(modifier), WTFMove(angle));
}

RefPtr<CSSValue> consumeViewTransitionName(CSSParserTokenRange& range)
{
if (auto noneValue = consumeIdent<CSSValueNone>(range))
return noneValue;
if (isAuto(range.peek().id()))
return nullptr;
return consumeCustomIdent(range);
}

// MARK: - @-rule descriptor consumers:

// MARK: @font-face
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/css/parser/CSSPropertyParserHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ RefPtr<CSSValue> consumeScrollSnapType(CSSParserTokenRange&);
RefPtr<CSSValue> consumeScrollbarColor(CSSParserTokenRange&, const CSSParserContext&);
RefPtr<CSSValue> consumeScrollbarGutter(CSSParserTokenRange&);
RefPtr<CSSValue> consumeTextBoxEdge(CSSParserTokenRange&);
RefPtr<CSSValue> consumeViewTransitionName(CSSParserTokenRange&);
RefPtr<CSSValue> consumeBorderRadiusCorner(CSSParserTokenRange&, CSSParserMode);
bool consumeRadii(std::array<RefPtr<CSSValue>, 4>& horizontalRadii, std::array<RefPtr<CSSValue>, 4>& verticalRadii, CSSParserTokenRange&, CSSParserMode, bool useLegacyParsing);
enum PathParsingOption : uint8_t { RejectRay = 1 << 0, RejectFillRule = 1 << 1 };
Expand Down

0 comments on commit 3586fe0

Please sign in to comment.