Bug 1320474 - Allow <string> in addition to <custom-ident> (excluding css-wide keywords and 'none') for css-animation keyframe names. r=birtles
authorJonathan Kew <jkew@mozilla.com>
Tue, 29 Nov 2016 12:58:44 +0000
changeset 324702 bed1ca42b7b4a29ef1638bee5156ba27ff3c4c7d
parent 324701 f7834b7b40502dc6b0231829b9786e6f37c8e918
child 324703 f41a419197de988085637d058a9d86f1a9cc4014
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersbirtles
bugs1320474
milestone53.0a1
Bug 1320474 - Allow <string> in addition to <custom-ident> (excluding css-wide keywords and 'none') for css-animation keyframe names. r=birtles
layout/style/nsCSSParser.cpp
layout/style/nsCSSPropList.h
layout/style/nsRuleNode.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4395,21 +4395,37 @@ CSSParserImpl::ParseKeyframesRule(RuleAp
 {
   uint32_t linenum, colnum;
   if (!GetNextTokenLocation(true, &linenum, &colnum) ||
       !GetToken(true)) {
     REPORT_UNEXPECTED_EOF(PEKeyframeNameEOF);
     return false;
   }
 
-  if (mToken.mType != eCSSToken_Ident) {
+  if (mToken.mType != eCSSToken_Ident && mToken.mType != eCSSToken_String) {
     REPORT_UNEXPECTED_TOKEN(PEKeyframeBadName);
     UngetToken();
     return false;
   }
+
+  if (mToken.mType == eCSSToken_Ident) {
+    // Check for keywords that are not allowed as custom-ident for the
+    // keyframes-name: standard CSS-wide keywords, plus 'none'.
+    static const nsCSSKeyword excludedKeywords[] = {
+      eCSSKeyword_none,
+      eCSSKeyword_UNKNOWN
+    };
+    nsCSSValue value;
+    if (!ParseCustomIdent(value, mToken.mIdent, excludedKeywords)) {
+      REPORT_UNEXPECTED_TOKEN(PEKeyframeBadName);
+      UngetToken();
+      return false;
+    }
+  }
+
   nsString name(mToken.mIdent);
 
   if (!ExpectSymbol('{', true)) {
     REPORT_UNEXPECTED_TOKEN(PEKeyframeBrace);
     return false;
   }
 
   RefPtr<nsCSSKeyframesRule> rule = new nsCSSKeyframesRule(name,
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -429,17 +429,17 @@ CSS_PROP_DISPLAY(
     animation-name,
     animation_name,
     AnimationName,
     CSS_PROPERTY_PARSE_VALUE_LIST |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
     "",
     // FIXME: The spec should say something about 'inherit' and 'initial'
     // not being allowed.
-    VARIANT_NONE | VARIANT_IDENTIFIER_NO_INHERIT, // used by list parsing
+    VARIANT_NONE | VARIANT_IDENTIFIER_NO_INHERIT | VARIANT_STRING, // used by list parsing
     nullptr,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
 CSS_PROP_DISPLAY(
     animation-play-state,
     animation_play_state,
     AnimationPlayState,
     CSS_PROPERTY_PARSE_VALUE_LIST |
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5704,16 +5704,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetName(parentDisplay->mAnimations[i].GetName());
     } else if (animName.unit == eCSSUnit_Initial ||
                animName.unit == eCSSUnit_Unset) {
       animation->SetName(EmptyString());
     } else if (animName.list) {
       switch (animName.list->mValue.GetUnit()) {
+        case eCSSUnit_String:
         case eCSSUnit_Ident: {
           nsDependentString
             nameStr(animName.list->mValue.GetStringBufferValue());
           animation->SetName(nameStr);
           break;
         }
         case eCSSUnit_None: {
           animation->SetName(EmptyString());