Changeset 207479 in webkit


Ignore:
Timestamp:
Oct 18, 2016 1:03:18 PM (8 years ago)
Author:
hyatt@apple.com
Message:

[CSS Parser] Get all the properties turned on
https://bugs.webkit.org/show_bug.cgi?id=163605

Reviewed by Dean Jackson.

  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSFunctionValue.h:
  • css/CSSPendingSubstitutionValue.cpp: Added.

(WebCore::CSSPendingSubstitutionValue::customCSSText):

  • css/CSSPendingSubstitutionValue.h: Added.

(WebCore::CSSPendingSubstitutionValue::create):
(WebCore::CSSPendingSubstitutionValue::shorthandValue):
(WebCore::CSSPendingSubstitutionValue::shorthandPropertyId):
(WebCore::CSSPendingSubstitutionValue::equals):
(WebCore::CSSPendingSubstitutionValue::CSSPendingSubstitutionValue):

  • css/CSSValue.cpp:

(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isPendingSubstitutionValue):

  • css/CSSValueKeywords.in:
  • css/StylePropertyShorthand.cpp:

(WebCore::transitionShorthandForParsing):

  • css/StylePropertyShorthand.h:
  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::completeURL):

  • css/parser/CSSParserImpl.cpp:

(WebCore::CSSParserImpl::parseValue):
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::consumeDeclarationValue):

  • css/parser/CSSParserMode.h:

(WebCore::CSSParserContext::completeURL):

  • css/parser/CSSParserToken.cpp:

(WebCore::CSSParserToken::parseAsCSSPropertyID):
(WebCore::CSSParserToken::parseAsUnresolvedCSSPropertyID): Deleted.

  • css/parser/CSSParserToken.h:
  • css/parser/CSSPropertyParser.cpp:

(WebCore::cssPropertyID):
(WebCore::CSSPropertyParser::addProperty):
(WebCore::CSSPropertyParser::addExpandedPropertyForValue):
(WebCore::CSSPropertyParser::parseValue):
(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::CSSPropertyParser::parseValueStart):
(WebCore::CSSPropertyParser::consumeCSSWideKeyword):
(WebCore::consumeTransformOrigin):
(WebCore::consumeWillChange):
(WebCore::consumeFontFeatureTag):
(WebCore::consumeFontFeatureSettings):
(WebCore::consumePage):
(WebCore::consumeQuotes):
(WebCore::FontVariantLigaturesParser::consumeLigature):
(WebCore::FontVariantLigaturesParser::finalizeValue):
(WebCore::consumeFontVariantLigatures):
(WebCore::consumeFontVariantCaps):
(WebCore::FontVariantNumericParser::consumeNumeric):
(WebCore::FontVariantNumericParser::finalizeValue):
(WebCore::consumeFontVariantNumeric):
(WebCore::consumeFontVariantCSS21):
(WebCore::consumeFontVariantList):
(WebCore::consumeFontWeight):
(WebCore::consumeFamilyName):
(WebCore::consumeGenericFamily):
(WebCore::consumeFontFamily):
(WebCore::consumeSpacing):
(WebCore::consumeTabSize):
(WebCore::consumeTextSizeAdjust):
(WebCore::consumeFontSize):
(WebCore::consumeLineHeight):
(WebCore::createPrimitiveValuePair):
(WebCore::consumeCounter):
(WebCore::consumePageSize):
(WebCore::consumeSize):
(WebCore::consumeTextIndent):
(WebCore::validWidthOrHeightKeyword):
(WebCore::consumeMaxWidthOrHeight):
(WebCore::consumeWidthOrHeight):
(WebCore::consumeMarginOrOffset):
(WebCore::consumeClipComponent):
(WebCore::consumeClip):
(WebCore::consumeTouchAction):
(WebCore::consumeLineClamp):
(WebCore::consumeLocale):
(WebCore::consumeColumnWidth):
(WebCore::consumeColumnCount):
(WebCore::consumeColumnGap):
(WebCore::consumeColumnSpan):
(WebCore::consumeZoom):
(WebCore::consumeAnimationIterationCount):
(WebCore::consumeAnimationName):
(WebCore::consumeTransitionProperty):
(WebCore::consumeCubicBezier):
(WebCore::consumeAnimationTimingFunction):
(WebCore::consumeAnimationValue):
(WebCore::isValidAnimationPropertyList):
(WebCore::consumeAnimationPropertyList):
(WebCore::CSSPropertyParser::consumeAnimationShorthand):
(WebCore::consumeZIndex):
(WebCore::parseSingleShadow):
(WebCore::consumeShadow):
(WebCore::consumeFilterFunction):
(WebCore::consumeFilter):
(WebCore::consumeTextDecorationLine):
(WebCore::consumeTextEmphasisStyle):
(WebCore::consumeOutlineColor):
(WebCore::consumeLineWidth):
(WebCore::consumeBorderWidth):
(WebCore::consumeTextStrokeWidth):
(WebCore::consumeColumnRuleWidth):
(WebCore::consumeTranslate3d):
(WebCore::consumeNumbers):
(WebCore::consumePerspective):
(WebCore::consumeTransformValue):
(WebCore::consumeTransform):
(WebCore::consumePositionLonghand):
(WebCore::consumePositionX):
(WebCore::consumePositionY):
(WebCore::consumePaintStroke):
(WebCore::consumePaintOrder):
(WebCore::consumeNoneOrURI):
(WebCore::consumeFlexBasis):
(WebCore::consumeStrokeDasharray):
(WebCore::consumeBaselineShift):
(WebCore::consumeRxOrRy):
(WebCore::consumeCursor):
(WebCore::consumeAttr):
(WebCore::consumeCounterContent):
(WebCore::consumeContent):
(WebCore::consumePositionList):
(WebCore::consumeScrollSnapCoordinate):
(WebCore::consumeScrollSnapPoints):
(WebCore::consumeBorderRadiusCorner):
(WebCore::consumeVerticalAlign):
(WebCore::consumeShapeRadius):
(WebCore::consumeBasicShapeCircle):
(WebCore::consumeBasicShapeEllipse):
(WebCore::consumeBasicShapePolygon):
(WebCore::complete4Sides):
(WebCore::consumeRadii):
(WebCore::consumeBasicShapeInset):
(WebCore::consumeBasicShape):
(WebCore::consumeWebkitClipPath):
(WebCore::consumeShapeOutside):
(WebCore::consumeContentDistributionOverflowPosition):
(WebCore::consumeBorderImageRepeatKeyword):
(WebCore::consumeBorderImageRepeat):
(WebCore::consumeBorderImageSlice):
(WebCore::consumeBorderImageOutset):
(WebCore::consumeBorderImageWidth):
(WebCore::consumeBorderImageComponents):
(WebCore::consumeWebkitBorderImage):
(WebCore::consumeReflect):
(WebCore::consumeImageOrientation):
(WebCore::consumeBackgroundBlendMode):
(WebCore::consumeBackgroundAttachment):
(WebCore::consumeBackgroundBox):
(WebCore::consumeBackgroundComposite):
(WebCore::consumePrefixedBackgroundBox):
(WebCore::consumeBackgroundSize):
(WebCore::consumeGridAutoFlow):
(WebCore::consumeBackgroundComponent):
(WebCore::addBackgroundValue):
(WebCore::consumeCommaSeparatedBackgroundComponent):
(WebCore::consumeSelfPositionKeyword):
(WebCore::consumeSelfPositionOverflowPosition):
(WebCore::consumeAlignItems):
(WebCore::consumeJustifyItems):
(WebCore::consumeFitContent):
(WebCore::consumeCustomIdentForGridLine):
(WebCore::consumeGridLine):
(WebCore::isGridTrackFixedSized):
(WebCore::consumeGridBreadth):
(WebCore::consumeGridTrackSize):
(WebCore::consumeGridLineNames):
(WebCore::consumeGridTrackRepeatFunction):
(WebCore::consumeGridTrackList):
(WebCore::consumeGridTemplatesRowsOrColumns):
(WebCore::consumeGridTemplateAreas):
(WebCore::consumeFontFaceUnicodeRange):
(WebCore::consumeFontFaceSrcURI):
(WebCore::consumeFontFaceSrcLocal):
(WebCore::consumeFontFaceSrc):
(WebCore::CSSPropertyParser::parseFontFaceDescriptor):
(WebCore::CSSPropertyParser::consumeSystemFont):
(WebCore::CSSPropertyParser::consumeFont):
(WebCore::CSSPropertyParser::consumeFontVariantShorthand):
(WebCore::CSSPropertyParser::consumeBorderSpacing):
(WebCore::consumeSingleViewportDescriptor):
(WebCore::CSSPropertyParser::parseViewportDescriptor):
(WebCore::consumeColumnWidthOrCount):
(WebCore::CSSPropertyParser::consumeColumns):
(WebCore::CSSPropertyParser::consumeShorthandGreedily):
(WebCore::CSSPropertyParser::consumeFlex):
(WebCore::CSSPropertyParser::consumeBorder):
(WebCore::CSSPropertyParser::consume4Values):
(WebCore::CSSPropertyParser::consumeBorderImage):
(WebCore::CSSPropertyParser::consumeLegacyBreakProperty):
(WebCore::consumeBackgroundPosition):
(WebCore::consumeRepeatStyleComponent):
(WebCore::consumeRepeatStyle):
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):
(WebCore::CSSPropertyParser::consumeGridItemPositionShorthand):
(WebCore::CSSPropertyParser::consumeGridAreaShorthand):
(WebCore::CSSPropertyParser::consumeGridTemplateRowsAndAreasAndColumns):
(WebCore::CSSPropertyParser::consumeGridTemplateShorthand):
(WebCore::CSSPropertyParser::consumeGridShorthand):
(WebCore::CSSPropertyParser::parseShorthand):
(WebCore::unresolvedCSSPropertyID): Deleted.

  • css/parser/CSSPropertyParser.h:
  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeIdent):
(WebCore::CSSPropertyParserHelpers::consumeCustomIdent):
(WebCore::CSSPropertyParserHelpers::consumeString):
(WebCore::CSSPropertyParserHelpers::consumeImageSet):

  • css/parser/CSSPropertyParserHelpers.h:
Location:
trunk/Source/WebCore
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r207463 r207479  
    12991299    css/CSSNamedImageValue.cpp
    13001300    css/CSSPageRule.cpp
     1301    css/CSSPendingSubstitutionValue.cpp
    13011302    css/CSSPrimitiveValue.cpp
    13021303    css/CSSProperty.cpp
  • trunk/Source/WebCore/ChangeLog

    r207477 r207479  
     12016-10-18  Dave Hyatt  <hyatt@apple.com>
     2
     3        [CSS Parser] Get all the properties turned on
     4        https://bugs.webkit.org/show_bug.cgi?id=163605
     5
     6        Reviewed by Dean Jackson.
     7
     8        * WebCore.xcodeproj/project.pbxproj:
     9        * css/CSSFunctionValue.h:
     10        * css/CSSPendingSubstitutionValue.cpp: Added.
     11        (WebCore::CSSPendingSubstitutionValue::customCSSText):
     12        * css/CSSPendingSubstitutionValue.h: Added.
     13        (WebCore::CSSPendingSubstitutionValue::create):
     14        (WebCore::CSSPendingSubstitutionValue::shorthandValue):
     15        (WebCore::CSSPendingSubstitutionValue::shorthandPropertyId):
     16        (WebCore::CSSPendingSubstitutionValue::equals):
     17        (WebCore::CSSPendingSubstitutionValue::CSSPendingSubstitutionValue):
     18        * css/CSSValue.cpp:
     19        (WebCore::CSSValue::cssText):
     20        (WebCore::CSSValue::destroy):
     21        * css/CSSValue.h:
     22        (WebCore::CSSValue::isPendingSubstitutionValue):
     23        * css/CSSValueKeywords.in:
     24        * css/StylePropertyShorthand.cpp:
     25        (WebCore::transitionShorthandForParsing):
     26        * css/StylePropertyShorthand.h:
     27        * css/parser/CSSParser.cpp:
     28        (WebCore::CSSParser::completeURL):
     29        * css/parser/CSSParserImpl.cpp:
     30        (WebCore::CSSParserImpl::parseValue):
     31        (WebCore::CSSParserImpl::consumeDeclaration):
     32        (WebCore::CSSParserImpl::consumeDeclarationValue):
     33        * css/parser/CSSParserMode.h:
     34        (WebCore::CSSParserContext::completeURL):
     35        * css/parser/CSSParserToken.cpp:
     36        (WebCore::CSSParserToken::parseAsCSSPropertyID):
     37        (WebCore::CSSParserToken::parseAsUnresolvedCSSPropertyID): Deleted.
     38        * css/parser/CSSParserToken.h:
     39        * css/parser/CSSPropertyParser.cpp:
     40        (WebCore::cssPropertyID):
     41        (WebCore::CSSPropertyParser::addProperty):
     42        (WebCore::CSSPropertyParser::addExpandedPropertyForValue):
     43        (WebCore::CSSPropertyParser::parseValue):
     44        (WebCore::CSSPropertyParser::parseSingleValue):
     45        (WebCore::CSSPropertyParser::parseValueStart):
     46        (WebCore::CSSPropertyParser::consumeCSSWideKeyword):
     47        (WebCore::consumeTransformOrigin):
     48        (WebCore::consumeWillChange):
     49        (WebCore::consumeFontFeatureTag):
     50        (WebCore::consumeFontFeatureSettings):
     51        (WebCore::consumePage):
     52        (WebCore::consumeQuotes):
     53        (WebCore::FontVariantLigaturesParser::consumeLigature):
     54        (WebCore::FontVariantLigaturesParser::finalizeValue):
     55        (WebCore::consumeFontVariantLigatures):
     56        (WebCore::consumeFontVariantCaps):
     57        (WebCore::FontVariantNumericParser::consumeNumeric):
     58        (WebCore::FontVariantNumericParser::finalizeValue):
     59        (WebCore::consumeFontVariantNumeric):
     60        (WebCore::consumeFontVariantCSS21):
     61        (WebCore::consumeFontVariantList):
     62        (WebCore::consumeFontWeight):
     63        (WebCore::consumeFamilyName):
     64        (WebCore::consumeGenericFamily):
     65        (WebCore::consumeFontFamily):
     66        (WebCore::consumeSpacing):
     67        (WebCore::consumeTabSize):
     68        (WebCore::consumeTextSizeAdjust):
     69        (WebCore::consumeFontSize):
     70        (WebCore::consumeLineHeight):
     71        (WebCore::createPrimitiveValuePair):
     72        (WebCore::consumeCounter):
     73        (WebCore::consumePageSize):
     74        (WebCore::consumeSize):
     75        (WebCore::consumeTextIndent):
     76        (WebCore::validWidthOrHeightKeyword):
     77        (WebCore::consumeMaxWidthOrHeight):
     78        (WebCore::consumeWidthOrHeight):
     79        (WebCore::consumeMarginOrOffset):
     80        (WebCore::consumeClipComponent):
     81        (WebCore::consumeClip):
     82        (WebCore::consumeTouchAction):
     83        (WebCore::consumeLineClamp):
     84        (WebCore::consumeLocale):
     85        (WebCore::consumeColumnWidth):
     86        (WebCore::consumeColumnCount):
     87        (WebCore::consumeColumnGap):
     88        (WebCore::consumeColumnSpan):
     89        (WebCore::consumeZoom):
     90        (WebCore::consumeAnimationIterationCount):
     91        (WebCore::consumeAnimationName):
     92        (WebCore::consumeTransitionProperty):
     93        (WebCore::consumeCubicBezier):
     94        (WebCore::consumeAnimationTimingFunction):
     95        (WebCore::consumeAnimationValue):
     96        (WebCore::isValidAnimationPropertyList):
     97        (WebCore::consumeAnimationPropertyList):
     98        (WebCore::CSSPropertyParser::consumeAnimationShorthand):
     99        (WebCore::consumeZIndex):
     100        (WebCore::parseSingleShadow):
     101        (WebCore::consumeShadow):
     102        (WebCore::consumeFilterFunction):
     103        (WebCore::consumeFilter):
     104        (WebCore::consumeTextDecorationLine):
     105        (WebCore::consumeTextEmphasisStyle):
     106        (WebCore::consumeOutlineColor):
     107        (WebCore::consumeLineWidth):
     108        (WebCore::consumeBorderWidth):
     109        (WebCore::consumeTextStrokeWidth):
     110        (WebCore::consumeColumnRuleWidth):
     111        (WebCore::consumeTranslate3d):
     112        (WebCore::consumeNumbers):
     113        (WebCore::consumePerspective):
     114        (WebCore::consumeTransformValue):
     115        (WebCore::consumeTransform):
     116        (WebCore::consumePositionLonghand):
     117        (WebCore::consumePositionX):
     118        (WebCore::consumePositionY):
     119        (WebCore::consumePaintStroke):
     120        (WebCore::consumePaintOrder):
     121        (WebCore::consumeNoneOrURI):
     122        (WebCore::consumeFlexBasis):
     123        (WebCore::consumeStrokeDasharray):
     124        (WebCore::consumeBaselineShift):
     125        (WebCore::consumeRxOrRy):
     126        (WebCore::consumeCursor):
     127        (WebCore::consumeAttr):
     128        (WebCore::consumeCounterContent):
     129        (WebCore::consumeContent):
     130        (WebCore::consumePositionList):
     131        (WebCore::consumeScrollSnapCoordinate):
     132        (WebCore::consumeScrollSnapPoints):
     133        (WebCore::consumeBorderRadiusCorner):
     134        (WebCore::consumeVerticalAlign):
     135        (WebCore::consumeShapeRadius):
     136        (WebCore::consumeBasicShapeCircle):
     137        (WebCore::consumeBasicShapeEllipse):
     138        (WebCore::consumeBasicShapePolygon):
     139        (WebCore::complete4Sides):
     140        (WebCore::consumeRadii):
     141        (WebCore::consumeBasicShapeInset):
     142        (WebCore::consumeBasicShape):
     143        (WebCore::consumeWebkitClipPath):
     144        (WebCore::consumeShapeOutside):
     145        (WebCore::consumeContentDistributionOverflowPosition):
     146        (WebCore::consumeBorderImageRepeatKeyword):
     147        (WebCore::consumeBorderImageRepeat):
     148        (WebCore::consumeBorderImageSlice):
     149        (WebCore::consumeBorderImageOutset):
     150        (WebCore::consumeBorderImageWidth):
     151        (WebCore::consumeBorderImageComponents):
     152        (WebCore::consumeWebkitBorderImage):
     153        (WebCore::consumeReflect):
     154        (WebCore::consumeImageOrientation):
     155        (WebCore::consumeBackgroundBlendMode):
     156        (WebCore::consumeBackgroundAttachment):
     157        (WebCore::consumeBackgroundBox):
     158        (WebCore::consumeBackgroundComposite):
     159        (WebCore::consumePrefixedBackgroundBox):
     160        (WebCore::consumeBackgroundSize):
     161        (WebCore::consumeGridAutoFlow):
     162        (WebCore::consumeBackgroundComponent):
     163        (WebCore::addBackgroundValue):
     164        (WebCore::consumeCommaSeparatedBackgroundComponent):
     165        (WebCore::consumeSelfPositionKeyword):
     166        (WebCore::consumeSelfPositionOverflowPosition):
     167        (WebCore::consumeAlignItems):
     168        (WebCore::consumeJustifyItems):
     169        (WebCore::consumeFitContent):
     170        (WebCore::consumeCustomIdentForGridLine):
     171        (WebCore::consumeGridLine):
     172        (WebCore::isGridTrackFixedSized):
     173        (WebCore::consumeGridBreadth):
     174        (WebCore::consumeGridTrackSize):
     175        (WebCore::consumeGridLineNames):
     176        (WebCore::consumeGridTrackRepeatFunction):
     177        (WebCore::consumeGridTrackList):
     178        (WebCore::consumeGridTemplatesRowsOrColumns):
     179        (WebCore::consumeGridTemplateAreas):
     180        (WebCore::consumeFontFaceUnicodeRange):
     181        (WebCore::consumeFontFaceSrcURI):
     182        (WebCore::consumeFontFaceSrcLocal):
     183        (WebCore::consumeFontFaceSrc):
     184        (WebCore::CSSPropertyParser::parseFontFaceDescriptor):
     185        (WebCore::CSSPropertyParser::consumeSystemFont):
     186        (WebCore::CSSPropertyParser::consumeFont):
     187        (WebCore::CSSPropertyParser::consumeFontVariantShorthand):
     188        (WebCore::CSSPropertyParser::consumeBorderSpacing):
     189        (WebCore::consumeSingleViewportDescriptor):
     190        (WebCore::CSSPropertyParser::parseViewportDescriptor):
     191        (WebCore::consumeColumnWidthOrCount):
     192        (WebCore::CSSPropertyParser::consumeColumns):
     193        (WebCore::CSSPropertyParser::consumeShorthandGreedily):
     194        (WebCore::CSSPropertyParser::consumeFlex):
     195        (WebCore::CSSPropertyParser::consumeBorder):
     196        (WebCore::CSSPropertyParser::consume4Values):
     197        (WebCore::CSSPropertyParser::consumeBorderImage):
     198        (WebCore::CSSPropertyParser::consumeLegacyBreakProperty):
     199        (WebCore::consumeBackgroundPosition):
     200        (WebCore::consumeRepeatStyleComponent):
     201        (WebCore::consumeRepeatStyle):
     202        (WebCore::CSSPropertyParser::consumeBackgroundShorthand):
     203        (WebCore::CSSPropertyParser::consumeGridItemPositionShorthand):
     204        (WebCore::CSSPropertyParser::consumeGridAreaShorthand):
     205        (WebCore::CSSPropertyParser::consumeGridTemplateRowsAndAreasAndColumns):
     206        (WebCore::CSSPropertyParser::consumeGridTemplateShorthand):
     207        (WebCore::CSSPropertyParser::consumeGridShorthand):
     208        (WebCore::CSSPropertyParser::parseShorthand):
     209        (WebCore::unresolvedCSSPropertyID): Deleted.
     210        * css/parser/CSSPropertyParser.h:
     211        * css/parser/CSSPropertyParserHelpers.cpp:
     212        (WebCore::CSSPropertyParserHelpers::consumeIdent):
     213        (WebCore::CSSPropertyParserHelpers::consumeCustomIdent):
     214        (WebCore::CSSPropertyParserHelpers::consumeString):
     215        (WebCore::CSSPropertyParserHelpers::consumeImageSet):
     216        * css/parser/CSSPropertyParserHelpers.h:
     217
    12182016-10-18  Brent Fulgham  <bfulgham@apple.com>
    2219
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r207463 r207479  
    33883388                9418278A1D8B244000492764 /* StyleColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941827881D8B242200492764 /* StyleColor.cpp */; };
    33893389                9418278B1D8B244000492764 /* StyleColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 941827891D8B242200492764 /* StyleColor.h */; };
     3390                9418278E1D8CAF9200492764 /* CSSPendingSubstitutionValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */; };
     3391                9418278F1D8CAF9200492764 /* CSSPendingSubstitutionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */; };
    33903392                9444CBD31D860C8B0073A074 /* SizesCalcParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBD01D860C740073A074 /* SizesCalcParser.cpp */; };
    33913393                9444CBD41D860C8B0073A074 /* SizesCalcParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBCF1D860C740073A074 /* SizesCalcParser.h */; };
     
    1074010742                941827881D8B242200492764 /* StyleColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleColor.cpp; sourceTree = "<group>"; };
    1074110743                941827891D8B242200492764 /* StyleColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleColor.h; sourceTree = "<group>"; };
     10744                9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSPendingSubstitutionValue.cpp; sourceTree = "<group>"; };
     10745                9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPendingSubstitutionValue.h; sourceTree = "<group>"; };
    1074210746                9444CBCF1D860C740073A074 /* SizesCalcParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SizesCalcParser.h; path = parser/SizesCalcParser.h; sourceTree = "<group>"; };
    1074310747                9444CBD01D860C740073A074 /* SizesCalcParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SizesCalcParser.cpp; path = parser/SizesCalcParser.cpp; sourceTree = "<group>"; };
     
    2283322837                                A80E6CD60A1989CA007FB8C5 /* CSSPageRule.h */,
    2283422838                                85C56CA60AA89D5F00D95755 /* CSSPageRule.idl */,
     22839                                9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */,
     22840                                9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */,
    2283522841                                A80E6CDB0A1989CA007FB8C5 /* CSSPrimitiveValue.cpp */,
    2283622842                                A80E6CBC0A1989CA007FB8C5 /* CSSPrimitiveValue.h */,
     
    2643226438                                297BE3D616C03C0B003316BD /* PlatformSpeechSynthesisVoice.h in Headers */,
    2643326439                                297BE3D716C03C0E003316BD /* PlatformSpeechSynthesizer.h in Headers */,
     26440                                9418278F1D8CAF9200492764 /* CSSPendingSubstitutionValue.h in Headers */,
    2643426441                                1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */,
    2643526442                                0F7D07331884C56C00B4AF86 /* PlatformTextTrack.h in Headers */,
     
    3092130928                                AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */,
    3092230929                                2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */,
     30930                                9418278E1D8CAF9200492764 /* CSSPendingSubstitutionValue.cpp in Sources */,
    3092330931                                120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */,
    3092430932                                07D637411BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm in Sources */,
  • trunk/Source/WebCore/css/CSSFunctionValue.h

    r206007 r207479  
    5656
    5757    bool equals(const CSSFunctionValue&) const;
     58   
     59    CSSValueID name() const { return m_name; }
    5860
    5961    CSSValueList* arguments() const { return m_args.get(); }
  • trunk/Source/WebCore/css/CSSValue.cpp

    r206839 r207479  
    5353#include "CSSLineBoxContainValue.h"
    5454#include "CSSNamedImageValue.h"
     55#include "CSSPendingSubstitutionValue.h"
    5556#include "CSSPrimitiveValue.h"
    5657#include "CSSProperty.h"
     
    366367    case VariableReferenceClass:
    367368        return downcast<CSSVariableReferenceValue>(*this).customCSSText();
     369    case PendingSubstitutionValueClass:
     370        return downcast<CSSPendingSubstitutionValue>(*this).customCSSText();
    368371    }
    369372
     
    522525    case VariableReferenceClass:
    523526        delete downcast<CSSVariableReferenceValue>(this);
     527        return;
     528    case PendingSubstitutionValueClass:
     529        delete downcast<CSSPendingSubstitutionValue>(this);
    524530        return;
    525531    }
  • trunk/Source/WebCore/css/CSSValue.h

    r207396 r207479  
    130130    bool isCustomIdentValue() const { return m_classType == CustomIdentClass; }
    131131    bool isVariableReferenceValue() const { return m_classType == VariableReferenceClass; }
     132    bool isPendingSubstitutionValue() const { return m_classType == PendingSubstitutionValueClass; }
    132133
    133134    bool isCSSOMSafe() const { return m_isCSSOMSafe; }
     
    211212        CustomIdentClass,
    212213        VariableReferenceClass,
     214        PendingSubstitutionValueClass,
    213215
    214216        // List class types must appear after ValueListClass.
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r207173 r207479  
    11961196drop-shadow
    11971197url
     1198cubic-bezier
     1199steps
    11981200
    11991201// colors
     
    12501252span
    12511253
     1254// grid-template-{columns|rows}
     1255minmax
     1256
    12521257// grid-auto-flow
    12531258auto-flow
  • trunk/Source/WebCore/css/StylePropertyShorthand.cpp

    r205809 r207479  
    5151}
    5252
     53StylePropertyShorthand transitionShorthandForParsing()
     54{
     55    // Similar to animations, we have property after timing-function and delay after
     56    // duration.
     57    static const CSSPropertyID transitionProperties[] = {
     58        CSSPropertyTransitionDuration, CSSPropertyTransitionTimingFunction,
     59        CSSPropertyTransitionDelay, CSSPropertyTransitionProperty};
     60    return StylePropertyShorthand(CSSPropertyTransition, transitionProperties);
     61}
     62
    5363bool isShorthandCSSProperty(CSSPropertyID id)
    5464{
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r205809 r207479  
    5454// Custom StylePropertyShorthand functions.
    5555StylePropertyShorthand animationShorthandForParsing();
     56StylePropertyShorthand transitionShorthandForParsing();
    5657StylePropertyShorthand borderAbridgedShorthand();
    5758
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r207471 r207479  
    15551555URL CSSParser::completeURL(const CSSParserContext& context, const String& url)
    15561556{
    1557     if (url.isNull())
    1558         return URL();
    1559     if (context.charset.isEmpty())
    1560         return URL(context.baseURL, url);
    1561     return URL(context.baseURL, url, context.charset);
     1557    return context.completeURL(url);
    15621558}
    15631559
    15641560URL CSSParser::completeURL(const String& url) const
    15651561{
    1566     return completeURL(m_context, url);
     1562    return m_context.completeURL(url);
    15671563}
    15681564
  • trunk/Source/WebCore/css/parser/CSSParserImpl.cpp

    r206753 r207479  
    6363}
    6464
    65 bool CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID unresolvedProperty, const String& string, bool important, const CSSParserContext& context)
     65bool CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context)
    6666{
    6767    CSSParserImpl parser(context);
     
    7272#endif
    7373    CSSTokenizer::Scope scope(string);
    74     parser.consumeDeclarationValue(scope.tokenRange(), unresolvedProperty, important, ruleType);
     74    parser.consumeDeclarationValue(scope.tokenRange(), propertyID, important, ruleType);
    7575    if (parser.m_parsedProperties.isEmpty())
    7676        return false;
     
    758758    ASSERT(range.peek().type() == IdentToken);
    759759    const CSSParserToken& token = range.consumeIncludingWhitespace();
    760     CSSPropertyID unresolvedProperty = token.parseAsUnresolvedCSSPropertyID();
     760    CSSPropertyID propertyID = token.parseAsCSSPropertyID();
    761761    if (range.consume().type() != ColonToken)
    762762        return; // Parse error
     
    778778
    779779    size_t propertiesCount = m_parsedProperties.size();
    780     if (unresolvedProperty == CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) {
     780    if (propertyID == CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) {
    781781        AtomicString variableName = token.value().toAtomicString();
    782782        consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important);
     
    786786        return;
    787787
    788     if (unresolvedProperty != CSSPropertyInvalid)
    789         consumeDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), unresolvedProperty, important, ruleType);
     788    if (propertyID != CSSPropertyInvalid)
     789        consumeDeclarationValue(range.makeSubRange(&range.peek(), declarationValueEnd), propertyID, important, ruleType);
    790790
    791791    if (m_observerWrapper && (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) {
     
    802802}
    803803
    804 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID unresolvedProperty, bool important, StyleRule::Type ruleType)
    805 {
    806     CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_context, m_parsedProperties, ruleType);
     804void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID propertyID, bool important, StyleRule::Type ruleType)
     805{
     806    CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_parsedProperties, ruleType);
    807807}
    808808
  • trunk/Source/WebCore/css/parser/CSSParserMode.h

    r207339 r207479  
    3232#define CSSParserMode_h
    3333
     34#include "TextEncoding.h"
    3435#include "URL.h"
    3536#include "URLHash.h"
     
    108109    bool springTimingFunctionEnabled { false };
    109110    bool useNewParser { false };
     111   
     112    URL completeURL(const String& url) const
     113    {
     114        if (url.isNull())
     115            return URL();
     116        if (charset.isEmpty())
     117            return URL(baseURL, url);
     118        return URL(baseURL, url, TextEncoding(charset));
     119    }
     120
    110121#if ENABLE(VARIATION_FONTS)
    111122    bool variationFontsEnabled { false };
  • trunk/Source/WebCore/css/parser/CSSParserToken.cpp

    r206043 r207479  
    297297}
    298298
    299 CSSPropertyID CSSParserToken::parseAsUnresolvedCSSPropertyID() const
     299CSSPropertyID CSSParserToken::parseAsCSSPropertyID() const
    300300{
    301301    ASSERT(m_type == IdentToken);
    302     return unresolvedCSSPropertyID(value());
     302    return cssPropertyID(value());
    303303}
    304304
  • trunk/Source/WebCore/css/parser/CSSParserToken.h

    r205103 r207479  
    137137    bool hasStringBacking() const;
    138138
    139     CSSPropertyID parseAsUnresolvedCSSPropertyID() const;
     139    CSSPropertyID parseAsCSSPropertyID() const;
    140140
    141141    void serialize(StringBuilder&) const;
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r207396 r207479  
    3333#include "CSSBasicShapes.h"
    3434#include "CSSBorderImage.h"
     35#include "CSSBorderImageSliceValue.h"
    3536#include "CSSContentDistributionValue.h"
    3637#include "CSSCursorImageValue.h"
    37 // FIXME-NEWPARSER #include "CSSCustomIdentValue.h"
     38#include "CSSCustomIdentValue.h"
    3839#include "CSSFontFaceSrcValue.h"
    39 // FIXME-NEWPARSER #include "CSSFontFamilyValue.h"
    4040#include "CSSFontFeatureValue.h"
    4141#include "CSSFunctionValue.h"
     
    4747#include "CSSParserFastPaths.h"
    4848#include "CSSParserIdioms.h"
    49 // FIXME-NEWPARSER #include "CSSPathValue.h"
    50 // FIXME-NEWPARSER #include "CSSPendingSubstitutionValue.h"
     49#include "CSSPendingSubstitutionValue.h"
    5150#include "CSSPrimitiveValueMappings.h"
    5251#include "CSSPropertyParserHelpers.h"
    53 // FIXME-NEWPARSER #include "CSSQuadValue.h"
    5452#include "CSSReflectValue.h"
     53#include "CSSRevertValue.h"
    5554#include "CSSShadowValue.h"
    56 // FIXME-NEWPARSER #include "CSSStringValue.h"
    5755#include "CSSTimingFunctionValue.h"
    58 // FIXME-NEWPARSER #include "CSSURIValue.h"
    5956#include "CSSUnicodeRangeValue.h"
    6057#include "CSSUnsetValue.h"
    61 // FIXME-NEWPARSER #include "CSSValuePair.h"
    62 // FIXME-NEWPARSER #include "CSSVariableReferenceValue.h"
    63 // FIXME-NEWPARSER #include "CSSVariableParser.h"
     58#include "CSSVariableParser.h"
     59#include "CSSVariableReferenceValue.h"
    6460#include "Counter.h"
    6561#include "FontFace.h"
    6662#include "HashTools.h"
     63// FIXME-NEWPARSER: Replace Pair and Rect with actual CSSValue subclasses (CSSValuePair and CSSQuadValue).
     64#include "Pair.h"
     65#include "Rect.h"
    6766#include "RenderTheme.h"
    6867#include "RuntimeEnabledFeatures.h"
    6968#include "SVGPathUtilities.h"
    7069#include "StylePropertyShorthand.h"
     70#include "StylePropertyShorthandFunctions.h"
    7171#include <memory>
    7272#include <wtf/text/StringBuilder.h>
     73
     74using namespace WTF;
    7375
    7476namespace WebCore {
     
    182184}
    183185
    184 CSSPropertyID unresolvedCSSPropertyID(StringView string)
     186CSSPropertyID cssPropertyID(StringView string)
    185187{
    186188    unsigned length = string.length();
     
    194196}
    195197   
    196 // FIXME-NEWPARSER
    197 // Comment out property parsing for now.
    198 /*
    199198using namespace CSSPropertyParserHelpers;
    200 
    201199
    202200CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range,
     
    209207}
    210208
    211 void CSSPropertyParser::addProperty(CSSPropertyID property, CSSPropertyID currentShorthand, const CSSValue& value, bool important, bool implicit)
    212 {
    213     ASSERT(!isPropertyAlias(property));
    214 
     209void CSSPropertyParser::addProperty(CSSPropertyID property, CSSPropertyID currentShorthand, Ref<CSSValue>&& value, bool important, bool implicit)
     210{
    215211    int shorthandIndex = 0;
    216212    bool setFromShorthand = false;
    217213
    218214    if (currentShorthand) {
    219         Vector<StylePropertyShorthand, 4> shorthands;
    220         getMatchingShorthandsForLonghand(property, &shorthands);
     215        auto shorthands = matchingShorthandsForLonghand(property);
    221216        setFromShorthand = true;
    222217        if (shorthands.size() > 1)
     
    224219    }
    225220
    226     m_parsedProperties->append(CSSProperty(property, value, important, setFromShorthand, shorthandIndex, implicit));
    227 }
    228 
    229 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, const CSSValue& value, bool important)
     221    m_parsedProperties->append(CSSProperty(property, WTFMove(value), important, setFromShorthand, shorthandIndex, implicit));
     222}
     223
     224void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, Ref<CSSValue>&& value, bool important)
    230225{
    231226    const StylePropertyShorthand& shorthand = shorthandForProperty(property);
     
    234229    const CSSPropertyID* longhands = shorthand.properties();
    235230    for (unsigned i = 0; i < shorthandLength; ++i)
    236         addProperty(longhands[i], property, value, important);
    237 }
    238 */
     231        addProperty(longhands[i], property, WTFMove(value), important);
     232}
    239233   
    240 bool CSSPropertyParser::parseValue(CSSPropertyID /*unresolvedProperty*/, bool /*important*/,
    241     const CSSParserTokenRange& /*range*/, const CSSParserContext& /*context*/,
    242     ParsedPropertyVector& /*parsedProperties*/, StyleRule::Type /*ruleType*/)
    243 {
    244     return false;
    245    
    246     /*
     234bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important,
     235    const CSSParserTokenRange& range, const CSSParserContext& context,
     236    ParsedPropertyVector& parsedProperties, StyleRule::Type ruleType)
     237{
    247238    int parsedPropertiesSize = parsedProperties.size();
    248239
    249240    CSSPropertyParser parser(range, context, &parsedProperties);
    250     CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);
    251241    bool parseSuccess;
    252242
    253     if (ruleType == StyleRule::Viewport) {
    254         parseSuccess = (RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(context.mode()))
    255             && parser.parseViewportDescriptor(resolvedProperty, important);
    256     } else if (ruleType == StyleRule::FontFace) {
    257         parseSuccess = parser.parseFontFaceDescriptor(resolvedProperty);
    258     } else {
    259         parseSuccess = parser.parseValueStart(unresolvedProperty, important);
    260     }
    261 
    262     // This doesn't count UA style sheets
    263     if (parseSuccess && context.useCounter())
    264         context.useCounter()->count(context.mode(), unresolvedProperty);
     243#if ENABLE(CSS_DEVICE_ADAPTATION)
     244    if (ruleType == StyleRule::Viewport)
     245        parseSuccess = parser.parseViewportDescriptor(propertyID, important);
     246    else
     247#endif
     248    if (ruleType == StyleRule::FontFace)
     249        parseSuccess = parser.parseFontFaceDescriptor(propertyID);
     250    else
     251        parseSuccess = parser.parseValueStart(propertyID, important);
    265252
    266253    if (!parseSuccess)
     
    268255
    269256    return parseSuccess;
    270      */
    271 }
    272 /*
    273 const CSSValue* CSSPropertyParser::parseSingleValue(
    274     CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context)
     257}
     258
     259RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context)
    275260{
    276261    CSSPropertyParser parser(range, context, nullptr);
    277     const CSSValue* value = parser.parseSingleValue(property);
     262    RefPtr<CSSValue> value = parser.parseSingleValue(property);
    278263    if (!value || !parser.m_range.atEnd())
    279264        return nullptr;
     
    281266}
    282267
    283 bool CSSPropertyParser::parseValueStart(CSSPropertyID unresolvedProperty, bool important)
    284 {
    285     if (consumeCSSWideKeyword(unresolvedProperty, important))
     268bool CSSPropertyParser::parseValueStart(CSSPropertyID propertyID, bool important)
     269{
     270    if (consumeCSSWideKeyword(propertyID, important))
    286271        return true;
    287272
    288273    CSSParserTokenRange originalRange = m_range;
    289     CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty);
    290     bool isShorthand = isShorthandProperty(propertyId);
     274    bool isShorthand = isShorthandCSSProperty(propertyID);
    291275
    292276    if (isShorthand) {
    293277        // Variable references will fail to parse here and will fall out to the variable ref parser below.
    294         if (parseShorthand(unresolvedProperty, important))
     278        if (parseShorthand(propertyID, important))
    295279            return true;
    296280    } else {
    297         if (const CSSValue* parsedValue = parseSingleValue(unresolvedProperty)) {
    298             if (m_range.atEnd()) {
    299                 addProperty(propertyId, CSSPropertyInvalid, *parsedValue, important);
    300                 return true;
    301             }
    302         }
    303     }
    304 
    305     if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::containsValidVariableReferences(originalRange)) {
    306         CSSVariableReferenceValue* variable = CSSVariableReferenceValue::create(CSSVariableData::create(originalRange));
     281        RefPtr<CSSValue> parsedValue = parseSingleValue(propertyID);
     282        if (parsedValue && m_range.atEnd()) {
     283            addProperty(propertyID, CSSPropertyInvalid, *parsedValue, important);
     284            return true;
     285        }
     286    }
     287
     288    if (CSSVariableParser::containsValidVariableReferences(originalRange)) {
     289        RefPtr<CSSVariableReferenceValue> variable = CSSVariableReferenceValue::create(CSSVariableData::create(originalRange));
    307290
    308291        if (isShorthand) {
    309             const CSSPendingSubstitutionValue& pendingValue = *CSSPendingSubstitutionValue::create(propertyId, variable);
    310             addExpandedPropertyForValue(propertyId, pendingValue, important);
    311         } else {
    312             addProperty(propertyId, CSSPropertyInvalid, *variable, important);
    313         }
     292            RefPtr<CSSPendingSubstitutionValue> pendingValue = CSSPendingSubstitutionValue::create(propertyID, variable.releaseNonNull());
     293            addExpandedPropertyForValue(propertyID, pendingValue.releaseNonNull(), important);
     294        } else
     295            addProperty(propertyID, CSSPropertyInvalid, variable.releaseNonNull(), important);
    314296        return true;
    315297    }
     
    318300}
    319301 
    320 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important)
     302bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID propertyID, bool important)
    321303{
    322304    CSSParserTokenRange rangeCopy = m_range;
    323     CSSValueID id = rangeCopy.consumeIncludingWhitespace().id();
     305    CSSValueID valueID = rangeCopy.consumeIncludingWhitespace().id();
    324306    if (!rangeCopy.atEnd())
    325307        return false;
    326308
    327     CSSValue* value = nullptr;
    328     if (id == CSSValueInitial)
    329         value = CSSInitialValue::create();
    330     else if (id == CSSValueInherit)
    331         value = CSSInheritedValue::create();
    332     else if (id == CSSValueUnset)
    333         value = CSSUnsetValue::create();
     309    RefPtr<CSSValue> value;
     310    if (valueID == CSSValueInherit)
     311        value = CSSValuePool::singleton().createInheritedValue();
     312    else if (valueID == CSSValueInitial)
     313        value = CSSValuePool::singleton().createExplicitInitialValue();
     314    else if (valueID == CSSValueUnset)
     315        value = CSSValuePool::singleton().createUnsetValue();
     316    else if (valueID == CSSValueRevert)
     317        value = CSSValuePool::singleton().createRevertValue();
    334318    else
    335319        return false;
    336 
    337     CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
    338     const StylePropertyShorthand& shorthand = shorthandForProperty(property);
     320   
     321    const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID);
    339322    if (!shorthand.length()) {
    340         if (CSSPropertyMetadata::isDescriptorOnly(unresolvedProperty))
    341             return false;
    342         addProperty(property, CSSPropertyInvalid, *value, important);
    343     } else {
    344         addExpandedPropertyForValue(property, *value, important);
    345     }
     323        if (CSSProperty::isDescriptorOnly(propertyID))
     324            return false;
     325        addProperty(propertyID, CSSPropertyInvalid, value.releaseNonNull(), important);
     326    } else
     327        addExpandedPropertyForValue(propertyID, value.releaseNonNull(), important);
    346328    m_range = rangeCopy;
    347329    return true;
    348330}
    349331
    350 static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
    351 {
    352     CSSValue* resultX = nullptr;
    353     CSSValue* resultY = nullptr;
     332static RefPtr<CSSValueList> consumeTransformOrigin(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
     333{
     334    RefPtr<CSSPrimitiveValue> resultX;
     335    RefPtr<CSSPrimitiveValue> resultY;
    354336    if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, resultY)) {
    355         CSSValueList* list = CSSValueList::createSpaceSeparated();
    356         list->append(*resultX);
    357         list->append(*resultY);
    358         CSSValue* resultZ = consumeLength(range, cssParserMode, ValueRangeAll);
     337        RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     338        list->append(resultX.releaseNonNull());
     339        list->append(resultY.releaseNonNull());
     340        RefPtr<CSSPrimitiveValue> resultZ = consumeLength(range, cssParserMode, ValueRangeAll);
    359341        if (!resultZ)
    360             resultZ = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels);
    361         list->append(*resultZ);
     342            resultZ = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PX);
     343        list->append(resultZ.releaseNonNull());
    362344        return list;
    363345    }
     
    366348
    367349// Methods for consuming non-shorthand properties starts here.
    368 static CSSValue* consumeWillChange(CSSParserTokenRange& range)
     350static RefPtr<CSSValue> consumeWillChange(CSSParserTokenRange& range)
    369351{
    370352    if (range.peek().id() == CSSValueAuto)
    371353        return consumeIdent(range);
    372354
    373     CSSValueList* values = CSSValueList::createCommaSeparated();
     355    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
    374356    // Every comma-separated list of identifiers is a valid will-change value,
    375357    // unless the list includes an explicitly disallowed identifier.
     
    377359        if (range.peek().type() != IdentToken)
    378360            return nullptr;
    379         CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(range.peek().value());
    380         if (unresolvedProperty) {
    381             ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty));
     361        CSSPropertyID propertyID = cssPropertyID(range.peek().value());
     362        if (propertyID != CSSPropertyInvalid) {
    382363            // Now "all" is used by both CSSValue and CSSPropertyValue.
    383364            // Need to return nullptr when currentValue is CSSPropertyAll.
    384             if (unresolvedProperty == CSSPropertyWillChange || unresolvedProperty == CSSPropertyAll)
     365            if (propertyID == CSSPropertyWillChange || propertyID == CSSPropertyAll)
    385366                return nullptr;
    386             values->append(*CSSCustomIdentValue::create(unresolvedProperty));
     367            values->append(CSSCustomIdentValue::create(propertyID));
    387368            range.consumeIncludingWhitespace();
    388369        } else {
     
    397378            case CSSValueContents:
    398379            case CSSValueScrollPosition:
    399                 values->append(*consumeIdent(range));
     380                values->append(consumeIdent(range).releaseNonNull());
    400381                break;
    401382            default:
     
    414395}
    415396
    416 static CSSFontFeatureValue* consumeFontFeatureTag(CSSParserTokenRange& range)
     397static RefPtr<CSSFontFeatureValue> consumeFontFeatureTag(CSSParserTokenRange& range)
    417398{
    418399    // Feature tag name consists of 4-letter characters.
     
    425406    if (token.value().length() != tagNameLength)
    426407        return nullptr;
    427     AtomicString tag = token.value().toAtomicString();
    428     for (unsigned i = 0; i < tagNameLength; ++i) {
     408   
     409    FontTag tag;
     410    for (unsigned i = 0; i < tag.size(); ++i) {
    429411        // Limits the range of characters to 0x20-0x7E, following the tag name rules defiend in the OpenType specification.
    430         UChar character = tag[i];
     412        UChar character = token.value()[i];
    431413        if (character < 0x20 || character > 0x7E)
    432414            return nullptr;
     415        tag[i] = toASCIILower(character);
    433416    }
    434417
     
    442425        tagValue = range.consumeIncludingWhitespace().id() == CSSValueOn;
    443426    }
    444     return CSSFontFeatureValue::create(tag, tagValue);
    445 }
    446 
    447 static CSSValue* consumeFontFeatureSettings(CSSParserTokenRange& range)
     427    return CSSFontFeatureValue::create(WTFMove(tag), tagValue);
     428}
     429
     430static RefPtr<CSSValue> consumeFontFeatureSettings(CSSParserTokenRange& range)
    448431{
    449432    if (range.peek().id() == CSSValueNormal)
    450433        return consumeIdent(range);
    451     CSSValueList* settings = CSSValueList::createCommaSeparated();
     434    RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated();
    452435    do {
    453         CSSFontFeatureValue* fontFeatureValue = consumeFontFeatureTag(range);
     436        RefPtr<CSSFontFeatureValue> fontFeatureValue = consumeFontFeatureTag(range);
    454437        if (!fontFeatureValue)
    455438            return nullptr;
    456         settings->append(*fontFeatureValue);
     439        settings->append(fontFeatureValue.releaseNonNull());
    457440    } while (consumeCommaIncludingWhitespace(range));
    458441    return settings;
    459442}
    460443
    461 static CSSValue* consumePage(CSSParserTokenRange& range)
     444static RefPtr<CSSValue> consumePage(CSSParserTokenRange& range)
    462445{
    463446    if (range.peek().id() == CSSValueAuto)
     
    466449}
    467450
    468 static CSSValue* consumeQuotes(CSSParserTokenRange& range)
     451static RefPtr<CSSValue> consumeQuotes(CSSParserTokenRange& range)
    469452{
    470453    if (range.peek().id() == CSSValueNone)
    471454        return consumeIdent(range);
    472     CSSValueList* values = CSSValueList::createSpaceSeparated();
     455    RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
    473456    while (!range.atEnd()) {
    474         CSSStringValue* parsedValue = consumeString(range);
     457        RefPtr<CSSPrimitiveValue> parsedValue = consumeString(range);
    475458        if (!parsedValue)
    476459            return nullptr;
    477         values->append(*parsedValue);
     460        values->append(parsedValue.releaseNonNull());
    478461    }
    479462    if (values->length() && values->length() % 2 == 0)
     
    482465}
    483466
    484 static CSSValue* consumeWebkitHighlight(CSSParserTokenRange& range)
    485 {
    486     if (range.peek().id() == CSSValueNone)
    487         return consumeIdent(range);
    488     return consumeString(range);
    489 }
    490 
    491467class FontVariantLigaturesParser {
    492     STACK_ALLOCATED();
    493 
    494468public:
    495469    FontVariantLigaturesParser()
     
    539513            return ParseResult::UnknownValue;
    540514        }
    541         m_result->append(*consumeIdent(range));
     515        m_result->append(consumeIdent(range).releaseNonNull());
    542516        return ParseResult::ConsumedValue;
    543517    }
    544518
    545     CSSValue* finalizeValue()
     519    RefPtr<CSSValue> finalizeValue()
    546520    {
    547521        if (!m_result->length())
    548             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     522            return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
    549523        return m_result.release();
    550524    }
     
    555529    bool m_sawHistoricalLigaturesValue;
    556530    bool m_sawContextualLigaturesValue;
    557     Member<CSSValueList> m_result;
     531    RefPtr<CSSValueList> m_result;
    558532};
    559533
    560 static CSSValue* consumeFontVariantLigatures(CSSParserTokenRange& range)
     534static RefPtr<CSSValue> consumeFontVariantLigatures(CSSParserTokenRange& range)
    561535{
    562536    if (range.peek().id() == CSSValueNormal || range.peek().id() == CSSValueNone)
     
    573547}
    574548
    575 static CSSPrimitiveValue* consumeFontVariantCaps(CSSParserTokenRange& range)
     549static RefPtr<CSSPrimitiveValue> consumeFontVariantCaps(CSSParserTokenRange& range)
    576550{
    577551    return consumeIdent<CSSValueNormal, CSSValueSmallCaps, CSSValueAllSmallCaps,
     
    581555
    582556class FontVariantNumericParser {
    583     STACK_ALLOCATED();
    584 
    585557public:
    586558    FontVariantNumericParser()
     
    635607            return ParseResult::UnknownValue;
    636608        }
    637         m_result->append(*consumeIdent(range));
     609        m_result->append(consumeIdent(range).releaseNonNull());
    638610        return ParseResult::ConsumedValue;
    639611    }
    640612
    641     CSSValue* finalizeValue()
     613    RefPtr<CSSValue> finalizeValue()
    642614    {
    643615        if (!m_result->length())
    644             return CSSPrimitiveValue::createIdentifier(CSSValueNormal);
     616            return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
    645617        return m_result.release();
    646618    }
     
    653625    bool m_sawOrdinalValue;
    654626    bool m_sawSlashedZeroValue;
    655     Member<CSSValueList> m_result;
     627    RefPtr<CSSValueList> m_result;
    656628};
    657629
    658 static CSSValue* consumeFontVariantNumeric(CSSParserTokenRange& range)
     630static RefPtr<CSSValue> consumeFontVariantNumeric(CSSParserTokenRange& range)
    659631{
    660632    if (range.peek().id() == CSSValueNormal)
     
    671643}
    672644
    673 static CSSPrimitiveValue* consumeFontVariantCSS21(CSSParserTokenRange& range)
     645static RefPtr<CSSPrimitiveValue> consumeFontVariantCSS21(CSSParserTokenRange& range)
    674646{
    675647    return consumeIdent<CSSValueNormal, CSSValueSmallCaps>(range);
    676648}
    677649
    678 static CSSValue* consumeFontVariantList(CSSParserTokenRange& range)
    679 {
    680     CSSValueList* values = CSSValueList::createCommaSeparated();
     650static RefPtr<CSSValue> consumeFontVariantList(CSSParserTokenRange& range)
     651{
     652    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
    681653    do {
    682654        if (range.peek().id() == CSSValueAll) {
     
    689661            return consumeIdent(range);
    690662        }
    691         CSSPrimitiveValue* fontVariant = consumeFontVariantCSS21(range);
     663        RefPtr<CSSPrimitiveValue> fontVariant = consumeFontVariantCSS21(range);
    692664        if (fontVariant)
    693             values->append(*fontVariant);
     665            values->append(fontVariant.releaseNonNull());
    694666    } while (consumeCommaIncludingWhitespace(range));
    695667
     
    700672}
    701673
    702 static CSSPrimitiveValue* consumeFontWeight(CSSParserTokenRange& range)
     674static RefPtr<CSSPrimitiveValue> consumeFontWeight(CSSParserTokenRange& range)
    703675{
    704676    const CSSParserToken& token = range.peek();
     
    711683        return nullptr;
    712684    range.consumeIncludingWhitespace();
    713     return CSSPrimitiveValue::createIdentifier(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1));
     685    return CSSValuePool::singleton().createIdentifierValue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1));
    714686}
    715687
     
    731703}
    732704
    733 static CSSValue* consumeFamilyName(CSSParserTokenRange& range)
     705static RefPtr<CSSValue> consumeFamilyName(CSSParserTokenRange& range)
    734706{
    735707    if (range.peek().type() == StringToken)
    736         return CSSFontFamilyValue::create(range.consumeIncludingWhitespace().value().toString());
     708        return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
    737709    if (range.peek().type() != IdentToken)
    738710        return nullptr;
     
    740712    if (familyName.isNull())
    741713        return nullptr;
    742     return CSSFontFamilyValue::create(familyName);
    743 }
    744 
    745 static CSSValue* consumeGenericFamily(CSSParserTokenRange& range)
     714    return CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::UnitTypes::CSS_STRING);
     715}
     716
     717static RefPtr<CSSValue> consumeGenericFamily(CSSParserTokenRange& range)
    746718{
    747719    return consumeIdentRange(range, CSSValueSerif, CSSValueWebkitBody);
    748720}
    749721
    750 static CSSValueList* consumeFontFamily(CSSParserTokenRange& range)
    751 {
    752     CSSValueList* list = CSSValueList::createCommaSeparated();
     722static RefPtr<CSSValueList> consumeFontFamily(CSSParserTokenRange& range)
     723{
     724    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    753725    do {
    754         CSSValue* parsedValue = consumeGenericFamily(range);
     726        RefPtr<CSSValue> parsedValue = consumeGenericFamily(range);
    755727        if (parsedValue) {
    756             list->append(*parsedValue);
     728            list->append(parsedValue.releaseNonNull());
    757729        } else {
    758730            parsedValue = consumeFamilyName(range);
    759731            if (parsedValue) {
    760                 list->append(*parsedValue);
     732                list->append(parsedValue.releaseNonNull());
    761733            } else {
    762734                return nullptr;
     
    767739}
    768740
    769 static CSSValue* consumeSpacing(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     741static RefPtr<CSSValue> consumeSpacing(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    770742{
    771743    if (range.peek().id() == CSSValueNormal)
     
    775747}
    776748
    777 static CSSValue* consumeTabSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    778 {
    779     CSSPrimitiveValue* parsedValue = consumeInteger(range, 0);
     749static RefPtr<CSSValue> consumeTabSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     750{
     751    RefPtr<CSSPrimitiveValue> parsedValue = consumeInteger(range, 0);
    780752    if (parsedValue)
    781753        return parsedValue;
     
    783755}
    784756
    785 static CSSValue* consumeTextSizeAdjust(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     757static RefPtr<CSSValue> consumeTextSizeAdjust(CSSParserTokenRange& range, CSSParserMode /* cssParserMode */)
    786758{
    787759    if (range.peek().id() == CSSValueAuto)
     
    792764}
    793765
    794 static CSSValue* consumeFontSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
     766static RefPtr<CSSValue> consumeFontSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
    795767{
    796768    if (range.peek().id() >= CSSValueXxSmall && range.peek().id() <= CSSValueLarger)
     
    799771}
    800772
    801 static CSSPrimitiveValue* consumeLineHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     773static RefPtr<CSSPrimitiveValue> consumeLineHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    802774{
    803775    if (range.peek().id() == CSSValueNormal)
    804776        return consumeIdent(range);
    805777
    806     CSSPrimitiveValue* lineHeight = consumeNumber(range, ValueRangeNonNegative);
     778    RefPtr<CSSPrimitiveValue> lineHeight = consumeNumber(range, ValueRangeNonNegative);
    807779    if (lineHeight)
    808780        return lineHeight;
     
    810782}
    811783
    812 static CSSValueList* consumeRotation(CSSParserTokenRange& range)
    813 {
    814     ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
    815     CSSValueList* list = CSSValueList::createSpaceSeparated();
    816 
    817     CSSValue* rotation = consumeAngle(range);
    818     if (!rotation)
    819         return nullptr;
    820     list->append(*rotation);
    821 
    822     if (range.atEnd())
    823         return list;
    824 
    825     for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation
    826         CSSValue* dimension = consumeNumber(range, ValueRangeAll);
    827         if (!dimension)
    828             return nullptr;
    829         list->append(*dimension);
    830     }
    831 
    832     return list;
    833 }
    834 
    835 static CSSValueList* consumeScale(CSSParserTokenRange& range)
    836 {
    837     ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
    838 
    839     CSSValue* scale = consumeNumber(range, ValueRangeAll);
    840     if (!scale)
    841         return nullptr;
    842     CSSValueList* list = CSSValueList::createSpaceSeparated();
    843     list->append(*scale);
    844     scale = consumeNumber(range, ValueRangeAll);
    845     if (scale) {
    846         list->append(*scale);
    847         scale = consumeNumber(range, ValueRangeAll);
    848         if (scale)
    849             list->append(*scale);
    850     }
    851 
    852     return list;
    853 }
    854 
    855 static CSSValueList* consumeTranslate(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    856 {
    857     ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
    858     CSSValue* translate = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll);
    859     if (!translate)
    860         return nullptr;
    861     CSSValueList* list = CSSValueList::createSpaceSeparated();
    862     list->append(*translate);
    863     translate = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll);
    864     if (translate) {
    865         list->append(*translate);
    866         translate = consumeLength(range, cssParserMode, ValueRangeAll);
    867         if (translate)
    868             list->append(*translate);
    869     }
    870 
    871     return list;
    872 }
    873 
    874 static CSSValue* consumeCounter(CSSParserTokenRange& range, int defaultValue)
     784template<typename... Args>
     785static Ref<CSSPrimitiveValue> createPrimitiveValuePair(Args&&... args)
     786{
     787    return CSSValuePool::singleton().createValue(Pair::create(std::forward<Args>(args)...));
     788}
     789
     790static RefPtr<CSSValue> consumeCounter(CSSParserTokenRange& range, int defaultValue)
    875791{
    876792    if (range.peek().id() == CSSValueNone)
    877793        return consumeIdent(range);
    878794
    879     CSSValueList* list = CSSValueList::createSpaceSeparated();
     795    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    880796    do {
    881         CSSCustomIdentValue* counterName = consumeCustomIdent(range);
     797        RefPtr<CSSPrimitiveValue> counterName = consumeCustomIdent(range);
    882798        if (!counterName)
    883799            return nullptr;
    884800        int i = defaultValue;
    885         if (CSSPrimitiveValue* counterValue = consumeInteger(range))
    886             i = counterValue->intValue());
    887         list->append(*CSSValuePair::create(counterName,
    888             CSSPrimitiveValue::create(i, CSSPrimitiveValue::UnitType::Integer),
    889             CSSValuePair::DropIdenticalValues));
     801        if (RefPtr<CSSPrimitiveValue> counterValue = consumeInteger(range))
     802            i = counterValue->intValue();
     803        list->append(createPrimitiveValuePair(counterName.releaseNonNull(), CSSPrimitiveValue::create(i, CSSPrimitiveValue::UnitTypes::CSS_NUMBER), Pair::IdenticalValueEncoding::Coalesce));
    890804    } while (!range.atEnd());
    891805    return list;
    892806}
    893807
    894 static CSSValue* consumePageSize(CSSParserTokenRange& range)
     808static RefPtr<CSSValue> consumePageSize(CSSParserTokenRange& range)
    895809{
    896810    return consumeIdent<CSSValueA3, CSSValueA4, CSSValueA5, CSSValueB4, CSSValueB5, CSSValueLedger, CSSValueLegal, CSSValueLetter>(range);
    897811}
    898812
    899 static CSSValueList* consumeSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    900 {
    901     CSSValueList* result = CSSValueList::createSpaceSeparated();
     813static RefPtr<CSSValueList> consumeSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     814{
     815    RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
    902816
    903817    if (range.peek().id() == CSSValueAuto) {
    904         result->append(*consumeIdent(range));
     818        result->append(consumeIdent(range).releaseNonNull());
    905819        return result;
    906820    }
    907821
    908     if (CSSValue* width = consumeLength(range, cssParserMode, ValueRangeNonNegative)) {
    909         CSSValue* height = consumeLength(range, cssParserMode, ValueRangeNonNegative);
    910         result->append(*width);
     822    if (RefPtr<CSSValue> width = consumeLength(range, cssParserMode, ValueRangeNonNegative)) {
     823        RefPtr<CSSValue> height = consumeLength(range, cssParserMode, ValueRangeNonNegative);
     824        result->append(width.releaseNonNull());
    911825        if (height)
    912             result->append(*height);
     826            result->append(height.releaseNonNull());
    913827        return result;
    914828    }
    915829
    916     CSSValue* pageSize = consumePageSize(range);
    917     CSSValue* orientation = consumeIdent<CSSValuePortrait, CSSValueLandscape>(range);
     830    RefPtr<CSSValue> pageSize = consumePageSize(range);
     831    RefPtr<CSSValue> orientation = consumeIdent<CSSValuePortrait, CSSValueLandscape>(range);
    918832    if (!pageSize)
    919833        pageSize = consumePageSize(range);
     
    922836        return nullptr;
    923837    if (pageSize)
    924         result->append(*pageSize);
     838        result->append(pageSize.releaseNonNull());
    925839    if (orientation)
    926         result->append(*orientation);
     840        result->append(orientation.releaseNonNull());
    927841    return result;
    928842}
    929843
    930 static CSSValue* consumeSnapHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    931 {
    932     CSSPrimitiveValue* unit = consumeLength(range, cssParserMode, ValueRangeNonNegative);
    933     if (!unit)
    934         return nullptr;
    935     CSSValueList* list = CSSValueList::createSpaceSeparated();
    936     list->append(*unit);
    937 
    938     if (CSSPrimitiveValue* position = consumePositiveInteger(range)) {
    939         if (position->intValue() > 100)
    940             return nullptr;
    941         list->append(*position);
    942     }
    943 
    944     return list;
    945 }
    946 
    947 static CSSValue* consumeTextIndent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     844static RefPtr<CSSValue> consumeTextIndent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    948845{
    949846    // [ <length> | <percentage> ] && hanging? && each-line?
    950847    // Keywords only allowed when css3Text is enabled.
    951     CSSValueList* list = CSSValueList::createSpaceSeparated();
     848    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    952849
    953850    bool hasLengthOrPercentage = false;
    954     bool hasEachLine = false;
     851//    bool hasEachLine = false;
    955852    bool hasHanging = false;
    956853
    957854    do {
    958855        if (!hasLengthOrPercentage) {
    959             if (CSSValue* textIndent = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) {
     856            if (RefPtr<CSSValue> textIndent = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) {
    960857                list->append(*textIndent);
    961858                hasLengthOrPercentage = true;
     
    964861        }
    965862
    966         if (RuntimeEnabledFeatures::css3TextEnabled()) {
    967             CSSValueID id = range.peek().id();
    968             if (!hasEachLine && id == CSSValueEachLine) {
    969                 list->append(*consumeIdent(range));
    970                 hasEachLine = true;
    971                 continue;
    972             }
    973             if (!hasHanging && id == CSSValueHanging) {
    974                 list->append(*consumeIdent(range));
    975                 hasHanging = true;
    976                 continue;
    977             }
    978         }
     863        CSSValueID id = range.peek().id();
     864 /* FIXME-NEWPARSER: We don't support this yet.
     865        if (!hasEachLine && id == CSSValueEachLine) {
     866            list->append(*consumeIdent(range));
     867            hasEachLine = true;
     868            continue;
     869        }
     870*/
     871       
     872        if (!hasHanging && id == CSSValueHanging) {
     873            list->append(consumeIdent(range).releaseNonNull());
     874            hasHanging = true;
     875            continue;
     876        }
     877       
    979878        return nullptr;
    980879    } while (!range.atEnd());
     
    986885}
    987886
    988 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& context)
     887// FIXME-NEWPARSER: Drop the prefix on min-content, max-content and fit-content.
     888static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& /*context*/)
    989889{
    990890    if (id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFillAvailable || id == CSSValueWebkitFitContent
    991         || id == CSSValueMinContent || id == CSSValueMaxContent || id == CSSValueFitContent) {
    992         if (context.useCounter()) {
    993             switch (id) {
    994             case CSSValueWebkitMinContent:
    995                 context.useCounter()->count(UseCounter::CSSValuePrefixedMinContent);
    996                 break;
    997             case CSSValueWebkitMaxContent:
    998                 context.useCounter()->count(UseCounter::CSSValuePrefixedMaxContent);
    999                 break;
    1000             case CSSValueWebkitFillAvailable:
    1001                 context.useCounter()->count(UseCounter::CSSValuePrefixedFillAvailable);
    1002                 break;
    1003             case CSSValueWebkitFitContent:
    1004                 context.useCounter()->count(UseCounter::CSSValuePrefixedFitContent);
    1005                 break;
    1006             default:
    1007                 break;
    1008             }
    1009         }
     891        || id == CSSValueWebkitMinContent || id == CSSValueWebkitMaxContent || id == CSSValueWebkitFitContent) {
    1010892        return true;
    1011893    }
     
    1013895}
    1014896
    1015 static CSSValue* consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
     897static RefPtr<CSSValue> consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
    1016898{
    1017899    if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.peek().id(), context))
    1018900        return consumeIdent(range);
    1019     return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
    1020 }
    1021 
    1022 static CSSValue* consumeWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
     901    return consumeLengthOrPercent(range, context.mode, ValueRangeNonNegative, unitless);
     902}
     903
     904static RefPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
    1023905{
    1024906    if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.peek().id(), context))
    1025907        return consumeIdent(range);
    1026     return consumeLengthOrPercent(range, context.mode(), ValueRangeNonNegative, unitless);
    1027 }
    1028 
    1029 static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
     908    return consumeLengthOrPercent(range, context.mode, ValueRangeNonNegative, unitless);
     909}
     910
     911static RefPtr<CSSValue> consumeMarginOrOffset(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
    1030912{
    1031913    if (range.peek().id() == CSSValueAuto)
     
    1034916}
    1035917
    1036 static CSSPrimitiveValue* consumeClipComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     918static RefPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    1037919{
    1038920    if (range.peek().id() == CSSValueAuto)
     
    1041923}
    1042924
    1043 static CSSValue* consumeClip(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     925static RefPtr<CSSValue> consumeClip(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    1044926{
    1045927    if (range.peek().id() == CSSValueAuto)
     
    1051933    CSSParserTokenRange args = consumeFunction(range);
    1052934    // rect(t, r, b, l) || rect(t r b l)
    1053     CSSPrimitiveValue* top = consumeClipComponent(args, cssParserMode);
     935    RefPtr<CSSPrimitiveValue> top = consumeClipComponent(args, cssParserMode);
    1054936    if (!top)
    1055937        return nullptr;
    1056938    bool needsComma = consumeCommaIncludingWhitespace(args);
    1057     CSSPrimitiveValue* right = consumeClipComponent(args, cssParserMode);
     939    RefPtr<CSSPrimitiveValue> right = consumeClipComponent(args, cssParserMode);
    1058940    if (!right || (needsComma && !consumeCommaIncludingWhitespace(args)))
    1059941        return nullptr;
    1060     CSSPrimitiveValue* bottom = consumeClipComponent(args, cssParserMode);
     942    RefPtr<CSSPrimitiveValue> bottom = consumeClipComponent(args, cssParserMode);
    1061943    if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args)))
    1062944        return nullptr;
    1063     CSSPrimitiveValue* left = consumeClipComponent(args, cssParserMode);
     945    RefPtr<CSSPrimitiveValue> left = consumeClipComponent(args, cssParserMode);
    1064946    if (!left || !args.atEnd())
    1065947        return nullptr;
    1066     return CSSQuadValue::create(top, right, bottom, left, CSSQuadValue::SerializeAsRect);
    1067 }
    1068 
    1069 static bool consumePan(CSSParserTokenRange& range, CSSValue*& panX, CSSValue*& panY)
    1070 {
    1071     CSSValueID id = range.peek().id();
    1072     if ((id == CSSValuePanX || id == CSSValuePanRight || id == CSSValuePanLeft) && !panX) {
    1073         if (id != CSSValuePanX && !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
    1074             return false;
    1075         panX = consumeIdent(range);
    1076     } else if ((id == CSSValuePanY || id == CSSValuePanDown || id == CSSValuePanUp) && !panY) {
    1077         if (id != CSSValuePanY && !RuntimeEnabledFeatures::cssTouchActionPanDirectionsEnabled())
    1078             return false;
    1079         panY = consumeIdent(range);
    1080     } else {
    1081         return false;
    1082     }
    1083     return true;
    1084 }
    1085 
    1086 static CSSValue* consumeTouchAction(CSSParserTokenRange& range)
    1087 {
    1088     CSSValueList* list = CSSValueList::createSpaceSeparated();
     948   
     949    auto rect = Rect::create();
     950    rect->setLeft(left.releaseNonNull());
     951    rect->setTop(top.releaseNonNull());
     952    rect->setRight(right.releaseNonNull());
     953    rect->setBottom(bottom.releaseNonNull());
     954    return CSSValuePool::singleton().createValue(WTFMove(rect));
     955}
     956
     957#if ENABLE(TOUCH_EVENTS)
     958static RefPtr<CSSValue> consumeTouchAction(CSSParserTokenRange& range)
     959{
     960    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    1089961    CSSValueID id = range.peek().id();
    1090962    if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation) {
    1091         list->append(*consumeIdent(range));
     963        list->append(consumeIdent(range).releaseNonNull());
    1092964        return list;
    1093965    }
    1094 
    1095     CSSValue* panX = nullptr;
    1096     CSSValue* panY = nullptr;
    1097     if (!consumePan(range, panX, panY))
    1098         return nullptr;
    1099     if (!range.atEnd() && !consumePan(range, panX, panY))
    1100         return nullptr;
    1101 
    1102     if (panX)
    1103         list->append(*panX);
    1104     if (panY)
    1105         list->append(*panY);
    1106     return list;
    1107 }
    1108 
    1109 static CSSPrimitiveValue* consumeLineClamp(CSSParserTokenRange& range)
     966    // FIXME-NEWPARSER: Support pan.
     967    return nullptr;
     968}
     969#endif
     970
     971static RefPtr<CSSPrimitiveValue> consumeLineClamp(CSSParserTokenRange& range)
    1110972{
    1111973    if (range.peek().type() != PercentageToken && range.peek().type() != NumberToken)
    1112974        return nullptr;
    1113     CSSPrimitiveValue* clampValue = consumePercent(range, ValueRangeNonNegative);
     975    RefPtr<CSSPrimitiveValue> clampValue = consumePercent(range, ValueRangeNonNegative);
    1114976    if (clampValue)
    1115977        return clampValue;
     
    1118980}
    1119981
    1120 static CSSValue* consumeLocale(CSSParserTokenRange& range)
     982static RefPtr<CSSValue> consumeLocale(CSSParserTokenRange& range)
    1121983{
    1122984    if (range.peek().id() == CSSValueAuto)
     
    1125987}
    1126988
    1127 static CSSValue* consumeColumnWidth(CSSParserTokenRange& range)
     989static RefPtr<CSSValue> consumeColumnWidth(CSSParserTokenRange& range)
    1128990{
    1129991    if (range.peek().id() == CSSValueAuto)
     
    1131993    // Always parse lengths in strict mode here, since it would be ambiguous otherwise when used in
    1132994    // the 'columns' shorthand property.
    1133     CSSPrimitiveValue* columnWidth = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative);
     995    RefPtr<CSSPrimitiveValue> columnWidth = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative);
    1134996    if (!columnWidth || (!columnWidth->isCalculated() && columnWidth->doubleValue() == 0))
    1135997        return nullptr;
     
    1137999}
    11381000
    1139 static CSSValue* consumeColumnCount(CSSParserTokenRange& range)
     1001static RefPtr<CSSValue> consumeColumnCount(CSSParserTokenRange& range)
    11401002{
    11411003    if (range.peek().id() == CSSValueAuto)
     
    11441006}
    11451007
    1146 static CSSValue* consumeColumnGap(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1008static RefPtr<CSSValue> consumeColumnGap(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    11471009{
    11481010    if (range.peek().id() == CSSValueNormal)
     
    11511013}
    11521014
    1153 static CSSValue* consumeColumnSpan(CSSParserTokenRange& range)
     1015static RefPtr<CSSValue> consumeColumnSpan(CSSParserTokenRange& range)
    11541016{
    11551017    return consumeIdent<CSSValueAll, CSSValueNone>(range);
    11561018}
    11571019
    1158 static CSSValue* consumeZoom(CSSParserTokenRange& range, const CSSParserContext& context)
     1020static RefPtr<CSSValue> consumeZoom(CSSParserTokenRange& range, const CSSParserContext& /*context*/)
    11591021{
    11601022    const CSSParserToken& token = range.peek();
    1161     CSSPrimitiveValue* zoom = nullptr;
    1162     if (token.type() == IdentToken) {
     1023    RefPtr<CSSPrimitiveValue> zoom;
     1024    if (token.type() == IdentToken)
    11631025        zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(range);
    1164     } else {
     1026    else {
    11651027        zoom = consumePercent(range, ValueRangeNonNegative);
    11661028        if (!zoom)
    11671029            zoom = consumeNumber(range, ValueRangeNonNegative);
    11681030    }
    1169     if (zoom && context.useCounter()
    1170         && !(token.id() == CSSValueNormal
    1171             || (token.type() == NumberToken && zoom->doubleValue() == 1)
    1172             || (token.type() == PercentageToken && zoom->doubleValue() == 100)))
    1173         context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne);
    11741031    return zoom;
    11751032}
    11761033
    1177 static CSSValue* consumeAnimationIterationCount(CSSParserTokenRange& range)
     1034static RefPtr<CSSValue> consumeAnimationIterationCount(CSSParserTokenRange& range)
    11781035{
    11791036    if (range.peek().id() == CSSValueInfinite)
     
    11821039}
    11831040
    1184 static CSSValue* consumeAnimationName(CSSParserTokenRange& range, const CSSParserContext& context, bool allowQuotedName)
     1041static RefPtr<CSSValue> consumeAnimationName(CSSParserTokenRange& range)
    11851042{
    11861043    if (range.peek().id() == CSSValueNone)
    11871044        return consumeIdent(range);
    11881045
    1189     if (allowQuotedName && range.peek().type() == StringToken) {
    1190         // Legacy support for strings in prefixed animations.
    1191         if (context.useCounter())
    1192             context.useCounter()->count(UseCounter::QuotedAnimationName);
    1193 
     1046    if (range.peek().type() == StringToken) {
    11941047        const CSSParserToken& token = range.consumeIncludingWhitespace();
    11951048        if (equalIgnoringASCIICase(token.value(), "none"))
    1196             return CSSPrimitiveValue::createIdentifier(CSSValueNone);
     1049            return CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
    11971050        return CSSCustomIdentValue::create(token.value().toString());
    11981051    }
     
    12011054}
    12021055
    1203 static CSSValue* consumeTransitionProperty(CSSParserTokenRange& range)
     1056static RefPtr<CSSValue> consumeTransitionProperty(CSSParserTokenRange& range)
    12041057{
    12051058    const CSSParserToken& token = range.peek();
     
    12091062        return consumeIdent(range);
    12101063
    1211     if (CSSPropertyID property = token.parseAsUnresolvedCSSPropertyID()) {
    1212         ASSERT(CSSPropertyMetadata::isEnabledProperty(property));
     1064    if (CSSPropertyID property = token.parseAsCSSPropertyID()) {
    12131065        range.consumeIncludingWhitespace();
    12141066        return CSSCustomIdentValue::create(property);
     
    12171069}
    12181070
    1219 static CSSValue* consumeSteps(CSSParserTokenRange& range)
    1220 {
     1071   
     1072static RefPtr<CSSValue> consumeSteps(CSSParserTokenRange& range) {
    12211073    ASSERT(range.peek().functionId() == CSSValueSteps);
    12221074    CSSParserTokenRange rangeCopy = range;
    12231075    CSSParserTokenRange args = consumeFunction(rangeCopy);
    1224 
    1225     CSSPrimitiveValue* steps = consumePositiveInteger(args);
     1076   
     1077    RefPtr<CSSPrimitiveValue> steps = consumePositiveInteger(args);
    12261078    if (!steps)
    12271079        return nullptr;
    1228 
    1229     StepsTimingFunction::StepPosition position = StepsTimingFunction::StepPosition::END;
     1080   
     1081    // FIXME-NEWPARSER: Support the middle value and change from a boolean to an enum.
     1082    bool stepAtStart = false;
    12301083    if (consumeCommaIncludingWhitespace(args)) {
    12311084        switch (args.consumeIncludingWhitespace().id()) {
    1232         case CSSValueMiddle:
    1233             if (!RuntimeEnabledFeatures::webAnimationsAPIEnabled())
     1085            case CSSValueStart:
     1086                stepAtStart = true;
     1087            break;
     1088            case CSSValueEnd:
     1089                stepAtStart = false;
     1090                break;
     1091            default:
    12341092                return nullptr;
    1235             position = StepsTimingFunction::StepPosition::MIDDLE;
    1236             break;
    1237         case CSSValueStart:
    1238             position = StepsTimingFunction::StepPosition::START;
    1239             break;
    1240         case CSSValueEnd:
    1241             position = StepsTimingFunction::StepPosition::END;
    1242             break;
    1243         default:
    1244             return nullptr;
    1245         }
    1246     }
    1247 
     1093        }
     1094    }
     1095   
    12481096    if (!args.atEnd())
    12491097        return nullptr;
    1250 
     1098   
    12511099    range = rangeCopy;
    1252     return CSSStepsTimingFunctionValue::create(steps->intValue(), position);
    1253 }
    1254 
    1255 static CSSValue* consumeCubicBezier(CSSParserTokenRange& range)
     1100    return CSSStepsTimingFunctionValue::create(steps->intValue(), stepAtStart);
     1101}
     1102
     1103static RefPtr<CSSValue> consumeCubicBezier(CSSParserTokenRange& range)
    12561104{
    12571105    ASSERT(range.peek().functionId() == CSSValueCubicBezier);
     
    12771125}
    12781126
    1279 static CSSValue* consumeAnimationTimingFunction(CSSParserTokenRange& range)
     1127static RefPtr<CSSValue> consumeAnimationTimingFunction(CSSParserTokenRange& range)
    12801128{
    12811129    CSSValueID id = range.peek().id();
    12821130    if (id == CSSValueEase || id == CSSValueLinear || id == CSSValueEaseIn
    1283         || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueStepStart
    1284         || id == CSSValueStepEnd || id == CSSValueStepMiddle)
     1131        || id == CSSValueEaseOut || id == CSSValueEaseInOut || id == CSSValueStepStart || id == CSSValueStepEnd)
    12851132        return consumeIdent(range);
    12861133
    12871134    CSSValueID function = range.peek().functionId();
     1135    if (function == CSSValueCubicBezier)
     1136        return consumeCubicBezier(range);
    12881137    if (function == CSSValueSteps)
    12891138        return consumeSteps(range);
    1290     if (function == CSSValueCubicBezier)
    1291         return consumeCubicBezier(range);
    12921139    return nullptr;
    12931140}
    12941141
    1295 static CSSValue* consumeAnimationValue(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, bool useLegacyParsing)
     1142static RefPtr<CSSValue> consumeAnimationValue(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
    12961143{
    12971144    switch (property) {
    12981145    case CSSPropertyAnimationDelay:
    12991146    case CSSPropertyTransitionDelay:
    1300         return consumeTime(range, ValueRangeAll);
     1147        return consumeTime(range, context.mode, ValueRangeAll, UnitlessQuirk::Forbid);
    13011148    case CSSPropertyAnimationDirection:
    13021149        return consumeIdent<CSSValueNormal, CSSValueAlternate, CSSValueReverse, CSSValueAlternateReverse>(range);
    13031150    case CSSPropertyAnimationDuration:
    13041151    case CSSPropertyTransitionDuration:
    1305         return consumeTime(range, ValueRangeNonNegative);
     1152        return consumeTime(range, context.mode, ValueRangeNonNegative, UnitlessQuirk::Forbid);
    13061153    case CSSPropertyAnimationFillMode:
    13071154        return consumeIdent<CSSValueNone, CSSValueForwards, CSSValueBackwards, CSSValueBoth>(range);
     
    13091156        return consumeAnimationIterationCount(range);
    13101157    case CSSPropertyAnimationName:
    1311         return consumeAnimationName(range, context, useLegacyParsing);
     1158        return consumeAnimationName(range);
    13121159    case CSSPropertyAnimationPlayState:
    13131160        return consumeIdent<CSSValueRunning, CSSValuePaused>(range);
     
    13281175        return true;
    13291176    for (auto& value : valueList) {
    1330         if (value->isPrimitiveValue() && toCSSPrimitiveValue(*value).isValueID()
    1331             && toCSSPrimitiveValue(*value).valueID() == CSSValueNone)
     1177        if (value->isPrimitiveValue() && downcast<CSSPrimitiveValue>(value.get()).isValueID()
     1178            && downcast<CSSPrimitiveValue>(value.get()).valueID() == CSSValueNone)
    13321179            return false;
    13331180    }
     
    13351182}
    13361183
    1337 static CSSValueList* consumeAnimationPropertyList(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, bool useLegacyParsing)
    1338 {
    1339     CSSValueList* list = CSSValueList::createCommaSeparated();
     1184static RefPtr<CSSValueList> consumeAnimationPropertyList(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
     1185{
     1186    RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
    13401187    do {
    1341         CSSValue* value = consumeAnimationValue(property, range, context, useLegacyParsing);
     1188        RefPtr<CSSValue> value = consumeAnimationValue(property, range, context);
    13421189        if (!value)
    13431190            return nullptr;
    1344         list->append(*value);
     1191        list->append(value.releaseNonNull());
    13451192    } while (consumeCommaIncludingWhitespace(range));
    13461193    if (!isValidAnimationPropertyList(property, *list))
     
    13501197}
    13511198
    1352 bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand& shorthand, bool useLegacyParsing, bool important)
     1199bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand& shorthand, bool important)
    13531200{
    13541201    const unsigned longhandCount = shorthand.length();
    1355     CSSValueList* longhands[8];
     1202    RefPtr<CSSValueList> longhands[8];
    13561203    ASSERT(longhandCount <= 8);
    13571204    for (size_t i = 0; i < longhandCount; ++i)
     
    13661213                    continue;
    13671214
    1368                 if (CSSValue* value = consumeAnimationValue(shorthand.properties()[i], m_range, m_context, useLegacyParsing)) {
     1215                if (RefPtr<CSSValue> value = consumeAnimationValue(shorthand.properties()[i], m_range, m_context)) {
    13691216                    parsedLonghand[i] = true;
    13701217                    foundProperty = true;
     
    13801227        for (size_t i = 0; i < longhandCount; ++i) {
    13811228            if (!parsedLonghand[i])
    1382                 longhands[i]->append(*CSSInitialValue::createLegacyImplicit());
     1229                longhands[i]->append(CSSValuePool::singleton().createImplicitInitialValue());
    13831230            parsedLonghand[i] = false;
    13841231        }
     
    13961243}
    13971244
    1398 static CSSValue* consumeZIndex(CSSParserTokenRange& range)
     1245static RefPtr<CSSValue> consumeZIndex(CSSParserTokenRange& range)
    13991246{
    14001247    if (range.peek().id() == CSSValueAuto)
     
    14031250}
    14041251
    1405 static CSSShadowValue* parseSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread)
    1406 {
    1407     CSSPrimitiveValue* style = nullptr;
    1408     CSSValue* color = nullptr;
     1252static RefPtr<CSSShadowValue> parseSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread)
     1253{
     1254    RefPtr<CSSPrimitiveValue> style;
     1255    RefPtr<CSSPrimitiveValue> color;
    14091256
    14101257    if (range.atEnd())
     
    14171264    color = consumeColor(range, cssParserMode);
    14181265
    1419     CSSPrimitiveValue* horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
     1266    RefPtr<CSSPrimitiveValue> horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
    14201267    if (!horizontalOffset)
    14211268        return nullptr;
    14221269
    1423     CSSPrimitiveValue* verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
     1270    RefPtr<CSSPrimitiveValue> verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll);
    14241271    if (!verticalOffset)
    14251272        return nullptr;
    14261273
    1427     CSSPrimitiveValue* blurRadius = consumeLength(range, cssParserMode, ValueRangeAll);
    1428     CSSPrimitiveValue* spreadDistance = nullptr;
     1274    RefPtr<CSSPrimitiveValue> blurRadius = consumeLength(range, cssParserMode, ValueRangeAll);
     1275    RefPtr<CSSPrimitiveValue> spreadDistance;
    14291276    if (blurRadius) {
    14301277        // Blur radius must be non-negative.
     
    14441291        }
    14451292    }
    1446     return CSSShadowValue::create(horizontalOffset, verticalOffset, blurRadius,
    1447         spreadDistance, style, color);
    1448 }
    1449 
    1450 static CSSValue* consumeShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool isBoxShadowProperty)
     1293    return CSSShadowValue::create(horizontalOffset.releaseNonNull(), verticalOffset.releaseNonNull(), blurRadius.releaseNonNull(),
     1294        spreadDistance.releaseNonNull(), style.releaseNonNull(), color.releaseNonNull());
     1295}
     1296
     1297static RefPtr<CSSValue> consumeShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool isBoxShadowProperty)
    14511298{
    14521299    if (range.peek().id() == CSSValueNone)
    14531300        return consumeIdent(range);
    14541301
    1455     CSSValueList* shadowValueList = CSSValueList::createCommaSeparated();
     1302    RefPtr<CSSValueList> shadowValueList = CSSValueList::createCommaSeparated();
    14561303    do {
    1457         if (CSSShadowValue* shadowValue = parseSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty))
     1304        if (RefPtr<CSSShadowValue> shadowValue = parseSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty))
    14581305            shadowValueList->append(*shadowValue);
    14591306        else
     
    14631310}
    14641311
    1465 static CSSFunctionValue* consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context)
     1312static RefPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context)
    14661313{
    14671314    CSSValueID filterType = range.peek().functionId();
     
    14691316        return nullptr;
    14701317    CSSParserTokenRange args = consumeFunction(range);
    1471     CSSFunctionValue* filterValue = CSSFunctionValue::create(filterType);
    1472     CSSValue* parsedValue = nullptr;
    1473 
    1474     if (filterType == CSSValueDropShadow) {
    1475         parsedValue = parseSingleShadow(args, context.mode(), false, false);
    1476     } else {
    1477         if (args.atEnd()) {
    1478             if (context.useCounter())
    1479                 context.useCounter()->count(UseCounter::CSSFilterFunctionNoArguments);
     1318    RefPtr<CSSFunctionValue>filterValue = CSSFunctionValue::create(filterType);
     1319    RefPtr<CSSValue> parsedValue;
     1320
     1321    if (filterType == CSSValueDropShadow)
     1322        parsedValue = parseSingleShadow(args, context.mode, false, false);
     1323    else {
     1324        if (args.atEnd())
    14801325            return filterValue;
    1481         }
    14821326        if (filterType == CSSValueBrightness) {
    14831327            // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5)
     
    14851329            if (!parsedValue)
    14861330                parsedValue = consumeNumber(args, ValueRangeAll);
    1487         } else if (filterType == CSSValueHueRotate) {
    1488             parsedValue = consumeAngle(args);
    1489         } else if (filterType == CSSValueBlur) {
     1331        } else if (filterType == CSSValueHueRotate)
     1332            parsedValue = consumeAngle(args, context.mode, UnitlessQuirk::Forbid);
     1333        else if (filterType == CSSValueBlur) {
    14901334            parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNegative);
    14911335        } else {
     
    14951339                parsedValue = consumeNumber(args, ValueRangeNonNegative);
    14961340            if (parsedValue && filterType != CSSValueSaturate && filterType != CSSValueContrast) {
    1497                 bool isPercentage = toCSSPrimitiveValue(parsedValue)->isPercentage();
     1341                bool isPercentage = downcast<CSSPrimitiveValue>(*parsedValue).isPercentage();
    14981342                double maxAllowed = isPercentage ? 100.0 : 1.0;
    1499                 if (toCSSPrimitiveValue(parsedValue)->doubleValue() > maxAllowed) {
    1500                     parsedValue = CSSPrimitiveValue::create(
    1501                         maxAllowed,
    1502                         isPercentage ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveValue::UnitType::Number);
     1343                if (downcast<CSSPrimitiveValue>(*parsedValue).doubleValue() > maxAllowed) {
     1344                    parsedValue = CSSPrimitiveValue::create(maxAllowed, isPercentage ? CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE : CSSPrimitiveValue::UnitTypes::CSS_NUMBER);
    15031345                }
    15041346            }
     
    15111353}
    15121354
    1513 static CSSValue* consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context)
     1355static RefPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context)
    15141356{
    15151357    if (range.peek().id() == CSSValueNone)
    15161358        return consumeIdent(range);
    15171359
    1518     CSSValueList* list = CSSValueList::createSpaceSeparated();
     1360    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    15191361    do {
    1520         CSSValue* filterValue = consumeUrl(range);
     1362        RefPtr<CSSValue> filterValue = consumeUrl(range);
    15211363        if (!filterValue) {
    15221364            filterValue = consumeFilterFunction(range, context);
     
    15241366                return nullptr;
    15251367        }
    1526         list->append(*filterValue);
     1368        list->append(filterValue.releaseNonNull());
    15271369    } while (!range.atEnd());
    15281370    return list;
    15291371}
    15301372
    1531 static CSSValue* consumeTextDecorationLine(CSSParserTokenRange& range)
     1373static RefPtr<CSSValue> consumeTextDecorationLine(CSSParserTokenRange& range)
    15321374{
    15331375    CSSValueID id = range.peek().id();
     
    15351377        return consumeIdent(range);
    15361378
    1537     CSSValueList* list = CSSValueList::createSpaceSeparated();
     1379    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    15381380    while (true) {
    1539         CSSPrimitiveValue* ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverline, CSSValueLineThrough>(range);
     1381        RefPtr<CSSPrimitiveValue> ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverline, CSSValueLineThrough>(range);
    15401382        if (!ident)
    15411383            break;
    1542         if (list->hasValue(*ident))
    1543             return nullptr;
    1544         list->append(*ident);
     1384        if (list->hasValue(ident.get()))
     1385            return nullptr;
     1386        list->append(ident.releaseNonNull());
    15451387    }
    15461388
     
    15501392}
    15511393
    1552 // none | strict | content | [ layout || style || paint || size ]
    1553 static CSSValue* consumeContain(CSSParserTokenRange& range)
     1394static RefPtr<CSSValue> consumeTextEmphasisStyle(CSSParserTokenRange& range)
    15541395{
    15551396    CSSValueID id = range.peek().id();
     
    15571398        return consumeIdent(range);
    15581399
    1559     CSSValueList* list = CSSValueList::createSpaceSeparated();
    1560     if (id == CSSValueStrict || id == CSSValueContent) {
    1561         list->append(*consumeIdent(range));
    1562         return list;
    1563     }
    1564     while (true) {
    1565         CSSPrimitiveValue* ident = consumeIdent<CSSValuePaint, CSSValueLayout, CSSValueStyle, CSSValueSize>(range);
    1566         if (!ident)
    1567             break;
    1568         if (list->hasValue(*ident))
    1569             return nullptr;
    1570         list->append(*ident);
    1571     }
    1572 
    1573     if (!list->length())
    1574         return nullptr;
    1575     return list;
    1576 }
    1577 
    1578 static CSSValue* consumePath(CSSParserTokenRange& range)
    1579 {
    1580     // FIXME: Add support for <url>, <basic-shape>, <geometry-box>.
    1581     if (range.peek().functionId() != CSSValuePath)
    1582         return nullptr;
    1583 
    1584     CSSParserTokenRange functionRange = range;
    1585     CSSParserTokenRange functionArgs = consumeFunction(functionRange);
    1586 
    1587     if (functionArgs.peek().type() != StringToken)
    1588         return nullptr;
    1589     String pathString = functionArgs.consumeIncludingWhitespace().value().toString();
    1590 
    1591     std::unique_ptr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
    1592     if (buildByteStreamFromString(pathString, *byteStream) != SVGParseStatus::NoError
    1593         || !functionArgs.atEnd())
    1594         return nullptr;
    1595 
    1596     range = functionRange;
    1597     if (byteStream->isEmpty())
    1598         return CSSPrimitiveValue::createIdentifier(CSSValueNone);
    1599     return CSSPathValue::create(std::move(byteStream));
    1600 }
    1601 
    1602 static CSSValue* consumePathOrNone(CSSParserTokenRange& range)
    1603 {
    1604     CSSValueID id = range.peek().id();
    1605     if (id == CSSValueNone)
    1606         return consumeIdent(range);
    1607 
    1608     return consumePath(range);
    1609 }
    1610 
    1611 static CSSValue* consumeMotionRotation(CSSParserTokenRange& range)
    1612 {
    1613     CSSValue* angle = consumeAngle(range);
    1614     CSSValue* keyword = consumeIdent<CSSValueAuto, CSSValueReverse>(range);
    1615     if (!angle && !keyword)
    1616         return nullptr;
    1617 
    1618     if (!angle)
    1619         angle = consumeAngle(range);
    1620 
    1621     CSSValueList* list = CSSValueList::createSpaceSeparated();
    1622     if (keyword)
    1623         list->append(*keyword);
    1624     if (angle)
    1625         list->append(*angle);
    1626     return list;
    1627 }
    1628 
    1629 static CSSValue* consumeTextEmphasisStyle(CSSParserTokenRange& range)
    1630 {
    1631     CSSValueID id = range.peek().id();
    1632     if (id == CSSValueNone)
    1633         return consumeIdent(range);
    1634 
    1635     if (CSSValue* textEmphasisStyle = consumeString(range))
     1400    if (RefPtr<CSSValue> textEmphasisStyle = consumeString(range))
    16361401        return textEmphasisStyle;
    16371402
    1638     CSSPrimitiveValue* fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range);
    1639     CSSPrimitiveValue* shape = consumeIdent<CSSValueDot, CSSValueCircle, CSSValueDoubleCircle, CSSValueTriangle, CSSValueSesame>(range);
     1403    RefPtr<CSSPrimitiveValue> fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range);
     1404    RefPtr<CSSPrimitiveValue> shape = consumeIdent<CSSValueDot, CSSValueCircle, CSSValueDoubleCircle, CSSValueTriangle, CSSValueSesame>(range);
    16401405    if (!fill)
    16411406        fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range);
    16421407    if (fill && shape) {
    1643         CSSValueList* parsedValues = CSSValueList::createSpaceSeparated();
    1644         parsedValues->append(*fill);
    1645         parsedValues->append(*shape);
     1408        RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated();
     1409        parsedValues->append(fill.releaseNonNull());
     1410        parsedValues->append(shape.releaseNonNull());
    16461411        return parsedValues;
    16471412    }
     
    16531418}
    16541419
    1655 static CSSValue* consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1420static RefPtr<CSSValue> consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    16561421{
    16571422    // Allow the special focus color even in HTML Standard parsing mode.
     
    16611426}
    16621427
    1663 static CSSPrimitiveValue* consumeLineWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
     1428static RefPtr<CSSPrimitiveValue> consumeLineWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
    16641429{
    16651430    CSSValueID id = range.peek().id();
     
    16691434}
    16701435
    1671 static CSSPrimitiveValue* consumeBorderWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
     1436static RefPtr<CSSPrimitiveValue> consumeBorderWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)
    16721437{
    16731438    return consumeLineWidth(range, cssParserMode, unitless);
    16741439}
    16751440
    1676 static CSSPrimitiveValue* consumeTextStrokeWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1441static RefPtr<CSSPrimitiveValue> consumeTextStrokeWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    16771442{
    16781443    return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid);
    16791444}
    16801445
    1681 static CSSPrimitiveValue* consumeColumnRuleWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1446static RefPtr<CSSPrimitiveValue> consumeColumnRuleWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    16821447{
    16831448    return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid);
    16841449}
    16851450
    1686 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSFunctionValue*& transformValue)
     1451static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParserMode, RefPtr<CSSFunctionValue>& transformValue)
    16871452{
    16881453    unsigned numberOfArguments = 2;
    1689     CSSValue* parsedValue = nullptr;
     1454    RefPtr<CSSValue> parsedValue;
    16901455    do {
    16911456        parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
     
    17031468}
    17041469
    1705 static bool consumeNumbers(CSSParserTokenRange& args, CSSFunctionValue*& transformValue, unsigned numberOfArguments)
     1470static bool consumeNumbers(CSSParserTokenRange& args, RefPtr<CSSFunctionValue>& transformValue, unsigned numberOfArguments)
    17061471{
    17071472    do {
    1708         CSSValue* parsedValue = consumeNumber(args, ValueRangeAll);
     1473        RefPtr<CSSPrimitiveValue> parsedValue = consumeNumber(args, ValueRangeAll);
    17091474        if (!parsedValue)
    17101475            return false;
    1711         transformValue->append(*parsedValue);
     1476        transformValue->append(parsedValue.releaseNonNull());
    17121477        if (--numberOfArguments && !consumeCommaIncludingWhitespace(args))
    17131478            return false;
     
    17161481}
    17171482
    1718 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSFunctionValue*& transformValue, bool useLegacyParsing)
    1719 {
    1720     CSSPrimitiveValue* parsedValue = consumeLength(args, cssParserMode, ValueRangeNonNegative);
    1721     if (!parsedValue && useLegacyParsing) {
     1483static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParserMode, RefPtr<CSSFunctionValue>& transformValue)
     1484{
     1485    RefPtr<CSSPrimitiveValue> parsedValue = consumeLength(args, cssParserMode, ValueRangeNonNegative);
     1486    if (!parsedValue) {
    17221487        double perspective;
    17231488        if (!consumeNumberRaw(args, perspective) || perspective < 0)
    17241489            return false;
    1725         parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType::Pixels);
     1490        parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitTypes::CSS_PX);
    17261491    }
    17271492    if (!parsedValue)
    17281493        return false;
    1729     transformValue->append(*parsedValue);
     1494    transformValue->append(parsedValue.releaseNonNull());
    17301495    return true;
    17311496}
    17321497
    1733 static CSSValue* consumeTransformValue(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)
     1498static RefPtr<CSSValue> consumeTransformValue(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    17341499{
    17351500    CSSValueID functionId = range.peek().functionId();
     
    17391504    if (args.atEnd())
    17401505        return nullptr;
    1741     CSSFunctionValue* transformValue = CSSFunctionValue::create(functionId);
    1742     CSSValue* parsedValue = nullptr;
     1506    RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(functionId);
     1507    RefPtr<CSSValue> parsedValue;
    17431508    switch (functionId) {
    17441509    case CSSValueRotate:
    1745     case CSSValueRotateX:
    1746     case CSSValueRotateY:
    1747     case CSSValueRotateZ:
    1748     case CSSValueSkewX:
    1749     case CSSValueSkewY:
     1510    case CSSValueRotatex:
     1511    case CSSValueRotatey:
     1512    case CSSValueRotatez:
     1513    case CSSValueSkewx:
     1514    case CSSValueSkewy:
    17501515    case CSSValueSkew:
    1751         parsedValue = consumeAngle(args);
     1516        parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid);
    17521517        if (!parsedValue)
    17531518            return nullptr;
    17541519        if (functionId == CSSValueSkew && consumeCommaIncludingWhitespace(args)) {
    17551520            transformValue->append(*parsedValue);
    1756             parsedValue = consumeAngle(args);
     1521            parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid);
    17571522            if (!parsedValue)
    17581523                return nullptr;
    17591524        }
    17601525        break;
    1761     case CSSValueScaleX:
    1762     case CSSValueScaleY:
    1763     case CSSValueScaleZ:
     1526    case CSSValueScalex:
     1527    case CSSValueScaley:
     1528    case CSSValueScalez:
    17641529    case CSSValueScale:
    17651530        parsedValue = consumeNumber(args, ValueRangeAll);
     
    17741539        break;
    17751540    case CSSValuePerspective:
    1776         if (!consumePerspective(args, cssParserMode, transformValue, useLegacyParsing))
     1541        if (!consumePerspective(args, cssParserMode, transformValue))
    17771542            return nullptr;
    17781543        break;
    1779     case CSSValueTranslateX:
    1780     case CSSValueTranslateY:
     1544    case CSSValueTranslatex:
     1545    case CSSValueTranslatey:
    17811546    case CSSValueTranslate:
    17821547        parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll);
     
    17901555        }
    17911556        break;
    1792     case CSSValueTranslateZ:
     1557    case CSSValueTranslatez:
    17931558        parsedValue = consumeLength(args, cssParserMode, ValueRangeAll);
    17941559        break;
     
    18051570        if (!consumeNumbers(args, transformValue, 3) || !consumeCommaIncludingWhitespace(args))
    18061571            return nullptr;
    1807         parsedValue = consumeAngle(args);
     1572        parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid);
    18081573        if (!parsedValue)
    18091574            return nullptr;
     
    18231588}
    18241589
    1825 static CSSValue* consumeTransform(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)
     1590static RefPtr<CSSValue> consumeTransform(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    18261591{
    18271592    if (range.peek().id() == CSSValueNone)
    18281593        return consumeIdent(range);
    18291594
    1830     CSSValueList* list = CSSValueList::createSpaceSeparated();
     1595    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    18311596    do {
    1832         CSSValue* parsedTransformValue = consumeTransformValue(range, cssParserMode, useLegacyParsing);
     1597        RefPtr<CSSValue> parsedTransformValue = consumeTransformValue(range, cssParserMode);
    18331598        if (!parsedTransformValue)
    18341599            return nullptr;
    1835         list->append(*parsedTransformValue);
     1600        list->append(parsedTransformValue.releaseNonNull());
    18361601    } while (!range.atEnd());
    18371602
     
    18401605
    18411606template <CSSValueID start, CSSValueID end>
    1842 static CSSValue* consumePositionLonghand(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1607static RefPtr<CSSValue> consumePositionLonghand(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    18431608{
    18441609    if (range.peek().type() == IdentToken) {
     
    18541619            return nullptr;
    18551620        range.consumeIncludingWhitespace();
    1856         return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitType::Percentage);
     1621        return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
    18571622    }
    18581623    return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll);
    18591624}
    18601625
    1861 static CSSValue* consumePositionX(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1626static RefPtr<CSSValue> consumePositionX(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    18621627{
    18631628    return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParserMode);
    18641629}
    18651630
    1866 static CSSValue* consumePositionY(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1631static RefPtr<CSSValue> consumePositionY(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    18671632{
    18681633    return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParserMode);
    18691634}
    18701635
    1871 static CSSValue* consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1636static RefPtr<CSSValue> consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    18721637{
    18731638    if (range.peek().id() == CSSValueNone)
    18741639        return consumeIdent(range);
    1875     CSSURIValue* url = consumeUrl(range);
     1640    RefPtr<CSSPrimitiveValue> url = consumeUrl(range);
    18761641    if (url) {
    1877         CSSValue* parsedValue = nullptr;
     1642        RefPtr<CSSValue> parsedValue;
    18781643        if (range.peek().id() == CSSValueNone)
    18791644            parsedValue = consumeIdent(range);
     
    18811646            parsedValue = consumeColor(range, cssParserMode);
    18821647        if (parsedValue) {
    1883             CSSValueList* values = CSSValueList::createSpaceSeparated();
    1884             values->append(*url);
    1885             values->append(*parsedValue);
     1648            RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
     1649            values->append(url.releaseNonNull());
     1650            values->append(parsedValue.releaseNonNull());
    18861651            return values;
    18871652        }
     
    18911656}
    18921657
    1893 static CSSValue* consumePaintOrder(CSSParserTokenRange& range)
     1658static RefPtr<CSSValue> consumePaintOrder(CSSParserTokenRange& range)
    18941659{
    18951660    if (range.peek().id() == CSSValueNormal)
     
    18971662
    18981663    Vector<CSSValueID, 3> paintTypeList;
    1899     CSSPrimitiveValue* fill = nullptr;
    1900     CSSPrimitiveValue* stroke = nullptr;
    1901     CSSPrimitiveValue* markers = nullptr;
     1664    RefPtr<CSSPrimitiveValue> fill;
     1665    RefPtr<CSSPrimitiveValue> stroke;
     1666    RefPtr<CSSPrimitiveValue> markers;
    19021667    do {
    19031668        CSSValueID id = range.peek().id();
     
    19171682    // list after parsing.
    19181683    CSSValueID firstPaintOrderType = paintTypeList.at(0);
    1919     CSSValueList* paintOrderList = CSSValueList::createSpaceSeparated();
     1684    RefPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated();
    19201685    switch (firstPaintOrderType) {
    19211686    case CSSValueFill:
    19221687    case CSSValueStroke:
    1923         paintOrderList->append(firstPaintOrderType == CSSValueFill ? *fill : *stroke);
     1688        paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releaseNonNull() : stroke.releaseNonNull());
    19241689        if (paintTypeList.size() > 1) {
    19251690            if (paintTypeList.at(1) == CSSValueMarkers)
    1926                 paintOrderList->append(*markers);
     1691                paintOrderList->append(markers.releaseNonNull());
    19271692        }
    19281693        break;
    19291694    case CSSValueMarkers:
    1930         paintOrderList->append(*markers);
     1695        paintOrderList->append(markers.releaseNonNull());
    19311696        if (paintTypeList.size() > 1) {
    19321697            if (paintTypeList.at(1) == CSSValueStroke)
    1933                 paintOrderList->append(*stroke);
     1698                paintOrderList->append(stroke.releaseNonNull());
    19341699        }
    19351700        break;
     
    19411706}
    19421707
    1943 static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range)
     1708static RefPtr<CSSValue> consumeNoneOrURI(CSSParserTokenRange& range)
    19441709{
    19451710    if (range.peek().id() == CSSValueNone)
     
    19481713}
    19491714
    1950 static CSSValue* consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1715static RefPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    19511716{
    19521717    // FIXME: Support intrinsic dimensions too.
     
    19561721}
    19571722
    1958 static CSSValue* consumeStrokeDasharray(CSSParserTokenRange& range)
     1723static RefPtr<CSSValue> consumeStrokeDasharray(CSSParserTokenRange& range)
    19591724{
    19601725    CSSValueID id = range.peek().id();
     
    19621727        return consumeIdent(range);
    19631728
    1964     CSSValueList* dashes = CSSValueList::createCommaSeparated();
     1729    RefPtr<CSSValueList> dashes = CSSValueList::createCommaSeparated();
    19651730    do {
    1966         CSSPrimitiveValue* dash = consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeNonNegative);
     1731        RefPtr<CSSPrimitiveValue> dash = consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeNonNegative);
    19671732        if (!dash || (consumeCommaIncludingWhitespace(range) && range.atEnd()))
    19681733            return nullptr;
    1969         dashes->append(*dash);
     1734        dashes->append(dash.releaseNonNull());
    19701735    } while (!range.atEnd());
    19711736    return dashes;
    19721737}
    19731738
    1974 static CSSPrimitiveValue* consumeBaselineShift(CSSParserTokenRange& range)
     1739static RefPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserTokenRange& range)
    19751740{
    19761741    CSSValueID id = range.peek().id();
     
    19801745}
    19811746
    1982 static CSSPrimitiveValue* consumeRxOrRy(CSSParserTokenRange& range)
     1747static RefPtr<CSSPrimitiveValue> consumeRxOrRy(CSSParserTokenRange& range)
    19831748{
    19841749    if (range.peek().id() == CSSValueAuto)
     
    19871752}
    19881753
    1989 static CSSValue* consumeCursor(CSSParserTokenRange& range, const CSSParserContext& context, bool inQuirksMode)
    1990 {
    1991     CSSValueList* list = nullptr;
    1992     while (CSSValue* image = consumeImage(range, context, ConsumeGeneratedImage::Forbid)) {
     1754static RefPtr<CSSValue> consumeCursor(CSSParserTokenRange& range, const CSSParserContext& context, bool inQuirksMode)
     1755{
     1756    RefPtr<CSSValueList> list;
     1757    while (RefPtr<CSSValue> image = consumeImage(range, context, ConsumeGeneratedImage::Forbid)) {
    19931758        double num;
    19941759        IntPoint hotSpot(-1, -1);
     
    20051770            list = CSSValueList::createCommaSeparated();
    20061771
    2007         list->append(*CSSCursorImageValue::create(image, hotSpotSpecified, hotSpot));
     1772        list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpotSpecified, hotSpot));
    20081773        if (!consumeCommaIncludingWhitespace(range))
    20091774            return nullptr;
     
    20111776
    20121777    CSSValueID id = range.peek().id();
    2013     if (!range.atEnd() && context.useCounter()) {
    2014         if (id == CSSValueWebkitZoomIn)
    2015             context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
    2016         else if (id == CSSValueWebkitZoomOut)
    2017             context.useCounter()->count(UseCounter::PrefixedCursorZoomOut);
    2018     }
    2019     CSSValue* cursorType = nullptr;
     1778    RefPtr<CSSValue> cursorType;
    20201779    if (id == CSSValueHand) {
    20211780        if (!inQuirksMode) // Non-standard behavior
    20221781            return nullptr;
    2023         cursorType = CSSPrimitiveValue::createIdentifier(CSSValuePointer);
     1782        cursorType = CSSValuePool::singleton().createIdentifierValue(CSSValuePointer);
    20241783        range.consumeIncludingWhitespace();
    20251784    } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSValueCopy || id == CSSValueNone) {
     
    20311790    if (!list)
    20321791        return cursorType;
    2033     list->append(*cursorType);
     1792    list->append(cursorType.releaseNonNull());
    20341793    return list;
    20351794}
    20361795
    2037 static CSSValue* consumeAttr(CSSParserTokenRange args, CSSParserContext context)
     1796static RefPtr<CSSValue> consumeAttr(CSSParserTokenRange args, CSSParserContext context)
    20381797{
    20391798    if (args.peek().type() != IdentToken)
    20401799        return nullptr;
    2041 
    2042     String attrName = args.consumeIncludingWhitespace().value().toString();
     1800   
     1801    StringView stringView = args.consumeIncludingWhitespace().value();
     1802    if (context.isHTMLDocument)
     1803        convertToASCIILowercaseInPlace(stringView);
     1804
     1805    String attrName = stringView.toString();
    20431806    if (!args.atEnd())
    20441807        return nullptr;
    20451808
    2046     if (context.isHTMLDocument())
    2047         attrName = attrName.lower();
    2048 
    2049     CSSFunctionValue* attrValue = CSSFunctionValue::create(CSSValueAttr);
    2050     attrValue->append(*CSSCustomIdentValue::create(attrName));
     1809    RefPtr<CSSFunctionValue> attrValue = CSSFunctionValue::create(CSSValueAttr);
     1810    attrValue->append(CSSCustomIdentValue::create(attrName));
    20511811    return attrValue;
    20521812}
    20531813
    2054 static CSSValue* consumeCounterContent(CSSParserTokenRange args, bool counters)
    2055 {
    2056     CSSCustomIdentValue* identifier = consumeCustomIdent(args);
     1814static RefPtr<CSSValue> consumeCounterContent(CSSParserTokenRange args, bool counters)
     1815{
     1816    RefPtr<CSSPrimitiveValue> identifier = consumeCustomIdent(args);
    20571817    if (!identifier)
    20581818        return nullptr;
    20591819
    2060     CSSStringValue* separator = nullptr;
    2061     if (!counters) {
    2062         separator = CSSStringValue::create(String());
    2063     } else {
     1820    RefPtr<CSSPrimitiveValue> separator;
     1821    if (!counters)
     1822        separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
     1823    else {
    20641824        if (!consumeCommaIncludingWhitespace(args) || args.peek().type() != StringToken)
    20651825            return nullptr;
    2066         separator = CSSStringValue::create(args.consumeIncludingWhitespace().value().toString());
    2067     }
    2068 
    2069     CSSPrimitiveValue* listStyle = nullptr;
     1826        separator = CSSPrimitiveValue::create(args.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
     1827    }
     1828
     1829    RefPtr<CSSPrimitiveValue> listStyle;
    20701830    if (consumeCommaIncludingWhitespace(args)) {
    20711831        CSSValueID id = args.peek().id();
     
    20731833            return nullptr;
    20741834        listStyle = consumeIdent(args);
    2075     } else {
    2076         listStyle = CSSPrimitiveValue::createIdentifier(CSSValueDecimal);
    2077     }
     1835    } else
     1836        listStyle = CSSValuePool::singleton().createIdentifierValue(CSSValueDecimal);
    20781837
    20791838    if (!args.atEnd())
    20801839        return nullptr;
    2081     return CSSCounterValue::create(identifier, listStyle, separator);
    2082 }
    2083 
    2084 static CSSValue* consumeContent(CSSParserTokenRange& range, CSSParserContext context)
     1840   
     1841    // FIXME-NEWPARSER: Should just have a CSSCounterValue.
     1842    return CSSValuePool::singleton().createValue(Counter::create(identifier.releaseNonNull(), listStyle.releaseNonNull(), separator.releaseNonNull()));
     1843}
     1844
     1845static RefPtr<CSSValue> consumeContent(CSSParserTokenRange& range, CSSParserContext context)
    20851846{
    20861847    if (identMatches<CSSValueNone, CSSValueNormal>(range.peek().id()))
    20871848        return consumeIdent(range);
    20881849
    2089     CSSValueList* values = CSSValueList::createSpaceSeparated();
     1850    RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
    20901851
    20911852    do {
    2092         CSSValue* parsedValue = consumeImage(range, context);
     1853        RefPtr<CSSValue> parsedValue = consumeImage(range, context);
    20931854        if (!parsedValue)
    20941855            parsedValue = consumeIdent<CSSValueOpenQuote, CSSValueCloseQuote, CSSValueNoOpenQuote, CSSValueNoCloseQuote>(range);
     
    21051866                return nullptr;
    21061867        }
    2107         values->append(*parsedValue);
     1868        values->append(parsedValue.releaseNonNull());
    21081869    } while (!range.atEnd());
    21091870
     
    21111872}
    21121873
    2113 static CSSPrimitiveValue* consumePerspective(CSSParserTokenRange& range, CSSParserMode cssParserMode, CSSPropertyID unresolvedProperty)
     1874static RefPtr<CSSPrimitiveValue> consumePerspective(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    21141875{
    21151876    if (range.peek().id() == CSSValueNone)
    21161877        return consumeIdent(range);
    2117     CSSPrimitiveValue* parsedValue = consumeLength(range, cssParserMode, ValueRangeAll);
    2118     if (!parsedValue && (unresolvedProperty == CSSPropertyAliasWebkitPerspective)) {
     1878    RefPtr<CSSPrimitiveValue> parsedValue = consumeLength(range, cssParserMode, ValueRangeAll);
     1879    if (!parsedValue) {
     1880        // FIXME: Make this quirk only apply to the webkit prefixed version of the property.
    21191881        double perspective;
    21201882        if (!consumeNumberRaw(range, perspective))
    21211883            return nullptr;
    2122         parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType::Pixels);
     1884        parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitTypes::CSS_PX);
    21231885    }
    21241886    if (parsedValue && (parsedValue->isCalculated() || parsedValue->doubleValue() > 0))
     
    21271889}
    21281890
    2129 static CSSValueList* consumePositionList(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    2130 {
    2131     CSSValueList* positions = CSSValueList::createCommaSeparated();
     1891static RefPtr<CSSValueList> consumePositionList(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1892{
     1893    RefPtr<CSSValueList> positions = CSSValueList::createCommaSeparated();
    21321894    do {
    2133         CSSValue* position = consumePosition(range, cssParserMode, UnitlessQuirk::Forbid);
     1895        RefPtr<CSSValue> position = consumePosition(range, cssParserMode, UnitlessQuirk::Forbid);
    21341896        if (!position)
    21351897            return nullptr;
    2136         positions->append(*position);
     1898        positions->append(position.releaseNonNull());
    21371899    } while (consumeCommaIncludingWhitespace(range));
    21381900    return positions;
    21391901}
    21401902
    2141 static CSSValue* consumeScrollSnapCoordinate(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1903static RefPtr<CSSValue> consumeScrollSnapCoordinate(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    21421904{
    21431905    if (range.peek().id() == CSSValueNone)
     
    21461908}
    21471909
    2148 static CSSValue* consumeScrollSnapPoints(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1910static RefPtr<CSSValue> consumeScrollSnapPoints(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    21491911{
    21501912    if (range.peek().id() == CSSValueNone)
     
    21521914    if (range.peek().functionId() == CSSValueRepeat) {
    21531915        CSSParserTokenRange args = consumeFunction(range);
    2154         CSSPrimitiveValue* parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative);
     1916        RefPtr<CSSPrimitiveValue> parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative);
    21551917        if (args.atEnd() && parsedValue && (parsedValue->isCalculated() || parsedValue->doubleValue() > 0)) {
    2156             CSSFunctionValue* result = CSSFunctionValue::create(CSSValueRepeat);
    2157             result->append(*parsedValue);
     1918            RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueRepeat);
     1919            result->append(parsedValue.releaseNonNull());
    21581920            return result;
    21591921        }
     
    21621924}
    21631925
    2164 static CSSValue* consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    2165 {
    2166     CSSValue* parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
     1926static RefPtr<CSSValue> consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1927{
     1928    RefPtr<CSSPrimitiveValue> parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
    21671929    if (!parsedValue1)
    21681930        return nullptr;
    2169     CSSValue* parsedValue2 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
     1931    RefPtr<CSSPrimitiveValue> parsedValue2 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
    21701932    if (!parsedValue2)
    21711933        parsedValue2 = parsedValue1;
    2172     return CSSValuePair::create(parsedValue1, parsedValue2, CSSValuePair::DropIdenticalValues);
    2173 }
    2174 
    2175 static CSSPrimitiveValue* consumeVerticalAlign(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    2176 {
    2177     CSSPrimitiveValue* parsedValue = consumeIdentRange(range, CSSValueBaseline, CSSValueWebkitBaselineMiddle);
     1934    return createPrimitiveValuePair(parsedValue1.releaseNonNull(), parsedValue2.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce);
     1935}
     1936
     1937static RefPtr<CSSPrimitiveValue> consumeVerticalAlign(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     1938{
     1939    RefPtr<CSSPrimitiveValue> parsedValue = consumeIdentRange(range, CSSValueBaseline, CSSValueWebkitBaselineMiddle);
    21781940    if (!parsedValue)
    21791941        parsedValue = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow);
     
    21811943}
    21821944
    2183 static CSSPrimitiveValue* consumeShapeRadius(CSSParserTokenRange& args, CSSParserMode cssParserMode)
     1945static RefPtr<CSSPrimitiveValue> consumeShapeRadius(CSSParserTokenRange& args, CSSParserMode cssParserMode)
    21841946{
    21851947    if (identMatches<CSSValueClosestSide, CSSValueFarthestSide>(args.peek().id()))
     
    21881950}
    21891951
    2190 static CSSBasicShapeCircleValue* consumeBasicShapeCircle(CSSParserTokenRange& args, const CSSParserContext& context)
     1952static RefPtr<CSSBasicShapeCircle> consumeBasicShapeCircle(CSSParserTokenRange& args, const CSSParserContext& context)
    21911953{
    21921954    // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes
    21931955    // circle( [<shape-radius>]? [at <position>]? )
    2194     CSSBasicShapeCircleValue* shape = CSSBasicShapeCircleValue::create();
    2195     if (CSSPrimitiveValue* radius = consumeShapeRadius(args, context.mode()))
    2196         shape->setRadius(radius);
     1956    RefPtr<CSSBasicShapeCircle> shape = CSSBasicShapeCircle::create();
     1957    if (RefPtr<CSSPrimitiveValue> radius = consumeShapeRadius(args, context.mode))
     1958        shape->setRadius(radius.releaseNonNull());
    21971959    if (consumeIdent<CSSValueAt>(args)) {
    2198         CSSValue* centerX = nullptr;
    2199         CSSValue* centerY = nullptr;
    2200         if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, centerX, centerY))
    2201             return nullptr;
    2202         shape->setCenterX(centerX);
    2203         shape->setCenterY(centerY);
     1960        RefPtr<CSSPrimitiveValue> centerX;
     1961        RefPtr<CSSPrimitiveValue> centerY;
     1962        if (!consumePosition(args, context.mode, UnitlessQuirk::Forbid, centerX, centerY))
     1963            return nullptr;
     1964        shape->setCenterX(centerX.releaseNonNull());
     1965        shape->setCenterY(centerY.releaseNonNull());
    22041966    }
    22051967    return shape;
    22061968}
    22071969
    2208 static CSSBasicShapeEllipseValue* consumeBasicShapeEllipse(CSSParserTokenRange& args, const CSSParserContext& context)
     1970static RefPtr<CSSBasicShapeEllipse> consumeBasicShapeEllipse(CSSParserTokenRange& args, const CSSParserContext& context)
    22091971{
    22101972    // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes
    22111973    // ellipse( [<shape-radius>{2}]? [at <position>]? )
    2212     CSSBasicShapeEllipseValue* shape = CSSBasicShapeEllipseValue::create();
    2213     if (CSSPrimitiveValue* radiusX = consumeShapeRadius(args, context.mode())) {
    2214         shape->setRadiusX(radiusX);
    2215         if (CSSPrimitiveValue* radiusY = consumeShapeRadius(args, context.mode()))
    2216             shape->setRadiusY(radiusY);
     1974    RefPtr<CSSBasicShapeEllipse> shape = CSSBasicShapeEllipse::create();
     1975    if (RefPtr<CSSPrimitiveValue> radiusX = consumeShapeRadius(args, context.mode)) {
     1976        shape->setRadiusX(radiusX.releaseNonNull());
     1977        if (RefPtr<CSSPrimitiveValue> radiusY = consumeShapeRadius(args, context.mode))
     1978            shape->setRadiusY(radiusY.releaseNonNull());
    22171979    }
    22181980    if (consumeIdent<CSSValueAt>(args)) {
    2219         CSSValue* centerX = nullptr;
    2220         CSSValue* centerY = nullptr;
    2221         if (!consumePosition(args, context.mode(), UnitlessQuirk::Forbid, centerX, centerY))
    2222             return nullptr;
    2223         shape->setCenterX(centerX);
    2224         shape->setCenterY(centerY);
     1981        RefPtr<CSSPrimitiveValue> centerX;
     1982        RefPtr<CSSPrimitiveValue> centerY;
     1983        if (!consumePosition(args, context.mode, UnitlessQuirk::Forbid, centerX, centerY))
     1984            return nullptr;
     1985        shape->setCenterX(centerX.releaseNonNull());
     1986        shape->setCenterY(centerY.releaseNonNull());
    22251987    }
    22261988    return shape;
    22271989}
    22281990
    2229 static CSSBasicShapePolygonValue* consumeBasicShapePolygon(CSSParserTokenRange& args, const CSSParserContext& context)
    2230 {
    2231     CSSBasicShapePolygonValue* shape = CSSBasicShapePolygonValue::create();
     1991static RefPtr<CSSBasicShapePolygon> consumeBasicShapePolygon(CSSParserTokenRange& args, const CSSParserContext& context)
     1992{
     1993    RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create();
    22321994    if (identMatches<CSSValueEvenodd, CSSValueNonzero>(args.peek().id())) {
    22331995        shape->setWindRule(args.consumeIncludingWhitespace().id() == CSSValueEvenodd ? RULE_EVENODD : RULE_NONZERO);
     
    22371999
    22382000    do {
    2239         CSSPrimitiveValue* xLength = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
     2001        RefPtr<CSSPrimitiveValue> xLength = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
    22402002        if (!xLength)
    22412003            return nullptr;
    2242         CSSPrimitiveValue* yLength = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
     2004        RefPtr<CSSPrimitiveValue> yLength = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
    22432005        if (!yLength)
    22442006            return nullptr;
    2245         shape->appendPoint(xLength, yLength);
     2007        shape->appendPoint(xLength.releaseNonNull(), yLength.releaseNonNull());
    22462008    } while (consumeCommaIncludingWhitespace(args));
    22472009    return shape;
    22482010}
    22492011
    2250 static void complete4Sides(CSSPrimitiveValue* side[4])
     2012static void complete4Sides(RefPtr<CSSPrimitiveValue> side[4])
    22512013{
    22522014    if (side[3])
     
    22602022}
    22612023
    2262 static bool consumeRadii(CSSPrimitiveValue* horizontalRadii[4], CSSPrimitiveValue* verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)
     2024static bool consumeRadii(RefPtr<CSSPrimitiveValue> horizontalRadii[4], RefPtr<CSSPrimitiveValue> verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)
    22632025{
    22642026    unsigned i = 0;
     
    22972059}
    22982060
    2299 static CSSBasicShapeInsetValue* consumeBasicShapeInset(CSSParserTokenRange& args, const CSSParserContext& context)
    2300 {
    2301     CSSBasicShapeInsetValue* shape = CSSBasicShapeInsetValue::create();
    2302     CSSPrimitiveValue* top = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
     2061static RefPtr<CSSBasicShapeInset> consumeBasicShapeInset(CSSParserTokenRange& args, const CSSParserContext& context)
     2062{
     2063    RefPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create();
     2064    RefPtr<CSSPrimitiveValue> top = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
    23032065    if (!top)
    23042066        return nullptr;
    2305     CSSPrimitiveValue* right = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
    2306     CSSPrimitiveValue* bottom = nullptr;
    2307     CSSPrimitiveValue* left = nullptr;
     2067    RefPtr<CSSPrimitiveValue> right = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
     2068    RefPtr<CSSPrimitiveValue> bottom;
     2069    RefPtr<CSSPrimitiveValue> left;
    23082070    if (right) {
    2309         bottom = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
     2071        bottom = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
    23102072        if (bottom)
    2311             left = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);
     2073            left = consumeLengthOrPercent(args, context.mode, ValueRangeAll);
    23122074    }
    23132075    if (left)
    2314         shape->updateShapeSize4Values(top, right, bottom, left);
     2076        shape->updateShapeSize4Values(top.releaseNonNull(), right.releaseNonNull(), bottom.releaseNonNull(), left.releaseNonNull());
    23152077    else if (bottom)
    2316         shape->updateShapeSize3Values(top, right, bottom);
     2078        shape->updateShapeSize3Values(top.releaseNonNull(), right.releaseNonNull(), bottom.releaseNonNull());
    23172079    else if (right)
    2318         shape->updateShapeSize2Values(top, right);
     2080        shape->updateShapeSize2Values(top.releaseNonNull(), right.releaseNonNull());
    23192081    else
    2320         shape->updateShapeSize1Value(top);
     2082        shape->updateShapeSize1Value(top.releaseNonNull());
    23212083
    23222084    if (consumeIdent<CSSValueRound>(args)) {
    2323         CSSPrimitiveValue* horizontalRadii[4] = { 0 };
    2324         CSSPrimitiveValue* verticalRadii[4] = { 0 };
    2325         if (!consumeRadii(horizontalRadii, verticalRadii, args, context.mode(), false))
    2326             return nullptr;
    2327         shape->setTopLeftRadius(CSSValuePair::create(horizontalRadii[0], verticalRadii[0], CSSValuePair::DropIdenticalValues));
    2328         shape->setTopRightRadius(CSSValuePair::create(horizontalRadii[1], verticalRadii[1], CSSValuePair::DropIdenticalValues));
    2329         shape->setBottomRightRadius(CSSValuePair::create(horizontalRadii[2], verticalRadii[2], CSSValuePair::DropIdenticalValues));
    2330         shape->setBottomLeftRadius(CSSValuePair::create(horizontalRadii[3], verticalRadii[3], CSSValuePair::DropIdenticalValues));
     2085        RefPtr<CSSPrimitiveValue> horizontalRadii[4] = { 0 };
     2086        RefPtr<CSSPrimitiveValue> verticalRadii[4] = { 0 };
     2087        if (!consumeRadii(horizontalRadii, verticalRadii, args, context.mode, false))
     2088            return nullptr;
     2089        shape->setTopLeftRadius(createPrimitiveValuePair(horizontalRadii[0].releaseNonNull(), verticalRadii[0].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce));
     2090        shape->setTopRightRadius(createPrimitiveValuePair(horizontalRadii[1].releaseNonNull(), verticalRadii[1].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce));
     2091        shape->setBottomRightRadius(createPrimitiveValuePair(horizontalRadii[2].releaseNonNull(), verticalRadii[2].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce));
     2092        shape->setBottomLeftRadius(createPrimitiveValuePair(horizontalRadii[3].releaseNonNull(), verticalRadii[3].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce));
    23312093    }
    23322094    return shape;
    23332095}
    23342096
    2335 static CSSValue* consumeBasicShape(CSSParserTokenRange& range, const CSSParserContext& context)
    2336 {
    2337     CSSValue* shape = nullptr;
     2097static RefPtr<CSSValue> consumeBasicShape(CSSParserTokenRange& range, const CSSParserContext& context)
     2098{
     2099    RefPtr<CSSValue> result;
    23382100    if (range.peek().type() != FunctionToken)
    23392101        return nullptr;
     
    23412103    CSSParserTokenRange rangeCopy = range;
    23422104    CSSParserTokenRange args = consumeFunction(rangeCopy);
     2105   
     2106    // FIXME-NEWPARSER: CSSBasicShape should be a CSSValue, and shapes should not be primitive values.
     2107    RefPtr<CSSBasicShape> shape;
    23432108    if (id == CSSValueCircle)
    23442109        shape = consumeBasicShapeCircle(args, context);
     
    23522117        return nullptr;
    23532118    range = rangeCopy;
    2354     return shape;
    2355 }
    2356 
    2357 static CSSValue* consumeWebkitClipPath(CSSParserTokenRange& range, const CSSParserContext& context)
     2119   
     2120    return CSSValuePool::singleton().createValue(shape.releaseNonNull());
     2121}
     2122
     2123static RefPtr<CSSValue> consumeWebkitClipPath(CSSParserTokenRange& range, const CSSParserContext& context)
    23582124{
    23592125    if (range.peek().id() == CSSValueNone)
    23602126        return consumeIdent(range);
    2361     if (CSSURIValue* url = consumeUrl(range))
     2127    if (RefPtr<CSSPrimitiveValue> url = consumeUrl(range))
    23622128        return url;
    23632129    return consumeBasicShape(range, context);
    23642130}
    23652131
    2366 static CSSValue* consumeShapeOutside(CSSParserTokenRange& range, const CSSParserContext& context)
    2367 {
    2368     if (CSSValue* imageValue = consumeImageOrNone(range, context))
     2132static RefPtr<CSSValue> consumeShapeOutside(CSSParserTokenRange& range, const CSSParserContext& context)
     2133{
     2134    if (RefPtr<CSSValue> imageValue = consumeImageOrNone(range, context))
    23692135        return imageValue;
    2370     CSSValueList* list = CSSValueList::createSpaceSeparated();
    2371     if (CSSValue* boxValue = consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range))
    2372         list->append(*boxValue);
    2373     if (CSSValue* shapeValue = consumeBasicShape(range, context)) {
    2374         list->append(*shapeValue);
     2136    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     2137    if (RefPtr<CSSValue> boxValue = consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range))
     2138        list->append(boxValue.releaseNonNull());
     2139    if (RefPtr<CSSValue> shapeValue = consumeBasicShape(range, context)) {
     2140        list->append(shapeValue.releaseNonNull());
    23752141        if (list->length() < 2) {
    2376             if (CSSValue* boxValue = consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range))
    2377                 list->append(*boxValue);
     2142            if (RefPtr<CSSValue> boxValue = consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, CSSValueMarginBox>(range))
     2143                list->append(boxValue.releaseNonNull());
    23782144        }
    23792145    }
     
    23832149}
    23842150
    2385 static CSSValue* consumeContentDistributionOverflowPosition(CSSParserTokenRange& range)
     2151static RefPtr<CSSValue> consumeContentDistributionOverflowPosition(CSSParserTokenRange& range)
    23862152{
    23872153    if (identMatches<CSSValueNormal, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id()))
     
    24222188}
    24232189
    2424 static CSSPrimitiveValue* consumeBorderImageRepeatKeyword(CSSParserTokenRange& range)
     2190static RefPtr<CSSPrimitiveValue> consumeBorderImageRepeatKeyword(CSSParserTokenRange& range)
    24252191{
    24262192    return consumeIdent<CSSValueStretch, CSSValueRepeat, CSSValueSpace, CSSValueRound>(range);
    24272193}
    24282194
    2429 static CSSValue* consumeBorderImageRepeat(CSSParserTokenRange& range)
    2430 {
    2431     CSSPrimitiveValue* horizontal = consumeBorderImageRepeatKeyword(range);
     2195static RefPtr<CSSValue> consumeBorderImageRepeat(CSSParserTokenRange& range)
     2196{
     2197    RefPtr<CSSPrimitiveValue> horizontal = consumeBorderImageRepeatKeyword(range);
    24322198    if (!horizontal)
    24332199        return nullptr;
    2434     CSSPrimitiveValue* vertical = consumeBorderImageRepeatKeyword(range);
     2200    RefPtr<CSSPrimitiveValue> vertical = consumeBorderImageRepeatKeyword(range);
    24352201    if (!vertical)
    24362202        vertical = horizontal;
    2437     return CSSValuePair::create(horizontal, vertical, CSSValuePair::DropIdenticalValues);
    2438 }
    2439 
    2440 static CSSValue* consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range)
     2203    return createPrimitiveValuePair(horizontal.releaseNonNull(), vertical.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce);
     2204}
     2205
     2206static RefPtr<CSSValue> consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range)
    24412207{
    24422208    bool fill = consumeIdent<CSSValueFill>(range);
    2443     CSSPrimitiveValue* slices[4] = { 0 };
     2209    RefPtr<CSSPrimitiveValue> slices[4] = { 0 };
    24442210
    24452211    for (size_t index = 0; index < 4; ++index) {
    2446         CSSPrimitiveValue* value = consumePercent(range, ValueRangeNonNegative);
     2212        RefPtr<CSSPrimitiveValue> value = consumePercent(range, ValueRangeNonNegative);
    24472213        if (!value)
    24482214            value = consumeNumber(range, ValueRangeNonNegative);
     
    24632229    if (property == CSSPropertyWebkitBorderImage || property == CSSPropertyWebkitMaskBoxImage || property == CSSPropertyWebkitBoxReflect)
    24642230        fill = true;
    2465     return CSSBorderImageSliceValue::create(CSSQuadValue::create(slices[0], slices[1], slices[2], slices[3], CSSQuadValue::SerializeAsQuad), fill);
    2466 }
    2467 
    2468 static CSSValue* consumeBorderImageOutset(CSSParserTokenRange& range)
    2469 {
    2470     CSSPrimitiveValue* outsets[4] = { 0 };
    2471 
    2472     CSSPrimitiveValue* value = nullptr;
     2231   
     2232    // Now build a rect value to hold all four of our primitive values.
     2233    // FIXME-NEWPARSER: Should just have a CSSQuadValue.
     2234    auto quad = Quad::create();
     2235    quad->setTop(slices[0].releaseNonNull());
     2236    quad->setRight(slices[1].releaseNonNull());
     2237    quad->setBottom(slices[2].releaseNonNull());
     2238    quad->setLeft(slices[3].releaseNonNull());
     2239   
     2240    // Make our new border image value now.
     2241    return CSSBorderImageSliceValue::create(CSSValuePool::singleton().createValue(WTFMove(quad)), fill);
     2242}
     2243
     2244static RefPtr<CSSValue> consumeBorderImageOutset(CSSParserTokenRange& range)
     2245{
     2246    RefPtr<CSSPrimitiveValue> outsets[4] = { 0 };
     2247
     2248    RefPtr<CSSPrimitiveValue> value;
    24732249    for (size_t index = 0; index < 4; ++index) {
    24742250        value = consumeNumber(range, ValueRangeNonNegative);
     
    24822258        return nullptr;
    24832259    complete4Sides(outsets);
    2484     return CSSQuadValue::create(outsets[0], outsets[1], outsets[2], outsets[3], CSSQuadValue::SerializeAsQuad);
    2485 }
    2486 
    2487 static CSSValue* consumeBorderImageWidth(CSSParserTokenRange& range)
    2488 {
    2489     CSSPrimitiveValue* widths[4] = { 0 };
    2490 
    2491     CSSPrimitiveValue* value = nullptr;
     2260   
     2261    // FIXME-NEWPARSER: Should just have a CSSQuadValue.
     2262    auto quad = Quad::create();
     2263    quad->setTop(outsets[0].releaseNonNull());
     2264    quad->setRight(outsets[1].releaseNonNull());
     2265    quad->setBottom(outsets[2].releaseNonNull());
     2266    quad->setLeft(outsets[3].releaseNonNull());
     2267   
     2268    return CSSValuePool::singleton().createValue(WTFMove(quad));
     2269}
     2270
     2271static RefPtr<CSSValue> consumeBorderImageWidth(CSSParserTokenRange& range)
     2272{
     2273    RefPtr<CSSPrimitiveValue> widths[4];
     2274
     2275    RefPtr<CSSPrimitiveValue> value;
    24922276    for (size_t index = 0; index < 4; ++index) {
    24932277        value = consumeNumber(range, ValueRangeNonNegative);
     
    25032287        return nullptr;
    25042288    complete4Sides(widths);
    2505     return CSSQuadValue::create(widths[0], widths[1], widths[2], widths[3], CSSQuadValue::SerializeAsQuad);
    2506 }
    2507 
    2508 static bool consumeBorderImageComponents(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, CSSValue*& source,
    2509     CSSValue*& slice, CSSValue*& width, CSSValue*& outset, CSSValue*& repeat)
     2289   
     2290    // FIXME-NEWPARSER: Should just have a CSSQuadValue.
     2291    auto quad = Quad::create();
     2292    quad->setTop(widths[0].releaseNonNull());
     2293    quad->setRight(widths[1].releaseNonNull());
     2294    quad->setBottom(widths[2].releaseNonNull());
     2295    quad->setLeft(widths[3].releaseNonNull());
     2296   
     2297    return CSSValuePool::singleton().createValue(WTFMove(quad));
     2298}
     2299
     2300static bool consumeBorderImageComponents(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, RefPtr<CSSValue>& source,
     2301    RefPtr<CSSValue>& slice, RefPtr<CSSValue>& width, RefPtr<CSSValue>& outset, RefPtr<CSSValue>& repeat)
    25102302{
    25112303    do {
     
    25442336}
    25452337
    2546 static CSSValue* consumeWebkitBorderImage(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
    2547 {
    2548     CSSValue* source = nullptr;
    2549     CSSValue* slice = nullptr;
    2550     CSSValue* width = nullptr;
    2551     CSSValue* outset = nullptr;
    2552     CSSValue* repeat = nullptr;
     2338static RefPtr<CSSValue> consumeWebkitBorderImage(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
     2339{
     2340    RefPtr<CSSValue> source;
     2341    RefPtr<CSSValue> slice;
     2342    RefPtr<CSSValue> width;
     2343    RefPtr<CSSValue> outset;
     2344    RefPtr<CSSValue> repeat;
    25532345    if (consumeBorderImageComponents(property, range, context, source, slice, width, outset, repeat))
    2554         return createBorderImageValue(source, slice, width, outset, repeat);
     2346        return createBorderImageValue(WTFMove(source), WTFMove(slice), WTFMove(width), WTFMove(outset), WTFMove(repeat));
    25552347    return nullptr;
    25562348}
    25572349
    2558 static CSSValue* consumeReflect(CSSParserTokenRange& range, const CSSParserContext& context)
    2559 {
    2560     CSSPrimitiveValue* direction = consumeIdent<CSSValueAbove, CSSValueBelow, CSSValueLeft, CSSValueRight>(range);
     2350static RefPtr<CSSValue> consumeReflect(CSSParserTokenRange& range, const CSSParserContext& context)
     2351{
     2352    RefPtr<CSSPrimitiveValue> direction = consumeIdent<CSSValueAbove, CSSValueBelow, CSSValueLeft, CSSValueRight>(range);
    25612353    if (!direction)
    25622354        return nullptr;
    25632355
    2564     CSSPrimitiveValue* offset = nullptr;
    2565     if (range.atEnd()) {
    2566         offset = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels);
    2567     } else {
    2568         offset = consumeLengthOrPercent(range, context.mode(), ValueRangeAll, UnitlessQuirk::Forbid);
     2356    RefPtr<CSSPrimitiveValue> offset;
     2357    if (range.atEnd())
     2358        offset = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PX);
     2359    else {
     2360        offset = consumeLengthOrPercent(range, context.mode, ValueRangeAll, UnitlessQuirk::Forbid);
    25692361        if (!offset)
    25702362            return nullptr;
    25712363    }
    25722364
    2573     CSSValue* mask = nullptr;
     2365    RefPtr<CSSValue> mask;
    25742366    if (!range.atEnd()) {
    25752367        mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, context);
     
    25772369            return nullptr;
    25782370    }
    2579     return CSSReflectValue::create(direction, offset, mask);
    2580 }
    2581 
    2582 static CSSValue* consumeFontSizeAdjust(CSSParserTokenRange& range)
    2583 {
    2584     if (range.peek().id() == CSSValueNone)
    2585         return consumeIdent(range);
    2586     return consumeNumber(range, ValueRangeNonNegative);
    2587 }
    2588 
    2589 static CSSValue* consumeImageOrientation(CSSParserTokenRange& range)
    2590 {
    2591     if (range.peek().id() == CSSValueFromImage)
    2592         return consumeIdent(range);
     2371    return CSSReflectValue::create(direction.releaseNonNull(), offset.releaseNonNull(), mask.releaseNonNull());
     2372}
     2373
     2374#if ENABLE(CSS_IMAGE_ORIENTATION)
     2375static RefPtr<CSSValue> consumeImageOrientation(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid)
     2376{
    25932377    if (range.peek().type() != NumberToken) {
    2594         CSSPrimitiveValue* angle = consumeAngle(range);
     2378        RefPtr<CSSPrimitiveValue> angle = consumeAngle(range, cssParserMode, unitless);
    25952379        if (angle && angle->doubleValue() == 0)
    25962380            return angle;
     
    25982382    return nullptr;
    25992383}
    2600 
    2601 static CSSValue* consumeBackgroundBlendMode(CSSParserTokenRange& range)
     2384#endif
     2385
     2386static RefPtr<CSSPrimitiveValue> consumeBackgroundBlendMode(CSSParserTokenRange& range)
    26022387{
    26032388    CSSValueID id = range.peek().id();
     
    26072392}
    26082393
    2609 static CSSValue* consumeBackgroundAttachment(CSSParserTokenRange& range)
     2394static RefPtr<CSSPrimitiveValue> consumeBackgroundAttachment(CSSParserTokenRange& range)
    26102395{
    26112396    return consumeIdent<CSSValueScroll, CSSValueFixed, CSSValueLocal>(range);
    26122397}
    26132398
    2614 static CSSValue* consumeBackgroundBox(CSSParserTokenRange& range)
     2399static RefPtr<CSSPrimitiveValue> consumeBackgroundBox(CSSParserTokenRange& range)
    26152400{
    26162401    return consumeIdent<CSSValueBorderBox, CSSValuePaddingBox, CSSValueContentBox>(range);
    26172402}
    26182403
    2619 static CSSValue* consumeBackgroundComposite(CSSParserTokenRange& range)
     2404static RefPtr<CSSPrimitiveValue> consumeBackgroundComposite(CSSParserTokenRange& range)
    26202405{
    26212406    return consumeIdentRange(range, CSSValueClear, CSSValuePlusLighter);
    26222407}
    26232408
    2624 static CSSValue* consumeMaskSourceType(CSSParserTokenRange& range)
    2625 {
    2626     ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled());
    2627     return consumeIdent<CSSValueAuto, CSSValueAlpha, CSSValueLuminance>(range);
    2628 }
    2629 
    2630 static CSSValue* consumePrefixedBackgroundBox(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
     2409static RefPtr<CSSPrimitiveValue> consumePrefixedBackgroundBox(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& /*context*/)
    26312410{
    26322411    // The values 'border', 'padding' and 'content' are deprecated and do not apply to the version of the property that has the -webkit- prefix removed.
    2633     if (CSSValue* value = consumeIdentRange(range, CSSValueBorder, CSSValuePaddingBox))
     2412    if (RefPtr<CSSPrimitiveValue> value = consumeIdentRange(range, CSSValueBorder, CSSValuePaddingBox))
    26342413        return value;
    26352414    if ((property == CSSPropertyWebkitBackgroundClip || property == CSSPropertyWebkitMaskClip) && range.peek().id() == CSSValueText)
     
    26382417}
    26392418
    2640 static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, CSSParserMode cssParserMode)
     2419static RefPtr<CSSPrimitiveValue> consumeBackgroundSize(CSSPropertyID property, CSSParserTokenRange& range, CSSParserMode cssParserMode)
    26412420{
    26422421    if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id()))
    26432422        return consumeIdent(range);
    26442423
    2645     CSSPrimitiveValue* horizontal = consumeIdent<CSSValueAuto>(range);
     2424    RefPtr<CSSPrimitiveValue> horizontal = consumeIdent<CSSValueAuto>(range);
    26462425    if (!horizontal)
    26472426        horizontal = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid);
    26482427
    2649     CSSPrimitiveValue* vertical = nullptr;
     2428    RefPtr<CSSPrimitiveValue> vertical;
    26502429    if (!range.atEnd()) {
    26512430        if (range.peek().id() == CSSValueAuto) // `auto' is the default
     
    26532432        else
    26542433            vertical = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid);
    2655     } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) {
     2434    } else if (!vertical && property == CSSPropertyWebkitBackgroundSize) {
    26562435        // Legacy syntax: "-webkit-background-size: 10px" is equivalent to "background-size: 10px 10px".
    26572436        vertical = horizontal;
     
    26592438    if (!vertical)
    26602439        return horizontal;
    2661     return CSSValuePair::create(horizontal, vertical, CSSValuePair::KeepIdenticalValues);
    2662 }
    2663 
    2664 static CSSValueList* consumeGridAutoFlow(CSSParserTokenRange& range)
    2665 {
    2666     CSSPrimitiveValue* rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range);
    2667     CSSPrimitiveValue* denseAlgorithm = consumeIdent<CSSValueDense>(range);
     2440    return createPrimitiveValuePair(horizontal.releaseNonNull(), vertical.releaseNonNull(), Pair::IdenticalValueEncoding::DoNotCoalesce);
     2441}
     2442
     2443static RefPtr<CSSValueList> consumeGridAutoFlow(CSSParserTokenRange& range)
     2444{
     2445    RefPtr<CSSPrimitiveValue> rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range);
     2446    RefPtr<CSSPrimitiveValue> denseAlgorithm = consumeIdent<CSSValueDense>(range);
    26682447    if (!rowOrColumnValue) {
    26692448        rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range);
     
    26712450            return nullptr;
    26722451    }
    2673     CSSValueList* parsedValues = CSSValueList::createSpaceSeparated();
     2452    RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated();
    26742453    if (rowOrColumnValue)
    2675         parsedValues->append(*rowOrColumnValue);
     2454        parsedValues->append(rowOrColumnValue.releaseNonNull());
    26762455    if (denseAlgorithm)
    2677         parsedValues->append(*denseAlgorithm);
     2456        parsedValues->append(denseAlgorithm.releaseNonNull());
    26782457    return parsedValues;
    26792458}
    26802459
    2681 static CSSValue* consumeBackgroundComponent(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, const CSSParserContext& context)
    2682 {
    2683     switch (unresolvedProperty) {
     2460static RefPtr<CSSValue> consumeBackgroundComponent(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
     2461{
     2462    switch (property) {
    26842463    case CSSPropertyBackgroundClip:
    26852464        return consumeBackgroundBox(range);
     
    26922471    case CSSPropertyWebkitMaskComposite:
    26932472        return consumeBackgroundComposite(range);
    2694     case CSSPropertyMaskSourceType:
    2695         return consumeMaskSourceType(range);
    26962473    case CSSPropertyWebkitBackgroundClip:
    26972474    case CSSPropertyWebkitBackgroundOrigin:
    26982475    case CSSPropertyWebkitMaskClip:
    26992476    case CSSPropertyWebkitMaskOrigin:
    2700         return consumePrefixedBackgroundBox(unresolvedProperty, range, context);
     2477        return consumePrefixedBackgroundBox(property, range, context);
    27012478    case CSSPropertyBackgroundImage:
    27022479    case CSSPropertyWebkitMaskImage:
     
    27042481    case CSSPropertyBackgroundPositionX:
    27052482    case CSSPropertyWebkitMaskPositionX:
    2706         return consumePositionX(range, context.mode());
     2483        return consumePositionX(range, context.mode);
    27072484    case CSSPropertyBackgroundPositionY:
    27082485    case CSSPropertyWebkitMaskPositionY:
    2709         return consumePositionY(range, context.mode());
     2486        return consumePositionY(range, context.mode);
    27102487    case CSSPropertyBackgroundSize:
    2711     case CSSPropertyAliasWebkitBackgroundSize:
     2488    case CSSPropertyWebkitBackgroundSize:
    27122489    case CSSPropertyWebkitMaskSize:
    2713         return consumeBackgroundSize(unresolvedProperty, range, context.mode());
     2490        return consumeBackgroundSize(property, range, context.mode);
    27142491    case CSSPropertyBackgroundColor:
    2715         return consumeColor(range, context.mode());
     2492        return consumeColor(range, context.mode);
    27162493    default:
    27172494        break;
     
    27202497}
    27212498
    2722 static void addBackgroundValue(CSSValue*& list, CSSValue* value)
     2499static void addBackgroundValue(RefPtr<CSSValue>& list, Ref<CSSValue>&& value)
    27232500{
    27242501    if (list) {
    27252502        if (!list->isBaseValueList()) {
    2726             CSSValue* firstValue = list;
     2503            RefPtr<CSSValue> firstValue = list;
    27272504            list = CSSValueList::createCommaSeparated();
    2728             toCSSValueList(list)->append(*firstValue);
    2729         }
    2730         toCSSValueList(list)->append(*value);
     2505            downcast<CSSValueList>(*list).append(firstValue.releaseNonNull());
     2506        }
     2507        downcast<CSSValueList>(*list).append(WTFMove(value));
    27312508    } else {
    27322509        // To conserve memory we don't actually wrap a single value in a list.
    2733         list = value;
    2734     }
    2735 }
    2736 
    2737 static CSSValue* consumeCommaSeparatedBackgroundComponent(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, const CSSParserContext& context)
    2738 {
    2739     CSSValue* result = nullptr;
     2510        list = WTFMove(value);
     2511    }
     2512}
     2513
     2514static RefPtr<CSSValue> consumeCommaSeparatedBackgroundComponent(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context)
     2515{
     2516    RefPtr<CSSValue> result;
    27402517    do {
    2741         CSSValue* value = consumeBackgroundComponent(unresolvedProperty, range, context);
     2518        RefPtr<CSSValue> value = consumeBackgroundComponent(property, range, context);
    27422519        if (!value)
    27432520            return nullptr;
    2744         addBackgroundValue(result, value);
     2521        addBackgroundValue(result, value.releaseNonNull());
    27452522    } while (consumeCommaIncludingWhitespace(range));
    27462523    return result;
    27472524}
    27482525
    2749 static CSSPrimitiveValue* consumeSelfPositionKeyword(CSSParserTokenRange& range)
     2526static RefPtr<CSSPrimitiveValue> consumeSelfPositionKeyword(CSSParserTokenRange& range)
    27502527{
    27512528    CSSValueID id = range.peek().id();
     
    27572534}
    27582535
    2759 static CSSValue* consumeSelfPositionOverflowPosition(CSSParserTokenRange& range)
     2536static RefPtr<CSSValue> consumeSelfPositionOverflowPosition(CSSParserTokenRange& range)
    27602537{
    27612538    if (identMatches<CSSValueAuto, CSSValueNormal, CSSValueStretch, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id()))
    27622539        return consumeIdent(range);
    27632540
    2764     CSSPrimitiveValue* overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range);
    2765     CSSPrimitiveValue* selfPosition = consumeSelfPositionKeyword(range);
     2541    RefPtr<CSSPrimitiveValue> overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range);
     2542    RefPtr<CSSPrimitiveValue> selfPosition = consumeSelfPositionKeyword(range);
    27662543    if (!selfPosition)
    27672544        return nullptr;
     
    27692546        overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range);
    27702547    if (overflowPosition)
    2771         return CSSValuePair::create(selfPosition, overflowPosition, CSSValuePair::DropIdenticalValues);
     2548        return createPrimitiveValuePair(selfPosition.releaseNonNull(), overflowPosition.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce);
    27722549    return selfPosition;
    27732550}
    27742551
    2775 static CSSValue* consumeAlignItems(CSSParserTokenRange& range)
     2552static RefPtr<CSSValue> consumeAlignItems(CSSParserTokenRange& range)
    27762553{
    27772554    // align-items property does not allow the 'auto' value.
     
    27812558}
    27822559
    2783 static CSSValue* consumeJustifyItems(CSSParserTokenRange& range)
     2560static RefPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range)
    27842561{
    27852562    CSSParserTokenRange rangeCopy = range;
    2786     CSSPrimitiveValue* legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
    2787     CSSPrimitiveValue* positionKeyword = consumeIdent<CSSValueCenter, CSSValueLeft, CSSValueRight>(rangeCopy);
     2563    RefPtr<CSSPrimitiveValue> legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
     2564    RefPtr<CSSPrimitiveValue> positionKeyword = consumeIdent<CSSValueCenter, CSSValueLeft, CSSValueRight>(rangeCopy);
    27882565    if (!legacy)
    27892566        legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
    27902567    if (legacy && positionKeyword) {
    27912568        range = rangeCopy;
    2792         return CSSValuePair::create(legacy, positionKeyword, CSSValuePair::DropIdenticalValues);
     2569        return createPrimitiveValuePair(legacy.releaseNonNull(), positionKeyword.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce);
    27932570    }
    27942571    return consumeSelfPositionOverflowPosition(range);
    27952572}
    27962573
    2797 static CSSValue* consumeFitContent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     2574static RefPtr<CSSValue> consumeFitContent(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    27982575{
    27992576    CSSParserTokenRange rangeCopy = range;
    28002577    CSSParserTokenRange args = consumeFunction(rangeCopy);
    2801     CSSPrimitiveValue* length = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow);
     2578    RefPtr<CSSPrimitiveValue> length = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow);
    28022579    if (!length || !args.atEnd())
    28032580        return nullptr;
    28042581    range = rangeCopy;
    2805     CSSFunctionValue* result = CSSFunctionValue::create(CSSValueFitContent);
    2806     result->append(*length);
     2582    RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueWebkitFitContent);
     2583    result->append(length.releaseNonNull());
    28072584    return result;
    28082585}
    28092586
    2810 static CSSCustomIdentValue* consumeCustomIdentForGridLine(CSSParserTokenRange& range)
     2587static RefPtr<CSSPrimitiveValue> consumeCustomIdentForGridLine(CSSParserTokenRange& range)
    28112588{
    28122589    if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan)
     
    28152592}
    28162593
    2817 static CSSValue* consumeGridLine(CSSParserTokenRange& range)
     2594static RefPtr<CSSValue> consumeGridLine(CSSParserTokenRange& range)
    28182595{
    28192596    if (range.peek().id() == CSSValueAuto)
    28202597        return consumeIdent(range);
    28212598
    2822     CSSPrimitiveValue* spanValue = nullptr;
    2823     CSSCustomIdentValue* gridLineName = nullptr;
    2824     CSSPrimitiveValue* numericValue = consumeInteger(range);
     2599    RefPtr<CSSPrimitiveValue> spanValue;
     2600    RefPtr<CSSPrimitiveValue> gridLineName;
     2601    RefPtr<CSSPrimitiveValue> numericValue = consumeInteger(range);
    28252602    if (numericValue) {
    28262603        gridLineName = consumeCustomIdentForGridLine(range);
     
    28532630        return nullptr; // An <integer> value of zero makes the declaration invalid.
    28542631
    2855     CSSValueList* values = CSSValueList::createSpaceSeparated();
     2632    RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
    28562633    if (spanValue)
    2857         values->append(*spanValue);
     2634        values->append(spanValue.releaseNonNull());
    28582635    if (numericValue)
    2859         values->append(*numericValue);
     2636        values->append(numericValue.releaseNonNull());
    28602637    if (gridLineName)
    2861         values->append(*gridLineName);
     2638        values->append(gridLineName.releaseNonNull());
    28622639    ASSERT(values->length());
    28632640    return values;
     
    28672644{
    28682645    CSSValueID valueID = primitiveValue.valueID();
    2869     if (valueID == CSSValueMinContent || valueID == CSSValueMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex())
     2646    if (valueID == CSSValueWebkitMinContent || valueID == CSSValueWebkitMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex())
    28702647        return false;
    28712648
     
    28762653{
    28772654    if (value.isPrimitiveValue())
    2878         return isGridTrackFixedSized(toCSSPrimitiveValue(value));
     2655        return isGridTrackFixedSized(downcast<CSSPrimitiveValue>(value));
    28792656
    28802657    ASSERT(value.isFunctionValue());
    2881     auto& function = toCSSFunctionValue(value);
    2882     if (function.functionType() == CSSValueFitContent)
     2658    auto& function = downcast<CSSFunctionValue>(value);
     2659    if (function.name() == CSSValueWebkitFitContent || function.arguments() == nullptr || function.arguments()->length() < 2)
    28832660        return false;
    28842661
    2885     const CSSPrimitiveValue& minPrimitiveValue = toCSSPrimitiveValue(function.item(0));
    2886     const CSSPrimitiveValue& maxPrimitiveValue = toCSSPrimitiveValue(function.item(1));
    2887     return isGridTrackFixedSized(minPrimitiveValue) || isGridTrackFixedSized(maxPrimitiveValue);
     2662    CSSValue* minPrimitiveValue = downcast<CSSPrimitiveValue>(function.arguments()->item(0));
     2663    CSSValue* maxPrimitiveValue = downcast<CSSPrimitiveValue>(function.arguments()->item(1));
     2664    return isGridTrackFixedSized(*minPrimitiveValue) || isGridTrackFixedSized(*maxPrimitiveValue);
    28882665}
    28892666
     
    29822759}
    29832760
    2984 static CSSPrimitiveValue* consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     2761static RefPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    29852762{
    29862763    const CSSParserToken& token = range.peek();
    2987     if (identMatches<CSSValueMinContent, CSSValueMaxContent, CSSValueAuto>(token.id()))
    2988         return consumeIdent(range);
    2989     if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitType::Fraction) {
     2764    if (identMatches<CSSValueWebkitMinContent, CSSValueWebkitMaxContent, CSSValueAuto>(token.id()))
     2765        return consumeIdent(range);
     2766    if (token.type() == DimensionToken && token.unitType() == CSSPrimitiveValue::UnitTypes::CSS_FR) {
    29902767        if (range.peek().numericValue() < 0)
    29912768            return nullptr;
    2992         return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType::Fraction);
     2769        return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_FR);
    29932770    }
    29942771    return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow);
    29952772}
    29962773
    2997 static CSSValue* consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     2774static RefPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    29982775{
    29992776    const CSSParserToken& token = range.peek();
     
    30042781        CSSParserTokenRange rangeCopy = range;
    30052782        CSSParserTokenRange args = consumeFunction(rangeCopy);
    3006         CSSPrimitiveValue* minTrackBreadth = consumeGridBreadth(args, cssParserMode);
     2783        RefPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBreadth(args, cssParserMode);
    30072784        if (!minTrackBreadth || minTrackBreadth->isFlex() || !consumeCommaIncludingWhitespace(args))
    30082785            return nullptr;
    3009         CSSPrimitiveValue* maxTrackBreadth = consumeGridBreadth(args, cssParserMode);
     2786        RefPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBreadth(args, cssParserMode);
    30102787        if (!maxTrackBreadth || !args.atEnd())
    30112788            return nullptr;
    30122789        range = rangeCopy;
    3013         CSSFunctionValue* result = CSSFunctionValue::create(CSSValueMinmax);
    3014         result->append(*minTrackBreadth);
    3015         result->append(*maxTrackBreadth);
     2790        RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueMinmax);
     2791        result->append(minTrackBreadth.releaseNonNull());
     2792        result->append(maxTrackBreadth.releaseNonNull());
    30162793        return result;
    30172794    }
    30182795
    3019     if (token.functionId() == CSSValueFitContent)
     2796    if (token.functionId() == CSSValueWebkitFitContent)
    30202797        return consumeFitContent(range, cssParserMode);
    30212798
     
    30242801
    30252802// Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a new one.
    3026 static CSSGridLineNamesValue* consumeGridLineNames(CSSParserTokenRange& range, CSSGridLineNamesValue* lineNames = nullptr)
     2803static RefPtr<CSSGridLineNamesValue> consumeGridLineNames(CSSParserTokenRange& range, CSSGridLineNamesValue* lineNames = nullptr)
    30272804{
    30282805    CSSParserTokenRange rangeCopy = range;
    30292806    if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken)
    30302807        return nullptr;
    3031     if (!lineNames)
    3032         lineNames = CSSGridLineNamesValue::create();
    3033     while (CSSCustomIdentValue* lineName = consumeCustomIdentForGridLine(rangeCopy))
    3034         lineNames->append(*lineName);
     2808   
     2809    RefPtr<CSSGridLineNamesValue> result = lineNames;
     2810    if (!result)
     2811        result = CSSGridLineNamesValue::create();
     2812    while (RefPtr<CSSPrimitiveValue> lineName = consumeCustomIdentForGridLine(rangeCopy))
     2813        result->append(lineName.releaseNonNull());
    30352814    if (rangeCopy.consumeIncludingWhitespace().type() != RightBracketToken)
    30362815        return nullptr;
    30372816    range = rangeCopy;
    3038     return lineNames;
     2817    return result;
    30392818}
    30402819
     
    30462825    size_t repetitions = 1;
    30472826    isAutoRepeat = identMatches<CSSValueAutoFill, CSSValueAutoFit>(args.peek().id());
    3048     CSSValueList* repeatedValues;
    3049     if (isAutoRepeat) {
     2827    RefPtr<CSSValueList> repeatedValues;
     2828    if (isAutoRepeat)
    30502829        repeatedValues = CSSGridAutoRepeatValue::create(args.consumeIncludingWhitespace().id());
    3051     } else {
     2830    else {
    30522831        // FIXME: a consumeIntegerRaw would be more efficient here.
    3053         CSSPrimitiveValue* repetition = consumePositiveInteger(args);
     2832        RefPtr<CSSPrimitiveValue> repetition = consumePositiveInteger(args);
    30542833        if (!repetition)
    30552834            return false;
     
    30592838    if (!consumeCommaIncludingWhitespace(args))
    30602839        return false;
    3061     CSSGridLineNamesValue* lineNames = consumeGridLineNames(args);
     2840    RefPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(args);
    30622841    if (lineNames)
    3063         repeatedValues->append(*lineNames);
     2842        repeatedValues->append(lineNames.releaseNonNull());
    30642843
    30652844    size_t numberOfTracks = 0;
    30662845    while (!args.atEnd()) {
    3067         CSSValue* trackSize = consumeGridTrackSize(args, cssParserMode);
     2846        RefPtr<CSSValue> trackSize = consumeGridTrackSize(args, cssParserMode);
    30682847        if (!trackSize)
    30692848            return false;
     
    30742853        lineNames = consumeGridLineNames(args);
    30752854        if (lineNames)
    3076             repeatedValues->append(*lineNames);
     2855            repeatedValues->append(lineNames.releaseNonNull());
    30772856    }
    30782857    // We should have found at least one <track-size> or else it is not a valid <track-list>.
     
    30802859        return false;
    30812860
    3082     if (isAutoRepeat) {
    3083         list.append(*repeatedValues);
    3084     } else {
     2861    if (isAutoRepeat)
     2862        list.append(repeatedValues.releaseNonNull());
     2863    else {
    30852864        // We clamp the repetitions to a multiple of the repeat() track list's size, while staying below the max grid size.
    30862865        repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks);
    30872866        for (size_t i = 0; i < repetitions; ++i) {
    30882867            for (size_t j = 0; j < repeatedValues->length(); ++j)
    3089                 list.append(repeatedValues->item(j));
     2868                list.append(adoptRef(*repeatedValues->item(j)));
    30902869        }
    30912870    }
     
    30952874enum TrackListType { GridTemplate, GridTemplateNoRepeat, GridAuto };
    30962875
    3097 static CSSValue* consumeGridTrackList(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackListType trackListType)
     2876static RefPtr<CSSValue> consumeGridTrackList(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackListType trackListType)
    30982877{
    30992878    bool allowGridLineNames = trackListType != GridAuto;
    3100     CSSValueList* values = CSSValueList::createSpaceSeparated();
    3101     CSSGridLineNamesValue* lineNames = consumeGridLineNames(range);
     2879    RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
     2880    RefPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(range);
    31022881    if (lineNames) {
    31032882        if (!allowGridLineNames)
    31042883            return nullptr;
    3105         values->append(*lineNames);
     2884        values->append(lineNames.releaseNonNull());
    31062885    }
    31072886
     
    31192898                return nullptr;
    31202899            seenAutoRepeat = seenAutoRepeat || isAutoRepeat;
    3121         } else if (CSSValue* value = consumeGridTrackSize(range, cssParserMode)) {
     2900        } else if (RefPtr<CSSValue> value = consumeGridTrackSize(range, cssParserMode)) {
    31222901            if (allTracksAreFixedSized)
    31232902                allTracksAreFixedSized = isGridTrackFixedSized(*value);
    3124             values->append(*value);
     2903            values->append(value.releaseNonNull());
    31252904        } else {
    31262905            return nullptr;
     
    31382917}
    31392918
    3140 static CSSValue* consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     2919static RefPtr<CSSValue> consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range, CSSParserMode cssParserMode)
    31412920{
    31422921    if (range.peek().id() == CSSValueNone)
     
    31452924}
    31462925
    3147 static CSSValue* consumeGridTemplateAreas(CSSParserTokenRange& range)
     2926static RefPtr<CSSValue> consumeGridTemplateAreas(CSSParserTokenRange& range)
    31482927{
    31492928    if (range.peek().id() == CSSValueNone)
     
    31662945}
    31672946
    3168 static void countKeywordOnlyPropertyUsage(CSSPropertyID property, UseCounter* counter, CSSValueID valueID)
    3169 {
    3170     if (!counter)
    3171         return;
    3172     switch (property) {
    3173     case CSSPropertyWebkitAppearance:
    3174         if (valueID == CSSValueNone) {
    3175             counter->count(UseCounter::CSSValueAppearanceNone);
    3176         } else {
    3177             counter->count(UseCounter::CSSValueAppearanceNotNone);
    3178             if (valueID == CSSValueButton)
    3179                 counter->count(UseCounter::CSSValueAppearanceButton);
    3180             else if (valueID == CSSValueCaret)
    3181                 counter->count(UseCounter::CSSValueAppearanceCaret);
    3182             else if (valueID == CSSValueCheckbox)
    3183                 counter->count(UseCounter::CSSValueAppearanceCheckbox);
    3184             else if (valueID == CSSValueMenulist)
    3185                 counter->count(UseCounter::CSSValueAppearanceMenulist);
    3186             else if (valueID == CSSValueMenulistButton)
    3187                 counter->count(UseCounter::CSSValueAppearanceMenulistButton);
    3188             else if (valueID == CSSValueListbox)
    3189                 counter->count(UseCounter::CSSValueAppearanceListbox);
    3190             else if (valueID == CSSValueRadio)
    3191                 counter->count(UseCounter::CSSValueAppearanceRadio);
    3192             else if (valueID == CSSValueSearchfield)
    3193                 counter->count(UseCounter::CSSValueAppearanceSearchField);
    3194             else if (valueID == CSSValueTextfield)
    3195                 counter->count(UseCounter::CSSValueAppearanceTextField);
    3196             else
    3197                 counter->count(UseCounter::CSSValueAppearanceOthers);
    3198         }
    3199         break;
    3200 
    3201     default:
    3202         break;
    3203     }
    3204 }
    3205 
    3206 const CSSValue* CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty, CSSPropertyID currentShorthand)
    3207 {
    3208     CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
     2947RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand)
     2948{
    32092949    if (CSSParserFastPaths::isKeywordPropertyID(property)) {
    3210         if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context.mode()))
    3211             return nullptr;
    3212         countKeywordOnlyPropertyUsage(property, m_context.useCounter(), m_range.peek().id());
     2950        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_range.peek().id(), m_context.mode))
     2951            return nullptr;
    32132952        return consumeIdent(m_range);
    32142953    }
     
    32202959    case CSSPropertyQuotes:
    32212960        return consumeQuotes(m_range);
    3222     case CSSPropertyWebkitHighlight:
    3223         return consumeWebkitHighlight(m_range);
    32242961    case CSSPropertyFontVariantCaps:
    32252962        return consumeFontVariantCaps(m_range);
     
    32362973    case CSSPropertyLetterSpacing:
    32372974    case CSSPropertyWordSpacing:
    3238         return consumeSpacing(m_range, m_context.mode());
     2975        return consumeSpacing(m_range, m_context.mode);
    32392976    case CSSPropertyTabSize:
    3240         return consumeTabSize(m_range, m_context.mode());
    3241     case CSSPropertyTextSizeAdjust:
    3242         return consumeTextSizeAdjust(m_range, m_context.mode());
     2977        return consumeTabSize(m_range, m_context.mode);
     2978    case CSSPropertyWebkitTextSizeAdjust:
     2979        return consumeTextSizeAdjust(m_range, m_context.mode);
    32432980    case CSSPropertyFontSize:
    3244         return consumeFontSize(m_range, m_context.mode(), UnitlessQuirk::Allow);
     2981        return consumeFontSize(m_range, m_context.mode, UnitlessQuirk::Allow);
    32452982    case CSSPropertyLineHeight:
    3246         return consumeLineHeight(m_range, m_context.mode());
    3247     case CSSPropertyRotate:
    3248         return consumeRotation(m_range);
    3249     case CSSPropertyScale:
    3250         return consumeScale(m_range);
    3251     case CSSPropertyTranslate:
    3252         return consumeTranslate(m_range, m_context.mode());
     2983        return consumeLineHeight(m_range, m_context.mode);
    32532984    case CSSPropertyWebkitBorderHorizontalSpacing:
    32542985    case CSSPropertyWebkitBorderVerticalSpacing:
    3255         return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
     2986        return consumeLength(m_range, m_context.mode, ValueRangeNonNegative);
    32562987    case CSSPropertyCounterIncrement:
    32572988    case CSSPropertyCounterReset:
    32582989        return consumeCounter(m_range, property == CSSPropertyCounterIncrement ? 1 : 0);
    32592990    case CSSPropertySize:
    3260         return consumeSize(m_range, m_context.mode());
    3261     case CSSPropertySnapHeight:
    3262         return consumeSnapHeight(m_range, m_context.mode());
     2991        return consumeSize(m_range, m_context.mode);
    32632992    case CSSPropertyTextIndent:
    3264         return consumeTextIndent(m_range, m_context.mode());
     2993        return consumeTextIndent(m_range, m_context.mode);
    32652994    case CSSPropertyMaxWidth:
    32662995    case CSSPropertyMaxHeight:
     
    32873016    case CSSPropertyRight:
    32883017    case CSSPropertyTop:
    3289         return consumeMarginOrOffset(m_range, m_context.mode(), UnitlessQuirk::Allow);
     3018        return consumeMarginOrOffset(m_range, m_context.mode, UnitlessQuirk::Allow);
    32903019    case CSSPropertyWebkitMarginStart:
    32913020    case CSSPropertyWebkitMarginEnd:
    32923021    case CSSPropertyWebkitMarginBefore:
    32933022    case CSSPropertyWebkitMarginAfter:
    3294         return consumeMarginOrOffset(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3023        return consumeMarginOrOffset(m_range, m_context.mode, UnitlessQuirk::Forbid);
    32953024    case CSSPropertyPaddingTop:
    32963025    case CSSPropertyPaddingRight:
    32973026    case CSSPropertyPaddingBottom:
    32983027    case CSSPropertyPaddingLeft:
    3299         return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNegative, UnitlessQuirk::Allow);
     3028        return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Allow);
    33003029    case CSSPropertyWebkitPaddingStart:
    33013030    case CSSPropertyWebkitPaddingEnd:
    33023031    case CSSPropertyWebkitPaddingBefore:
    33033032    case CSSPropertyWebkitPaddingAfter:
    3304         return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNegative, UnitlessQuirk::Forbid);
     3033        return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Forbid);
    33053034    case CSSPropertyClip:
    3306         return consumeClip(m_range, m_context.mode());
     3035        return consumeClip(m_range, m_context.mode);
     3036#if ENABLE(TOUCH_EVENTS)
    33073037    case CSSPropertyTouchAction:
    33083038        return consumeTouchAction(m_range);
    3309     case CSSPropertyScrollSnapDestination:
     3039#endif
    33103040    case CSSPropertyObjectPosition:
    33113041    case CSSPropertyPerspectiveOrigin:
    3312         return consumePosition(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3042        return consumePosition(m_range, m_context.mode, UnitlessQuirk::Forbid);
    33133043    case CSSPropertyWebkitLineClamp:
    33143044        return consumeLineClamp(m_range);
    33153045    case CSSPropertyWebkitFontSizeDelta:
    3316         return consumeLength(m_range, m_context.mode(), ValueRangeAll, UnitlessQuirk::Allow);
     3046        return consumeLength(m_range, m_context.mode, ValueRangeAll, UnitlessQuirk::Allow);
    33173047    case CSSPropertyWebkitHyphenateCharacter:
    33183048    case CSSPropertyWebkitLocale:
     
    33233053        return consumeColumnCount(m_range);
    33243054    case CSSPropertyColumnGap:
    3325         return consumeColumnGap(m_range, m_context.mode());
     3055        return consumeColumnGap(m_range, m_context.mode);
    33263056    case CSSPropertyColumnSpan:
    33273057        return consumeColumnSpan(m_range);
     
    33403070    case CSSPropertyAnimationTimingFunction:
    33413071    case CSSPropertyTransitionTimingFunction:
    3342         return consumeAnimationPropertyList(property, m_range, m_context, unresolvedProperty == CSSPropertyAliasWebkitAnimationName);
     3072        return consumeAnimationPropertyList(property, m_range, m_context);
    33433073    case CSSPropertyGridColumnGap:
    33443074    case CSSPropertyGridRowGap:
    3345         return consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
    3346     case CSSPropertyShapeMargin:
    3347         return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNegative);
    3348     case CSSPropertyShapeImageThreshold:
     3075        return consumeLength(m_range, m_context.mode, ValueRangeNonNegative);
     3076    case CSSPropertyWebkitShapeMargin:
     3077        return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative);
     3078    case CSSPropertyWebkitShapeImageThreshold:
    33493079        return consumeNumber(m_range, ValueRangeAll);
    33503080    case CSSPropertyWebkitBoxOrdinalGroup:
     
    33523082    case CSSPropertyWidows:
    33533083        return consumePositiveInteger(m_range);
    3354     case CSSPropertyTextDecorationColor:
    3355         ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
    3356         return consumeColor(m_range, m_context.mode());
     3084    case CSSPropertyWebkitTextDecorationColor:
     3085        return consumeColor(m_range, m_context.mode);
    33573086    case CSSPropertyWebkitTextStrokeWidth:
    3358         return consumeTextStrokeWidth(m_range, m_context.mode());
     3087        return consumeTextStrokeWidth(m_range, m_context.mode);
    33593088    case CSSPropertyWebkitTextFillColor:
     3089#if ENABLE(TOUCH_EVENTS)
    33603090    case CSSPropertyWebkitTapHighlightColor:
     3091#endif
    33613092    case CSSPropertyWebkitTextEmphasisColor:
    33623093    case CSSPropertyWebkitBorderStartColor:
     
    33693100    case CSSPropertyLightingColor:
    33703101    case CSSPropertyColumnRuleColor:
    3371         return consumeColor(m_range, m_context.mode());
     3102        return consumeColor(m_range, m_context.mode);
    33723103    case CSSPropertyColor:
    33733104    case CSSPropertyBackgroundColor:
    3374         return consumeColor(m_range, m_context.mode(), inQuirksMode());
     3105        return consumeColor(m_range, m_context.mode, inQuirksMode());
    33753106    case CSSPropertyWebkitBorderStartWidth:
    33763107    case CSSPropertyWebkitBorderEndWidth:
    33773108    case CSSPropertyWebkitBorderBeforeWidth:
    33783109    case CSSPropertyWebkitBorderAfterWidth:
    3379         return consumeBorderWidth(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3110        return consumeBorderWidth(m_range, m_context.mode, UnitlessQuirk::Forbid);
    33803111    case CSSPropertyBorderBottomColor:
    33813112    case CSSPropertyBorderLeftColor:
     
    33843115        bool allowQuirkyColors = inQuirksMode()
    33853116            && (currentShorthand == CSSPropertyInvalid || currentShorthand == CSSPropertyBorderColor);
    3386         return consumeColor(m_range, m_context.mode(), allowQuirkyColors);
     3117        return consumeColor(m_range, m_context.mode, allowQuirkyColors);
    33873118    }
    33883119    case CSSPropertyBorderBottomWidth:
     
    33933124            && (currentShorthand == CSSPropertyInvalid || currentShorthand == CSSPropertyBorderWidth);
    33943125        UnitlessQuirk unitless = allowQuirkyLengths ? UnitlessQuirk::Allow : UnitlessQuirk::Forbid;
    3395         return consumeBorderWidth(m_range, m_context.mode(), unitless);
     3126        return consumeBorderWidth(m_range, m_context.mode, unitless);
    33963127    }
    33973128    case CSSPropertyZIndex:
     
    33993130    case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3
    34003131    case CSSPropertyBoxShadow:
    3401         return consumeShadow(m_range, m_context.mode(), property == CSSPropertyBoxShadow);
     3132        return consumeShadow(m_range, m_context.mode, property == CSSPropertyBoxShadow);
    34023133    case CSSPropertyFilter:
    3403     case CSSPropertyBackdropFilter:
     3134    case CSSPropertyWebkitBackdropFilter:
    34043135        return consumeFilter(m_range, m_context);
    34053136    case CSSPropertyTextDecoration:
    3406         ASSERT(!RuntimeEnabledFeatures::css3TextDecorationsEnabled());
    3407         // fallthrough
    34083137    case CSSPropertyWebkitTextDecorationsInEffect:
    3409     case CSSPropertyTextDecorationLine:
     3138    case CSSPropertyWebkitTextDecorationLine:
    34103139        return consumeTextDecorationLine(m_range);
    3411     case CSSPropertyD:
    3412     case CSSPropertyMotionPath:
    3413         return consumePathOrNone(m_range);
    3414     case CSSPropertyMotionOffset:
    3415         return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll);
    3416     case CSSPropertyMotionRotation:
    3417         return consumeMotionRotation(m_range);
    34183140    case CSSPropertyWebkitTextEmphasisStyle:
    34193141        return consumeTextEmphasisStyle(m_range);
    34203142    case CSSPropertyOutlineColor:
    3421         return consumeOutlineColor(m_range, m_context.mode());
     3143        return consumeOutlineColor(m_range, m_context.mode);
    34223144    case CSSPropertyOutlineOffset:
    3423         return consumeLength(m_range, m_context.mode(), ValueRangeAll);
     3145        return consumeLength(m_range, m_context.mode, ValueRangeAll);
    34243146    case CSSPropertyOutlineWidth:
    3425         return consumeLineWidth(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3147        return consumeLineWidth(m_range, m_context.mode, UnitlessQuirk::Forbid);
    34263148    case CSSPropertyTransform:
    3427         return consumeTransform(m_range, m_context.mode(), unresolvedProperty == CSSPropertyAliasWebkitTransform);
    3428     case CSSPropertyWebkitTransformOriginX:
    3429     case CSSPropertyWebkitPerspectiveOriginX:
    3430         return consumePositionX(m_range, m_context.mode());
    3431     case CSSPropertyWebkitTransformOriginY:
    3432     case CSSPropertyWebkitPerspectiveOriginY:
    3433         return consumePositionY(m_range, m_context.mode());
    3434     case CSSPropertyWebkitTransformOriginZ:
    3435         return consumeLength(m_range, m_context.mode(), ValueRangeAll);
     3149        return consumeTransform(m_range, m_context.mode);
     3150    case CSSPropertyTransformOriginX:
     3151    case CSSPropertyPerspectiveOriginX:
     3152        return consumePositionX(m_range, m_context.mode);
     3153    case CSSPropertyTransformOriginY:
     3154    case CSSPropertyPerspectiveOriginY:
     3155        return consumePositionY(m_range, m_context.mode);
     3156    case CSSPropertyTransformOriginZ:
     3157        return consumeLength(m_range, m_context.mode, ValueRangeAll);
    34363158    case CSSPropertyFill:
    34373159    case CSSPropertyStroke:
    3438         return consumePaintStroke(m_range, m_context.mode());
     3160        return consumePaintStroke(m_range, m_context.mode);
    34393161    case CSSPropertyPaintOrder:
    34403162        return consumePaintOrder(m_range);
     
    34463168        return consumeNoneOrURI(m_range);
    34473169    case CSSPropertyFlexBasis:
    3448         return consumeFlexBasis(m_range, m_context.mode());
     3170        return consumeFlexBasis(m_range, m_context.mode);
    34493171    case CSSPropertyFlexGrow:
    34503172    case CSSPropertyFlexShrink:
     
    34533175        return consumeStrokeDasharray(m_range);
    34543176    case CSSPropertyColumnRuleWidth:
    3455         return consumeColumnRuleWidth(m_range, m_context.mode());
     3177        return consumeColumnRuleWidth(m_range, m_context.mode);
    34563178    case CSSPropertyStrokeOpacity:
    34573179    case CSSPropertyFillOpacity:
     
    34783200    case CSSPropertyCursor:
    34793201        return consumeCursor(m_range, m_context, inQuirksMode());
    3480     case CSSPropertyContain:
    3481         return consumeContain(m_range);
    34823202    case CSSPropertyTransformOrigin:
    3483         return consumeTransformOrigin(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3203        return consumeTransformOrigin(m_range, m_context.mode, UnitlessQuirk::Forbid);
    34843204    case CSSPropertyContent:
    34853205        return consumeContent(m_range, m_context);
     
    34893209        return consumeImageOrNone(m_range, m_context);
    34903210    case CSSPropertyPerspective:
    3491         return consumePerspective(m_range, m_context.mode(), unresolvedProperty);
    3492     case CSSPropertyScrollSnapCoordinate:
    3493         return consumeScrollSnapCoordinate(m_range, m_context.mode());
    3494     case CSSPropertyScrollSnapPointsX:
    3495     case CSSPropertyScrollSnapPointsY:
    3496         return consumeScrollSnapPoints(m_range, m_context.mode());
     3211        return consumePerspective(m_range, m_context.mode);
     3212    case CSSPropertyWebkitScrollSnapCoordinate:
     3213        return consumeScrollSnapCoordinate(m_range, m_context.mode);
     3214    case CSSPropertyWebkitScrollSnapPointsX:
     3215    case CSSPropertyWebkitScrollSnapPointsY:
     3216        return consumeScrollSnapPoints(m_range, m_context.mode);
    34973217    case CSSPropertyBorderTopRightRadius:
    34983218    case CSSPropertyBorderTopLeftRadius:
    34993219    case CSSPropertyBorderBottomLeftRadius:
    35003220    case CSSPropertyBorderBottomRightRadius:
    3501         return consumeBorderRadiusCorner(m_range, m_context.mode());
     3221        return consumeBorderRadiusCorner(m_range, m_context.mode);
    35023222    case CSSPropertyWebkitBoxFlexGroup:
    35033223        return consumeInteger(m_range, 0);
    35043224    case CSSPropertyOrder:
    35053225        return consumeInteger(m_range);
    3506     case CSSPropertyTextUnderlinePosition:
     3226    case CSSPropertyWebkitTextUnderlinePosition:
    35073227        // auto | [ under || [ left | right ] ], but we only support auto | under for now
    3508         ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
    35093228        return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range);
    35103229    case CSSPropertyVerticalAlign:
    3511         return consumeVerticalAlign(m_range, m_context.mode());
    3512     case CSSPropertyShapeOutside:
     3230        return consumeVerticalAlign(m_range, m_context.mode);
     3231    case CSSPropertyWebkitShapeOutside:
    35133232        return consumeShapeOutside(m_range, m_context);
    35143233    case CSSPropertyWebkitClipPath:
     
    35163235    case CSSPropertyJustifyContent:
    35173236    case CSSPropertyAlignContent:
    3518         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35193237        return consumeContentDistributionOverflowPosition(m_range);
    35203238    case CSSPropertyBorderImageRepeat:
     
    35343252    case CSSPropertyWebkitBoxReflect:
    35353253        return consumeReflect(m_range, m_context);
    3536     case CSSPropertyFontSizeAdjust:
    3537         ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled());
    3538         return consumeFontSizeAdjust(m_range);
     3254#if ENABLE(CSS_IMAGE_ORIENTATION)
    35393255    case CSSPropertyImageOrientation:
    3540         ASSERT(RuntimeEnabledFeatures::imageOrientationEnabled());
    35413256        return consumeImageOrientation(m_range);
     3257#endif
    35423258    case CSSPropertyBackgroundAttachment:
    35433259    case CSSPropertyBackgroundBlendMode:
     
    35483264    case CSSPropertyBackgroundPositionY:
    35493265    case CSSPropertyBackgroundSize:
    3550     case CSSPropertyMaskSourceType:
    35513266    case CSSPropertyWebkitBackgroundClip:
    35523267    case CSSPropertyWebkitBackgroundOrigin:
     
    35583273    case CSSPropertyWebkitMaskPositionY:
    35593274    case CSSPropertyWebkitMaskSize:
    3560         return consumeCommaSeparatedBackgroundComponent(unresolvedProperty, m_range, m_context);
     3275        return consumeCommaSeparatedBackgroundComponent(property, m_range, m_context);
    35613276    case CSSPropertyWebkitMaskRepeatX:
    35623277    case CSSPropertyWebkitMaskRepeatY:
    35633278        return nullptr;
    35643279    case CSSPropertyAlignItems:
    3565         DCHECK(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35663280        return consumeAlignItems(m_range);
    35673281    case CSSPropertyJustifySelf:
    35683282    case CSSPropertyAlignSelf:
    3569         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35703283        return consumeSelfPositionOverflowPosition(m_range);
    35713284    case CSSPropertyJustifyItems:
    3572         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35733285        return consumeJustifyItems(m_range);
    35743286    case CSSPropertyGridColumnEnd:
     
    35763288    case CSSPropertyGridRowEnd:
    35773289    case CSSPropertyGridRowStart:
    3578         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35793290        return consumeGridLine(m_range);
    35803291    case CSSPropertyGridAutoColumns:
    35813292    case CSSPropertyGridAutoRows:
    3582         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    3583         return consumeGridTrackList(m_range, m_context.mode(), GridAuto);
     3293        return consumeGridTrackList(m_range, m_context.mode, GridAuto);
    35843294    case CSSPropertyGridTemplateColumns:
    35853295    case CSSPropertyGridTemplateRows:
    3586         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    3587         return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode());
     3296        return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode);
    35883297    case CSSPropertyGridTemplateAreas:
    3589         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35903298        return consumeGridTemplateAreas(m_range);
    35913299    case CSSPropertyGridAutoFlow:
    3592         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    35933300        return consumeGridAutoFlow(m_range);
    35943301    default:
     
    35973304}
    35983305
    3599 static CSSPrimitiveValue* consumeFontDisplay(CSSParserTokenRange& range)
    3600 {
    3601     return consumeIdent<CSSValueAuto, CSSValueBlock, CSSValueSwap, CSSValueFallback, CSSValueOptional>(range);
    3602 }
    3603 
    3604 static CSSValueList* consumeFontFaceUnicodeRange(CSSParserTokenRange& range)
    3605 {
    3606     CSSValueList* values = CSSValueList::createCommaSeparated();
     3306static RefPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParserTokenRange& range)
     3307{
     3308    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
    36073309
    36083310    do {
     
    36153317        if (start > end)
    36163318            return nullptr;
    3617         values->append(*CSSUnicodeRangeValue::create(start, end));
     3319        values->append(CSSUnicodeRangeValue::create(start, end));
    36183320    } while (consumeCommaIncludingWhitespace(range));
    36193321
     
    36213323}
    36223324
    3623 static CSSValue* consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)
     3325static RefPtr<CSSValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)
    36243326{
    36253327    String url = consumeUrlAsStringView(range).toString();
    36263328    if (url.isNull())
    36273329        return nullptr;
    3628     CSSFontFaceSrcValue* uriValue(CSSFontFaceSrcValue::create(url, context.completeURL(url), context.shouldCheckContentSecurityPolicy()));
    3629     uriValue->setReferrer(context.referrer());
     3330   
     3331    RefPtr<CSSFontFaceSrcValue> uriValue = CSSFontFaceSrcValue::create(context.completeURL(url));
    36303332
    36313333    if (range.peek().functionId() != CSSValueFormat)
     
    36423344}
    36433345
    3644 static CSSValue* consumeFontFaceSrcLocal(CSSParserTokenRange& range, const CSSParserContext& context)
     3346static RefPtr<CSSValue> consumeFontFaceSrcLocal(CSSParserTokenRange& range)
    36453347{
    36463348    CSSParserTokenRange args = consumeFunction(range);
    3647     ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = context.shouldCheckContentSecurityPolicy();
    36483349    if (args.peek().type() == StringToken) {
    36493350        const CSSParserToken& arg = args.consumeIncludingWhitespace();
    36503351        if (!args.atEnd())
    36513352            return nullptr;
    3652         return CSSFontFaceSrcValue::createLocal(arg.value().toString(), shouldCheckContentSecurityPolicy);
     3353        return CSSFontFaceSrcValue::createLocal(arg.value().toString());
    36533354    }
    36543355    if (args.peek().type() == IdentToken) {
     
    36563357        if (!args.atEnd())
    36573358            return nullptr;
    3658         return CSSFontFaceSrcValue::createLocal(familyName, shouldCheckContentSecurityPolicy);
     3359        return CSSFontFaceSrcValue::createLocal(familyName);
    36593360    }
    36603361    return nullptr;
    36613362}
    36623363
    3663 static CSSValueList* consumeFontFaceSrc(CSSParserTokenRange& range, const CSSParserContext& context)
    3664 {
    3665     CSSValueList* values = CSSValueList::createCommaSeparated();
     3364static RefPtr<CSSValueList> consumeFontFaceSrc(CSSParserTokenRange& range, const CSSParserContext& context)
     3365{
     3366    RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
    36663367
    36673368    do {
    36683369        const CSSParserToken& token = range.peek();
    3669         CSSValue* parsedValue = nullptr;
     3370        RefPtr<CSSValue> parsedValue;
    36703371        if (token.functionId() == CSSValueLocal)
    3671             parsedValue = consumeFontFaceSrcLocal(range, context);
     3372            parsedValue = consumeFontFaceSrcLocal(range);
    36723373        else
    36733374            parsedValue = consumeFontFaceSrcURI(range, context);
    36743375        if (!parsedValue)
    36753376            return nullptr;
    3676         values->append(*parsedValue);
     3377        values->append(parsedValue.releaseNonNull());
    36773378    } while (consumeCommaIncludingWhitespace(range));
    36783379    return values;
     
    36813382bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId)
    36823383{
    3683     CSSValue* parsedValue = nullptr;
     3384    RefPtr<CSSValue> parsedValue;
    36843385    switch (propId) {
    36853386    case CSSPropertyFontFamily:
     
    36943395        parsedValue = consumeFontFaceUnicodeRange(m_range);
    36953396        break;
    3696     case CSSPropertyFontDisplay:
    3697         parsedValue = consumeFontDisplay(m_range);
    3698         break;
    36993397    case CSSPropertyFontStretch:
    37003398    case CSSPropertyFontStyle: {
    37013399        CSSValueID id = m_range.consumeIncludingWhitespace().id();
    3702         if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode()))
    3703             return false;
    3704         parsedValue = CSSPrimitiveValue::createIdentifier(id);
     3400        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode))
     3401            return false;
     3402        parsedValue = CSSValuePool::singleton().createIdentifierValue(id);
    37053403        break;
    37063404    }
     
    37313429    if (!m_range.atEnd())
    37323430        return false;
    3733 
    3734     FontStyle fontStyle = FontStyleNormal;
    3735     FontWeight fontWeight = FontWeightNormal;
    3736     float fontSize = 0;
    3737     AtomicString fontFamily;
    3738     LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSize, fontFamily);
    3739 
    3740     addProperty(CSSPropertyFontStyle, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(fontStyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important);
    3741     addProperty(CSSPropertyFontWeight, CSSPropertyFont, *CSSPrimitiveValue::create(fontWeight), important);
    3742     addProperty(CSSPropertyFontSize, CSSPropertyFont, *CSSPrimitiveValue::create(fontSize, CSSPrimitiveValue::UnitType::Pixels), important);
    3743     CSSValueList* fontFamilyList = CSSValueList::createCommaSeparated();
    3744     fontFamilyList->append(*CSSFontFamilyValue::create(fontFamily));
    3745     addProperty(CSSPropertyFontFamily, CSSPropertyFont, *fontFamilyList, important);
    3746 
    3747     addProperty(CSSPropertyFontStretch, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3748     addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3749     addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3750     addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3751     addProperty(CSSPropertyLineHeight, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
     3431   
     3432    FontCascadeDescription fontDescription;
     3433    RenderTheme::defaultTheme()->systemFont(systemFontID, fontDescription);
     3434    if (!fontDescription.isAbsoluteSize())
     3435        return false;
     3436   
     3437    addProperty(CSSPropertyFontStyle, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(fontDescription.italic() == FontItalicOn ? CSSValueItalic : CSSValueNormal), important);
     3438    addProperty(CSSPropertyFontWeight, CSSPropertyFont, CSSValuePool::singleton().createValue(fontDescription.weight()), important);
     3439    addProperty(CSSPropertyFontSize, CSSPropertyFont, CSSValuePool::singleton().createValue(fontDescription.specifiedSize(), CSSPrimitiveValue::CSS_PX), important);
     3440    Ref<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
     3441    fontFamilyList->append(CSSValuePool::singleton().createFontFamilyValue(fontDescription.familyAt(0), FromSystemFontID::Yes));
     3442    addProperty(CSSPropertyFontFamily, CSSPropertyFont, WTFMove(fontFamilyList), important);
     3443    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3444    addProperty(CSSPropertyLineHeight, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3445
     3446    // FIXME_NEWPARSER: What about FontVariantNumeric and FontVariantLigatures?
     3447
    37523448    return true;
    37533449}
     
    37633459    }
    37643460    // Optional font-style, font-variant, font-stretch and font-weight.
    3765     CSSPrimitiveValue* fontStyle = nullptr;
    3766     CSSPrimitiveValue* fontVariantCaps = nullptr;
    3767     CSSPrimitiveValue* fontWeight = nullptr;
    3768     CSSPrimitiveValue* fontStretch = nullptr;
     3461    RefPtr<CSSPrimitiveValue> fontStyle;
     3462    RefPtr<CSSPrimitiveValue> fontVariantCaps;
     3463    RefPtr<CSSPrimitiveValue> fontWeight;
     3464    RefPtr<CSSPrimitiveValue> fontStretch;
    37693465    while (!m_range.atEnd()) {
    37703466        CSSValueID id = m_range.peek().id();
    3771         if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStyle, id, m_context.mode())) {
     3467        if (!fontStyle && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStyle, id, m_context.mode)) {
    37723468            fontStyle = consumeIdent(m_range);
    37733469            continue;
     
    37853481                continue;
    37863482        }
    3787         if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode()))
     3483        if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode))
    37883484            fontStretch = consumeIdent(m_range);
    37893485        else
     
    37943490        return false;
    37953491
    3796     addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? *fontStyle : *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3797     addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? *fontVariantCaps : *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3798     addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3799     addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3800 
    3801     addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? *fontWeight : *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
    3802     addProperty(CSSPropertyFontStretch, CSSPropertyFont, fontStretch ? *fontStretch : *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
     3492    addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3493    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? fontVariantCaps.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3494    addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3495    addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3496
     3497    addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? fontWeight.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
     3498    addProperty(CSSPropertyFontStretch, CSSPropertyFont, fontStretch ? fontStretch.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
    38033499
    38043500    // Now a font size _must_ come.
    3805     CSSValue* fontSize = consumeFontSize(m_range, m_context.mode());
     3501    RefPtr<CSSValue> fontSize = consumeFontSize(m_range, m_context.mode);
    38063502    if (!fontSize || m_range.atEnd())
    38073503        return false;
     
    38103506
    38113507    if (consumeSlashIncludingWhitespace(m_range)) {
    3812         CSSPrimitiveValue* lineHeight = consumeLineHeight(m_range, m_context.mode());
     3508        RefPtr<CSSPrimitiveValue> lineHeight = consumeLineHeight(m_range, m_context.mode);
    38133509        if (!lineHeight)
    38143510            return false;
    3815         addProperty(CSSPropertyLineHeight, CSSPropertyFont, *lineHeight, important);
     3511        addProperty(CSSPropertyLineHeight, CSSPropertyFont, lineHeight.releaseNonNull(), important);
    38163512    } else {
    3817         addProperty(CSSPropertyLineHeight, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
     3513        addProperty(CSSPropertyLineHeight, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
    38183514    }
    38193515
    38203516    // Font family must come now.
    3821     CSSValue* parsedFamilyValue = consumeFontFamily(m_range);
     3517    RefPtr<CSSValue> parsedFamilyValue = consumeFontFamily(m_range);
    38223518    if (!parsedFamilyValue)
    38233519        return false;
    38243520
    3825     addProperty(CSSPropertyFontFamily, CSSPropertyFont, *parsedFamilyValue, important);
     3521    addProperty(CSSPropertyFontFamily, CSSPropertyFont, parsedFamilyValue.releaseNonNull(), important);
    38263522
    38273523    // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires that
     
    38343530{
    38353531    if (identMatches<CSSValueNormal, CSSValueNone>(m_range.peek().id())) {
    3836         addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, *consumeIdent(m_range), important);
    3837         addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
     3532        addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, consumeIdent(m_range).releaseNonNull(), important);
     3533        addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
    38383534        return m_range.atEnd();
    38393535    }
    38403536
    3841     CSSPrimitiveValue* capsValue = nullptr;
     3537    RefPtr<CSSPrimitiveValue> capsValue;
    38423538    FontVariantLigaturesParser ligaturesParser;
    38433539    FontVariantNumericParser numericParser;
     
    38713567    } while (!m_range.atEnd());
    38723568
    3873     addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, *ligaturesParser.finalizeValue(), important);
    3874     addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, *numericParser.finalizeValue(), important);
    3875     addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, capsValue ? *capsValue : *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);
     3569    addProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, ligaturesParser.finalizeValue().releaseNonNull(), important);
     3570    addProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, numericParser.finalizeValue().releaseNonNull(), important);
     3571    addProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, capsValue ? capsValue.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important);
    38763572    return true;
    38773573}
     
    38793575bool CSSPropertyParser::consumeBorderSpacing(bool important)
    38803576{
    3881     CSSValue* horizontalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNonNegative, UnitlessQuirk::Allow);
     3577    RefPtr<CSSValue> horizontalSpacing = consumeLength(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Allow);
    38823578    if (!horizontalSpacing)
    38833579        return false;
    3884     CSSValue* verticalSpacing = horizontalSpacing;
     3580    RefPtr<CSSValue> verticalSpacing = horizontalSpacing;
    38853581    if (!m_range.atEnd())
    3886         verticalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNonNegative, UnitlessQuirk::Allow);
     3582        verticalSpacing = consumeLength(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Allow);
    38873583    if (!verticalSpacing || !m_range.atEnd())
    38883584        return false;
    3889     addProperty(CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyBorderSpacing, *horizontalSpacing, important);
    3890     addProperty(CSSPropertyWebkitBorderVerticalSpacing, CSSPropertyBorderSpacing, *verticalSpacing, important);
     3585    addProperty(CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyBorderSpacing, horizontalSpacing.releaseNonNull(), important);
     3586    addProperty(CSSPropertyWebkitBorderVerticalSpacing, CSSPropertyBorderSpacing, verticalSpacing.releaseNonNull(), important);
    38913587    return true;
    38923588}
    38933589
    3894 static CSSValue* consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSSPropertyID propId, CSSParserMode cssParserMode)
     3590#if ENABLE(CSS_DEVICE_ADAPTATION)
     3591
     3592static RefPtr<CSSValue> consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSSPropertyID propId, CSSParserMode cssParserMode)
    38953593{
    38963594    CSSValueID id = range.peek().id();
     
    39003598    case CSSPropertyMinHeight:
    39013599    case CSSPropertyMaxHeight:
    3902         if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom)
     3600        if (id == CSSValueAuto)
    39033601            return consumeIdent(range);
    39043602        return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
     
    39083606        if (id == CSSValueAuto)
    39093607            return consumeIdent(range);
    3910         CSSValue* parsedValue = consumeNumber(range, ValueRangeNonNegative);
     3608        RefPtr<CSSValue> parsedValue = consumeNumber(range, ValueRangeNonNegative);
    39113609        if (parsedValue)
    39123610            return parsedValue;
     
    39283626bool CSSPropertyParser::parseViewportDescriptor(CSSPropertyID propId, bool important)
    39293627{
    3930     ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_context.mode()));
    3931 
    39323628    switch (propId) {
    39333629    case CSSPropertyWidth: {
    3934         CSSValue* minWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMinWidth, m_context.mode());
     3630        RefPtr<CSSValue> minWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMinWidth, m_context.mode);
    39353631        if (!minWidth)
    39363632            return false;
    3937         CSSValue* maxWidth = minWidth;
     3633        RefPtr<CSSValue> maxWidth = minWidth;
    39383634        if (!m_range.atEnd())
    3939             maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWidth, m_context.mode());
     3635            maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWidth, m_context.mode);
    39403636        if (!maxWidth || !m_range.atEnd())
    39413637            return false;
     
    39453641    }
    39463642    case CSSPropertyHeight: {
    3947         CSSValue* minHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMinHeight, m_context.mode());
     3643        RefPtr<CSSValue> minHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMinHeight, m_context.mode);
    39483644        if (!minHeight)
    39493645            return false;
    3950         CSSValue* maxHeight = minHeight;
     3646        RefPtr<CSSValue> maxHeight = minHeight;
    39513647        if (!m_range.atEnd())
    3952             maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxHeight, m_context.mode());
     3648            maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxHeight, m_context.mode);
    39533649        if (!maxHeight || !m_range.atEnd())
    39543650            return false;
     
    39663662    case CSSPropertyUserZoom:
    39673663    case CSSPropertyOrientation: {
    3968         CSSValue* parsedValue = consumeSingleViewportDescriptor(m_range, propId, m_context.mode());
     3664        RefPtr<CSSValue> parsedValue = consumeSingleViewportDescriptor(m_range, propId, m_context.mode);
    39693665        if (!parsedValue || !m_range.atEnd())
    39703666            return false;
    3971         addProperty(propId, CSSPropertyInvalid, *parsedValue, important);
     3667        addProperty(propId, CSSPropertyInvalid, parsedValue.releaseNonNull(), important);
    39723668        return true;
    39733669    }
     
    39773673}
    39783674
    3979 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSValue*& columnWidth, CSSValue*& columnCount)
     3675#endif
     3676
     3677static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, RefPtr<CSSValue>& columnWidth, RefPtr<CSSValue>& columnCount)
    39803678{
    39813679    if (range.peek().id() == CSSValueAuto) {
     
    39953693bool CSSPropertyParser::consumeColumns(bool important)
    39963694{
    3997     CSSValue* columnWidth = nullptr;
    3998     CSSValue* columnCount = nullptr;
     3695    RefPtr<CSSValue> columnWidth;
     3696    RefPtr<CSSValue> columnCount;
    39993697    if (!consumeColumnWidthOrCount(m_range, columnWidth, columnCount))
    40003698        return false;
     
    40033701        return false;
    40043702    if (!columnWidth)
    4005         columnWidth = CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     3703        columnWidth = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    40063704    if (!columnCount)
    4007         columnCount = CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    4008     addProperty(CSSPropertyColumnWidth, CSSPropertyInvalid, *columnWidth, important);
    4009     addProperty(CSSPropertyColumnCount, CSSPropertyInvalid, *columnCount, important);
     3705        columnCount = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
     3706    addProperty(CSSPropertyColumnWidth, CSSPropertyInvalid, columnWidth.releaseNonNull(), important);
     3707    addProperty(CSSPropertyColumnCount, CSSPropertyInvalid, columnCount.releaseNonNull(), important);
    40103708    return true;
    40113709}
     
    40143712{
    40153713    ASSERT(shorthand.length() <= 6); // Existing shorthands have at most 6 longhands.
    4016     const CSSValue* longhands[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
     3714    RefPtr<CSSValue> longhands[6];
    40173715    const CSSPropertyID* shorthandProperties = shorthand.properties();
    40183716    do {
     
    40313729    for (size_t i = 0; i < shorthand.length(); ++i) {
    40323730        if (longhands[i])
    4033             addProperty(shorthandProperties[i], shorthand.id(), *longhands[i], important);
     3731            addProperty(shorthandProperties[i], shorthand.id(), longhands[i].releaseNonNull(), important);
    40343732        else
    4035             addProperty(shorthandProperties[i], shorthand.id(), *CSSInitialValue::createLegacyImplicit(), important);
     3733            addProperty(shorthandProperties[i], shorthand.id(), CSSValuePool::singleton().createImplicitInitialValue(), important);
    40363734    }
    40373735    return true;
     
    40433741    double flexGrow = unsetValue;
    40443742    double flexShrink = unsetValue;
    4045     CSSPrimitiveValue* flexBasis = nullptr;
     3743    RefPtr<CSSPrimitiveValue> flexBasis;
    40463744
    40473745    if (m_range.peek().id() == CSSValueNone) {
    40483746        flexGrow = 0;
    40493747        flexShrink = 0;
    4050         flexBasis = CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     3748        flexBasis = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    40513749        m_range.consumeIncludingWhitespace();
    40523750    } else {
     
    40623760                    flexShrink = num;
    40633761                else if (!num) // flex only allows a basis of 0 (sans units) if flex-grow and flex-shrink values have already been set.
    4064                     flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Pixels);
     3762                    flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PX);
    40653763                else
    40663764                    return false;
     
    40693767                    flexBasis = consumeIdent(m_range);
    40703768                if (!flexBasis)
    4071                     flexBasis = consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeNonNegative);
     3769                    flexBasis = consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative);
    40723770                if (index == 2 && !m_range.atEnd())
    40733771                    return false;
     
    40813779            flexShrink = 1;
    40823780        if (!flexBasis)
    4083             flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Percentage);
     3781            flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
    40843782    }
    40853783
    40863784    if (!m_range.atEnd())
    40873785        return false;
    4088     addProperty(CSSPropertyFlexGrow, CSSPropertyFlex, *CSSPrimitiveValue::create(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitType::Number), important);
    4089     addProperty(CSSPropertyFlexShrink, CSSPropertyFlex, *CSSPrimitiveValue::create(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitType::Number), important);
    4090     addProperty(CSSPropertyFlexBasis, CSSPropertyFlex, *flexBasis, important);
     3786    addProperty(CSSPropertyFlexGrow, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitTypes::CSS_NUMBER), important);
     3787    addProperty(CSSPropertyFlexShrink, CSSPropertyFlex, CSSPrimitiveValue::create(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitTypes::CSS_NUMBER), important);
     3788    addProperty(CSSPropertyFlexBasis, CSSPropertyFlex, flexBasis.releaseNonNull(), important);
    40913789    return true;
    40923790}
     
    40943792bool CSSPropertyParser::consumeBorder(bool important)
    40953793{
    4096     CSSValue* width = nullptr;
    4097     const CSSValue* style = nullptr;
    4098     CSSValue* color = nullptr;
     3794    RefPtr<CSSValue> width;
     3795    RefPtr<CSSValue> style;
     3796    RefPtr<CSSValue> color;
    40993797
    41003798    while (!width || !style || !color) {
    41013799        if (!width) {
    4102             width = consumeLineWidth(m_range, m_context.mode(), UnitlessQuirk::Forbid);
     3800            width = consumeLineWidth(m_range, m_context.mode, UnitlessQuirk::Forbid);
    41033801            if (width)
    41043802                continue;
     
    41103808        }
    41113809        if (!color) {
    4112             color = consumeColor(m_range, m_context.mode());
     3810            color = consumeColor(m_range, m_context.mode);
    41133811            if (color)
    41143812                continue;
     
    41213819
    41223820    if (!width)
    4123         width = CSSInitialValue::createLegacyImplicit();
     3821        width = CSSValuePool::singleton().createImplicitInitialValue();
    41243822    if (!style)
    4125         style = CSSInitialValue::createLegacyImplicit();
     3823        style = CSSValuePool::singleton().createImplicitInitialValue();
    41263824    if (!color)
    4127         color = CSSInitialValue::createLegacyImplicit();
    4128 
    4129     addExpandedPropertyForValue(CSSPropertyBorderWidth, *width, important);
    4130     addExpandedPropertyForValue(CSSPropertyBorderStyle, *style, important);
    4131     addExpandedPropertyForValue(CSSPropertyBorderColor, *color, important);
    4132     addExpandedPropertyForValue(CSSPropertyBorderImage, *CSSInitialValue::createLegacyImplicit(), important);
     3825        color = CSSValuePool::singleton().createImplicitInitialValue();
     3826
     3827    addExpandedPropertyForValue(CSSPropertyBorderWidth, width.releaseNonNull(), important);
     3828    addExpandedPropertyForValue(CSSPropertyBorderStyle, style.releaseNonNull(), important);
     3829    addExpandedPropertyForValue(CSSPropertyBorderColor, color.releaseNonNull(), important);
     3830    addExpandedPropertyForValue(CSSPropertyBorderImage, CSSValuePool::singleton().createImplicitInitialValue(), important);
    41333831
    41343832    return m_range.atEnd();
     
    41393837    ASSERT(shorthand.length() == 4);
    41403838    const CSSPropertyID* longhands = shorthand.properties();
    4141     const CSSValue* top = parseSingleValue(longhands[0], shorthand.id());
     3839    RefPtr<CSSValue> top = parseSingleValue(longhands[0], shorthand.id());
    41423840    if (!top)
    41433841        return false;
    41443842
    4145     const CSSValue* right = parseSingleValue(longhands[1], shorthand.id());
    4146     const CSSValue* bottom = nullptr;
    4147     const CSSValue* left = nullptr;
     3843    RefPtr<CSSValue> right = parseSingleValue(longhands[1], shorthand.id());
     3844    RefPtr<CSSValue> bottom;
     3845    RefPtr<CSSValue> left;
    41483846    if (right) {
    41493847        bottom = parseSingleValue(longhands[2], shorthand.id());
     
    41593857        left = right;
    41603858
    4161     addProperty(longhands[0], shorthand.id(), *top, important);
    4162     addProperty(longhands[1], shorthand.id(), *right, important);
    4163     addProperty(longhands[2], shorthand.id(), *bottom, important);
    4164     addProperty(longhands[3], shorthand.id(), *left, important);
     3859    addProperty(longhands[0], shorthand.id(), top.releaseNonNull(), important);
     3860    addProperty(longhands[1], shorthand.id(), right.releaseNonNull(), important);
     3861    addProperty(longhands[2], shorthand.id(), bottom.releaseNonNull(), important);
     3862    addProperty(longhands[3], shorthand.id(), left.releaseNonNull(), important);
    41653863
    41663864    return m_range.atEnd();
     
    41693867bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool important)
    41703868{
    4171     CSSValue* source = nullptr;
    4172     CSSValue* slice = nullptr;
    4173     CSSValue* width = nullptr;
    4174     CSSValue* outset = nullptr;
    4175     CSSValue* repeat = nullptr;
     3869    RefPtr<CSSValue> source;
     3870    RefPtr<CSSValue> slice;
     3871    RefPtr<CSSValue> width;
     3872    RefPtr<CSSValue> outset;
     3873    RefPtr<CSSValue> repeat;
     3874   
    41763875    if (consumeBorderImageComponents(property, m_range, m_context, source, slice, width, outset, repeat)) {
     3876        if (!source)
     3877            source = CSSValuePool::singleton().createImplicitInitialValue();
     3878        if (!slice)
     3879            slice = CSSValuePool::singleton().createImplicitInitialValue();
     3880        if (!width)
     3881            width = CSSValuePool::singleton().createImplicitInitialValue();
     3882        if (!outset)
     3883            outset = CSSValuePool::singleton().createImplicitInitialValue();
     3884        if (!repeat)
     3885            repeat = CSSValuePool::singleton().createImplicitInitialValue();
    41773886        switch (property) {
    41783887        case CSSPropertyWebkitMaskBoxImage:
    4179             addProperty(CSSPropertyWebkitMaskBoxImageSource, CSSPropertyWebkitMaskBoxImage, source ? *source : *CSSInitialValue::createLegacyImplicit(), important);
    4180             addProperty(CSSPropertyWebkitMaskBoxImageSlice, CSSPropertyWebkitMaskBoxImage, slice ? *slice : *CSSInitialValue::createLegacyImplicit(), important);
    4181             addProperty(CSSPropertyWebkitMaskBoxImageWidth, CSSPropertyWebkitMaskBoxImage, width ? *width : *CSSInitialValue::createLegacyImplicit(), important);
    4182             addProperty(CSSPropertyWebkitMaskBoxImageOutset, CSSPropertyWebkitMaskBoxImage, outset ? *outset : *CSSInitialValue::createLegacyImplicit(), important);
    4183             addProperty(CSSPropertyWebkitMaskBoxImageRepeat, CSSPropertyWebkitMaskBoxImage, repeat ? *repeat : *CSSInitialValue::createLegacyImplicit(), important);
     3888            addProperty(CSSPropertyWebkitMaskBoxImageSource, CSSPropertyWebkitMaskBoxImage, source.releaseNonNull(), important);
     3889            addProperty(CSSPropertyWebkitMaskBoxImageSlice, CSSPropertyWebkitMaskBoxImage, slice.releaseNonNull(), important);
     3890            addProperty(CSSPropertyWebkitMaskBoxImageWidth, CSSPropertyWebkitMaskBoxImage, width.releaseNonNull(), important);
     3891            addProperty(CSSPropertyWebkitMaskBoxImageOutset, CSSPropertyWebkitMaskBoxImage, outset.releaseNonNull(), important);
     3892            addProperty(CSSPropertyWebkitMaskBoxImageRepeat, CSSPropertyWebkitMaskBoxImage, repeat.releaseNonNull(), important);
    41843893            return true;
    41853894        case CSSPropertyBorderImage:
    4186             addProperty(CSSPropertyBorderImageSource, CSSPropertyBorderImage, source ? *source : *CSSInitialValue::createLegacyImplicit(), important);
    4187             addProperty(CSSPropertyBorderImageSlice, CSSPropertyBorderImage, slice ? *slice : *CSSInitialValue::createLegacyImplicit(), important);
    4188             addProperty(CSSPropertyBorderImageWidth, CSSPropertyBorderImage, width ? *width : *CSSInitialValue::createLegacyImplicit(), important);
    4189             addProperty(CSSPropertyBorderImageOutset, CSSPropertyBorderImage, outset ? *outset : *CSSInitialValue::createLegacyImplicit(), important);
    4190             addProperty(CSSPropertyBorderImageRepeat, CSSPropertyBorderImage, repeat ? *repeat : *CSSInitialValue::createLegacyImplicit(), important);
     3895            addProperty(CSSPropertyBorderImageSource, CSSPropertyBorderImage, source.releaseNonNull(), important);
     3896            addProperty(CSSPropertyBorderImageSlice, CSSPropertyBorderImage, slice.releaseNonNull(), important);
     3897            addProperty(CSSPropertyBorderImageWidth, CSSPropertyBorderImage, width.releaseNonNull() , important);
     3898            addProperty(CSSPropertyBorderImageOutset, CSSPropertyBorderImage, outset.releaseNonNull(), important);
     3899            addProperty(CSSPropertyBorderImageRepeat, CSSPropertyBorderImage, repeat.releaseNonNull(), important);
    41913900            return true;
    41923901        default:
     
    42383947    // shorthands for their break-(after|before|inside) counterparts. We'll do the same for the
    42393948    // non-standard properties -webkit-column-break-(after|before|inside).
    4240     CSSPrimitiveValue* keyword = consumeIdent(m_range);
     3949    RefPtr<CSSPrimitiveValue> keyword = consumeIdent(m_range);
    42413950    if (!keyword)
    42423951        return false;
     
    42643973
    42653974    CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property);
    4266     addProperty(genericBreakProperty, property, *CSSPrimitiveValue::createIdentifier(value), important);
     3975    addProperty(genericBreakProperty, property, CSSValuePool::singleton().createIdentifierValue(value), important);
    42673976    return true;
    42683977}
    42693978
    4270 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& resultY)
     3979static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless, RefPtr<CSSValue>& resultX, RefPtr<CSSValue>& resultY)
    42713980{
    42723981    do {
    4273         CSSValue* positionX = nullptr;
    4274         CSSValue* positionY = nullptr;
    4275         if (!consumePosition(range, context.mode(), unitless, positionX, positionY))
    4276             return false;
    4277         addBackgroundValue(resultX, positionX);
    4278         addBackgroundValue(resultY, positionY);
     3982        RefPtr<CSSPrimitiveValue> positionX;
     3983        RefPtr<CSSPrimitiveValue> positionY;
     3984        if (!consumePosition(range, context.mode, unitless, positionX, positionY))
     3985            return false;
     3986        addBackgroundValue(resultX, positionX.releaseNonNull());
     3987        addBackgroundValue(resultY, positionY.releaseNonNull());
    42793988    } while (consumeCommaIncludingWhitespace(range));
    42803989    return true;
    42813990}
    42823991
    4283 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, CSSValue*& value1, CSSValue*& value2, bool& implicit)
     3992static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, RefPtr<CSSPrimitiveValue>& value1, RefPtr<CSSPrimitiveValue>& value2, bool& implicit)
    42843993{
    42853994    if (consumeIdent<CSSValueRepeatX>(range)) {
    4286         value1 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
    4287         value2 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
     3995        value1 = CSSValuePool::singleton().createIdentifierValue(CSSValueRepeat);
     3996        value2 = CSSValuePool::singleton().createIdentifierValue(CSSValueNoRepeat);
    42883997        implicit = true;
    42893998        return true;
    42903999    }
    42914000    if (consumeIdent<CSSValueRepeatY>(range)) {
    4292         value1 = CSSPrimitiveValue::createIdentifier(CSSValueNoRepeat);
    4293         value2 = CSSPrimitiveValue::createIdentifier(CSSValueRepeat);
     4001        value1 = CSSValuePool::singleton().createIdentifierValue(CSSValueNoRepeat);
     4002        value2 = CSSValuePool::singleton().createIdentifierValue(CSSValueRepeat);
    42944003        implicit = true;
    42954004        return true;
     
    43074016}
    43084017
    4309 static bool consumeRepeatStyle(CSSParserTokenRange& range, CSSValue*& resultX, CSSValue*& resultY, bool& implicit)
     4018static bool consumeRepeatStyle(CSSParserTokenRange& range, RefPtr<CSSValue>& resultX, RefPtr<CSSValue>& resultY, bool& implicit)
    43104019{
    43114020    do {
    4312         CSSValue* repeatX = nullptr;
    4313         CSSValue* repeatY = nullptr;
     4021        RefPtr<CSSPrimitiveValue> repeatX;
     4022        RefPtr<CSSPrimitiveValue> repeatY;
    43144023        if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit))
    43154024            return false;
    4316         addBackgroundValue(resultX, repeatX);
    4317         addBackgroundValue(resultY, repeatY);
     4025        addBackgroundValue(resultX, repeatX.releaseNonNull());
     4026        addBackgroundValue(resultY, repeatY.releaseNonNull());
    43184027    } while (consumeCommaIncludingWhitespace(range));
    43194028    return true;
     
    43254034{
    43264035    const unsigned longhandCount = shorthand.length();
    4327     CSSValue* longhands[10] = { 0 };
     4036    RefPtr<CSSValue> longhands[10];
    43284037    ASSERT(longhandCount <= 10);
    43294038
     
    43314040    do {
    43324041        bool parsedLonghand[10] = { false };
    4333         CSSValue* originValue = nullptr;
     4042        RefPtr<CSSValue> originValue;
    43344043        do {
    43354044            bool foundProperty = false;
     
    43384047                    continue;
    43394048
    4340                 CSSValue* value = nullptr;
    4341                 CSSValue* valueY = nullptr;
     4049                RefPtr<CSSValue> value;
     4050                RefPtr<CSSValue> valueY;
    43424051                CSSPropertyID property = shorthand.properties()[i];
    43434052                if (property == CSSPropertyBackgroundRepeatX || property == CSSPropertyWebkitMaskRepeatX) {
    4344                     consumeRepeatStyleComponent(m_range, value, valueY, implicit);
     4053                    RefPtr<CSSPrimitiveValue> primitiveValue;
     4054                    RefPtr<CSSPrimitiveValue> primitiveValueY;
     4055                    consumeRepeatStyleComponent(m_range, primitiveValue, primitiveValueY, implicit);
     4056                    value = primitiveValue;
     4057                    valueY = primitiveValueY;
    43454058                } else if (property == CSSPropertyBackgroundPositionX || property == CSSPropertyWebkitMaskPositionX) {
    43464059                    CSSParserTokenRange rangeCopy = m_range;
    4347                     if (!consumePosition(rangeCopy, m_context.mode(), UnitlessQuirk::Forbid, value, valueY))
     4060                    RefPtr<CSSPrimitiveValue> primitiveValue;
     4061                    RefPtr<CSSPrimitiveValue> primitiveValueY;
     4062                    if (!consumePosition(rangeCopy, m_context.mode, UnitlessQuirk::Forbid, primitiveValue, primitiveValueY))
    43484063                        continue;
     4064                    value = primitiveValue;
     4065                    valueY = primitiveValueY;
    43494066                    m_range = rangeCopy;
    43504067                } else if (property == CSSPropertyBackgroundSize || property == CSSPropertyWebkitMaskSize) {
    43514068                    if (!consumeSlashIncludingWhitespace(m_range))
    43524069                        continue;
    4353                     value = consumeBackgroundSize(property, m_range, m_context.mode());
     4070                    value = consumeBackgroundSize(property, m_range, m_context.mode);
    43544071                    if (!value || !parsedLonghand[i - 1]) // Position must have been parsed in the current layer.
    43554072                        return false;
     
    43654082                    parsedLonghand[i] = true;
    43664083                    foundProperty = true;
    4367                     addBackgroundValue(longhands[i], value);
     4084                    addBackgroundValue(longhands[i], value.releaseNonNull());
    43684085                    if (valueY) {
    43694086                        parsedLonghand[i + 1] = true;
    4370                         addBackgroundValue(longhands[i + 1], valueY);
     4087                        addBackgroundValue(longhands[i + 1], valueY.releaseNonNull());
    43714088                    }
    43724089                }
     
    43854102            }
    43864103            if ((property == CSSPropertyBackgroundClip || property == CSSPropertyWebkitMaskClip) && !parsedLonghand[i] && originValue) {
    4387                 addBackgroundValue(longhands[i], originValue);
     4104                addBackgroundValue(longhands[i], originValue.releaseNonNull());
    43884105                continue;
    43894106            }
    43904107            if (!parsedLonghand[i])
    4391                 addBackgroundValue(longhands[i], CSSInitialValue::createLegacyImplicit());
     4108                addBackgroundValue(longhands[i], CSSValuePool::singleton().createImplicitInitialValue());
    43924109        }
    43934110    } while (consumeCommaIncludingWhitespace(m_range));
     
    43974114    for (size_t i = 0; i < longhandCount; ++i) {
    43984115        CSSPropertyID property = shorthand.properties()[i];
    4399         if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.useLegacyBackgroundSizeShorthandBehavior())
     4116        if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.useLegacyBackgroundSizeShorthandBehavior)
    44004117            continue;
    44014118        addProperty(property, shorthand.id(), *longhands[i], important, implicit);
     
    44064123bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthandId, bool important)
    44074124{
    4408     ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    44094125    const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId);
    44104126    ASSERT(shorthand.length() == 2);
    4411     CSSValue* startValue = consumeGridLine(m_range);
     4127    RefPtr<CSSValue> startValue = consumeGridLine(m_range);
    44124128    if (!startValue)
    44134129        return false;
    44144130
    4415     CSSValue* endValue = nullptr;
     4131    RefPtr<CSSValue> endValue;
    44164132    if (consumeSlashIncludingWhitespace(m_range)) {
    44174133        endValue = consumeGridLine(m_range);
     
    44194135            return false;
    44204136    } else {
    4421         endValue = startValue->isCustomIdentValue() ? startValue : CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     4137        endValue = startValue->isCustomIdentValue() ? startValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    44224138    }
    44234139    if (!m_range.atEnd())
    44244140        return false;
    4425     addProperty(shorthand.properties()[0], shorthandId, *startValue, important);
    4426     addProperty(shorthand.properties()[1], shorthandId, *endValue, important);
     4141    addProperty(shorthand.properties()[0], shorthandId, startValue.releaseNonNull(), important);
     4142    addProperty(shorthand.properties()[1], shorthandId, endValue.releaseNonNull(), important);
    44274143    return true;
    44284144}
     
    44304146bool CSSPropertyParser::consumeGridAreaShorthand(bool important)
    44314147{
    4432     ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    4433     ASSERT(gridAreaShorthand().length() == 4);
    4434     CSSValue* rowStartValue = consumeGridLine(m_range);
     4148    RefPtr<CSSValue> rowStartValue = consumeGridLine(m_range);
    44354149    if (!rowStartValue)
    44364150        return false;
    4437     CSSValue* columnStartValue = nullptr;
    4438     CSSValue* rowEndValue = nullptr;
    4439     CSSValue* columnEndValue = nullptr;
     4151    RefPtr<CSSValue> columnStartValue;
     4152    RefPtr<CSSValue> rowEndValue;
     4153    RefPtr<CSSValue> columnEndValue;
    44404154    if (consumeSlashIncludingWhitespace(m_range)) {
    44414155        columnStartValue = consumeGridLine(m_range);
     
    44564170        return false;
    44574171    if (!columnStartValue)
    4458         columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     4172        columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    44594173    if (!rowEndValue)
    4460         rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     4174        rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    44614175    if (!columnEndValue)
    4462         columnEndValue = columnStartValue->isCustomIdentValue() ? columnStartValue : CSSPrimitiveValue::createIdentifier(CSSValueAuto);
    4463 
    4464     addProperty(CSSPropertyGridRowStart, CSSPropertyGridArea, *rowStartValue, important);
    4465     addProperty(CSSPropertyGridColumnStart, CSSPropertyGridArea, *columnStartValue, important);
    4466     addProperty(CSSPropertyGridRowEnd, CSSPropertyGridArea, *rowEndValue, important);
    4467     addProperty(CSSPropertyGridColumnEnd, CSSPropertyGridArea, *columnEndValue, important);
     4176        columnEndValue = columnStartValue->isCustomIdentValue() ? columnStartValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
     4177
     4178    addProperty(CSSPropertyGridRowStart, CSSPropertyGridArea, rowStartValue.releaseNonNull(), important);
     4179    addProperty(CSSPropertyGridColumnStart, CSSPropertyGridArea, columnStartValue.releaseNonNull(), important);
     4180    addProperty(CSSPropertyGridRowEnd, CSSPropertyGridArea, rowEndValue.releaseNonNull(), important);
     4181    addProperty(CSSPropertyGridColumnEnd, CSSPropertyGridArea, columnEndValue.releaseNonNull(), important);
    44684182    return true;
    44694183}
     
    44744188    size_t rowCount = 0;
    44754189    size_t columnCount = 0;
    4476     CSSValueList* templateRows = CSSValueList::createSpaceSeparated();
     4190    RefPtr<CSSValueList> templateRows = CSSValueList::createSpaceSeparated();
    44774191
    44784192    // Persists between loop iterations so we can use the same value for
    44794193    // consecutive <line-names> values
    4480     CSSGridLineNamesValue* lineNames = nullptr;
     4194    RefPtr<CSSGridLineNamesValue> lineNames;
    44814195
    44824196    do {
    44834197        // Handle leading <custom-ident>*.
    44844198        bool hasPreviousLineNames = lineNames;
    4485         lineNames = consumeGridLineNames(m_range, lineNames);
     4199        lineNames = consumeGridLineNames(m_range, lineNames.get());
    44864200        if (lineNames && !hasPreviousLineNames)
    44874201            templateRows->append(*lineNames);
     
    44934207
    44944208        // Handle template-rows's track-size.
    4495         CSSValue* value = consumeGridTrackSize(m_range, m_context.mode());
     4209        RefPtr<CSSValue> value = consumeGridTrackSize(m_range, m_context.mode);
    44964210        if (!value)
    4497             value = CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     4211            value = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    44984212        templateRows->append(*value);
    44994213
     
    45014215        lineNames = consumeGridLineNames(m_range);
    45024216        if (lineNames)
    4503             templateRows->append(*lineNames);
     4217            templateRows->append(lineNames.releaseNonNull());
    45044218    } while (!m_range.atEnd() && !(m_range.peek().type() == DelimiterToken && m_range.peek().delimiter() == '/'));
    45054219
    4506     CSSValue* columnsValue = nullptr;
     4220    RefPtr<CSSValue> columnsValue;
    45074221    if (!m_range.atEnd()) {
    45084222        if (!consumeSlashIncludingWhitespace(m_range))
    45094223            return false;
    4510         columnsValue = consumeGridTrackList(m_range, m_context.mode(), GridTemplateNoRepeat);
     4224        columnsValue = consumeGridTrackList(m_range, m_context.mode, GridTemplateNoRepeat);
    45114225        if (!columnsValue || !m_range.atEnd())
    45124226            return false;
    45134227    } else {
    4514         columnsValue = CSSPrimitiveValue::createIdentifier(CSSValueNone);
    4515     }
    4516     addProperty(CSSPropertyGridTemplateRows, shorthandId, *templateRows, important);
    4517     addProperty(CSSPropertyGridTemplateColumns, shorthandId, *columnsValue, important);
    4518     addProperty(CSSPropertyGridTemplateAreas, shorthandId, *CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount), important);
     4228        columnsValue = CSSValuePool::singleton().createIdentifierValue(CSSValueNone);
     4229    }
     4230    addProperty(CSSPropertyGridTemplateRows, shorthandId, templateRows.releaseNonNull(), important);
     4231    addProperty(CSSPropertyGridTemplateColumns, shorthandId, columnsValue.releaseNonNull(), important);
     4232    addProperty(CSSPropertyGridTemplateAreas, shorthandId, CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount), important);
    45194233    return true;
    45204234}
     
    45224236bool CSSPropertyParser::consumeGridTemplateShorthand(CSSPropertyID shorthandId, bool important)
    45234237{
    4524     ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    4525     ASSERT(gridTemplateShorthand().length() == 3);
    4526 
    45274238    CSSParserTokenRange rangeCopy = m_range;
    4528     CSSValue* rowsValue = consumeIdent<CSSValueNone>(m_range);
     4239    RefPtr<CSSValue> rowsValue = consumeIdent<CSSValueNone>(m_range);
    45294240
    45304241    // 1- 'none' case.
    45314242    if (rowsValue && m_range.atEnd()) {
    4532         addProperty(CSSPropertyGridTemplateRows, shorthandId, *CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
    4533         addProperty(CSSPropertyGridTemplateColumns, shorthandId, *CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
    4534         addProperty(CSSPropertyGridTemplateAreas, shorthandId, *CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
     4243        addProperty(CSSPropertyGridTemplateRows, shorthandId, CSSValuePool::singleton().createIdentifierValue(CSSValueNone), important);
     4244        addProperty(CSSPropertyGridTemplateColumns, shorthandId, CSSValuePool::singleton().createIdentifierValue(CSSValueNone), important);
     4245        addProperty(CSSPropertyGridTemplateAreas, shorthandId, CSSValuePool::singleton().createIdentifierValue(CSSValueNone), important);
    45354246        return true;
    45364247    }
     
    45384249    // 2- <grid-template-rows> / <grid-template-columns>
    45394250    if (!rowsValue)
    4540         rowsValue = consumeGridTrackList(m_range, m_context.mode(), GridTemplate);
     4251        rowsValue = consumeGridTrackList(m_range, m_context.mode, GridTemplate);
    45414252
    45424253    if (rowsValue) {
    45434254        if (!consumeSlashIncludingWhitespace(m_range))
    45444255            return false;
    4545         CSSValue* columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_context.mode());
     4256        RefPtr<CSSValue> columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_context.mode);
    45464257        if (!columnsValue || !m_range.atEnd())
    45474258            return false;
    45484259
    4549         addProperty(CSSPropertyGridTemplateRows, shorthandId, *rowsValue, important);
    4550         addProperty(CSSPropertyGridTemplateColumns, shorthandId, *columnsValue, important);
    4551         addProperty(CSSPropertyGridTemplateAreas, shorthandId, *CSSPrimitiveValue::createIdentifier(CSSValueNone), important);
     4260        addProperty(CSSPropertyGridTemplateRows, shorthandId, rowsValue.releaseNonNull(), important);
     4261        addProperty(CSSPropertyGridTemplateColumns, shorthandId, columnsValue.releaseNonNull(), important);
     4262        addProperty(CSSPropertyGridTemplateAreas, shorthandId, CSSValuePool::singleton().createIdentifierValue(CSSValueNone), important);
    45524263        return true;
    45534264    }
     
    45604271bool CSSPropertyParser::consumeGridShorthand(bool important)
    45614272{
    4562     ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
    45634273    ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8);
    45644274
     
    45694279        // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
    45704280        // The sub-properties not specified are set to their initial value, as normal for shorthands.
    4571         addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4572         addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4573         addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4574         addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4575         addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
     4281        addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4282        addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4283        addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4284        addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4285        addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
    45764286        return true;
    45774287    }
     
    45804290
    45814291    // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ]
    4582     CSSValueList* gridAutoFlow = consumeGridAutoFlow(m_range);
     4292    RefPtr<CSSValueList> gridAutoFlow = consumeGridAutoFlow(m_range);
    45834293    if (!gridAutoFlow)
    45844294        return false;
    45854295
    4586     CSSValue* autoColumnsValue = nullptr;
    4587     CSSValue* autoRowsValue = nullptr;
     4296    RefPtr<CSSValue> autoColumnsValue;
     4297    RefPtr<CSSValue> autoRowsValue;
    45884298
    45894299    if (!m_range.atEnd()) {
    4590         autoRowsValue = consumeGridTrackList(m_range, m_context.mode(), GridAuto);
     4300        autoRowsValue = consumeGridTrackList(m_range, m_context.mode, GridAuto);
    45914301        if (!autoRowsValue)
    45924302            return false;
    45934303        if (consumeSlashIncludingWhitespace(m_range)) {
    4594             autoColumnsValue = consumeGridTrackList(m_range, m_context.mode(), GridAuto);
     4304            autoColumnsValue = consumeGridTrackList(m_range, m_context.mode, GridAuto);
    45954305            if (!autoColumnsValue)
    45964306                return false;
     
    46004310    } else {
    46014311        // Other omitted values are set to their initial values.
    4602         autoColumnsValue = CSSInitialValue::createLegacyImplicit();
    4603         autoRowsValue = CSSInitialValue::createLegacyImplicit();
     4312        autoColumnsValue = CSSValuePool::singleton().createImplicitInitialValue();
     4313        autoRowsValue = CSSValuePool::singleton().createImplicitInitialValue();
    46044314    }
    46054315
     
    46104320    // It can only be specified the explicit or the implicit grid properties in a single grid declaration.
    46114321    // The sub-properties not specified are set to their initial value, as normal for shorthands.
    4612     addProperty(CSSPropertyGridTemplateColumns, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4613     addProperty(CSSPropertyGridTemplateRows, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4614     addProperty(CSSPropertyGridTemplateAreas, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4615     addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, *gridAutoFlow, important);
    4616     addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, *autoColumnsValue, important);
    4617     addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, *autoRowsValue, important);
    4618     addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
    4619     addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, *CSSInitialValue::createLegacyImplicit(), important);
     4322    addProperty(CSSPropertyGridTemplateColumns, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4323    addProperty(CSSPropertyGridTemplateRows, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4324    addProperty(CSSPropertyGridTemplateAreas, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4325    addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, gridAutoFlow.releaseNonNull(), important);
     4326    addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, autoColumnsValue.releaseNonNull(), important);
     4327    addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, autoRowsValue.releaseNonNull(), important);
     4328    addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
     4329    addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, CSSValuePool::singleton().createImplicitInitialValue(), important);
    46204330    return true;
    46214331}
    46224332
    4623 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool important)
    4624 {
    4625     CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
    4626 
     4333bool CSSPropertyParser::parseShorthand(CSSPropertyID property, bool important)
     4334{
    46274335    switch (property) {
    46284336    case CSSPropertyWebkitMarginCollapse: {
    46294337        CSSValueID id = m_range.consumeIncludingWhitespace().id();
    4630         if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginBeforeCollapse, id, m_context.mode()))
    4631             return false;
    4632         CSSValue* beforeCollapse = CSSPrimitiveValue::createIdentifier(id);
    4633         addProperty(CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginCollapse, *beforeCollapse, important);
     4338        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginBeforeCollapse, id, m_context.mode))
     4339            return false;
     4340        RefPtr<CSSValue> beforeCollapse = CSSValuePool::singleton().createIdentifierValue(id);
     4341        addProperty(CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarginCollapse, beforeCollapse.releaseNonNull(), important);
    46344342        if (m_range.atEnd()) {
    4635             addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, *beforeCollapse, important);
     4343            addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, beforeCollapse.releaseNonNull(), important);
    46364344            return true;
    46374345        }
    46384346        id = m_range.consumeIncludingWhitespace().id();
    4639         if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginAfterCollapse, id, m_context.mode()))
    4640             return false;
    4641         addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, *CSSPrimitiveValue::createIdentifier(id), important);
     4347        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebkitMarginAfterCollapse, id, m_context.mode))
     4348            return false;
     4349        addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, CSSValuePool::singleton().createIdentifierValue(id), important);
    46424350        return true;
    46434351    }
    46444352    case CSSPropertyOverflow: {
    46454353        CSSValueID id = m_range.consumeIncludingWhitespace().id();
    4646         if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode()))
     4354        if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode))
    46474355            return false;
    46484356        if (!m_range.atEnd())
    46494357            return false;
    4650         CSSValue* overflowYValue = CSSPrimitiveValue::createIdentifier(id);
    4651 
    4652         CSSValue* overflowXValue = nullptr;
     4358        RefPtr<CSSValue> overflowYValue = CSSValuePool::singleton().createIdentifierValue(id);
     4359        RefPtr<CSSValue> overflowXValue;
    46534360
    46544361        // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. If this value has been
     
    46574364        // paged-x or paged-y, then overflow-x and overflow-y should have the same value.
    46584365        if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY)
    4659             overflowXValue = CSSPrimitiveValue::createIdentifier(CSSValueAuto);
     4366            overflowXValue = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto);
    46604367        else
    46614368            overflowXValue = overflowYValue;
     
    46774384        return consumeColumns(important);
    46784385    case CSSPropertyAnimation:
    4679         return consumeAnimationShorthand(animationShorthandForParsing(), unresolvedProperty == CSSPropertyAliasWebkitAnimation, important);
     4386        return consumeAnimationShorthand(animationShorthandForParsing(), important);
    46804387    case CSSPropertyTransition:
    4681         return consumeAnimationShorthand(transitionShorthandForParsing(), false, important);
     4388        return consumeAnimationShorthand(transitionShorthandForParsing(), important);
    46824389    case CSSPropertyTextDecoration:
    4683         ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());
    4684         return consumeShorthandGreedily(textDecorationShorthand(), important);
     4390        return consumeShorthandGreedily(webkitTextDecorationShorthand(), important);
    46854391    case CSSPropertyMargin:
    46864392        return consume4Values(marginShorthand(), important);
    46874393    case CSSPropertyPadding:
    46884394        return consume4Values(paddingShorthand(), important);
    4689     case CSSPropertyMotion:
    4690         return consumeShorthandGreedily(motionShorthand(), important);
    46914395    case CSSPropertyWebkitTextEmphasis:
    46924396        return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important);
     
    47044408        return consumeShorthandGreedily(webkitTextStrokeShorthand(), important);
    47054409    case CSSPropertyMarker: {
    4706         const CSSValue* marker = parseSingleValue(CSSPropertyMarkerStart);
     4410        RefPtr<CSSValue> marker = parseSingleValue(CSSPropertyMarkerStart);
    47074411        if (!marker || !m_range.atEnd())
    47084412            return false;
    4709         addProperty(CSSPropertyMarkerStart, CSSPropertyMarker, *marker, important);
    4710         addProperty(CSSPropertyMarkerMid, CSSPropertyMarker, *marker, important);
    4711         addProperty(CSSPropertyMarkerEnd, CSSPropertyMarker, *marker, important);
     4413        addProperty(CSSPropertyMarkerStart, CSSPropertyMarker, marker.releaseNonNull(), important);
     4414        addProperty(CSSPropertyMarkerMid, CSSPropertyMarker, marker.releaseNonNull(), important);
     4415        addProperty(CSSPropertyMarkerEnd, CSSPropertyMarker, marker.releaseNonNull(), important);
    47124416        return true;
    47134417    }
     
    47214425        return consumeShorthandGreedily(listStyleShorthand(), important);
    47224426    case CSSPropertyBorderRadius: {
    4723         CSSPrimitiveValue* horizontalRadii[4] = { 0 };
    4724         CSSPrimitiveValue* verticalRadii[4] = { 0 };
    4725         if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mode(), unresolvedProperty == CSSPropertyAliasWebkitBorderRadius))
    4726             return false;
    4727         addProperty(CSSPropertyBorderTopLeftRadius, CSSPropertyBorderRadius, *CSSValuePair::create(horizontalRadii[0], verticalRadii[0], CSSValuePair::DropIdenticalValues), important);
    4728         addProperty(CSSPropertyBorderTopRightRadius, CSSPropertyBorderRadius, *CSSValuePair::create(horizontalRadii[1], verticalRadii[1], CSSValuePair::DropIdenticalValues), important);
    4729         addProperty(CSSPropertyBorderBottomRightRadius, CSSPropertyBorderRadius, *CSSValuePair::create(horizontalRadii[2], verticalRadii[2], CSSValuePair::DropIdenticalValues), important);
    4730         addProperty(CSSPropertyBorderBottomLeftRadius, CSSPropertyBorderRadius, *CSSValuePair::create(horizontalRadii[3], verticalRadii[3], CSSValuePair::DropIdenticalValues), important);
     4427        RefPtr<CSSPrimitiveValue> horizontalRadii[4];
     4428        RefPtr<CSSPrimitiveValue> verticalRadii[4];
     4429        if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mode, property == CSSPropertyWebkitBorderRadius))
     4430            return false;
     4431        addProperty(CSSPropertyBorderTopLeftRadius, CSSPropertyBorderRadius, createPrimitiveValuePair(horizontalRadii[0].releaseNonNull(), verticalRadii[0].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce), important);
     4432        addProperty(CSSPropertyBorderTopRightRadius, CSSPropertyBorderRadius, createPrimitiveValuePair(horizontalRadii[1].releaseNonNull(), verticalRadii[1].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce), important);
     4433        addProperty(CSSPropertyBorderBottomRightRadius, CSSPropertyBorderRadius, createPrimitiveValuePair(horizontalRadii[2].releaseNonNull(), verticalRadii[2].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce), important);
     4434        addProperty(CSSPropertyBorderBottomLeftRadius, CSSPropertyBorderRadius, createPrimitiveValuePair(horizontalRadii[3].releaseNonNull(), verticalRadii[3].releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce), important);
    47314435        return true;
    47324436    }
     
    47594463    case CSSPropertyWebkitMaskPosition:
    47604464    case CSSPropertyBackgroundPosition: {
    4761         CSSValue* resultX = nullptr;
    4762         CSSValue* resultY = nullptr;
     4465        RefPtr<CSSValue> resultX;
     4466        RefPtr<CSSValue> resultY;
    47634467        if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow, resultX, resultY) || !m_range.atEnd())
    47644468            return false;
    4765         addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionX : CSSPropertyWebkitMaskPositionX, property, *resultX, important);
    4766         addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionY : CSSPropertyWebkitMaskPositionY, property, *resultY, important);
     4469        addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionX : CSSPropertyWebkitMaskPositionX, property, resultX.releaseNonNull(), important);
     4470        addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionY : CSSPropertyWebkitMaskPositionY, property, resultY.releaseNonNull(), important);
    47674471        return true;
    47684472    }
    47694473    case CSSPropertyBackgroundRepeat:
    47704474    case CSSPropertyWebkitMaskRepeat: {
    4771         CSSValue* resultX = nullptr;
    4772         CSSValue* resultY = nullptr;
     4475        RefPtr<CSSValue> resultX;
     4476        RefPtr<CSSValue> resultY;
    47734477        bool implicit = false;
    47744478        if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range.atEnd())
    47754479            return false;
    4776         addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatX : CSSPropertyWebkitMaskRepeatX, property, *resultX, important, implicit);
    4777         addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatY : CSSPropertyWebkitMaskRepeatY, property, *resultY, important, implicit);
     4480        addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatX : CSSPropertyWebkitMaskRepeatX, property, resultX.releaseNonNull(), important, implicit);
     4481        addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatY : CSSPropertyWebkitMaskRepeatY, property, resultY.releaseNonNull(), important, implicit);
    47784482        return true;
    47794483    }
     
    47834487        return consumeBackgroundShorthand(webkitMaskShorthand(), important);
    47844488    case CSSPropertyGridGap: {
    4785         ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled() && shorthandForProperty(CSSPropertyGridGap).length() == 2);
    4786         CSSValue* rowGap = consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
    4787         CSSValue* columnGap = consumeLength(m_range, m_context.mode(), ValueRangeNonNegative);
     4489        RefPtr<CSSValue> rowGap = consumeLength(m_range, m_context.mode, ValueRangeNonNegative);
     4490        RefPtr<CSSValue> columnGap = consumeLength(m_range, m_context.mode, ValueRangeNonNegative);
    47884491        if (!rowGap || !m_range.atEnd())
    47894492            return false;
    47904493        if (!columnGap)
    47914494            columnGap = rowGap;
    4792         addProperty(CSSPropertyGridRowGap, CSSPropertyGridGap, *rowGap, important);
    4793         addProperty(CSSPropertyGridColumnGap, CSSPropertyGridGap, *columnGap, important);
     4495        addProperty(CSSPropertyGridRowGap, CSSPropertyGridGap, rowGap.releaseNonNull(), important);
     4496        addProperty(CSSPropertyGridColumnGap, CSSPropertyGridGap, columnGap.releaseNonNull(), important);
    47944497        return true;
    47954498    }
     
    48074510    }
    48084511}
    4809 */
    48104512
    48114513} // namespace WebCore
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.h

    r205660 r207479  
    4545
    4646    // Parses a non-shorthand CSS property
    47     static const CSSValue* parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
     47    static RefPtr<CSSValue> parseSingleValue(CSSPropertyID, const CSSParserTokenRange&, const CSSParserContext&);
    4848
    4949private:
     
    5252
    5353    // FIXME: Rename once the CSSParserValue-based parseValue is removed
    54     bool parseValueStart(CSSPropertyID unresolvedProperty, bool important);
    55     bool consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important);
    56     const CSSValue* parseSingleValue(CSSPropertyID, CSSPropertyID = CSSPropertyInvalid);
     54    bool parseValueStart(CSSPropertyID, bool important);
     55    bool consumeCSSWideKeyword(CSSPropertyID, bool important);
     56    RefPtr<CSSValue> parseSingleValue(CSSPropertyID, CSSPropertyID = CSSPropertyInvalid);
    5757
    5858    bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; }
     
    6161    bool parseFontFaceDescriptor(CSSPropertyID);
    6262
    63     void addProperty(CSSPropertyID, CSSPropertyID, const CSSValue&, bool important, bool implicit = false);
    64     void addExpandedPropertyForValue(CSSPropertyID propId, const CSSValue&, bool);
     63    void addProperty(CSSPropertyID, CSSPropertyID, Ref<CSSValue>&&, bool important, bool implicit = false);
     64    void addExpandedPropertyForValue(CSSPropertyID propId, Ref<CSSValue>&&, bool);
    6565
    6666    bool consumeBorder(bool important);
     
    7171
    7272    // Legacy parsing allows <string>s for animation-name
    73     bool consumeAnimationShorthand(const StylePropertyShorthand&, bool useLegacyParsing, bool important);
     73    bool consumeAnimationShorthand(const StylePropertyShorthand&, bool important);
    7474    bool consumeBackgroundShorthand(const StylePropertyShorthand&, bool important);
    7575
     
    103103};
    104104
    105 CSSPropertyID unresolvedCSSPropertyID(StringView);
     105CSSPropertyID cssPropertyID(StringView);
    106106CSSValueID cssValueKeywordID(StringView);
    107107
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r207396 r207479  
    324324    if (range.peek().type() != IdentToken)
    325325        return nullptr;
    326     return CSSPrimitiveValue::createIdentifier(range.consumeIncludingWhitespace().id());
     326    return CSSValuePool::singleton().createIdentifierValue(range.consumeIncludingWhitespace().id());
    327327}
    328328
     
    334334}
    335335
    336 RefPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserTokenRange& range)
     336// FIXME-NEWPARSER: Eventually we'd like this to use CSSCustomIdentValue, but we need
     337// to do other plumbing work first (like changing Pair to CSSValuePair and make it not
     338// use only primitive values).
     339RefPtr<CSSPrimitiveValue> consumeCustomIdent(CSSParserTokenRange& range)
    337340{
    338341    if (range.peek().type() != IdentToken || isCSSWideKeyword(range.peek().id()))
    339342        return nullptr;
    340     return CSSCustomIdentValue::create(range.consumeIncludingWhitespace().value().toString());
     343    return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
    341344}
    342345
     
    345348    if (range.peek().type() != StringToken)
    346349        return nullptr;
    347     return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
     350    return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);
    348351}
    349352
     
    10351038
    10361039        RefPtr<CSSValue> image = CSSImageValue::create(completeURL(context, urlValue));
    1037         imageSet->append(*image);
     1040        imageSet->append(image.releaseNonNull());
    10381041
    10391042        const CSSParserToken& token = args.consumeIncludingWhitespace();
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h

    r206043 r207479  
    7272template<CSSValueID... allowedIdents> RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&);
    7373
    74 RefPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserTokenRange&);
     74RefPtr<CSSPrimitiveValue> consumeCustomIdent(CSSParserTokenRange&);
    7575RefPtr<CSSPrimitiveValue> consumeString(CSSParserTokenRange&);
    7676StringView consumeUrlAsStringView(CSSParserTokenRange&);
Note: See TracChangeset for help on using the changeset viewer.