Skip to content
Permalink
Browse files
CSS Keyframes names can't be CSS wide keywords
https://bugs.webkit.org/show_bug.cgi?id=246596
rdar://101226253

Reviewed by Tim Nguyen.

The CSS Animations and CSS Values specifications require identifier-based
keyframes names to not be CSS wide keywords, nor "default", nor "none".

* LayoutTests/imported/w3c/web-platform-tests/css/css-animations/parsing/keyframes-name-invalid-expected.txt:
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeKeyframesRule): Forbid the invalid names.

Canonical link: https://commits.webkit.org/255640@main
  • Loading branch information
grorg committed Oct 17, 2022
1 parent 68f5a2f commit d71fb1b829e793d50dc0d909865611cdb22e5589
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
@@ -1,11 +1,11 @@

FAIL invalid: @keyframes none { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes default { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes initial { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes inherit { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes unset { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes revert { } assert_equals: expected 0 but got 1
FAIL invalid: @keyframes revert-layer { } assert_equals: expected 0 but got 1
PASS invalid: @keyframes none { }
PASS invalid: @keyframes default { }
PASS invalid: @keyframes initial { }
PASS invalid: @keyframes inherit { }
PASS invalid: @keyframes unset { }
PASS invalid: @keyframes revert { }
PASS invalid: @keyframes revert-layer { }
PASS invalid: @keyframes 12 { }
PASS invalid: @keyframes -12 { }
PASS invalid: @keyframes 12foo { }
@@ -648,13 +648,16 @@ RefPtr<StyleRuleKeyframes> CSSParserImpl::consumeKeyframesRule(CSSParserTokenRan
if (!prelude.atEnd())
return nullptr; // Parse error; expected single non-whitespace token in @keyframes header

AtomString name;
if (nameToken.type() == IdentToken) {
name = nameToken.value().toAtomString();
} else if (nameToken.type() == StringToken)
name = nameToken.value().toAtomString();
else
return nullptr; // Parse error; expected ident token in @keyframes header
// According to the CSS Values specification, identifier-based keyframe names
// are not allowed to be CSS wide keywords or "default". And CSS Animations
// additionally excludes the "none" keyword.
if (!isValidCustomIdentifier(nameToken.id()) || nameToken.id() == CSSValueNone)
return nullptr;
} else if (nameToken.type() != StringToken)
return nullptr; // Parse error; expected ident token or string in @keyframes header

auto name = nameToken.value().toAtomString();

if (m_observerWrapper) {
m_observerWrapper->observer().startRuleHeader(StyleRuleType::Keyframes, m_observerWrapper->startOffset(rangeCopy));

0 comments on commit d71fb1b

Please sign in to comment.