Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / parser / CSSPropertyParser.cpp
index a717ac7..7cf43db 100644 (file)
@@ -50,6 +50,7 @@
 #include "core/css/CSSKeyframesRule.h"
 #include "core/css/CSSLineBoxContainValue.h"
 #include "core/css/CSSPrimitiveValue.h"
+#include "core/css/CSSPropertyMetadata.h"
 #include "core/css/CSSPropertySourceData.h"
 #include "core/css/CSSReflectValue.h"
 #include "core/css/CSSSVGDocumentValue.h"
@@ -64,8 +65,6 @@
 #include "core/css/HashTools.h"
 #include "core/css/Pair.h"
 #include "core/css/Rect.h"
-#include "core/css/RuntimeCSSEnabled.h"
-#include "core/css/parser/BisonCSSParser.h"
 #include "core/css/parser/CSSParserIdioms.h"
 #include "core/css/parser/CSSParserValues.h"
 #include "core/frame/UseCounter.h"
@@ -87,16 +86,6 @@ namespace blink {
 static const double MAX_SCALE = 1000000;
 
 template <unsigned N>
-static bool equal(const CSSParserString& a, const char (&b)[N])
-{
-    unsigned length = N - 1; // Ignore the trailing null character
-    if (a.length() != length)
-        return false;
-
-    return a.is8Bit() ? WTF::equal(a.characters8(), reinterpret_cast<const LChar*>(b), length) : WTF::equal(a.characters16(), reinterpret_cast<const LChar*>(b), length);
-}
-
-template <unsigned N>
 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N])
 {
     unsigned length = N - 1; // Ignore the trailing null character
@@ -118,14 +107,13 @@ static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> createPrimitiveValuePair(PassRe
     return cssValuePool().createValue(Pair::create(first, second, identicalValuesPolicy));
 }
 
-CSSPropertyParser::CSSPropertyParser(OwnPtr<CSSParserValueList>& valueList,
-    const CSSParserContext& context, bool inViewport, bool savedImportant,
+CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList,
+    const CSSParserContext& context, bool inViewport,
     WillBeHeapVector<CSSProperty, 256>& parsedProperties,
     CSSRuleSourceData::Type ruleType)
     : m_valueList(valueList)
     , m_context(context)
     , m_inViewport(inViewport)
-    , m_important(savedImportant) // See comment in header, should be removed.
     , m_parsedProperties(parsedProperties)
     , m_ruleType(ruleType)
     , m_inParseShorthand(0)
@@ -134,8 +122,12 @@ CSSPropertyParser::CSSPropertyParser(OwnPtr<CSSParserValueList>& valueList,
 {
 }
 
-CSSPropertyParser::~CSSPropertyParser()
+bool CSSPropertyParser::parseValue(CSSPropertyID property, bool important,
+    CSSParserValueList* valueList, const CSSParserContext& context, bool inViewport,
+    WillBeHeapVector<CSSProperty, 256>& parsedProperties, CSSRuleSourceData::Type ruleType)
 {
+    CSSPropertyParser parser(valueList, context, inViewport, parsedProperties, ruleType);
+    return parser.parseValue(property, important);
 }
 
 void CSSPropertyParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtrWillBeRawPtr<CSSValue> value, bool important, bool implicit)
@@ -357,6 +349,14 @@ static inline bool isComma(CSSParserValue* value)
     return value && value->unit == CSSParserValue::Operator && value->iValue == ',';
 }
 
+static bool consumeComma(CSSParserValueList* valueList)
+{
+    if (!isComma(valueList->current()))
+        return false;
+    valueList->next();
+    return true;
+}
+
 static inline bool isForwardSlashOperator(CSSParserValue* value)
 {
     ASSERT(value);
@@ -368,17 +368,17 @@ static bool isGeneratedImageValue(CSSParserValue* val)
     if (val->unit != CSSParserValue::Function)
         return false;
 
-    return equalIgnoringCase(val->function->name, "-webkit-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")
-        || equalIgnoringCase(val->function->name, "linear-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient(")
-        || equalIgnoringCase(val->function->name, "repeating-linear-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-radial-gradient(")
-        || equalIgnoringCase(val->function->name, "radial-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient(")
-        || equalIgnoringCase(val->function->name, "repeating-radial-gradient(")
-        || equalIgnoringCase(val->function->name, "-webkit-canvas(")
-        || equalIgnoringCase(val->function->name, "-webkit-cross-fade(");
+    return equalIgnoringCase(val->function->name, "-webkit-gradient")
+        || equalIgnoringCase(val->function->name, "-webkit-linear-gradient")
+        || equalIgnoringCase(val->function->name, "linear-gradient")
+        || equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient")
+        || equalIgnoringCase(val->function->name, "repeating-linear-gradient")
+        || equalIgnoringCase(val->function->name, "-webkit-radial-gradient")
+        || equalIgnoringCase(val->function->name, "radial-gradient")
+        || equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient")
+        || equalIgnoringCase(val->function->name, "repeating-radial-gradient")
+        || equalIgnoringCase(val->function->name, "-webkit-canvas")
+        || equalIgnoringCase(val->function->name, "-webkit-cross-fade");
 }
 
 bool CSSPropertyParser::validWidthOrHeight(CSSParserValue* value)
@@ -489,20 +489,11 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertySize:                 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
         return parseSize(propId, important);
 
-    case CSSPropertyQuotes:               // [<string> <string>]+ | none | inherit
-        if (id)
+    case CSSPropertyQuotes: // [<string> <string>]+ | none
+        if (id == CSSValueNone)
             validPrimitive = true;
         else
-            return parseQuotes(propId, important);
-        break;
-    case CSSPropertyUnicodeBidi: // normal | embed | bidi-override | isolate | isolate-override | plaintext | inherit
-        if (id == CSSValueNormal
-            || id == CSSValueEmbed
-            || id == CSSValueBidiOverride
-            || id == CSSValueWebkitIsolate
-            || id == CSSValueWebkitIsolateOverride
-            || id == CSSValueWebkitPlaintext)
-            validPrimitive = true;
+            parsedValue = parseQuotes();
         break;
 
     case CSSPropertyContent:              // [ <string> | <uri> | <counter> | attr(X) | open-quote |
@@ -552,12 +543,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         return parseFontWeight(important);
     }
 
-    case CSSPropertyFontStretch: { // normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
-        if (m_valueList->size() != 1)
-            return false;
-        return parseFontStretch(important);
-    }
-
     case CSSPropertyBorderSpacing: {
         if (num == 1) {
             ShorthandScope scope(this, CSSPropertyBorderSpacing);
@@ -602,9 +587,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyWebkitTextEmphasisColor:
     case CSSPropertyWebkitTextFillColor:
     case CSSPropertyWebkitTextStrokeColor:
-        if (propId == CSSPropertyTextDecorationColor
-            && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
-            return false;
+        ASSERT(propId != CSSPropertyTextDecorationColor || RuntimeEnabledFeatures::css3TextDecorationsEnabled());
 
         if ((id >= CSSValueAqua && id <= CSSValueWebkitText) || id == CSSValueMenu) {
             validPrimitive = isValueAllowedInMode(id, m_context.mode());
@@ -653,8 +636,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
                 String uri = value->string;
                 if (!uri.isNull())
                     image = createCSSImageValueWithReferrer(uri, completeURL(uri));
-            } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
-                image = parseImageSet(m_valueList.get());
+            } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set")) {
+                image = parseImageSet(m_valueList);
                 if (!image)
                     break;
             } else
@@ -682,9 +665,9 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
             if (image)
                 list->append(CSSCursorImageValue::create(image, hasHotSpot, hotSpot));
 
-            if (!value || !(value->unit == CSSParserValue::Operator && value->iValue == ','))
+            if (!consumeComma(m_valueList))
                 return false;
-            value = m_valueList->next(); // comma
+            value = m_valueList->current();
         }
         if (value && m_context.useCounter()) {
             if (value->id == CSSValueWebkitZoomIn)
@@ -731,8 +714,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyBackgroundSize:
     case CSSPropertyWebkitBackgroundSize:
     case CSSPropertyBackgroundRepeat:
-    case CSSPropertyBackgroundRepeatX:
-    case CSSPropertyBackgroundRepeatY:
     case CSSPropertyWebkitMaskClip:
     case CSSPropertyWebkitMaskComposite:
     case CSSPropertyWebkitMaskImage:
@@ -769,7 +750,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         return result;
     }
     case CSSPropertyObjectPosition:
-        return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObjectPosition(important);
+        parsedValue = parseObjectPosition();
+        break;
     case CSSPropertyListStyleImage:     // <uri> | none | inherit
     case CSSPropertyBorderImageSource:
     case CSSPropertyWebkitMaskBoxImageSource:
@@ -780,13 +762,13 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
             parsedValue = createCSSImageValueWithReferrer(value->string, completeURL(value->string));
             m_valueList->next();
         } else if (isGeneratedImageValue(value)) {
-            if (parseGeneratedImage(m_valueList.get(), parsedValue))
+            if (parseGeneratedImage(m_valueList, parsedValue))
                 m_valueList->next();
             else
                 return false;
         }
-        else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set(")) {
-            parsedValue = parseImageSet(m_valueList.get());
+        else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "-webkit-image-set")) {
+            parsedValue = parseImageSet(m_valueList);
             if (!parsedValue)
                 return false;
             m_valueList->next();
@@ -893,27 +875,29 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         if (id == CSSValueAuto)
             validPrimitive = true;
         else
-            validPrimitive = (!id && validUnit(value, FPositiveInteger, HTMLQuirksMode));
+            validPrimitive = (!id && validUnit(value, FPositiveInteger));
         break;
 
     case CSSPropertyZIndex: // auto | <integer> | inherit
         if (id == CSSValueAuto)
             validPrimitive = true;
         else
-            validPrimitive = (!id && validUnit(value, FInteger, HTMLQuirksMode));
+            validPrimitive = (!id && validUnit(value, FInteger));
         break;
 
     case CSSPropertyLineHeight:
         return parseLineHeight(important);
-    case CSSPropertyCounterIncrement:    // [ <identifier> <integer>? ]+ | none | inherit
-        if (id != CSSValueNone)
-            return parseCounter(propId, 1, important);
-        validPrimitive = true;
+    case CSSPropertyCounterIncrement:
+        if (id == CSSValueNone)
+            validPrimitive = true;
+        else
+            parsedValue = parseCounter(1);
         break;
-    case CSSPropertyCounterReset:        // [ <identifier> <integer>? ]+ | none | inherit
-        if (id != CSSValueNone)
-            return parseCounter(propId, 0, important);
-        validPrimitive = true;
+    case CSSPropertyCounterReset:
+        if (id == CSSValueNone)
+            validPrimitive = true;
+        else
+            parsedValue = parseCounter(0);
         break;
     case CSSPropertyFontFamily:
         // [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
@@ -934,31 +918,25 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         // none | [ underline || overline || line-through || blink ] | inherit
         return parseTextDecoration(propId, important);
 
-    case CSSPropertyTextDecorationStyle:
-        // solid | double | dotted | dashed | wavy
-        if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()
-            && (id == CSSValueSolid || id == CSSValueDouble || id == CSSValueDotted || id == CSSValueDashed || id == CSSValueWavy))
-            validPrimitive = true;
-        break;
-
     case CSSPropertyTextUnderlinePosition:
         // auto | under | inherit
-        if (RuntimeEnabledFeatures::css3TextDecorationsEnabled())
-            return parseTextUnderlinePosition(important);
-        return false;
+        ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
+        return parseTextUnderlinePosition(important);
 
     case CSSPropertyZoom:          // normal | reset | document | <number> | <percentage> | inherit
         if (id == CSSValueNormal || id == CSSValueReset || id == CSSValueDocument)
             validPrimitive = true;
         else
-            validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg, HTMLStandardMode));
+            validPrimitive = (!id && validUnit(value, FNumber | FPercent | FNonNeg));
         break;
 
     case CSSPropertySrc: // Only used within @font-face and @-webkit-filter, so cannot use inherit | initial or be !important. This is a list of urls or local references.
-        return parseFontFaceSrc();
+        parsedValue = parseFontFaceSrc();
+        break;
 
     case CSSPropertyUnicodeRange:
-        return parseFontFaceUnicodeRange();
+        parsedValue = parseFontFaceUnicodeRange();
+        break;
 
     /* CSS3 properties */
 
@@ -1036,7 +1014,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         validPrimitive = validUnit(value, FInteger | FNonNeg);
         break;
     case CSSPropertyWebkitAspectRatio:
-        return parseAspectRatio(important);
+        parsedValue = parseAspectRatio();
+        break;
     case CSSPropertyBorderRadius:
     case CSSPropertyWebkitBorderRadius:
         return parseBorderRadius(propId, important);
@@ -1049,7 +1028,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         if (id == CSSValueNone)
             validPrimitive = true;
         else {
-            RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(m_valueList.get(), propId);
+            RefPtrWillBeRawPtr<CSSValueList> shadowValueList = parseShadow(m_valueList, propId);
             if (shadowValueList) {
                 addProperty(propId, shadowValueList.release(), important);
                 m_valueList->next();
@@ -1062,7 +1041,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         if (id == CSSValueNone)
             validPrimitive = true;
         else
-            return parseReflect(propId, important);
+            parsedValue = parseReflect();
         break;
     case CSSPropertyOpacity:
         validPrimitive = validUnit(value, FNumber);
@@ -1071,10 +1050,10 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         validPrimitive = validUnit(value, FNumber);
         break;
     case CSSPropertyWebkitBoxFlexGroup:
-        validPrimitive = validUnit(value, FInteger | FNonNeg, HTMLStandardMode);
+        validPrimitive = validUnit(value, FInteger | FNonNeg);
         break;
     case CSSPropertyWebkitBoxOrdinalGroup:
-        validPrimitive = validUnit(value, FInteger | FNonNeg, HTMLStandardMode) && value->fValue;
+        validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
         break;
     case CSSPropertyWebkitFilter:
         if (id == CSSValueNone)
@@ -1096,7 +1075,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
             addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important);
             return true;
         }
-        return parseFlex(m_valueList.get(), important);
+        return parseFlex(m_valueList, important);
     }
     case CSSPropertyFlexBasis:
         // FIXME: Support intrinsic dimensions too.
@@ -1110,7 +1089,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         validPrimitive = validUnit(value, FNumber | FNonNeg);
         break;
     case CSSPropertyOrder:
-        validPrimitive = validUnit(value, FInteger, HTMLStandardMode);
+        validPrimitive = validUnit(value, FInteger);
         break;
     case CSSPropertyInternalMarqueeIncrement:
         validPrimitive = validUnit(value, FLength | FPercent);
@@ -1149,13 +1128,15 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         addProperty(propId, list.release(), important);
         return true;
     }
+    case CSSPropertyWebkitPerspectiveOriginX:
     case CSSPropertyWebkitTransformOriginX:
-        parsedValue = parseFillPositionX(m_valueList.get());
+        parsedValue = parseFillPositionX(m_valueList);
         if (parsedValue)
             m_valueList->next();
         break;
+    case CSSPropertyWebkitPerspectiveOriginY:
     case CSSPropertyWebkitTransformOriginY:
-        parsedValue = parseFillPositionY(m_valueList.get());
+        parsedValue = parseFillPositionY(m_valueList);
         if (parsedValue)
             m_valueList->next();
         break;
@@ -1181,7 +1162,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
             return true;
         }
         break;
-    case CSSPropertyPerspectiveOrigin: {
+    case CSSPropertyPerspectiveOrigin:
+    case CSSPropertyWebkitPerspectiveOrigin: {
         RefPtrWillBeRawPtr<CSSValueList> list = parseTransformOrigin();
         if (!list || list->length() == 3)
             return false;
@@ -1191,20 +1173,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         addProperty(propId, list.release(), important);
         return true;
     }
-    case CSSPropertyWebkitPerspectiveOrigin:
-    case CSSPropertyWebkitPerspectiveOriginX:
-    case CSSPropertyWebkitPerspectiveOriginY: {
-        RefPtrWillBeRawPtr<CSSValue> val1 = nullptr;
-        RefPtrWillBeRawPtr<CSSValue> val2 = nullptr;
-        CSSPropertyID propId1, propId2;
-        if (parseWebkitPerspectiveOrigin(propId, propId1, propId2, val1, val2)) {
-            addProperty(propId1, val1.release(), important);
-            if (val2)
-                addProperty(propId2, val2.release(), important);
-            return true;
-        }
-        return false;
-    }
     case CSSPropertyAnimationDelay:
     case CSSPropertyAnimationDirection:
     case CSSPropertyAnimationDuration:
@@ -1213,8 +1181,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyAnimationPlayState:
     case CSSPropertyAnimationIterationCount:
     case CSSPropertyAnimationTimingFunction:
-        if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
-            break;
+        ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
     case CSSPropertyWebkitAnimationDelay:
     case CSSPropertyWebkitAnimationDirection:
     case CSSPropertyWebkitAnimationDuration:
@@ -1239,13 +1206,10 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     }
 
     case CSSPropertyJustifySelf:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
-
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseItemPositionOverflowPosition(propId, important);
     case CSSPropertyJustifyItems:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
 
         if (parseLegacyPosition(propId, important))
             return true;
@@ -1253,58 +1217,49 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         m_valueList->setCurrentIndex(0);
         return parseItemPositionOverflowPosition(propId, important);
     case CSSPropertyGridAutoFlow:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         parsedValue = parseGridAutoFlow(*m_valueList);
         break;
     case CSSPropertyGridAutoColumns:
     case CSSPropertyGridAutoRows:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         parsedValue = parseGridTrackSize(*m_valueList);
         break;
 
     case CSSPropertyGridTemplateColumns:
     case CSSPropertyGridTemplateRows:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
-        parsedValue = parseGridTrackList(important);
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
+        parsedValue = parseGridTrackList();
         break;
 
     case CSSPropertyGridColumnEnd:
     case CSSPropertyGridColumnStart:
     case CSSPropertyGridRowEnd:
     case CSSPropertyGridRowStart:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         parsedValue = parseGridPosition();
         break;
 
     case CSSPropertyGridColumn:
     case CSSPropertyGridRow:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseGridItemPositionShorthand(propId, important);
 
     case CSSPropertyGridArea:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseGridAreaShorthand(important);
 
     case CSSPropertyGridTemplateAreas:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         parsedValue = parseGridTemplateAreas();
         break;
 
     case CSSPropertyGridTemplate:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseGridTemplateShorthand(important);
 
     case CSSPropertyGrid:
-        if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
-            return false;
+        ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseGridShorthand(important);
 
     case CSSPropertyWebkitMarginCollapse: {
@@ -1340,9 +1295,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         parsedValue = parseColumnWidth();
         break;
     case CSSPropertyWillChange:
-        if (!RuntimeEnabledFeatures::cssWillChangeEnabled())
-            return false;
-        return parseWillChange(important);
+        parsedValue = parseWillChange();
+        break;
     // End of CSS3 properties
 
     // Apple specific properties.  These will never be standardized and are purely to
@@ -1350,7 +1304,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyWebkitLineClamp:
         // When specifying number of lines, don't allow 0 as a valid value
         // When specifying either type of unit, require non-negative integers
-        validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg, HTMLQuirksMode));
+        validPrimitive = (!id && (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE || value->fValue) && validUnit(value, FInteger | FPercent | FNonNeg));
         break;
 
     case CSSPropertyWebkitFontSizeDelta:           // <length>
@@ -1472,8 +1426,7 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyWebkitTextStroke:
         return parseShorthand(propId, webkitTextStrokeShorthand(), important);
     case CSSPropertyAnimation:
-        if (!RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled())
-            break;
+        ASSERT(RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
     case CSSPropertyWebkitAnimation:
         return parseAnimationShorthand(propId, important);
     case CSSPropertyTransition:
@@ -1537,8 +1490,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         break;
 
     case CSSPropertyTouchAction:
-        // auto | none | [pan-x || pan-y] | manipulation
-        return parseTouchAction(important);
+        parsedValue = parseTouchAction();
+        break;
 
     case CSSPropertyAlignSelf:
         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
@@ -1548,95 +1501,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
         return parseItemPositionOverflowPosition(propId, important);
 
-    case CSSPropertyBorderBottomStyle:
-    case CSSPropertyBorderCollapse:
-    case CSSPropertyBorderLeftStyle:
-    case CSSPropertyBorderRightStyle:
-    case CSSPropertyBorderTopStyle:
-    case CSSPropertyBoxSizing:
-    case CSSPropertyCaptionSide:
-    case CSSPropertyClear:
-    case CSSPropertyDirection:
-    case CSSPropertyDisplay:
-    case CSSPropertyEmptyCells:
-    case CSSPropertyFloat:
-    case CSSPropertyFontStyle:
-    case CSSPropertyImageRendering:
-    case CSSPropertyListStylePosition:
-    case CSSPropertyListStyleType:
-    case CSSPropertyObjectFit:
-    case CSSPropertyOutlineStyle:
-    case CSSPropertyOverflowWrap:
-    case CSSPropertyOverflowX:
-    case CSSPropertyOverflowY:
-    case CSSPropertyPageBreakAfter:
-    case CSSPropertyPageBreakBefore:
-    case CSSPropertyPageBreakInside:
-    case CSSPropertyPointerEvents:
-    case CSSPropertyPosition:
-    case CSSPropertyResize:
-    case CSSPropertySpeak:
-    case CSSPropertyTableLayout:
-    case CSSPropertyTextAlignLast:
-    case CSSPropertyTextJustify:
-    case CSSPropertyTextOverflow:
-    case CSSPropertyTextRendering:
-    case CSSPropertyTextTransform:
-    case CSSPropertyTouchActionDelay:
-    case CSSPropertyVisibility:
-    case CSSPropertyWebkitAppearance:
-    case CSSPropertyBackfaceVisibility:
-    case CSSPropertyWebkitBackfaceVisibility:
-    case CSSPropertyWebkitBorderAfterStyle:
-    case CSSPropertyWebkitBorderBeforeStyle:
-    case CSSPropertyWebkitBorderEndStyle:
-    case CSSPropertyWebkitBorderFit:
-    case CSSPropertyWebkitBorderStartStyle:
-    case CSSPropertyWebkitBoxAlign:
-    case CSSPropertyWebkitBoxDecorationBreak:
-    case CSSPropertyWebkitBoxDirection:
-    case CSSPropertyWebkitBoxLines:
-    case CSSPropertyWebkitBoxOrient:
-    case CSSPropertyWebkitBoxPack:
-    case CSSPropertyInternalCallback:
-    case CSSPropertyWebkitColumnBreakAfter:
-    case CSSPropertyWebkitColumnBreakBefore:
-    case CSSPropertyWebkitColumnBreakInside:
-    case CSSPropertyColumnFill:
-    case CSSPropertyWebkitColumnRuleStyle:
-    case CSSPropertyAlignContent:
-    case CSSPropertyFlexDirection:
-    case CSSPropertyFlexWrap:
-    case CSSPropertyJustifyContent:
-    case CSSPropertyFontKerning:
-    case CSSPropertyWebkitFontSmoothing:
-    case CSSPropertyWebkitLineBreak:
-    case CSSPropertyWebkitMarginAfterCollapse:
-    case CSSPropertyWebkitMarginBeforeCollapse:
-    case CSSPropertyWebkitMarginBottomCollapse:
-    case CSSPropertyWebkitMarginTopCollapse:
-    case CSSPropertyInternalMarqueeDirection:
-    case CSSPropertyInternalMarqueeStyle:
-    case CSSPropertyWebkitPrintColorAdjust:
-    case CSSPropertyWebkitRtlOrdering:
-    case CSSPropertyWebkitRubyPosition:
-    case CSSPropertyWebkitTextCombine:
-    case CSSPropertyWebkitTextEmphasisPosition:
-    case CSSPropertyWebkitTextSecurity:
-    case CSSPropertyTransformStyle:
-    case CSSPropertyWebkitTransformStyle:
-    case CSSPropertyWebkitUserDrag:
-    case CSSPropertyWebkitUserModify:
-    case CSSPropertyWebkitUserSelect:
-    case CSSPropertyWebkitWritingMode:
-    case CSSPropertyWhiteSpace:
-    case CSSPropertyWordBreak:
-    case CSSPropertyWordWrap:
-    case CSSPropertyMixBlendMode:
-    case CSSPropertyIsolation:
-        // These properties should be handled before in isValidKeywordPropertyAndValue().
-        ASSERT_NOT_REACHED();
-        return false;
     // Properties below are validated inside parseViewportProperty, because we
     // check for parser state. We need to invalidate if someone adds them outside
     // a @viewport rule.
@@ -1647,13 +1511,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID propId, bool important)
         validPrimitive = false;
         break;
 
-    case CSSPropertyAll:
-        if (id == CSSValueInitial || id == CSSValueInherit || id == CSSValueUnset) {
-            validPrimitive = true;
-            break;
-        }
-        return false;
-
     default:
         return parseSVGValue(propId, important);
     }
@@ -1888,10 +1745,8 @@ bool CSSPropertyParser::parseAnimationShorthand(CSSPropertyID propId, bool impor
         values[i] = CSSValueList::createCommaSeparated();
 
     while (m_valueList->current()) {
-        CSSParserValue* val = m_valueList->current();
-        if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+        if (consumeComma(m_valueList)) {
             // We hit the end. Fill in all remaining values with the initial value.
-            m_valueList->next();
             for (size_t i = 0; i < numProperties; ++i) {
                 if (!parsedProperty[i])
                     values[i]->append(cssValuePool().createImplicitInitialValue());
@@ -1946,10 +1801,8 @@ bool CSSPropertyParser::parseTransitionShorthand(CSSPropertyID propId, bool impo
         values[i] = CSSValueList::createCommaSeparated();
 
     while (m_valueList->current()) {
-        CSSParserValue* val = m_valueList->current();
-        if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+        if (consumeComma(m_valueList)) {
             // We hit the end. Fill in all remaining values with the initial value.
-            m_valueList->next();
             for (size_t i = 0; i < numProperties; ++i) {
                 if (!parsedProperty[i])
                     values[i]->append(cssValuePool().createImplicitInitialValue());
@@ -2007,7 +1860,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseColumnCount()
 {
     CSSParserValue* value = m_valueList->current();
     if (value->id == CSSValueAuto
-        || (!value->id && validUnit(value, FPositiveInteger, HTMLQuirksMode))) {
+        || (!value->id && validUnit(value, FPositiveInteger))) {
         RefPtrWillBeRawPtr<CSSValue> parsedValue = parseValidPrimitive(value->id, value);
         m_valueList->next();
         return parsedValue;
@@ -2100,7 +1953,7 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID propId, const StyleProperty
         return true;
 
     // Fill in any remaining properties with the initial value.
-    ImplicitScope implicitScope(this, PropertyImplicit);
+    ImplicitScope implicitScope(this);
     const StylePropertyShorthand* const* const propertiesForInitialization = shorthand.propertiesForInitialization();
     for (unsigned i = 0; i < shorthand.length(); ++i) {
         if (propertyFound[i])
@@ -2137,7 +1990,7 @@ bool CSSPropertyParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *
             if (!parseValue(properties[0], important))
                 return false;
             CSSValue* value = m_parsedProperties.last().value();
-            ImplicitScope implicitScope(this, PropertyImplicit);
+            ImplicitScope implicitScope(this);
             addProperty(properties[1], value, important);
             addProperty(properties[2], value, important);
             addProperty(properties[3], value, important);
@@ -2147,7 +2000,7 @@ bool CSSPropertyParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *
             if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
                 return false;
             CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
-            ImplicitScope implicitScope(this, PropertyImplicit);
+            ImplicitScope implicitScope(this);
             addProperty(properties[2], value, important);
             value = m_parsedProperties[m_parsedProperties.size() - 2].value();
             addProperty(properties[3], value, important);
@@ -2157,7 +2010,7 @@ bool CSSPropertyParser::parse4Values(CSSPropertyID propId, const CSSPropertyID *
             if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important))
                 return false;
             CSSValue* value = m_parsedProperties[m_parsedProperties.size() - 2].value();
-            ImplicitScope implicitScope(this, PropertyImplicit);
+            ImplicitScope implicitScope(this);
             addProperty(properties[3], value, important);
             break;
         }
@@ -2270,26 +2123,21 @@ CSSPropertyParser::SizeParameterType CSSPropertyParser::parseSizeParameter(CSSVa
     }
 }
 
-// [ <string> <string> ]+ | inherit | none
-// inherit and none are handled in parseValue.
-bool CSSPropertyParser::parseQuotes(CSSPropertyID propId, bool important)
+// [ <string> <string> ]+ | none, but none is handled in parseValue
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseQuotes()
 {
     RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
     while (CSSParserValue* val = m_valueList->current()) {
         RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr;
-        if (val->unit == CSSPrimitiveValue::CSS_STRING)
-            parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
-        else
-            break;
+        if (val->unit != CSSPrimitiveValue::CSS_STRING)
+            return nullptr;
+        parsedValue = CSSPrimitiveValue::create(val->string, CSSPrimitiveValue::CSS_STRING);
         values->append(parsedValue.release());
         m_valueList->next();
     }
-    if (values->length() && values->length() % 2 == 0) {
-        addProperty(propId, values.release(), important);
-        m_valueList->next();
-        return true;
-    }
-    return false;
+    if (values->length() && values->length() % 2 == 0)
+        return values.release();
+    return nullptr;
 }
 
 // [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
@@ -2309,36 +2157,28 @@ bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important)
             CSSParserValueList* args = val->function->args.get();
             if (!args)
                 return false;
-            if (equalIgnoringCase(val->function->name, "attr(")) {
+            if (equalIgnoringCase(val->function->name, "attr")) {
                 parsedValue = parseAttr(args);
                 if (!parsedValue)
                     return false;
-            } else if (equalIgnoringCase(val->function->name, "counter(")) {
+            } else if (equalIgnoringCase(val->function->name, "counter")) {
                 parsedValue = parseCounterContent(args, false);
                 if (!parsedValue)
                     return false;
-            } else if (equalIgnoringCase(val->function->name, "counters(")) {
+            } else if (equalIgnoringCase(val->function->name, "counters")) {
                 parsedValue = parseCounterContent(args, true);
                 if (!parsedValue)
                     return false;
-            } else if (equalIgnoringCase(val->function->name, "-webkit-image-set(")) {
-                parsedValue = parseImageSet(m_valueList.get());
+            } else if (equalIgnoringCase(val->function->name, "-webkit-image-set")) {
+                parsedValue = parseImageSet(m_valueList);
                 if (!parsedValue)
                     return false;
             } else if (isGeneratedImageValue(val)) {
-                if (!parseGeneratedImage(m_valueList.get(), parsedValue))
+                if (!parseGeneratedImage(m_valueList, parsedValue))
                     return false;
             } else
                 return false;
         } else if (val->unit == CSSPrimitiveValue::CSS_IDENT) {
-            // open-quote
-            // close-quote
-            // no-open-quote
-            // no-close-quote
-            // inherit
-            // FIXME: These are not yet implemented (http://bugs.webkit.org/show_bug.cgi?id=6503).
-            // none
-            // normal
             switch (val->id) {
             case CSSValueOpenQuote:
             case CSSValueCloseQuote:
@@ -2414,8 +2254,8 @@ bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
     if (isGeneratedImageValue(valueList->current()))
         return parseGeneratedImage(valueList, value);
 
-    if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringCase(valueList->current()->function->name, "-webkit-image-set(")) {
-        value = parseImageSet(m_valueList.get());
+    if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringCase(valueList->current()->function->name, "-webkit-image-set")) {
+        value = parseImageSet(m_valueList);
         if (value)
             return true;
     }
@@ -2910,7 +2750,7 @@ bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
                     break;
                 case CSSPropertyBackgroundImage:
                 case CSSPropertyWebkitMaskImage:
-                    if (parseFillImage(m_valueList.get(), currValue))
+                    if (parseFillImage(m_valueList, currValue))
                         m_valueList->next();
                     break;
                 case CSSPropertyWebkitBackgroundClip:
@@ -2939,19 +2779,19 @@ bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
                     break;
                 case CSSPropertyBackgroundPosition:
                 case CSSPropertyWebkitMaskPosition:
-                    parseFillPosition(m_valueList.get(), currValue, currValue2);
+                    parseFillPosition(m_valueList, currValue, currValue2);
                     // parseFillPosition advances the m_valueList pointer.
                     break;
                 case CSSPropertyBackgroundPositionX:
                 case CSSPropertyWebkitMaskPositionX: {
-                    currValue = parseFillPositionX(m_valueList.get());
+                    currValue = parseFillPositionX(m_valueList);
                     if (currValue)
                         m_valueList->next();
                     break;
                 }
                 case CSSPropertyBackgroundPositionY:
                 case CSSPropertyWebkitMaskPositionY: {
-                    currValue = parseFillPositionY(m_valueList.get());
+                    currValue = parseFillPositionY(m_valueList);
                     if (currValue)
                         m_valueList->next();
                     break;
@@ -2988,13 +2828,12 @@ bool CSSPropertyParser::parseFillProperty(CSSPropertyID propId, CSSPropertyID& p
                     break;
                 }
                 case CSSPropertyMaskSourceType: {
-                    if (RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()) {
-                        if (val->id == CSSValueAuto || val->id == CSSValueAlpha || val->id == CSSValueLuminance) {
-                            currValue = cssValuePool().createIdentifierValue(val->id);
-                            m_valueList->next();
-                        } else {
-                            currValue = nullptr;
-                        }
+                    ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled());
+                    if (val->id == CSSValueAuto || val->id == CSSValueAlpha || val->id == CSSValueLuminance) {
+                        currValue = cssValuePool().createIdentifierValue(val->id);
+                        m_valueList->next();
+                    } else {
+                        currValue = nullptr;
                     }
                     break;
                 }
@@ -3117,14 +2956,16 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationProperty()
     // Since all is valid css property keyword, cssPropertyID for all
     // returns non-null value. We need to check "all" before
     // cssPropertyID check.
-    if (equalIgnoringCase(value, "all"))
+    if (value->id == CSSValueAll)
         return cssValuePool().createIdentifierValue(CSSValueAll);
-    CSSPropertyID result = cssPropertyID(value->string);
-    if (result && RuntimeCSSEnabled::isCSSPropertyEnabled(result))
-        return cssValuePool().createIdentifierValue(result);
-    if (equalIgnoringCase(value, "none"))
+    CSSPropertyID property = cssPropertyID(value->string);
+    if (property) {
+        ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
+        return cssValuePool().createIdentifierValue(property);
+    }
+    if (value->id == CSSValueNone)
         return cssValuePool().createIdentifierValue(CSSValueNone);
-    if (equalIgnoringCase(value, "inherit") || equalIgnoringCase(value, "initial"))
+    if (value->id == CSSValueInitial || value->id == CSSValueInherit)
         return nullptr;
     return createPrimitiveStringValue(value);
 }
@@ -3135,7 +2976,7 @@ bool CSSPropertyParser::parseWebkitTransformOriginShorthand(bool important)
     RefPtrWillBeRawPtr<CSSValue> originY = nullptr;
     RefPtrWillBeRawPtr<CSSValue> originZ = nullptr;
 
-    parse2ValuesFillPosition(m_valueList.get(), originX, originY);
+    parse2ValuesFillPosition(m_valueList, originX, originY);
 
     if (m_valueList->current()) {
         if (!validUnit(m_valueList->current(), FLength))
@@ -3163,10 +3004,7 @@ bool CSSPropertyParser::parseCubicBezierTimingFunctionValue(CSSParserValueList*&
     if (!v)
         // The last number in the function has no comma after it, so we're done.
         return true;
-    if (!isComma(v))
-        return false;
-    args->next();
-    return true;
+    return consumeComma(args);
 }
 
 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction()
@@ -3174,7 +3012,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
     CSSParserValue* value = m_valueList->current();
     if (value->id == CSSValueEase || value->id == CSSValueLinear || value->id == CSSValueEaseIn || value->id == CSSValueEaseOut
         || value->id == CSSValueEaseInOut || value->id == CSSValueStepStart || value->id == CSSValueStepEnd
-        || (value->id == CSSValueStepMiddle && RuntimeEnabledFeatures::webAnimationsElementAnimateEnabled()))
+        || value->id == CSSValueStepMiddle)
         return cssValuePool().createIdentifierValue(value->id);
 
     // We must be a function.
@@ -3183,14 +3021,14 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
 
     CSSParserValueList* args = value->function->args.get();
 
-    if (equalIgnoringCase(value->function->name, "steps(")) {
+    if (equalIgnoringCase(value->function->name, "steps")) {
         // For steps, 1 or 2 params must be specified (comma-separated)
         if (!args || (args->size() != 1 && args->size() != 3))
             return nullptr;
 
         // There are two values.
         int numSteps;
-        StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction::StepAtEnd;
+        StepsTimingFunction::StepAtPosition stepAtPosition = StepsTimingFunction::End;
 
         CSSParserValue* v = args->current();
         if (!validUnit(v, FInteger))
@@ -3198,24 +3036,22 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
         numSteps = clampToInteger(v->fValue);
         if (numSteps < 1)
             return nullptr;
-        v = args->next();
 
-        if (v) {
+        if (args->next()) {
             // There is a comma so we need to parse the second value
-            if (!isComma(v))
+            if (!consumeComma(args))
                 return nullptr;
-            v = args->next();
-            switch (v->id) {
+            switch (args->current()->id) {
             case CSSValueMiddle:
                 if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled())
                     return nullptr;
-                stepAtPosition = StepsTimingFunction::StepAtMiddle;
+                stepAtPosition = StepsTimingFunction::Middle;
                 break;
             case CSSValueStart:
-                stepAtPosition = StepsTimingFunction::StepAtStart;
+                stepAtPosition = StepsTimingFunction::Start;
                 break;
             case CSSValueEnd:
-                stepAtPosition = StepsTimingFunction::StepAtEnd;
+                stepAtPosition = StepsTimingFunction::End;
                 break;
             default:
                 return nullptr;
@@ -3225,7 +3061,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAnimationTimingFunction
         return CSSStepsTimingFunctionValue::create(numSteps, stepAtPosition);
     }
 
-    if (equalIgnoringCase(value->function->name, "cubic-bezier(")) {
+    if (equalIgnoringCase(value->function->name, "cubic-bezier")) {
         // For cubic bezier, 4 values must be specified.
         if (!args || args->size() != 7)
             return nullptr;
@@ -3501,10 +3337,8 @@ bool CSSPropertyParser::parseGridTemplateRowsAndAreas(PassRefPtrWillBeRawPtr<CSS
 
         // This will handle the trailing/leading <custom-ident>* in the grammar.
         trailingIdentWasAdded = false;
-        if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList) {
-            parseGridLineNames(*m_valueList, *templateRows);
-            trailingIdentWasAdded = true;
-        }
+        if (m_valueList->current() && m_valueList->current()->unit == CSSParserValue::ValueList)
+            trailingIdentWasAdded = parseGridLineNames(*m_valueList, *templateRows);
     }
 
     // [<track-list> /]?
@@ -3549,7 +3383,7 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
     if (firstValueIsNone) {
         columnsValue = cssValuePool().createIdentifierValue(CSSValueNone);
     } else {
-        columnsValue = parseGridTrackList(important);
+        columnsValue = parseGridTrackList();
     }
 
     // 2- <grid-template-columns> / <grid-template-columns> syntax.
@@ -3557,7 +3391,7 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
         if (!(m_valueList->current() && isForwardSlashOperator(m_valueList->current()) && m_valueList->next()))
             return false;
         index = m_valueList->currentIndex();
-        if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList(important)) {
+        if (RefPtrWillBeRawPtr<CSSValue> rowsValue = parseGridTrackList()) {
             if (m_valueList->current())
                 return false;
             addProperty(CSSPropertyGridTemplateColumns, columnsValue, important);
@@ -3580,7 +3414,7 @@ bool CSSPropertyParser::parseGridTemplateShorthand(bool important)
 bool CSSPropertyParser::parseGridShorthand(bool important)
 {
     ShorthandScope scope(this, CSSPropertyGrid);
-    ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 4);
+    ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 6);
 
     // 1- <grid-template>
     if (parseGridTemplateShorthand(important)) {
@@ -3692,14 +3526,14 @@ bool CSSPropertyParser::parseSingleGridAreaLonghand(RefPtrWillBeRawPtr<CSSValue>
     return true;
 }
 
-void CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
+bool CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSValueList& valueList, CSSGridLineNamesValue* previousNamedAreaTrailingLineNames)
 {
     ASSERT(inputList.current() && inputList.current()->unit == CSSParserValue::ValueList);
 
     CSSParserValueList* identList = inputList.current()->valueList;
     if (!identList->size()) {
         inputList.next();
-        return;
+        return false;
     }
 
     // Need to ensure the identList is at the heading index, since the parserList might have been rewound.
@@ -3718,9 +3552,10 @@ void CSSPropertyParser::parseGridLineNames(CSSParserValueList& inputList, CSSVal
         valueList.append(lineNames.release());
 
     inputList.next();
+    return true;
 }
 
-PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList()
 {
     ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
 
@@ -3740,7 +3575,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackList(bool impo
     while (CSSParserValue* currentValue = m_valueList->current()) {
         if (isForwardSlashOperator(currentValue))
             break;
-        if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "repeat(")) {
+        if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "repeat")) {
             if (!parseGridTrackRepeatFunction(*values))
                 return nullptr;
             seenTrackSizeOrRepeatFunction = true;
@@ -3786,12 +3621,14 @@ bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list)
     if (currentValue && currentValue->unit == CSSParserValue::ValueList)
         parseGridLineNames(*arguments, *repeatedValues);
 
+    bool seenTrackSize = false;
     while (arguments->current()) {
         RefPtrWillBeRawPtr<CSSValue> trackSize = parseGridTrackSize(*arguments);
         if (!trackSize)
             return false;
 
         repeatedValues->append(trackSize);
+        seenTrackSize = true;
 
         // This takes care of any trailing <ident>* in the grammar.
         currentValue = arguments->current();
@@ -3799,6 +3636,10 @@ bool CSSPropertyParser::parseGridTrackRepeatFunction(CSSValueList& list)
             parseGridLineNames(*arguments, *repeatedValues);
     }
 
+    // We should have found at least one <track-size> or else it is not a valid <track-list>.
+    if (!seenTrackSize)
+        return false;
+
     for (size_t i = 0; i < repetitions; ++i) {
         for (size_t j = 0; j < repeatedValues->length(); ++j)
             list.append(repeatedValues->item(j));
@@ -3820,7 +3661,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseGridTrackSize(CSSParser
     if (currentValue->id == CSSValueAuto)
         return cssValuePool().createIdentifierValue(CSSValueAuto);
 
-    if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "minmax(")) {
+    if (currentValue->unit == CSSParserValue::Function && equalIgnoringCase(currentValue->function->name, "minmax")) {
         // The spec defines the following grammar: minmax( <track-breadth> , <track-breadth> )
         CSSParserValueList* arguments = currentValue->function->args.get();
         if (!arguments || arguments->size() != 3 || !isComma(arguments->valueAt(1)))
@@ -3871,7 +3712,7 @@ bool CSSPropertyParser::parseGridTemplateAreasRow(NamedGridAreaMap& gridAreaMap,
         return false;
 
     String gridRowNames = currentValue->string;
-    if (!gridRowNames.length())
+    if (gridRowNames.isEmpty() || gridRowNames.containsOnlyWhitespace())
         return false;
 
     Vector<String> columnNames;
@@ -4006,11 +3847,11 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
     if (!counters)
         separator = cssValuePool().createValue(String(), CSSPrimitiveValue::CSS_STRING);
     else {
-        i = args->next();
-        if (i->unit != CSSParserValue::Operator || i->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return nullptr;
 
-        i = args->next();
+        i = args->current();
         if (i->unit != CSSPrimitiveValue::CSS_STRING)
             return nullptr;
 
@@ -4022,10 +3863,10 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounterContent(CSSParse
     if (!i) // Make the list style default decimal
         listStyle = cssValuePool().createIdentifierValue(CSSValueDecimal);
     else {
-        if (i->unit != CSSParserValue::Operator || i->iValue != ',')
+        if (!consumeComma(args))
             return nullptr;
 
-        i = args->next();
+        i = args->current();
         if (i->unit != CSSPrimitiveValue::CSS_IDENT)
             return nullptr;
 
@@ -4046,20 +3887,18 @@ bool CSSPropertyParser::parseClipShape(CSSPropertyID propId, bool important)
     CSSParserValue* value = m_valueList->current();
     CSSParserValueList* args = value->function->args.get();
 
-    if (!equalIgnoringCase(value->function->name, "rect(") || !args)
+    if (!equalIgnoringCase(value->function->name, "rect") || !args)
         return false;
 
     // rect(t, r, b, l) || rect(t r b l)
     if (args->size() != 4 && args->size() != 7)
         return false;
     RefPtrWillBeRawPtr<Rect> rect = Rect::create();
-    bool valid = true;
     int i = 0;
     CSSParserValue* a = args->current();
     while (a) {
-        valid = a->id == CSSValueAuto || validUnit(a, FLength);
-        if (!valid)
-            break;
+        if (a->id != CSSValueAuto && !validUnit(a, FLength))
+            return false;
         RefPtrWillBeRawPtr<CSSPrimitiveValue> length = a->id == CSSValueAuto ?
             cssValuePool().createIdentifierValue(CSSValueAuto) :
             createPrimitiveNumericValue(a);
@@ -4073,21 +3912,15 @@ bool CSSPropertyParser::parseClipShape(CSSPropertyID propId, bool important)
             rect->setLeft(length);
         a = args->next();
         if (a && args->size() == 7) {
-            if (a->unit == CSSParserValue::Operator && a->iValue == ',') {
-                a = args->next();
-            } else {
-                valid = false;
-                break;
-            }
+            if (!consumeComma(args))
+                return false;
+            a = args->current();
         }
         i++;
     }
-    if (valid) {
-        addProperty(propId, cssValuePool().createValue(rect.release()), important);
-        m_valueList->next();
-        return true;
-    }
-    return false;
+    addProperty(propId, cssValuePool().createValue(rect.release()), important);
+    m_valueList->next();
+    return true;
 }
 
 static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4])
@@ -4102,8 +3935,8 @@ static void completeBorderRadii(RefPtrWillBeRawPtr<CSSPrimitiveValue> radii[4])
     radii[3] = radii[1];
 }
 
-// FIXME: This should be refactored with CSSParser::parseBorderRadius.
-// CSSParser::parseBorderRadius contains support for some legacy radius construction.
+// FIXME: This should be refactored with parseBorderRadius.
+// parseBorderRadius contains support for some legacy radius construction.
 PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseInsetRoundedCorners(PassRefPtrWillBeRawPtr<CSSBasicShapeInset> shape, CSSParserValueList* args)
 {
     CSSParserValue* argument = args->next();
@@ -4183,7 +4016,7 @@ PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapeInset(CS
     bool hasRoundedInset = false;
 
     while (argument) {
-        if (argument->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(argument->string, "round")) {
+        if (argument->unit == CSSPrimitiveValue::CSS_IDENT && argument->id == CSSValueRound) {
             hasRoundedInset = true;
             break;
         }
@@ -4430,11 +4263,11 @@ PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
     CSSParserValue* argument = args->current();
     if (argument->id == CSSValueEvenodd || argument->id == CSSValueNonzero) {
         shape->setWindRule(argument->id == CSSValueEvenodd ? RULE_EVENODD : RULE_NONZERO);
+        args->next();
 
-        if (!isComma(args->next()))
+        if (!consumeComma(args))
             return nullptr;
 
-        argument = args->next();
         size -= 2;
     }
 
@@ -4442,28 +4275,23 @@ PassRefPtrWillBeRawPtr<CSSBasicShape> CSSPropertyParser::parseBasicShapePolygon(
     if (!size || (size % 3) - 2)
         return nullptr;
 
-    CSSParserValue* argumentX = argument;
-    while (argumentX) {
-
-        if (!validUnit(argumentX, FLength | FPercent))
+    while (true) {
+        CSSParserValue* argumentX = args->current();
+        if (!argumentX || !validUnit(argumentX, FLength | FPercent))
             return nullptr;
         RefPtrWillBeRawPtr<CSSPrimitiveValue> xLength = createPrimitiveNumericValue(argumentX);
 
         CSSParserValue* argumentY = args->next();
         if (!argumentY || !validUnit(argumentY, FLength | FPercent))
             return nullptr;
-
         RefPtrWillBeRawPtr<CSSPrimitiveValue> yLength = createPrimitiveNumericValue(argumentY);
 
         shape->appendPoint(xLength.release(), yLength.release());
 
-        CSSParserValue* commaOrNull = args->next();
-        if (!commaOrNull)
-            argumentX = 0;
-        else if (!isComma(commaOrNull))
+        if (!args->next())
+            break;
+        if (!consumeComma(args))
             return nullptr;
-        else
-            argumentX = args->next();
     }
 
     return shape;
@@ -4496,7 +4324,7 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseShapeProperty(CSSProper
     }
 
     RefPtrWillBeRawPtr<CSSValue> imageValue = nullptr;
-    if (valueId != CSSValueNone && parseFillImage(m_valueList.get(), imageValue)) {
+    if (valueId != CSSValueNone && parseFillImage(m_valueList, imageValue)) {
         m_valueList->next();
         return imageValue.release();
     }
@@ -4550,13 +4378,13 @@ PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBasicShape()
         return nullptr;
 
     RefPtrWillBeRawPtr<CSSBasicShape> shape = nullptr;
-    if (equalIgnoringCase(value->function->name, "circle("))
+    if (equalIgnoringCase(value->function->name, "circle"))
         shape = parseBasicShapeCircle(args);
-    else if (equalIgnoringCase(value->function->name, "ellipse("))
+    else if (equalIgnoringCase(value->function->name, "ellipse"))
         shape = parseBasicShapeEllipse(args);
-    else if (equalIgnoringCase(value->function->name, "polygon("))
+    else if (equalIgnoringCase(value->function->name, "polygon"))
         shape = parseBasicShapePolygon(args);
-    else if (equalIgnoringCase(value->function->name, "inset("))
+    else if (equalIgnoringCase(value->function->name, "inset"))
         shape = parseBasicShapeInset(args);
 
     if (!shape)
@@ -4593,7 +4421,8 @@ bool CSSPropertyParser::parseFont(bool important)
             fontVariantParsed = true;
         } else if (!fontWeightParsed && parseFontWeight(important)) {
             fontWeightParsed = true;
-        } else if (!fontStretchParsed && parseFontStretch(important)) {
+        } else if (!fontStretchParsed && isValidKeywordPropertyAndValue(CSSPropertyFontStretch, value->id, m_context)) {
+            addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(value->id), important);
             fontStretchParsed = true;
         } else {
             break;
@@ -4805,9 +4634,8 @@ bool CSSPropertyParser::parseFontVariant(bool important)
                 values = CSSValueList::createCommaSeparated();
                 parsedValue = cssValuePool().createIdentifierValue(val->id);
             }
-        } else if (val->unit == CSSParserValue::Operator && val->iValue == ',') {
+        } else if (consumeComma(m_valueList)) {
             expectComma = false;
-            m_valueList->next();
             continue;
         }
 
@@ -4851,16 +4679,6 @@ bool CSSPropertyParser::parseFontWeight(bool important)
     return false;
 }
 
-bool CSSPropertyParser::parseFontStretch(bool important)
-{
-    CSSParserValue* value = m_valueList->current();
-    if (value->id == CSSValueNormal || (value->id >= CSSValueUltraCondensed && value->id <= CSSValueUltraExpanded)) {
-        addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(value->id), important);
-        return true;
-    }
-    return false;
-}
-
 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
 {
     RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL(m_valueList->current()->string)));
@@ -4877,7 +4695,7 @@ bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList)
         return true;
     }
 
-    if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->function->name, "format("))
+    if (value->unit != CSSParserValue::Function || !equalIgnoringCase(value->function->name, "format"))
         return false;
 
     // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20111004/ says that format() contains a comma-separated list of strings,
@@ -4921,54 +4739,44 @@ bool CSSPropertyParser::parseFontFaceSrcLocal(CSSValueList* valueList)
     return true;
 }
 
-bool CSSPropertyParser::parseFontFaceSrc()
+PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceSrc()
 {
     RefPtrWillBeRawPtr<CSSValueList> values(CSSValueList::createCommaSeparated());
 
     while (CSSParserValue* value = m_valueList->current()) {
         if (value->unit == CSSPrimitiveValue::CSS_URI) {
             if (!parseFontFaceSrcURI(values.get()))
-                return false;
-        } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "local(")) {
+                return nullptr;
+        } else if (value->unit == CSSParserValue::Function && equalIgnoringCase(value->function->name, "local")) {
             if (!parseFontFaceSrcLocal(values.get()))
-                return false;
-        } else
-            return false;
+                return nullptr;
+        } else {
+            return nullptr;
+        }
     }
     if (!values->length())
-        return false;
+        return nullptr;
 
-    addProperty(CSSPropertySrc, values.release(), m_important);
     m_valueList->next();
-    return true;
+    return values.release();
 }
 
-bool CSSPropertyParser::parseFontFaceUnicodeRange()
+PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFontFaceUnicodeRange()
 {
     RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
-    bool failed = false;
-    bool operatorExpected = false;
-    for (; m_valueList->current(); m_valueList->next(), operatorExpected = !operatorExpected) {
-        if (operatorExpected) {
-            if (m_valueList->current()->unit == CSSParserValue::Operator && m_valueList->current()->iValue == ',')
-                continue;
-            failed = true;
-            break;
-        }
-        if (m_valueList->current()->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE) {
-            failed = true;
-            break;
-        }
 
-        String rangeString = m_valueList->current()->string;
+    do {
+        CSSParserValue* current = m_valueList->current();
+        if (!current || current->unit != CSSPrimitiveValue::CSS_UNICODE_RANGE)
+            return nullptr;
+
+        String rangeString = current->string;
         UChar32 from = 0;
         UChar32 to = 0;
         unsigned length = rangeString.length();
 
-        if (length < 3) {
-            failed = true;
-            break;
-        }
+        if (length < 3)
+            return nullptr;
 
         unsigned i = 2;
         while (i < length) {
@@ -4982,14 +4790,10 @@ bool CSSPropertyParser::parseFontFaceUnicodeRange()
                 from += 10 + c - 'A';
             else if (c >= 'a' && c <= 'f')
                 from += 10 + c - 'a';
-            else {
-                failed = true;
-                break;
-            }
+            else
+                return nullptr;
             i++;
         }
-        if (failed)
-            break;
 
         if (i == length)
             to = from;
@@ -5001,13 +4805,11 @@ bool CSSPropertyParser::parseFontFaceUnicodeRange()
                 i++;
             }
             if (i < length)
-                failed = true;
+                return nullptr;
             to = from + span - 1;
         } else {
-            if (length < i + 2) {
-                failed = true;
-                break;
-            }
+            if (length < i + 2)
+                return nullptr;
             i++;
             while (i < length) {
                 UChar c = rangeString[i];
@@ -5018,22 +4820,17 @@ bool CSSPropertyParser::parseFontFaceUnicodeRange()
                     to += 10 + c - 'A';
                 else if (c >= 'a' && c <= 'f')
                     to += 10 + c - 'a';
-                else {
-                    failed = true;
-                    break;
-                }
+                else
+                    return nullptr;
                 i++;
             }
-            if (failed)
-                break;
         }
         if (from <= to)
             values->append(CSSUnicodeRangeValue::create(from, to));
-    }
-    if (failed || !values->length())
-        return false;
-    addProperty(CSSPropertyUnicodeRange, values.release(), m_important);
-    return true;
+        m_valueList->next();
+    } while (consumeComma(m_valueList));
+
+    return values.release();
 }
 
 // Returns the number of characters which form a valid double
@@ -5349,8 +5146,8 @@ template bool CSSPropertyParser::fastParseColor(RGBA32&, const String&, bool str
 bool CSSPropertyParser::isCalculation(CSSParserValue* value)
 {
     return (value->unit == CSSParserValue::Function)
-        && (equalIgnoringCase(value->function->name, "calc(")
-            || equalIgnoringCase(value->function->name, "-webkit-calc("));
+        && (equalIgnoringCase(value->function->name, "calc")
+            || equalIgnoringCase(value->function->name, "-webkit-calc"));
 }
 
 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v)
@@ -5388,29 +5185,29 @@ bool CSSPropertyParser::parseColorParameters(CSSParserValue* value, int* colorAr
     CSSParserValue* v = args->current();
     Units unitType = FUnknown;
     // Get the first value and its type
-    if (validUnit(v, FInteger, HTMLStandardMode))
+    if (validUnit(v, FInteger))
         unitType = FInteger;
-    else if (validUnit(v, FPercent, HTMLStandardMode))
+    else if (validUnit(v, FPercent))
         unitType = FPercent;
     else
         return false;
 
     colorArray[0] = colorIntFromValue(v);
     for (int i = 1; i < 3; i++) {
-        v = args->next();
-        if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return false;
-        v = args->next();
-        if (!validUnit(v, unitType, HTMLStandardMode))
+        v = args->current();
+        if (!validUnit(v, unitType))
             return false;
         colorArray[i] = colorIntFromValue(v);
     }
     if (parseAlpha) {
-        v = args->next();
-        if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return false;
-        v = args->next();
-        if (!validUnit(v, FNumber, HTMLStandardMode))
+        v = args->current();
+        if (!validUnit(v, FNumber))
             return false;
         // Convert the floating pointer number of alpha to an integer in the range [0, 256),
         // with an equal distribution across all 256 values.
@@ -5429,26 +5226,26 @@ bool CSSPropertyParser::parseHSLParameters(CSSParserValue* value, double* colorA
     CSSParserValueList* args = value->function->args.get();
     CSSParserValue* v = args->current();
     // Get the first value
-    if (!validUnit(v, FNumber, HTMLStandardMode))
+    if (!validUnit(v, FNumber))
         return false;
     // normalize the Hue value and change it to be between 0 and 1.0
     colorArray[0] = (((static_cast<int>(v->fValue) % 360) + 360) % 360) / 360.0;
     for (int i = 1; i < 3; i++) {
-        v = args->next();
-        if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return false;
-        v = args->next();
-        if (!validUnit(v, FPercent, HTMLStandardMode))
+        v = args->current();
+        if (!validUnit(v, FPercent))
             return false;
         double percentValue = m_parsedCalculation ? m_parsedCalculation.release()->doubleValue() : v->fValue;
         colorArray[i] = std::max(0.0, std::min(100.0, percentValue)) / 100.0; // needs to be value between 0 and 1.0
     }
     if (parseAlpha) {
-        v = args->next();
-        if (v->unit != CSSParserValue::Operator && v->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return false;
-        v = args->next();
-        if (!validUnit(v, FNumber, HTMLStandardMode))
+        v = args->current();
+        if (!validUnit(v, FNumber))
             return false;
         colorArray[3] = std::max(0.0, std::min(1.0, v->fValue));
     }
@@ -5479,7 +5276,7 @@ bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
     } else if (value->unit == CSSParserValue::Function &&
                 value->function->args != 0 &&
                 value->function->args->size() == 5 /* rgb + two commas */ &&
-                equalIgnoringCase(value->function->name, "rgb(")) {
+                equalIgnoringCase(value->function->name, "rgb")) {
         int colorValues[3];
         if (!parseColorParameters(value, colorValues, false))
             return false;
@@ -5488,7 +5285,7 @@ bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
         if (value->unit == CSSParserValue::Function &&
                 value->function->args != 0 &&
                 value->function->args->size() == 7 /* rgba + three commas */ &&
-                equalIgnoringCase(value->function->name, "rgba(")) {
+                equalIgnoringCase(value->function->name, "rgba")) {
             int colorValues[4];
             if (!parseColorParameters(value, colorValues, true))
                 return false;
@@ -5496,7 +5293,7 @@ bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
         } else if (value->unit == CSSParserValue::Function &&
                     value->function->args != 0 &&
                     value->function->args->size() == 5 /* hsl + two commas */ &&
-                    equalIgnoringCase(value->function->name, "hsl(")) {
+                    equalIgnoringCase(value->function->name, "hsl")) {
             double colorValues[3];
             if (!parseHSLParameters(value, colorValues, false))
                 return false;
@@ -5504,7 +5301,7 @@ bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
         } else if (value->unit == CSSParserValue::Function &&
                     value->function->args != 0 &&
                     value->function->args->size() == 7 /* hsla + three commas */ &&
-                    equalIgnoringCase(value->function->name, "hsla(")) {
+                    equalIgnoringCase(value->function->name, "hsla")) {
             double colorValues[4];
             if (!parseHSLParameters(value, colorValues, true))
                 return false;
@@ -5701,7 +5498,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseShadow(CSSParserVal
     return nullptr;
 }
 
-bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect()
 {
     // box-reflect: <direction> <offset> <mask>
 
@@ -5716,7 +5513,7 @@ bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important)
         direction = cssValuePool().createIdentifierValue(val->id);
         break;
     default:
-        return false;
+        return nullptr;
     }
 
     // The offset comes next.
@@ -5726,7 +5523,7 @@ bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important)
         offset = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
     else {
         if (!validUnit(val, FLength | FPercent))
-            return false;
+            return nullptr;
         offset = createPrimitiveNumericValue(val);
     }
 
@@ -5734,15 +5531,12 @@ bool CSSPropertyParser::parseReflect(CSSPropertyID propId, bool important)
     RefPtrWillBeRawPtr<CSSValue> mask = nullptr;
     val = m_valueList->next();
     if (val) {
-        mask = parseBorderImage(propId);
+        mask = parseBorderImage(CSSPropertyWebkitBoxReflect);
         if (!mask)
-            return false;
+            return nullptr;
     }
 
-    RefPtrWillBeRawPtr<CSSReflectValue> reflectValue = CSSReflectValue::create(direction.release(), offset.release(), mask.release());
-    addProperty(propId, reflectValue.release(), important);
-    m_valueList->next();
-    return true;
+    return CSSReflectValue::create(direction.release(), offset.release(), mask.release());
 }
 
 static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unsetValue, int argSize)
@@ -5786,7 +5580,7 @@ bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
     if (flexShrink == unsetValue)
         flexShrink = 1;
     if (!flexBasis)
-        flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
+        flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PERCENTAGE);
 
     addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
     addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
@@ -5794,18 +5588,14 @@ bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
     return true;
 }
 
-bool CSSPropertyParser::parseObjectPosition(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseObjectPosition()
 {
     RefPtrWillBeRawPtr<CSSValue> xValue = nullptr;
     RefPtrWillBeRawPtr<CSSValue> yValue = nullptr;
-    parseFillPosition(m_valueList.get(), xValue, yValue);
+    parseFillPosition(m_valueList, xValue, yValue);
     if (!xValue || !yValue)
-        return false;
-    addProperty(
-        CSSPropertyObjectPosition,
-        createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimitiveValue(yValue.get()), Pair::KeepIdenticalValues),
-        important);
-    return true;
+        return nullptr;
+    return createPrimitiveValuePair(toCSSPrimitiveValue(xValue.get()), toCSSPrimitiveValue(yValue.get()), Pair::KeepIdenticalValues);
 }
 
 class BorderImageParseContext {
@@ -5958,12 +5748,12 @@ bool BorderImageParseContext::buildFromParser(CSSPropertyParser& parser, CSSProp
                 context.commitImage(parser.createCSSImageValueWithReferrer(val->string, parser.m_context.completeURL(val->string)));
             } else if (isGeneratedImageValue(val)) {
                 RefPtrWillBeRawPtr<CSSValue> value = nullptr;
-                if (parser.parseGeneratedImage(parser.m_valueList.get(), value))
+                if (parser.parseGeneratedImage(parser.m_valueList, value))
                     context.commitImage(value.release());
                 else
                     return false;
-            } else if (val->unit == CSSParserValue::Function && equalIgnoringCase(val->function->name, "-webkit-image-set(")) {
-                RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser.m_valueList.get());
+            } else if (val->unit == CSSParserValue::Function && equalIgnoringCase(val->function->name, "-webkit-image-set")) {
+                RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser.m_valueList);
                 if (value)
                     context.commitImage(value.release());
                 else
@@ -6153,7 +5943,7 @@ bool CSSPropertyParser::parseBorderImageSlice(CSSPropertyID propId, RefPtrWillBe
     BorderImageSliceParseContext context(this);
     for (CSSParserValue* val = m_valueList->current(); val; val = m_valueList->next()) {
         // FIXME calc() http://webkit.org/b/16662 : calc is parsed but values are not created yet.
-        if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInteger | FNonNeg | FPercent, HTMLStandardMode)) {
+        if (context.allowNumber() && !isCalculation(val) && validUnit(val, FInteger | FNonNeg | FPercent)) {
             context.commitNumber(val);
         } else if (context.allowFill() && val->id == CSSValueFill) {
             context.commitFill();
@@ -6349,7 +6139,7 @@ bool CSSPropertyParser::parseBorderRadius(CSSPropertyID propId, bool important)
     } else
         completeBorderRadii(radii[1]);
 
-    ImplicitScope implicitScope(this, PropertyImplicit);
+    ImplicitScope implicitScope(this);
     addProperty(CSSPropertyBorderTopLeftRadius, createPrimitiveValuePair(radii[0][0].release(), radii[1][0].release()), important);
     addProperty(CSSPropertyBorderTopRightRadius, createPrimitiveValuePair(radii[0][1].release(), radii[1][1].release()), important);
     addProperty(CSSPropertyBorderBottomRightRadius, createPrimitiveValuePair(radii[0][2].release(), radii[1][2].release()), important);
@@ -6357,75 +6147,59 @@ bool CSSPropertyParser::parseBorderRadius(CSSPropertyID propId, bool important)
     return true;
 }
 
-bool CSSPropertyParser::parseAspectRatio(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseAspectRatio()
 {
     unsigned num = m_valueList->size();
     if (num == 1 && m_valueList->valueAt(0)->id == CSSValueNone) {
-        addProperty(CSSPropertyWebkitAspectRatio, cssValuePool().createIdentifierValue(CSSValueNone), important);
-        return true;
+        m_valueList->next();
+        return cssValuePool().createIdentifierValue(CSSValueNone);
     }
 
     if (num != 3)
-        return false;
+        return nullptr;
 
-    CSSParserValue* lvalue = m_valueList->valueAt(0);
-    CSSParserValue* op = m_valueList->valueAt(1);
-    CSSParserValue* rvalue = m_valueList->valueAt(2);
+    CSSParserValue* lvalue = m_valueList->current();
+    CSSParserValue* op = m_valueList->next();
+    CSSParserValue* rvalue = m_valueList->next();
+    m_valueList->next();
 
     if (!isForwardSlashOperator(op))
-        return false;
+        return nullptr;
 
     if (!validUnit(lvalue, FNumber | FNonNeg) || !validUnit(rvalue, FNumber | FNonNeg))
-        return false;
+        return nullptr;
 
     if (!lvalue->fValue || !rvalue->fValue)
-        return false;
-
-    addProperty(CSSPropertyWebkitAspectRatio, CSSAspectRatioValue::create(narrowPrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue)), important);
+        return nullptr;
 
-    return true;
+    return CSSAspectRatioValue::create(narrowPrecisionToFloat(lvalue->fValue), narrowPrecisionToFloat(rvalue->fValue));
 }
 
-bool CSSPropertyParser::parseCounter(CSSPropertyID propId, int defaultValue, bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseCounter(int defaultValue)
 {
-    enum { ID, VAL } state = ID;
-
     RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
-    RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = nullptr;
 
-    while (true) {
+    while (m_valueList->current()) {
         CSSParserValue* val = m_valueList->current();
-        switch (state) {
-            case ID:
-                if (val && val->unit == CSSPrimitiveValue::CSS_IDENT) {
-                    counterName = createPrimitiveStringValue(val);
-                    state = VAL;
-                    m_valueList->next();
-                    continue;
-                }
-                break;
-            case VAL: {
-                int i = defaultValue;
-                if (val && val->unit == CSSPrimitiveValue::CSS_NUMBER) {
-                    i = clampToInteger(val->fValue);
-                    m_valueList->next();
-                }
+        if (val->unit != CSSPrimitiveValue::CSS_IDENT)
+            return nullptr;
+        RefPtrWillBeRawPtr<CSSPrimitiveValue> counterName = createPrimitiveStringValue(val);
+        m_valueList->next();
 
-                list->append(createPrimitiveValuePair(counterName.release(),
-                    cssValuePool().createValue(i, CSSPrimitiveValue::CSS_NUMBER)));
-                state = ID;
-                continue;
-            }
+        val = m_valueList->current();
+        int i = defaultValue;
+        if (val && validUnit(val, FInteger)) {
+            i = clampToInteger(val->fValue);
+            m_valueList->next();
         }
-        break;
-    }
 
-    if (list->length() > 0) {
-        addProperty(propId, list.release(), important);
-        return true;
+        list->append(createPrimitiveValuePair(counterName.release(),
+            cssValuePool().createValue(i, CSSPrimitiveValue::CSS_NUMBER)));
     }
 
-    return false;
+    if (!list->length())
+        return nullptr;
+    return list.release();
 }
 
 // This should go away once we drop support for -webkit-gradient
@@ -6433,13 +6207,13 @@ static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> parseDeprecatedGradientPoint(CS
 {
     RefPtrWillBeRawPtr<CSSPrimitiveValue> result = nullptr;
     if (a->unit == CSSPrimitiveValue::CSS_IDENT) {
-        if ((equalIgnoringCase(a, "left") && horizontal)
-            || (equalIgnoringCase(a, "top") && !horizontal))
+        if ((a->id == CSSValueLeft && horizontal)
+            || (a->id == CSSValueTop && !horizontal))
             result = cssValuePool().createValue(0., CSSPrimitiveValue::CSS_PERCENTAGE);
-        else if ((equalIgnoringCase(a, "right") && horizontal)
-                 || (equalIgnoringCase(a, "bottom") && !horizontal))
+        else if ((a->id == CSSValueRight && horizontal)
+            || (a->id == CSSValueBottom && !horizontal))
             result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PERCENTAGE);
-        else if (equalIgnoringCase(a, "center"))
+        else if (a->id == CSSValueCenter)
             result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERCENTAGE);
     } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimitiveValue::CSS_PERCENTAGE) {
         result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveValue::UnitType>(a->unit));
@@ -6452,22 +6226,22 @@ bool parseDeprecatedGradientColorStop(CSSPropertyParser* p, CSSParserValue* a, C
     if (a->unit != CSSParserValue::Function)
         return false;
 
-    if (!equalIgnoringCase(a->function->name, "from(") &&
-        !equalIgnoringCase(a->function->name, "to(") &&
-        !equalIgnoringCase(a->function->name, "color-stop("))
+    if (!equalIgnoringCase(a->function->name, "from") &&
+        !equalIgnoringCase(a->function->name, "to") &&
+        !equalIgnoringCase(a->function->name, "color-stop"))
         return false;
 
     CSSParserValueList* args = a->function->args.get();
     if (!args)
         return false;
 
-    if (equalIgnoringCase(a->function->name, "from(")
-        || equalIgnoringCase(a->function->name, "to(")) {
+    if (equalIgnoringCase(a->function->name, "from")
+        || equalIgnoringCase(a->function->name, "to")) {
         // The "from" and "to" stops expect 1 argument.
         if (args->size() != 1)
             return false;
 
-        if (equalIgnoringCase(a->function->name, "from("))
+        if (equalIgnoringCase(a->function->name, "from"))
             stop.m_position = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER);
         else
             stop.m_position = cssValuePool().createValue(1, CSSPrimitiveValue::CSS_NUMBER);
@@ -6482,7 +6256,7 @@ bool parseDeprecatedGradientColorStop(CSSPropertyParser* p, CSSParserValue* a, C
     }
 
     // The "color-stop" function expects 3 arguments.
-    if (equalIgnoringCase(a->function->name, "color-stop(")) {
+    if (equalIgnoringCase(a->function->name, "color-stop")) {
         if (args->size() != 3)
             return false;
 
@@ -6494,11 +6268,11 @@ bool parseDeprecatedGradientColorStop(CSSPropertyParser* p, CSSParserValue* a, C
         else
             return false;
 
-        stopArg = args->next();
-        if (stopArg->unit != CSSParserValue::Operator || stopArg->iValue != ',')
+        args->next();
+        if (!consumeComma(args))
             return false;
 
-        stopArg = args->next();
+        stopArg = args->current();
         CSSValueID id = stopArg->id;
         if (id == CSSValueWebkitText || (id >= CSSValueAqua && id <= CSSValueWindowtext) || id == CSSValueMenu)
             stop.m_color = cssValuePool().createIdentifierValue(id);
@@ -6523,7 +6297,7 @@ bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
     CSSParserValue* a = args->current();
     if (!a || a->unit != CSSPrimitiveValue::CSS_IDENT)
         return false;
-    if (equalIgnoringCase(a, "linear"))
+    if (a->id == CSSValueLinear)
         gradientType = CSSDeprecatedLinearGradient;
     else if (equalIgnoringCase(a, "radial"))
         gradientType = CSSDeprecatedRadialGradient;
@@ -6542,16 +6316,15 @@ bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
         // The rest of the gradient types shouldn't appear here.
         ASSERT_NOT_REACHED();
     }
+    args->next();
 
-    // Comma.
-    a = args->next();
-    if (!isComma(a))
+    if (!consumeComma(args))
         return false;
 
     // Next comes the starting point for the gradient as an x y pair.  There is no
     // comma between the x and the y values.
     // First X.  It can be left, right, number or percent.
-    a = args->next();
+    a = args->current();
     if (!a)
         return false;
     RefPtrWillBeRawPtr<CSSPrimitiveValue> point = parseDeprecatedGradientPoint(a, true);
@@ -6569,26 +6342,26 @@ bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
     result->setFirstY(point.release());
 
     // Comma after the first point.
-    a = args->next();
-    if (!isComma(a))
+    args->next();
+    if (!consumeComma(args))
         return false;
 
     // For radial gradients only, we now expect a numeric radius.
     if (gradientType == CSSDeprecatedRadialGradient) {
-        a = args->next();
+        a = args->current();
         if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
             return false;
         toCSSRadialGradientValue(result.get())->setFirstRadius(createPrimitiveNumericValue(a));
 
         // Comma after the first radius.
-        a = args->next();
-        if (!isComma(a))
+        args->next();
+        if (!consumeComma(args))
             return false;
     }
 
     // Next is the ending point for the gradient as an x, y pair.
     // Second X.  It can be left, right, number or percent.
-    a = args->next();
+    a = args->current();
     if (!a)
         return false;
     point = parseDeprecatedGradientPoint(a, true);
@@ -6604,29 +6377,30 @@ bool CSSPropertyParser::parseDeprecatedGradient(CSSParserValueList* valueList, R
     if (!point)
         return false;
     result->setSecondY(point.release());
+    args->next();
 
     // For radial gradients only, we now expect the second radius.
     if (gradientType == CSSDeprecatedRadialGradient) {
         // Comma after the second point.
-        a = args->next();
-        if (!isComma(a))
+        if (!consumeComma(args))
             return false;
 
-        a = args->next();
+        a = args->current();
         if (!a || a->unit != CSSPrimitiveValue::CSS_NUMBER)
             return false;
         toCSSRadialGradientValue(result.get())->setSecondRadius(createPrimitiveNumericValue(a));
+        args->next();
     }
 
     // We now will accept any number of stops (0 or more).
-    a = args->next();
+    a = args->current();
     while (a) {
         // Look for the comma before the next stop.
-        if (!isComma(a))
+        if (!consumeComma(args))
             return false;
 
         // Now examine the stop itself.
-        a = args->next();
+        a = args->current();
         if (!a)
             return false;
 
@@ -6763,20 +6537,14 @@ bool CSSPropertyParser::parseDeprecatedRadialGradient(CSSParserValueList* valueL
     RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
     // parse2ValuesFillPosition advances the args next pointer.
     parse2ValuesFillPosition(args, centerX, centerY);
+
+    if ((centerX || centerY) && !consumeComma(args))
+        return false;
+
     a = args->current();
     if (!a)
         return false;
 
-    if (centerX || centerY) {
-        // Comma
-        if (!isComma(a))
-            return false;
-
-        a = args->next();
-        if (!a)
-            return false;
-    }
-
     result->setFirstX(toCSSPrimitiveValue(centerX.get()));
     result->setSecondX(toCSSPrimitiveValue(centerX.get()));
     // CSS3 radial gradients always share the same start and end point.
@@ -7028,7 +6796,7 @@ bool CSSPropertyParser::parseRadialGradient(CSSParserValueList* valueList, RefPt
     // at <position>
     RefPtrWillBeRawPtr<CSSValue> centerX = nullptr;
     RefPtrWillBeRawPtr<CSSValue> centerY = nullptr;
-    if (a->unit == CSSPrimitiveValue::CSS_IDENT && equalIgnoringCase(a, "at")) {
+    if (a->unit == CSSPrimitiveValue::CSS_IDENT && a->id == CSSValueAt) {
         a = args->next();
         if (!a)
             return false;
@@ -7102,56 +6870,56 @@ bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
     if (val->unit != CSSParserValue::Function)
         return false;
 
-    if (equalIgnoringCase(val->function->name, "-webkit-gradient(")) {
+    if (equalIgnoringCase(val->function->name, "-webkit-gradient")) {
         // FIXME: This should send a deprecation message.
         if (m_context.useCounter())
             m_context.useCounter()->count(UseCounter::DeprecatedWebKitGradient);
         return parseDeprecatedGradient(valueList, value);
     }
 
-    if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient(")) {
+    if (equalIgnoringCase(val->function->name, "-webkit-linear-gradient")) {
         // FIXME: This should send a deprecation message.
         if (m_context.useCounter())
             m_context.useCounter()->count(UseCounter::DeprecatedWebKitLinearGradient);
         return parseDeprecatedLinearGradient(valueList, value, NonRepeating);
     }
 
-    if (equalIgnoringCase(val->function->name, "linear-gradient("))
+    if (equalIgnoringCase(val->function->name, "linear-gradient"))
         return parseLinearGradient(valueList, value, NonRepeating);
 
-    if (equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient(")) {
+    if (equalIgnoringCase(val->function->name, "-webkit-repeating-linear-gradient")) {
         // FIXME: This should send a deprecation message.
         if (m_context.useCounter())
             m_context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingLinearGradient);
         return parseDeprecatedLinearGradient(valueList, value, Repeating);
     }
 
-    if (equalIgnoringCase(val->function->name, "repeating-linear-gradient("))
+    if (equalIgnoringCase(val->function->name, "repeating-linear-gradient"))
         return parseLinearGradient(valueList, value, Repeating);
 
-    if (equalIgnoringCase(val->function->name, "-webkit-radial-gradient(")) {
+    if (equalIgnoringCase(val->function->name, "-webkit-radial-gradient")) {
         // FIXME: This should send a deprecation message.
         if (m_context.useCounter())
             m_context.useCounter()->count(UseCounter::DeprecatedWebKitRadialGradient);
         return parseDeprecatedRadialGradient(valueList, value, NonRepeating);
     }
 
-    if (equalIgnoringCase(val->function->name, "radial-gradient("))
+    if (equalIgnoringCase(val->function->name, "radial-gradient"))
         return parseRadialGradient(valueList, value, NonRepeating);
 
-    if (equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient(")) {
+    if (equalIgnoringCase(val->function->name, "-webkit-repeating-radial-gradient")) {
         if (m_context.useCounter())
             m_context.useCounter()->count(UseCounter::DeprecatedWebKitRepeatingRadialGradient);
         return parseDeprecatedRadialGradient(valueList, value, Repeating);
     }
 
-    if (equalIgnoringCase(val->function->name, "repeating-radial-gradient("))
+    if (equalIgnoringCase(val->function->name, "repeating-radial-gradient"))
         return parseRadialGradient(valueList, value, Repeating);
 
-    if (equalIgnoringCase(val->function->name, "-webkit-canvas("))
+    if (equalIgnoringCase(val->function->name, "-webkit-canvas"))
         return parseCanvas(valueList, value);
 
-    if (equalIgnoringCase(val->function->name, "-webkit-cross-fade("))
+    if (equalIgnoringCase(val->function->name, "-webkit-cross-fade"))
         return parseCrossfade(valueList, value);
 
     return false;
@@ -7163,39 +6931,35 @@ bool CSSPropertyParser::parseCrossfade(CSSParserValueList* valueList, RefPtrWill
     CSSParserValueList* args = valueList->current()->function->args.get();
     if (!args || args->size() != 5)
         return false;
-    CSSParserValue* a = args->current();
     RefPtrWillBeRawPtr<CSSValue> fromImageValue = nullptr;
     RefPtrWillBeRawPtr<CSSValue> toImageValue = nullptr;
 
     // The first argument is the "from" image. It is a fill image.
-    if (!a || !parseFillImage(args, fromImageValue))
+    if (!args->current() || !parseFillImage(args, fromImageValue))
         return false;
-    a = args->next();
+    args->next();
 
-    // Skip a comma
-    if (!isComma(a))
+    if (!consumeComma(args))
         return false;
-    a = args->next();
 
     // The second argument is the "to" image. It is a fill image.
-    if (!a || !parseFillImage(args, toImageValue))
+    if (!args->current() || !parseFillImage(args, toImageValue))
         return false;
-    a = args->next();
+    args->next();
 
-    // Skip a comma
-    if (!isComma(a))
+    if (!consumeComma(args))
         return false;
-    a = args->next();
 
     // The third argument is the crossfade value. It is a percentage or a fractional number.
     RefPtrWillBeRawPtr<CSSPrimitiveValue> percentage = nullptr;
-    if (!a)
+    CSSParserValue* value = args->current();
+    if (!value)
         return false;
 
-    if (a->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
-        percentage = cssValuePool().createValue(clampTo<double>(a->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
-    else if (a->unit == CSSPrimitiveValue::CSS_NUMBER)
-        percentage = cssValuePool().createValue(clampTo<double>(a->fValue, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
+    if (value->unit == CSSPrimitiveValue::CSS_PERCENTAGE)
+        percentage = cssValuePool().createValue(clampTo<double>(value->fValue / 100, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
+    else if (value->unit == CSSPrimitiveValue::CSS_NUMBER)
+        percentage = cssValuePool().createValue(clampTo<double>(value->fValue, 0, 1), CSSPrimitiveValue::CSS_NUMBER);
     else
         return false;
 
@@ -7236,8 +7000,8 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
 
     RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create();
 
-    CSSParserValue* arg = functionArgs->current();
-    while (arg) {
+    while (functionArgs->current()) {
+        CSSParserValue* arg = functionArgs->current();
         if (arg->unit != CSSPrimitiveValue::CSS_URI)
             return nullptr;
 
@@ -7263,53 +7027,42 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseImageSet(CSSParserValue
         if (imageScaleFactor <= 0)
             return nullptr;
         imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimitiveValue::CSS_NUMBER));
+        functionArgs->next();
 
         // If there are no more arguments, we're done.
-        arg = functionArgs->next();
-        if (!arg)
+        if (!functionArgs->current())
             break;
 
         // If there are more arguments, they should be after a comma.
-        if (!isComma(arg))
+        if (!consumeComma(functionArgs))
             return nullptr;
-
-        // Skip the comma and move on to the next argument.
-        arg = functionArgs->next();
     }
 
     return imageSet.release();
 }
 
-bool CSSPropertyParser::parseWillChange(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseWillChange()
 {
-    ASSERT(RuntimeEnabledFeatures::cssWillChangeEnabled());
-
     RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
     if (m_valueList->current()->id == CSSValueAuto) {
-        if (m_valueList->next())
-            return false;
+        // FIXME: This will be read back as an empty string instead of auto
+        return values.release();
     }
 
     // Every comma-separated list of CSS_IDENTs is a valid will-change value,
     // unless the list includes an explicitly disallowed CSS_IDENT.
-    bool expectComma = false;
-    for (CSSParserValue* currentValue = m_valueList->current(); currentValue; currentValue = m_valueList->next()) {
-        if (expectComma) {
-            if (!isComma(currentValue))
-                return false;
-            expectComma = false;
-            continue;
-        }
-
-        if (currentValue->unit != CSSPrimitiveValue::CSS_IDENT)
-            return false;
+    while (true) {
+        CSSParserValue* currentValue = m_valueList->current();
+        if (!currentValue || currentValue->unit != CSSPrimitiveValue::CSS_IDENT)
+            return nullptr;
 
         CSSPropertyID property = cssPropertyID(currentValue->string);
-        if (property && RuntimeCSSEnabled::isCSSPropertyEnabled(property)) {
+        if (property) {
+            ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
             // Now "all" is used by both CSSValue and CSSPropertyValue.
-            // Need to return false when currentValue is CSSPropertyAll.
+            // Need to return nullptr when currentValue is CSSPropertyAll.
             if (property == CSSPropertyWillChange || property == CSSPropertyAll)
-                return false;
+                return nullptr;
             values->append(cssValuePool().createIdentifierValue(property));
         } else {
             switch (currentValue->id) {
@@ -7319,7 +7072,7 @@ bool CSSPropertyParser::parseWillChange(bool important)
             case CSSValueDefault:
             case CSSValueInitial:
             case CSSValueInherit:
-                return false;
+                return nullptr;
             case CSSValueContents:
             case CSSValueScrollPosition:
                 values->append(cssValuePool().createIdentifierValue(currentValue->id));
@@ -7328,34 +7081,37 @@ bool CSSPropertyParser::parseWillChange(bool important)
                 break;
             }
         }
-        expectComma = true;
+
+        if (!m_valueList->next())
+            break;
+        if (!consumeComma(m_valueList))
+            return nullptr;
     }
 
-    addProperty(CSSPropertyWillChange, values.release(), important);
-    return true;
+    return values.release();
 }
 
 static void filterInfoForName(const CSSParserString& name, CSSFilterValue::FilterOperationType& filterType, unsigned& maximumArgumentCount)
 {
-    if (equalIgnoringCase(name, "grayscale("))
+    if (equalIgnoringCase(name, "grayscale"))
         filterType = CSSFilterValue::GrayscaleFilterOperation;
-    else if (equalIgnoringCase(name, "sepia("))
+    else if (equalIgnoringCase(name, "sepia"))
         filterType = CSSFilterValue::SepiaFilterOperation;
-    else if (equalIgnoringCase(name, "saturate("))
+    else if (equalIgnoringCase(name, "saturate"))
         filterType = CSSFilterValue::SaturateFilterOperation;
-    else if (equalIgnoringCase(name, "hue-rotate("))
+    else if (equalIgnoringCase(name, "hue-rotate"))
         filterType = CSSFilterValue::HueRotateFilterOperation;
-    else if (equalIgnoringCase(name, "invert("))
+    else if (equalIgnoringCase(name, "invert"))
         filterType = CSSFilterValue::InvertFilterOperation;
-    else if (equalIgnoringCase(name, "opacity("))
+    else if (equalIgnoringCase(name, "opacity"))
         filterType = CSSFilterValue::OpacityFilterOperation;
-    else if (equalIgnoringCase(name, "brightness("))
+    else if (equalIgnoringCase(name, "brightness"))
         filterType = CSSFilterValue::BrightnessFilterOperation;
-    else if (equalIgnoringCase(name, "contrast("))
+    else if (equalIgnoringCase(name, "contrast"))
         filterType = CSSFilterValue::ContrastFilterOperation;
-    else if (equalIgnoringCase(name, "blur("))
+    else if (equalIgnoringCase(name, "blur"))
         filterType = CSSFilterValue::BlurFilterOperation;
-    else if (equalIgnoringCase(name, "drop-shadow(")) {
+    else if (equalIgnoringCase(name, "drop-shadow")) {
         filterType = CSSFilterValue::DropShadowFilterOperation;
         maximumArgumentCount = 4;  // x-offset, y-offset, blur-radius, color -- spread and inset style not allowed.
     }
@@ -7374,13 +7130,10 @@ PassRefPtrWillBeRawPtr<CSSFilterValue> CSSPropertyParser::parseBuiltinFilterArgu
     case CSSFilterValue::OpacityFilterOperation:
     case CSSFilterValue::ContrastFilterOperation: {
         // One optional argument, 0-1 or 0%-100%, if missing use 100%.
-        if (args->size() > 1)
-            return nullptr;
-
         if (args->size()) {
             CSSParserValue* value = args->current();
             // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
-            if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber | FNonNeg, HTMLStandardMode))
+            if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber | FNonNeg))
                 return nullptr;
 
             double amount = value->fValue;
@@ -7401,13 +7154,10 @@ PassRefPtrWillBeRawPtr<CSSFilterValue> CSSPropertyParser::parseBuiltinFilterArgu
     }
     case CSSFilterValue::BrightnessFilterOperation: {
         // One optional argument, if missing use 100%.
-        if (args->size() > 1)
-            return nullptr;
-
         if (args->size()) {
             CSSParserValue* value = args->current();
             // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
-            if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber, HTMLStandardMode))
+            if (value->unit != CSSPrimitiveValue::CSS_PERCENTAGE && !validUnit(value, FNumber))
                 return nullptr;
 
             filterValue->append(cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveValue::UnitType>(value->unit)));
@@ -7416,9 +7166,6 @@ PassRefPtrWillBeRawPtr<CSSFilterValue> CSSPropertyParser::parseBuiltinFilterArgu
     }
     case CSSFilterValue::HueRotateFilterOperation: {
         // hue-rotate() takes one optional angle.
-        if (args->size() > 1)
-            return nullptr;
-
         if (args->size()) {
             CSSParserValue* argument = args->current();
             if (!validUnit(argument, FAngle, HTMLStandardMode))
@@ -7430,9 +7177,6 @@ PassRefPtrWillBeRawPtr<CSSFilterValue> CSSPropertyParser::parseBuiltinFilterArgu
     }
     case CSSFilterValue::BlurFilterOperation: {
         // Blur takes a single length. Zero parameters are allowed.
-        if (args->size() > 1)
-            return nullptr;
-
         if (args->size()) {
             CSSParserValue* argument = args->current();
             if (!validUnit(argument, FLength | FNonNeg, HTMLStandardMode))
@@ -7485,7 +7229,7 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseFilter()
                 return nullptr;
 
             CSSParserValueList* args = value->function->args.get();
-            if (!args)
+            if (!args || args->size() > maximumArgumentCount)
                 return nullptr;
 
             RefPtrWillBeRawPtr<CSSFilterValue> filterValue = parseBuiltinFilterArguments(args, filterType);
@@ -7565,79 +7309,36 @@ PassRefPtrWillBeRawPtr<CSSValueList> CSSPropertyParser::parseTransformOrigin()
     return list.release();
 }
 
-bool CSSPropertyParser::parseWebkitPerspectiveOrigin(CSSPropertyID propId, CSSPropertyID& propId1, CSSPropertyID& propId2, RefPtrWillBeRawPtr<CSSValue>& value, RefPtrWillBeRawPtr<CSSValue>& value2)
-{
-    propId1 = propId;
-    propId2 = propId;
-    if (propId == CSSPropertyWebkitPerspectiveOrigin) {
-        propId1 = CSSPropertyWebkitPerspectiveOriginX;
-        propId2 = CSSPropertyWebkitPerspectiveOriginY;
-    }
-
-    switch (propId) {
-        case CSSPropertyWebkitPerspectiveOrigin:
-            if (m_valueList->size() > 2)
-                return false;
-            parse2ValuesFillPosition(m_valueList.get(), value, value2);
-            break;
-        case CSSPropertyWebkitPerspectiveOriginX: {
-            value = parseFillPositionX(m_valueList.get());
-            if (value)
-                m_valueList->next();
-            break;
-        }
-        case CSSPropertyWebkitPerspectiveOriginY: {
-            value = parseFillPositionY(m_valueList.get());
-            if (value)
-                m_valueList->next();
-            break;
-        }
-        default:
-            ASSERT_NOT_REACHED();
-            return false;
-    }
-
-    return value;
-}
-
-bool CSSPropertyParser::parseTouchAction(bool important)
+PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseTouchAction()
 {
     CSSParserValue* value = m_valueList->current();
     RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     if (m_valueList->size() == 1 && value && (value->id == CSSValueAuto || value->id == CSSValueNone || value->id == CSSValueManipulation)) {
         list->append(cssValuePool().createIdentifierValue(value->id));
-        addProperty(CSSPropertyTouchAction, list.release(), important);
         m_valueList->next();
-        return true;
+        return list.release();
     }
 
-    bool isValid = true;
-    while (isValid && value) {
+    while (value) {
         switch (value->id) {
         case CSSValuePanX:
         case CSSValuePanY: {
             RefPtrWillBeRawPtr<CSSValue> panValue = cssValuePool().createIdentifierValue(value->id);
-            if (list->hasValue(panValue.get())) {
-                isValid = false;
-                break;
-            }
+            if (list->hasValue(panValue.get()))
+                return nullptr;
             list->append(panValue.release());
             break;
         }
         default:
-            isValid = false;
-            break;
+            return nullptr;
         }
-        if (isValid)
-            value = m_valueList->next();
+        value = m_valueList->next();
     }
 
-    if (list->length() && isValid) {
-        addProperty(CSSPropertyTouchAction, list.release(), important);
-        return true;
-    }
+    if (list->length())
+        return list.release();
 
-    return false;
+    return nullptr;
 }
 
 void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefPtrWillBeRawPtr<CSSValue> value, bool important)
@@ -7654,9 +7355,7 @@ void CSSPropertyParser::addTextDecorationProperty(CSSPropertyID propId, PassRefP
 
 bool CSSPropertyParser::parseTextDecoration(CSSPropertyID propId, bool important)
 {
-    if (propId == CSSPropertyTextDecorationLine
-        && !RuntimeEnabledFeatures::css3TextDecorationsEnabled())
-        return false;
+    ASSERT(propId != CSSPropertyTextDecorationLine || RuntimeEnabledFeatures::css3TextDecorationsEnabled());
 
     CSSParserValue* value = m_valueList->current();
     if (value && value->id == CSSValueNone) {
@@ -7886,20 +7585,16 @@ bool CSSPropertyParser::parseFontFeatureSettings(bool important)
     }
 
     RefPtrWillBeRawPtr<CSSValueList> settings = CSSValueList::createCommaSeparated();
-    for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
-        if (!parseFontFeatureTag(settings.get()))
+    while (true) {
+        if (!m_valueList->current() || !parseFontFeatureTag(settings.get()))
             return false;
-
-        // If the list isn't parsed fully, the current value should be comma.
-        value = m_valueList->current();
-        if (value && !isComma(value))
+        if (!m_valueList->current())
+            break;
+        if (!consumeComma(m_valueList))
             return false;
     }
-    if (settings->length()) {
-        addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), important);
-        return true;
-    }
-    return false;
+    addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), important);
+    return true;
 }
 
 bool CSSPropertyParser::parseFontVariantLigatures(bool important)
@@ -8068,7 +7763,12 @@ static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned l
 
     const char* name = buffer;
     const Property* hashTableEntry = findProperty(name, length);
-    return hashTableEntry ? static_cast<CSSPropertyID>(hashTableEntry->id) : CSSPropertyInvalid;
+    if (!hashTableEntry)
+        return CSSPropertyInvalid;
+    CSSPropertyID property = static_cast<CSSPropertyID>(hashTableEntry->id);
+    if (!CSSPropertyMetadata::isEnabledProperty(property))
+        return CSSPropertyInvalid;
+    return property;
 }
 
 CSSPropertyID cssPropertyID(const String& string)
@@ -8163,8 +7863,7 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
 
     case CSSPropertyBaselineShift:
     // baseline | super | sub | <percentage> | <length> | inherit
-        if (id == CSSValueBaseline || id == CSSValueSub
-            || id >= CSSValueSuper)
+        if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper)
             validPrimitive = true;
         else
             validPrimitive = validUnit(value, FLength | FPercent, SVGAttributeMode);
@@ -8235,11 +7934,6 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
             validPrimitive = true;
         break;
 
-    case CSSPropertyImageRendering: // auto | optimizeSpeed | pixelated
-        if (RuntimeEnabledFeatures::imageRenderingPixelatedEnabled() && id == CSSValuePixelated) {
-            validPrimitive = true;
-            break;
-        }
     case CSSPropertyColorRendering: // optimizeQuality | inherit
         if (id == CSSValueAuto || id == CSSValueOptimizespeed
             || id == CSSValueOptimizequality)
@@ -8365,7 +8059,7 @@ bool CSSPropertyParser::parseSVGValue(CSSPropertyID propId, bool important)
     /* shorthand properties */
     case CSSPropertyMarker: {
         ShorthandScope scope(this, propId);
-        CSSPropertyParser::ImplicitScope implicitScope(this, PropertyImplicit);
+        CSSPropertyParser::ImplicitScope implicitScope(this);
         if (!parseValue(CSSPropertyMarkerStart, important))
             return false;
         if (m_valueList->current()) {