Changeset 207479 in webkit
- Timestamp:
- Oct 18, 2016 1:03:18 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r207463 r207479 1299 1299 css/CSSNamedImageValue.cpp 1300 1300 css/CSSPageRule.cpp 1301 css/CSSPendingSubstitutionValue.cpp 1301 1302 css/CSSPrimitiveValue.cpp 1302 1303 css/CSSProperty.cpp -
trunk/Source/WebCore/ChangeLog
r207477 r207479 1 2016-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 1 218 2016-10-18 Brent Fulgham <bfulgham@apple.com> 2 219 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207463 r207479 3388 3388 9418278A1D8B244000492764 /* StyleColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 941827881D8B242200492764 /* StyleColor.cpp */; }; 3389 3389 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 */; }; 3390 3392 9444CBD31D860C8B0073A074 /* SizesCalcParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9444CBD01D860C740073A074 /* SizesCalcParser.cpp */; }; 3391 3393 9444CBD41D860C8B0073A074 /* SizesCalcParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 9444CBCF1D860C740073A074 /* SizesCalcParser.h */; }; … … 10740 10742 941827881D8B242200492764 /* StyleColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleColor.cpp; sourceTree = "<group>"; }; 10741 10743 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>"; }; 10742 10746 9444CBCF1D860C740073A074 /* SizesCalcParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SizesCalcParser.h; path = parser/SizesCalcParser.h; sourceTree = "<group>"; }; 10743 10747 9444CBD01D860C740073A074 /* SizesCalcParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SizesCalcParser.cpp; path = parser/SizesCalcParser.cpp; sourceTree = "<group>"; }; … … 22833 22837 A80E6CD60A1989CA007FB8C5 /* CSSPageRule.h */, 22834 22838 85C56CA60AA89D5F00D95755 /* CSSPageRule.idl */, 22839 9418278C1D8CAE9500492764 /* CSSPendingSubstitutionValue.cpp */, 22840 9418278D1D8CAE9500492764 /* CSSPendingSubstitutionValue.h */, 22835 22841 A80E6CDB0A1989CA007FB8C5 /* CSSPrimitiveValue.cpp */, 22836 22842 A80E6CBC0A1989CA007FB8C5 /* CSSPrimitiveValue.h */, … … 26432 26438 297BE3D616C03C0B003316BD /* PlatformSpeechSynthesisVoice.h in Headers */, 26433 26439 297BE3D716C03C0E003316BD /* PlatformSpeechSynthesizer.h in Headers */, 26440 9418278F1D8CAF9200492764 /* CSSPendingSubstitutionValue.h in Headers */, 26434 26441 1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */, 26435 26442 0F7D07331884C56C00B4AF86 /* PlatformTextTrack.h in Headers */, … … 30921 30928 AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */, 30922 30929 2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */, 30930 9418278E1D8CAF9200492764 /* CSSPendingSubstitutionValue.cpp in Sources */, 30923 30931 120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */, 30924 30932 07D637411BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm in Sources */, -
trunk/Source/WebCore/css/CSSFunctionValue.h
r206007 r207479 56 56 57 57 bool equals(const CSSFunctionValue&) const; 58 59 CSSValueID name() const { return m_name; } 58 60 59 61 CSSValueList* arguments() const { return m_args.get(); } -
trunk/Source/WebCore/css/CSSValue.cpp
r206839 r207479 53 53 #include "CSSLineBoxContainValue.h" 54 54 #include "CSSNamedImageValue.h" 55 #include "CSSPendingSubstitutionValue.h" 55 56 #include "CSSPrimitiveValue.h" 56 57 #include "CSSProperty.h" … … 366 367 case VariableReferenceClass: 367 368 return downcast<CSSVariableReferenceValue>(*this).customCSSText(); 369 case PendingSubstitutionValueClass: 370 return downcast<CSSPendingSubstitutionValue>(*this).customCSSText(); 368 371 } 369 372 … … 522 525 case VariableReferenceClass: 523 526 delete downcast<CSSVariableReferenceValue>(this); 527 return; 528 case PendingSubstitutionValueClass: 529 delete downcast<CSSPendingSubstitutionValue>(this); 524 530 return; 525 531 } -
trunk/Source/WebCore/css/CSSValue.h
r207396 r207479 130 130 bool isCustomIdentValue() const { return m_classType == CustomIdentClass; } 131 131 bool isVariableReferenceValue() const { return m_classType == VariableReferenceClass; } 132 bool isPendingSubstitutionValue() const { return m_classType == PendingSubstitutionValueClass; } 132 133 133 134 bool isCSSOMSafe() const { return m_isCSSOMSafe; } … … 211 212 CustomIdentClass, 212 213 VariableReferenceClass, 214 PendingSubstitutionValueClass, 213 215 214 216 // List class types must appear after ValueListClass. -
trunk/Source/WebCore/css/CSSValueKeywords.in
r207173 r207479 1196 1196 drop-shadow 1197 1197 url 1198 cubic-bezier 1199 steps 1198 1200 1199 1201 // colors … … 1250 1252 span 1251 1253 1254 // grid-template-{columns|rows} 1255 minmax 1256 1252 1257 // grid-auto-flow 1253 1258 auto-flow -
trunk/Source/WebCore/css/StylePropertyShorthand.cpp
r205809 r207479 51 51 } 52 52 53 StylePropertyShorthand 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 53 63 bool isShorthandCSSProperty(CSSPropertyID id) 54 64 { -
trunk/Source/WebCore/css/StylePropertyShorthand.h
r205809 r207479 54 54 // Custom StylePropertyShorthand functions. 55 55 StylePropertyShorthand animationShorthandForParsing(); 56 StylePropertyShorthand transitionShorthandForParsing(); 56 57 StylePropertyShorthand borderAbridgedShorthand(); 57 58 -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r207471 r207479 1555 1555 URL CSSParser::completeURL(const CSSParserContext& context, const String& url) 1556 1556 { 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); 1562 1558 } 1563 1559 1564 1560 URL CSSParser::completeURL(const String& url) const 1565 1561 { 1566 return completeURL(m_context,url);1562 return m_context.completeURL(url); 1567 1563 } 1568 1564 -
trunk/Source/WebCore/css/parser/CSSParserImpl.cpp
r206753 r207479 63 63 } 64 64 65 bool CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID unresolvedProperty, const String& string, bool important, const CSSParserContext& context)65 bool CSSParserImpl::parseValue(MutableStyleProperties* declaration, CSSPropertyID propertyID, const String& string, bool important, const CSSParserContext& context) 66 66 { 67 67 CSSParserImpl parser(context); … … 72 72 #endif 73 73 CSSTokenizer::Scope scope(string); 74 parser.consumeDeclarationValue(scope.tokenRange(), unresolvedProperty, important, ruleType);74 parser.consumeDeclarationValue(scope.tokenRange(), propertyID, important, ruleType); 75 75 if (parser.m_parsedProperties.isEmpty()) 76 76 return false; … … 758 758 ASSERT(range.peek().type() == IdentToken); 759 759 const CSSParserToken& token = range.consumeIncludingWhitespace(); 760 CSSPropertyID unresolvedProperty = token.parseAsUnresolvedCSSPropertyID();760 CSSPropertyID propertyID = token.parseAsCSSPropertyID(); 761 761 if (range.consume().type() != ColonToken) 762 762 return; // Parse error … … 778 778 779 779 size_t propertiesCount = m_parsedProperties.size(); 780 if ( unresolvedProperty== CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) {780 if (propertyID == CSSPropertyInvalid && CSSVariableParser::isValidVariableName(token)) { 781 781 AtomicString variableName = token.value().toAtomicString(); 782 782 consumeVariableValue(range.makeSubRange(&range.peek(), declarationValueEnd), variableName, important); … … 786 786 return; 787 787 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); 790 790 791 791 if (m_observerWrapper && (ruleType == StyleRule::Style || ruleType == StyleRule::Keyframe)) { … … 802 802 } 803 803 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);804 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSPropertyID propertyID, bool important, StyleRule::Type ruleType) 805 { 806 CSSPropertyParser::parseValue(propertyID, important, range, m_context, m_parsedProperties, ruleType); 807 807 } 808 808 -
trunk/Source/WebCore/css/parser/CSSParserMode.h
r207339 r207479 32 32 #define CSSParserMode_h 33 33 34 #include "TextEncoding.h" 34 35 #include "URL.h" 35 36 #include "URLHash.h" … … 108 109 bool springTimingFunctionEnabled { false }; 109 110 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 110 121 #if ENABLE(VARIATION_FONTS) 111 122 bool variationFontsEnabled { false }; -
trunk/Source/WebCore/css/parser/CSSParserToken.cpp
r206043 r207479 297 297 } 298 298 299 CSSPropertyID CSSParserToken::parseAs UnresolvedCSSPropertyID() const299 CSSPropertyID CSSParserToken::parseAsCSSPropertyID() const 300 300 { 301 301 ASSERT(m_type == IdentToken); 302 return unresolvedCSSPropertyID(value());302 return cssPropertyID(value()); 303 303 } 304 304 -
trunk/Source/WebCore/css/parser/CSSParserToken.h
r205103 r207479 137 137 bool hasStringBacking() const; 138 138 139 CSSPropertyID parseAs UnresolvedCSSPropertyID() const;139 CSSPropertyID parseAsCSSPropertyID() const; 140 140 141 141 void serialize(StringBuilder&) const; -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r207396 r207479 33 33 #include "CSSBasicShapes.h" 34 34 #include "CSSBorderImage.h" 35 #include "CSSBorderImageSliceValue.h" 35 36 #include "CSSContentDistributionValue.h" 36 37 #include "CSSCursorImageValue.h" 37 // FIXME-NEWPARSER#include "CSSCustomIdentValue.h"38 #include "CSSCustomIdentValue.h" 38 39 #include "CSSFontFaceSrcValue.h" 39 // FIXME-NEWPARSER #include "CSSFontFamilyValue.h"40 40 #include "CSSFontFeatureValue.h" 41 41 #include "CSSFunctionValue.h" … … 47 47 #include "CSSParserFastPaths.h" 48 48 #include "CSSParserIdioms.h" 49 // FIXME-NEWPARSER #include "CSSPathValue.h" 50 // FIXME-NEWPARSER #include "CSSPendingSubstitutionValue.h" 49 #include "CSSPendingSubstitutionValue.h" 51 50 #include "CSSPrimitiveValueMappings.h" 52 51 #include "CSSPropertyParserHelpers.h" 53 // FIXME-NEWPARSER #include "CSSQuadValue.h"54 52 #include "CSSReflectValue.h" 53 #include "CSSRevertValue.h" 55 54 #include "CSSShadowValue.h" 56 // FIXME-NEWPARSER #include "CSSStringValue.h"57 55 #include "CSSTimingFunctionValue.h" 58 // FIXME-NEWPARSER #include "CSSURIValue.h"59 56 #include "CSSUnicodeRangeValue.h" 60 57 #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" 64 60 #include "Counter.h" 65 61 #include "FontFace.h" 66 62 #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" 67 66 #include "RenderTheme.h" 68 67 #include "RuntimeEnabledFeatures.h" 69 68 #include "SVGPathUtilities.h" 70 69 #include "StylePropertyShorthand.h" 70 #include "StylePropertyShorthandFunctions.h" 71 71 #include <memory> 72 72 #include <wtf/text/StringBuilder.h> 73 74 using namespace WTF; 73 75 74 76 namespace WebCore { … … 182 184 } 183 185 184 CSSPropertyID unresolvedCSSPropertyID(StringView string)186 CSSPropertyID cssPropertyID(StringView string) 185 187 { 186 188 unsigned length = string.length(); … … 194 196 } 195 197 196 // FIXME-NEWPARSER197 // Comment out property parsing for now.198 /*199 198 using namespace CSSPropertyParserHelpers; 200 201 199 202 200 CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range, … … 209 207 } 210 208 211 void CSSPropertyParser::addProperty(CSSPropertyID property, CSSPropertyID currentShorthand, const CSSValue& value, bool important, bool implicit) 212 { 213 ASSERT(!isPropertyAlias(property)); 214 209 void CSSPropertyParser::addProperty(CSSPropertyID property, CSSPropertyID currentShorthand, Ref<CSSValue>&& value, bool important, bool implicit) 210 { 215 211 int shorthandIndex = 0; 216 212 bool setFromShorthand = false; 217 213 218 214 if (currentShorthand) { 219 Vector<StylePropertyShorthand, 4> shorthands; 220 getMatchingShorthandsForLonghand(property, &shorthands); 215 auto shorthands = matchingShorthandsForLonghand(property); 221 216 setFromShorthand = true; 222 217 if (shorthands.size() > 1) … … 224 219 } 225 220 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 224 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, Ref<CSSValue>&& value, bool important) 230 225 { 231 226 const StylePropertyShorthand& shorthand = shorthandForProperty(property); … … 234 229 const CSSPropertyID* longhands = shorthand.properties(); 235 230 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 } 239 233 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 /* 234 bool CSSPropertyParser::parseValue(CSSPropertyID propertyID, bool important, 235 const CSSParserTokenRange& range, const CSSParserContext& context, 236 ParsedPropertyVector& parsedProperties, StyleRule::Type ruleType) 237 { 247 238 int parsedPropertiesSize = parsedProperties.size(); 248 239 249 240 CSSPropertyParser parser(range, context, &parsedProperties); 250 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);251 241 bool parseSuccess; 252 242 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); 265 252 266 253 if (!parseSuccess) … … 268 255 269 256 return parseSuccess; 270 */ 271 } 272 /* 273 const CSSValue* CSSPropertyParser::parseSingleValue( 274 CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context) 257 } 258 259 RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, const CSSParserTokenRange& range, const CSSParserContext& context) 275 260 { 276 261 CSSPropertyParser parser(range, context, nullptr); 277 const CSSValue*value = parser.parseSingleValue(property);262 RefPtr<CSSValue> value = parser.parseSingleValue(property); 278 263 if (!value || !parser.m_range.atEnd()) 279 264 return nullptr; … … 281 266 } 282 267 283 bool CSSPropertyParser::parseValueStart(CSSPropertyID unresolvedProperty, bool important)284 { 285 if (consumeCSSWideKeyword( unresolvedProperty, important))268 bool CSSPropertyParser::parseValueStart(CSSPropertyID propertyID, bool important) 269 { 270 if (consumeCSSWideKeyword(propertyID, important)) 286 271 return true; 287 272 288 273 CSSParserTokenRange originalRange = m_range; 289 CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty); 290 bool isShorthand = isShorthandProperty(propertyId); 274 bool isShorthand = isShorthandCSSProperty(propertyID); 291 275 292 276 if (isShorthand) { 293 277 // 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)) 295 279 return true; 296 280 } 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)); 307 290 308 291 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); 314 296 return true; 315 297 } … … 318 300 } 319 301 320 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID unresolvedProperty, bool important)302 bool CSSPropertyParser::consumeCSSWideKeyword(CSSPropertyID propertyID, bool important) 321 303 { 322 304 CSSParserTokenRange rangeCopy = m_range; 323 CSSValueID id= rangeCopy.consumeIncludingWhitespace().id();305 CSSValueID valueID = rangeCopy.consumeIncludingWhitespace().id(); 324 306 if (!rangeCopy.atEnd()) 325 307 return false; 326 308 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(); 334 318 else 335 319 return false; 336 337 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 338 const StylePropertyShorthand& shorthand = shorthandForProperty(property); 320 321 const StylePropertyShorthand& shorthand = shorthandForProperty(propertyID); 339 322 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); 346 328 m_range = rangeCopy; 347 329 return true; 348 330 } 349 331 350 static CSSValueList*consumeTransformOrigin(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)351 { 352 CSSValue* resultX = nullptr;353 CSSValue* resultY = nullptr;332 static RefPtr<CSSValueList> consumeTransformOrigin(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) 333 { 334 RefPtr<CSSPrimitiveValue> resultX; 335 RefPtr<CSSPrimitiveValue> resultY; 354 336 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); 359 341 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()); 362 344 return list; 363 345 } … … 366 348 367 349 // Methods for consuming non-shorthand properties starts here. 368 static CSSValue*consumeWillChange(CSSParserTokenRange& range)350 static RefPtr<CSSValue> consumeWillChange(CSSParserTokenRange& range) 369 351 { 370 352 if (range.peek().id() == CSSValueAuto) 371 353 return consumeIdent(range); 372 354 373 CSSValueList*values = CSSValueList::createCommaSeparated();355 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); 374 356 // Every comma-separated list of identifiers is a valid will-change value, 375 357 // unless the list includes an explicitly disallowed identifier. … … 377 359 if (range.peek().type() != IdentToken) 378 360 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) { 382 363 // Now "all" is used by both CSSValue and CSSPropertyValue. 383 364 // Need to return nullptr when currentValue is CSSPropertyAll. 384 if ( unresolvedProperty == CSSPropertyWillChange || unresolvedProperty== CSSPropertyAll)365 if (propertyID == CSSPropertyWillChange || propertyID == CSSPropertyAll) 385 366 return nullptr; 386 values->append( *CSSCustomIdentValue::create(unresolvedProperty));367 values->append(CSSCustomIdentValue::create(propertyID)); 387 368 range.consumeIncludingWhitespace(); 388 369 } else { … … 397 378 case CSSValueContents: 398 379 case CSSValueScrollPosition: 399 values->append( *consumeIdent(range));380 values->append(consumeIdent(range).releaseNonNull()); 400 381 break; 401 382 default: … … 414 395 } 415 396 416 static CSSFontFeatureValue*consumeFontFeatureTag(CSSParserTokenRange& range)397 static RefPtr<CSSFontFeatureValue> consumeFontFeatureTag(CSSParserTokenRange& range) 417 398 { 418 399 // Feature tag name consists of 4-letter characters. … … 425 406 if (token.value().length() != tagNameLength) 426 407 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) { 429 411 // Limits the range of characters to 0x20-0x7E, following the tag name rules defiend in the OpenType specification. 430 UChar character = t ag[i];412 UChar character = token.value()[i]; 431 413 if (character < 0x20 || character > 0x7E) 432 414 return nullptr; 415 tag[i] = toASCIILower(character); 433 416 } 434 417 … … 442 425 tagValue = range.consumeIncludingWhitespace().id() == CSSValueOn; 443 426 } 444 return CSSFontFeatureValue::create( tag, tagValue);445 } 446 447 static CSSValue*consumeFontFeatureSettings(CSSParserTokenRange& range)427 return CSSFontFeatureValue::create(WTFMove(tag), tagValue); 428 } 429 430 static RefPtr<CSSValue> consumeFontFeatureSettings(CSSParserTokenRange& range) 448 431 { 449 432 if (range.peek().id() == CSSValueNormal) 450 433 return consumeIdent(range); 451 CSSValueList*settings = CSSValueList::createCommaSeparated();434 RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated(); 452 435 do { 453 CSSFontFeatureValue*fontFeatureValue = consumeFontFeatureTag(range);436 RefPtr<CSSFontFeatureValue> fontFeatureValue = consumeFontFeatureTag(range); 454 437 if (!fontFeatureValue) 455 438 return nullptr; 456 settings->append( *fontFeatureValue);439 settings->append(fontFeatureValue.releaseNonNull()); 457 440 } while (consumeCommaIncludingWhitespace(range)); 458 441 return settings; 459 442 } 460 443 461 static CSSValue*consumePage(CSSParserTokenRange& range)444 static RefPtr<CSSValue> consumePage(CSSParserTokenRange& range) 462 445 { 463 446 if (range.peek().id() == CSSValueAuto) … … 466 449 } 467 450 468 static CSSValue*consumeQuotes(CSSParserTokenRange& range)451 static RefPtr<CSSValue> consumeQuotes(CSSParserTokenRange& range) 469 452 { 470 453 if (range.peek().id() == CSSValueNone) 471 454 return consumeIdent(range); 472 CSSValueList*values = CSSValueList::createSpaceSeparated();455 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 473 456 while (!range.atEnd()) { 474 CSSStringValue*parsedValue = consumeString(range);457 RefPtr<CSSPrimitiveValue> parsedValue = consumeString(range); 475 458 if (!parsedValue) 476 459 return nullptr; 477 values->append( *parsedValue);460 values->append(parsedValue.releaseNonNull()); 478 461 } 479 462 if (values->length() && values->length() % 2 == 0) … … 482 465 } 483 466 484 static CSSValue* consumeWebkitHighlight(CSSParserTokenRange& range)485 {486 if (range.peek().id() == CSSValueNone)487 return consumeIdent(range);488 return consumeString(range);489 }490 491 467 class FontVariantLigaturesParser { 492 STACK_ALLOCATED();493 494 468 public: 495 469 FontVariantLigaturesParser() … … 539 513 return ParseResult::UnknownValue; 540 514 } 541 m_result->append( *consumeIdent(range));515 m_result->append(consumeIdent(range).releaseNonNull()); 542 516 return ParseResult::ConsumedValue; 543 517 } 544 518 545 CSSValue*finalizeValue()519 RefPtr<CSSValue> finalizeValue() 546 520 { 547 521 if (!m_result->length()) 548 return CSS PrimitiveValue::createIdentifier(CSSValueNormal);522 return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal); 549 523 return m_result.release(); 550 524 } … … 555 529 bool m_sawHistoricalLigaturesValue; 556 530 bool m_sawContextualLigaturesValue; 557 Member<CSSValueList> m_result;531 RefPtr<CSSValueList> m_result; 558 532 }; 559 533 560 static CSSValue*consumeFontVariantLigatures(CSSParserTokenRange& range)534 static RefPtr<CSSValue> consumeFontVariantLigatures(CSSParserTokenRange& range) 561 535 { 562 536 if (range.peek().id() == CSSValueNormal || range.peek().id() == CSSValueNone) … … 573 547 } 574 548 575 static CSSPrimitiveValue*consumeFontVariantCaps(CSSParserTokenRange& range)549 static RefPtr<CSSPrimitiveValue> consumeFontVariantCaps(CSSParserTokenRange& range) 576 550 { 577 551 return consumeIdent<CSSValueNormal, CSSValueSmallCaps, CSSValueAllSmallCaps, … … 581 555 582 556 class FontVariantNumericParser { 583 STACK_ALLOCATED();584 585 557 public: 586 558 FontVariantNumericParser() … … 635 607 return ParseResult::UnknownValue; 636 608 } 637 m_result->append( *consumeIdent(range));609 m_result->append(consumeIdent(range).releaseNonNull()); 638 610 return ParseResult::ConsumedValue; 639 611 } 640 612 641 CSSValue*finalizeValue()613 RefPtr<CSSValue> finalizeValue() 642 614 { 643 615 if (!m_result->length()) 644 return CSS PrimitiveValue::createIdentifier(CSSValueNormal);616 return CSSValuePool::singleton().createIdentifierValue(CSSValueNormal); 645 617 return m_result.release(); 646 618 } … … 653 625 bool m_sawOrdinalValue; 654 626 bool m_sawSlashedZeroValue; 655 Member<CSSValueList> m_result;627 RefPtr<CSSValueList> m_result; 656 628 }; 657 629 658 static CSSValue*consumeFontVariantNumeric(CSSParserTokenRange& range)630 static RefPtr<CSSValue> consumeFontVariantNumeric(CSSParserTokenRange& range) 659 631 { 660 632 if (range.peek().id() == CSSValueNormal) … … 671 643 } 672 644 673 static CSSPrimitiveValue*consumeFontVariantCSS21(CSSParserTokenRange& range)645 static RefPtr<CSSPrimitiveValue> consumeFontVariantCSS21(CSSParserTokenRange& range) 674 646 { 675 647 return consumeIdent<CSSValueNormal, CSSValueSmallCaps>(range); 676 648 } 677 649 678 static CSSValue*consumeFontVariantList(CSSParserTokenRange& range)679 { 680 CSSValueList*values = CSSValueList::createCommaSeparated();650 static RefPtr<CSSValue> consumeFontVariantList(CSSParserTokenRange& range) 651 { 652 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); 681 653 do { 682 654 if (range.peek().id() == CSSValueAll) { … … 689 661 return consumeIdent(range); 690 662 } 691 CSSPrimitiveValue*fontVariant = consumeFontVariantCSS21(range);663 RefPtr<CSSPrimitiveValue> fontVariant = consumeFontVariantCSS21(range); 692 664 if (fontVariant) 693 values->append( *fontVariant);665 values->append(fontVariant.releaseNonNull()); 694 666 } while (consumeCommaIncludingWhitespace(range)); 695 667 … … 700 672 } 701 673 702 static CSSPrimitiveValue*consumeFontWeight(CSSParserTokenRange& range)674 static RefPtr<CSSPrimitiveValue> consumeFontWeight(CSSParserTokenRange& range) 703 675 { 704 676 const CSSParserToken& token = range.peek(); … … 711 683 return nullptr; 712 684 range.consumeIncludingWhitespace(); 713 return CSS PrimitiveValue::createIdentifier(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1));685 return CSSValuePool::singleton().createIdentifierValue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)); 714 686 } 715 687 … … 731 703 } 732 704 733 static CSSValue*consumeFamilyName(CSSParserTokenRange& range)705 static RefPtr<CSSValue> consumeFamilyName(CSSParserTokenRange& range) 734 706 { 735 707 if (range.peek().type() == StringToken) 736 return CSS FontFamilyValue::create(range.consumeIncludingWhitespace().value().toString());708 return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING); 737 709 if (range.peek().type() != IdentToken) 738 710 return nullptr; … … 740 712 if (familyName.isNull()) 741 713 return nullptr; 742 return CSS FontFamilyValue::create(familyName);743 } 744 745 static CSSValue*consumeGenericFamily(CSSParserTokenRange& range)714 return CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::UnitTypes::CSS_STRING); 715 } 716 717 static RefPtr<CSSValue> consumeGenericFamily(CSSParserTokenRange& range) 746 718 { 747 719 return consumeIdentRange(range, CSSValueSerif, CSSValueWebkitBody); 748 720 } 749 721 750 static CSSValueList*consumeFontFamily(CSSParserTokenRange& range)751 { 752 CSSValueList*list = CSSValueList::createCommaSeparated();722 static RefPtr<CSSValueList> consumeFontFamily(CSSParserTokenRange& range) 723 { 724 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 753 725 do { 754 CSSValue*parsedValue = consumeGenericFamily(range);726 RefPtr<CSSValue> parsedValue = consumeGenericFamily(range); 755 727 if (parsedValue) { 756 list->append( *parsedValue);728 list->append(parsedValue.releaseNonNull()); 757 729 } else { 758 730 parsedValue = consumeFamilyName(range); 759 731 if (parsedValue) { 760 list->append( *parsedValue);732 list->append(parsedValue.releaseNonNull()); 761 733 } else { 762 734 return nullptr; … … 767 739 } 768 740 769 static CSSValue*consumeSpacing(CSSParserTokenRange& range, CSSParserMode cssParserMode)741 static RefPtr<CSSValue> consumeSpacing(CSSParserTokenRange& range, CSSParserMode cssParserMode) 770 742 { 771 743 if (range.peek().id() == CSSValueNormal) … … 775 747 } 776 748 777 static CSSValue*consumeTabSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)778 { 779 CSSPrimitiveValue*parsedValue = consumeInteger(range, 0);749 static RefPtr<CSSValue> consumeTabSize(CSSParserTokenRange& range, CSSParserMode cssParserMode) 750 { 751 RefPtr<CSSPrimitiveValue> parsedValue = consumeInteger(range, 0); 780 752 if (parsedValue) 781 753 return parsedValue; … … 783 755 } 784 756 785 static CSSValue* consumeTextSizeAdjust(CSSParserTokenRange& range, CSSParserMode cssParserMode)757 static RefPtr<CSSValue> consumeTextSizeAdjust(CSSParserTokenRange& range, CSSParserMode /* cssParserMode */) 786 758 { 787 759 if (range.peek().id() == CSSValueAuto) … … 792 764 } 793 765 794 static CSSValue*consumeFontSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid)766 static RefPtr<CSSValue> consumeFontSize(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid) 795 767 { 796 768 if (range.peek().id() >= CSSValueXxSmall && range.peek().id() <= CSSValueLarger) … … 799 771 } 800 772 801 static CSSPrimitiveValue*consumeLineHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode)773 static RefPtr<CSSPrimitiveValue> consumeLineHeight(CSSParserTokenRange& range, CSSParserMode cssParserMode) 802 774 { 803 775 if (range.peek().id() == CSSValueNormal) 804 776 return consumeIdent(range); 805 777 806 CSSPrimitiveValue*lineHeight = consumeNumber(range, ValueRangeNonNegative);778 RefPtr<CSSPrimitiveValue> lineHeight = consumeNumber(range, ValueRangeNonNegative); 807 779 if (lineHeight) 808 780 return lineHeight; … … 810 782 } 811 783 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) 784 template<typename... Args> 785 static Ref<CSSPrimitiveValue> createPrimitiveValuePair(Args&&... args) 786 { 787 return CSSValuePool::singleton().createValue(Pair::create(std::forward<Args>(args)...)); 788 } 789 790 static RefPtr<CSSValue> consumeCounter(CSSParserTokenRange& range, int defaultValue) 875 791 { 876 792 if (range.peek().id() == CSSValueNone) 877 793 return consumeIdent(range); 878 794 879 CSSValueList*list = CSSValueList::createSpaceSeparated();795 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 880 796 do { 881 CSSCustomIdentValue*counterName = consumeCustomIdent(range);797 RefPtr<CSSPrimitiveValue> counterName = consumeCustomIdent(range); 882 798 if (!counterName) 883 799 return nullptr; 884 800 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)); 890 804 } while (!range.atEnd()); 891 805 return list; 892 806 } 893 807 894 static CSSValue*consumePageSize(CSSParserTokenRange& range)808 static RefPtr<CSSValue> consumePageSize(CSSParserTokenRange& range) 895 809 { 896 810 return consumeIdent<CSSValueA3, CSSValueA4, CSSValueA5, CSSValueB4, CSSValueB5, CSSValueLedger, CSSValueLegal, CSSValueLetter>(range); 897 811 } 898 812 899 static CSSValueList*consumeSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)900 { 901 CSSValueList*result = CSSValueList::createSpaceSeparated();813 static RefPtr<CSSValueList> consumeSize(CSSParserTokenRange& range, CSSParserMode cssParserMode) 814 { 815 RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); 902 816 903 817 if (range.peek().id() == CSSValueAuto) { 904 result->append( *consumeIdent(range));818 result->append(consumeIdent(range).releaseNonNull()); 905 819 return result; 906 820 } 907 821 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()); 911 825 if (height) 912 result->append( *height);826 result->append(height.releaseNonNull()); 913 827 return result; 914 828 } 915 829 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); 918 832 if (!pageSize) 919 833 pageSize = consumePageSize(range); … … 922 836 return nullptr; 923 837 if (pageSize) 924 result->append( *pageSize);838 result->append(pageSize.releaseNonNull()); 925 839 if (orientation) 926 result->append( *orientation);840 result->append(orientation.releaseNonNull()); 927 841 return result; 928 842 } 929 843 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) 844 static RefPtr<CSSValue> consumeTextIndent(CSSParserTokenRange& range, CSSParserMode cssParserMode) 948 845 { 949 846 // [ <length> | <percentage> ] && hanging? && each-line? 950 847 // Keywords only allowed when css3Text is enabled. 951 CSSValueList*list = CSSValueList::createSpaceSeparated();848 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 952 849 953 850 bool hasLengthOrPercentage = false; 954 bool hasEachLine = false;851 // bool hasEachLine = false; 955 852 bool hasHanging = false; 956 853 957 854 do { 958 855 if (!hasLengthOrPercentage) { 959 if ( CSSValue*textIndent = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) {856 if (RefPtr<CSSValue> textIndent = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow)) { 960 857 list->append(*textIndent); 961 858 hasLengthOrPercentage = true; … … 964 861 } 965 862 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 979 878 return nullptr; 980 879 } while (!range.atEnd()); … … 986 885 } 987 886 988 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& context) 887 // FIXME-NEWPARSER: Drop the prefix on min-content, max-content and fit-content. 888 static bool validWidthOrHeightKeyword(CSSValueID id, const CSSParserContext& /*context*/) 989 889 { 990 890 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) { 1010 892 return true; 1011 893 } … … 1013 895 } 1014 896 1015 static CSSValue*consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid)897 static RefPtr<CSSValue> consumeMaxWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) 1016 898 { 1017 899 if (range.peek().id() == CSSValueNone || validWidthOrHeightKeyword(range.peek().id(), context)) 1018 900 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 904 static RefPtr<CSSValue> consumeWidthOrHeight(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless = UnitlessQuirk::Forbid) 1023 905 { 1024 906 if (range.peek().id() == CSSValueAuto || validWidthOrHeightKeyword(range.peek().id(), context)) 1025 907 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 911 static RefPtr<CSSValue> consumeMarginOrOffset(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) 1030 912 { 1031 913 if (range.peek().id() == CSSValueAuto) … … 1034 916 } 1035 917 1036 static CSSPrimitiveValue*consumeClipComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode)918 static RefPtr<CSSPrimitiveValue> consumeClipComponent(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1037 919 { 1038 920 if (range.peek().id() == CSSValueAuto) … … 1041 923 } 1042 924 1043 static CSSValue*consumeClip(CSSParserTokenRange& range, CSSParserMode cssParserMode)925 static RefPtr<CSSValue> consumeClip(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1044 926 { 1045 927 if (range.peek().id() == CSSValueAuto) … … 1051 933 CSSParserTokenRange args = consumeFunction(range); 1052 934 // rect(t, r, b, l) || rect(t r b l) 1053 CSSPrimitiveValue*top = consumeClipComponent(args, cssParserMode);935 RefPtr<CSSPrimitiveValue> top = consumeClipComponent(args, cssParserMode); 1054 936 if (!top) 1055 937 return nullptr; 1056 938 bool needsComma = consumeCommaIncludingWhitespace(args); 1057 CSSPrimitiveValue*right = consumeClipComponent(args, cssParserMode);939 RefPtr<CSSPrimitiveValue> right = consumeClipComponent(args, cssParserMode); 1058 940 if (!right || (needsComma && !consumeCommaIncludingWhitespace(args))) 1059 941 return nullptr; 1060 CSSPrimitiveValue*bottom = consumeClipComponent(args, cssParserMode);942 RefPtr<CSSPrimitiveValue> bottom = consumeClipComponent(args, cssParserMode); 1061 943 if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args))) 1062 944 return nullptr; 1063 CSSPrimitiveValue*left = consumeClipComponent(args, cssParserMode);945 RefPtr<CSSPrimitiveValue> left = consumeClipComponent(args, cssParserMode); 1064 946 if (!left || !args.atEnd()) 1065 947 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) 958 static RefPtr<CSSValue> consumeTouchAction(CSSParserTokenRange& range) 959 { 960 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1089 961 CSSValueID id = range.peek().id(); 1090 962 if (id == CSSValueAuto || id == CSSValueNone || id == CSSValueManipulation) { 1091 list->append( *consumeIdent(range));963 list->append(consumeIdent(range).releaseNonNull()); 1092 964 return list; 1093 965 } 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 971 static RefPtr<CSSPrimitiveValue> consumeLineClamp(CSSParserTokenRange& range) 1110 972 { 1111 973 if (range.peek().type() != PercentageToken && range.peek().type() != NumberToken) 1112 974 return nullptr; 1113 CSSPrimitiveValue*clampValue = consumePercent(range, ValueRangeNonNegative);975 RefPtr<CSSPrimitiveValue> clampValue = consumePercent(range, ValueRangeNonNegative); 1114 976 if (clampValue) 1115 977 return clampValue; … … 1118 980 } 1119 981 1120 static CSSValue*consumeLocale(CSSParserTokenRange& range)982 static RefPtr<CSSValue> consumeLocale(CSSParserTokenRange& range) 1121 983 { 1122 984 if (range.peek().id() == CSSValueAuto) … … 1125 987 } 1126 988 1127 static CSSValue*consumeColumnWidth(CSSParserTokenRange& range)989 static RefPtr<CSSValue> consumeColumnWidth(CSSParserTokenRange& range) 1128 990 { 1129 991 if (range.peek().id() == CSSValueAuto) … … 1131 993 // Always parse lengths in strict mode here, since it would be ambiguous otherwise when used in 1132 994 // the 'columns' shorthand property. 1133 CSSPrimitiveValue*columnWidth = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative);995 RefPtr<CSSPrimitiveValue> columnWidth = consumeLength(range, HTMLStandardMode, ValueRangeNonNegative); 1134 996 if (!columnWidth || (!columnWidth->isCalculated() && columnWidth->doubleValue() == 0)) 1135 997 return nullptr; … … 1137 999 } 1138 1000 1139 static CSSValue*consumeColumnCount(CSSParserTokenRange& range)1001 static RefPtr<CSSValue> consumeColumnCount(CSSParserTokenRange& range) 1140 1002 { 1141 1003 if (range.peek().id() == CSSValueAuto) … … 1144 1006 } 1145 1007 1146 static CSSValue*consumeColumnGap(CSSParserTokenRange& range, CSSParserMode cssParserMode)1008 static RefPtr<CSSValue> consumeColumnGap(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1147 1009 { 1148 1010 if (range.peek().id() == CSSValueNormal) … … 1151 1013 } 1152 1014 1153 static CSSValue*consumeColumnSpan(CSSParserTokenRange& range)1015 static RefPtr<CSSValue> consumeColumnSpan(CSSParserTokenRange& range) 1154 1016 { 1155 1017 return consumeIdent<CSSValueAll, CSSValueNone>(range); 1156 1018 } 1157 1019 1158 static CSSValue* consumeZoom(CSSParserTokenRange& range, const CSSParserContext& context)1020 static RefPtr<CSSValue> consumeZoom(CSSParserTokenRange& range, const CSSParserContext& /*context*/) 1159 1021 { 1160 1022 const CSSParserToken& token = range.peek(); 1161 CSSPrimitiveValue* zoom = nullptr;1162 if (token.type() == IdentToken) {1023 RefPtr<CSSPrimitiveValue> zoom; 1024 if (token.type() == IdentToken) 1163 1025 zoom = consumeIdent<CSSValueNormal, CSSValueReset, CSSValueDocument>(range); 1164 }else {1026 else { 1165 1027 zoom = consumePercent(range, ValueRangeNonNegative); 1166 1028 if (!zoom) 1167 1029 zoom = consumeNumber(range, ValueRangeNonNegative); 1168 1030 } 1169 if (zoom && context.useCounter()1170 && !(token.id() == CSSValueNormal1171 || (token.type() == NumberToken && zoom->doubleValue() == 1)1172 || (token.type() == PercentageToken && zoom->doubleValue() == 100)))1173 context.useCounter()->count(UseCounter::CSSZoomNotEqualToOne);1174 1031 return zoom; 1175 1032 } 1176 1033 1177 static CSSValue*consumeAnimationIterationCount(CSSParserTokenRange& range)1034 static RefPtr<CSSValue> consumeAnimationIterationCount(CSSParserTokenRange& range) 1178 1035 { 1179 1036 if (range.peek().id() == CSSValueInfinite) … … 1182 1039 } 1183 1040 1184 static CSSValue* consumeAnimationName(CSSParserTokenRange& range, const CSSParserContext& context, bool allowQuotedName)1041 static RefPtr<CSSValue> consumeAnimationName(CSSParserTokenRange& range) 1185 1042 { 1186 1043 if (range.peek().id() == CSSValueNone) 1187 1044 return consumeIdent(range); 1188 1045 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) { 1194 1047 const CSSParserToken& token = range.consumeIncludingWhitespace(); 1195 1048 if (equalIgnoringASCIICase(token.value(), "none")) 1196 return CSS PrimitiveValue::createIdentifier(CSSValueNone);1049 return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); 1197 1050 return CSSCustomIdentValue::create(token.value().toString()); 1198 1051 } … … 1201 1054 } 1202 1055 1203 static CSSValue*consumeTransitionProperty(CSSParserTokenRange& range)1056 static RefPtr<CSSValue> consumeTransitionProperty(CSSParserTokenRange& range) 1204 1057 { 1205 1058 const CSSParserToken& token = range.peek(); … … 1209 1062 return consumeIdent(range); 1210 1063 1211 if (CSSPropertyID property = token.parseAsUnresolvedCSSPropertyID()) { 1212 ASSERT(CSSPropertyMetadata::isEnabledProperty(property)); 1064 if (CSSPropertyID property = token.parseAsCSSPropertyID()) { 1213 1065 range.consumeIncludingWhitespace(); 1214 1066 return CSSCustomIdentValue::create(property); … … 1217 1069 } 1218 1070 1219 static CSSValue* consumeSteps(CSSParserTokenRange& range) 1220 {1071 1072 static RefPtr<CSSValue> consumeSteps(CSSParserTokenRange& range) { 1221 1073 ASSERT(range.peek().functionId() == CSSValueSteps); 1222 1074 CSSParserTokenRange rangeCopy = range; 1223 1075 CSSParserTokenRange args = consumeFunction(rangeCopy); 1224 1225 CSSPrimitiveValue*steps = consumePositiveInteger(args);1076 1077 RefPtr<CSSPrimitiveValue> steps = consumePositiveInteger(args); 1226 1078 if (!steps) 1227 1079 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; 1230 1083 if (consumeCommaIncludingWhitespace(args)) { 1231 1084 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: 1234 1092 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 1248 1096 if (!args.atEnd()) 1249 1097 return nullptr; 1250 1098 1251 1099 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 1103 static RefPtr<CSSValue> consumeCubicBezier(CSSParserTokenRange& range) 1256 1104 { 1257 1105 ASSERT(range.peek().functionId() == CSSValueCubicBezier); … … 1277 1125 } 1278 1126 1279 static CSSValue*consumeAnimationTimingFunction(CSSParserTokenRange& range)1127 static RefPtr<CSSValue> consumeAnimationTimingFunction(CSSParserTokenRange& range) 1280 1128 { 1281 1129 CSSValueID id = range.peek().id(); 1282 1130 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) 1285 1132 return consumeIdent(range); 1286 1133 1287 1134 CSSValueID function = range.peek().functionId(); 1135 if (function == CSSValueCubicBezier) 1136 return consumeCubicBezier(range); 1288 1137 if (function == CSSValueSteps) 1289 1138 return consumeSteps(range); 1290 if (function == CSSValueCubicBezier)1291 return consumeCubicBezier(range);1292 1139 return nullptr; 1293 1140 } 1294 1141 1295 static CSSValue* consumeAnimationValue(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, bool useLegacyParsing)1142 static RefPtr<CSSValue> consumeAnimationValue(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context) 1296 1143 { 1297 1144 switch (property) { 1298 1145 case CSSPropertyAnimationDelay: 1299 1146 case CSSPropertyTransitionDelay: 1300 return consumeTime(range, ValueRangeAll);1147 return consumeTime(range, context.mode, ValueRangeAll, UnitlessQuirk::Forbid); 1301 1148 case CSSPropertyAnimationDirection: 1302 1149 return consumeIdent<CSSValueNormal, CSSValueAlternate, CSSValueReverse, CSSValueAlternateReverse>(range); 1303 1150 case CSSPropertyAnimationDuration: 1304 1151 case CSSPropertyTransitionDuration: 1305 return consumeTime(range, ValueRangeNonNegative);1152 return consumeTime(range, context.mode, ValueRangeNonNegative, UnitlessQuirk::Forbid); 1306 1153 case CSSPropertyAnimationFillMode: 1307 1154 return consumeIdent<CSSValueNone, CSSValueForwards, CSSValueBackwards, CSSValueBoth>(range); … … 1309 1156 return consumeAnimationIterationCount(range); 1310 1157 case CSSPropertyAnimationName: 1311 return consumeAnimationName(range , context, useLegacyParsing);1158 return consumeAnimationName(range); 1312 1159 case CSSPropertyAnimationPlayState: 1313 1160 return consumeIdent<CSSValueRunning, CSSValuePaused>(range); … … 1328 1175 return true; 1329 1176 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) 1332 1179 return false; 1333 1180 } … … 1335 1182 } 1336 1183 1337 static CSSValueList* consumeAnimationPropertyList(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context, bool useLegacyParsing)1338 { 1339 CSSValueList*list = CSSValueList::createCommaSeparated();1184 static RefPtr<CSSValueList> consumeAnimationPropertyList(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context) 1185 { 1186 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 1340 1187 do { 1341 CSSValue* value = consumeAnimationValue(property, range, context, useLegacyParsing);1188 RefPtr<CSSValue> value = consumeAnimationValue(property, range, context); 1342 1189 if (!value) 1343 1190 return nullptr; 1344 list->append( *value);1191 list->append(value.releaseNonNull()); 1345 1192 } while (consumeCommaIncludingWhitespace(range)); 1346 1193 if (!isValidAnimationPropertyList(property, *list)) … … 1350 1197 } 1351 1198 1352 bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand& shorthand, bool useLegacyParsing, boolimportant)1199 bool CSSPropertyParser::consumeAnimationShorthand(const StylePropertyShorthand& shorthand, bool important) 1353 1200 { 1354 1201 const unsigned longhandCount = shorthand.length(); 1355 CSSValueList*longhands[8];1202 RefPtr<CSSValueList> longhands[8]; 1356 1203 ASSERT(longhandCount <= 8); 1357 1204 for (size_t i = 0; i < longhandCount; ++i) … … 1366 1213 continue; 1367 1214 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)) { 1369 1216 parsedLonghand[i] = true; 1370 1217 foundProperty = true; … … 1380 1227 for (size_t i = 0; i < longhandCount; ++i) { 1381 1228 if (!parsedLonghand[i]) 1382 longhands[i]->append( *CSSInitialValue::createLegacyImplicit());1229 longhands[i]->append(CSSValuePool::singleton().createImplicitInitialValue()); 1383 1230 parsedLonghand[i] = false; 1384 1231 } … … 1396 1243 } 1397 1244 1398 static CSSValue*consumeZIndex(CSSParserTokenRange& range)1245 static RefPtr<CSSValue> consumeZIndex(CSSParserTokenRange& range) 1399 1246 { 1400 1247 if (range.peek().id() == CSSValueAuto) … … 1403 1250 } 1404 1251 1405 static CSSShadowValue*parseSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread)1406 { 1407 CSSPrimitiveValue* style = nullptr;1408 CSSValue* color = nullptr;1252 static RefPtr<CSSShadowValue> parseSingleShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool allowInset, bool allowSpread) 1253 { 1254 RefPtr<CSSPrimitiveValue> style; 1255 RefPtr<CSSPrimitiveValue> color; 1409 1256 1410 1257 if (range.atEnd()) … … 1417 1264 color = consumeColor(range, cssParserMode); 1418 1265 1419 CSSPrimitiveValue*horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll);1266 RefPtr<CSSPrimitiveValue> horizontalOffset = consumeLength(range, cssParserMode, ValueRangeAll); 1420 1267 if (!horizontalOffset) 1421 1268 return nullptr; 1422 1269 1423 CSSPrimitiveValue*verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll);1270 RefPtr<CSSPrimitiveValue> verticalOffset = consumeLength(range, cssParserMode, ValueRangeAll); 1424 1271 if (!verticalOffset) 1425 1272 return nullptr; 1426 1273 1427 CSSPrimitiveValue*blurRadius = consumeLength(range, cssParserMode, ValueRangeAll);1428 CSSPrimitiveValue* spreadDistance = nullptr;1274 RefPtr<CSSPrimitiveValue> blurRadius = consumeLength(range, cssParserMode, ValueRangeAll); 1275 RefPtr<CSSPrimitiveValue> spreadDistance; 1429 1276 if (blurRadius) { 1430 1277 // Blur radius must be non-negative. … … 1444 1291 } 1445 1292 } 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 1297 static RefPtr<CSSValue> consumeShadow(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool isBoxShadowProperty) 1451 1298 { 1452 1299 if (range.peek().id() == CSSValueNone) 1453 1300 return consumeIdent(range); 1454 1301 1455 CSSValueList*shadowValueList = CSSValueList::createCommaSeparated();1302 RefPtr<CSSValueList> shadowValueList = CSSValueList::createCommaSeparated(); 1456 1303 do { 1457 if ( CSSShadowValue*shadowValue = parseSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty))1304 if (RefPtr<CSSShadowValue> shadowValue = parseSingleShadow(range, cssParserMode, isBoxShadowProperty, isBoxShadowProperty)) 1458 1305 shadowValueList->append(*shadowValue); 1459 1306 else … … 1463 1310 } 1464 1311 1465 static CSSFunctionValue*consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context)1312 static RefPtr<CSSFunctionValue> consumeFilterFunction(CSSParserTokenRange& range, const CSSParserContext& context) 1466 1313 { 1467 1314 CSSValueID filterType = range.peek().functionId(); … … 1469 1316 return nullptr; 1470 1317 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()) 1480 1325 return filterValue; 1481 }1482 1326 if (filterType == CSSValueBrightness) { 1483 1327 // FIXME (crbug.com/397061): Support calc expressions like calc(10% + 0.5) … … 1485 1329 if (!parsedValue) 1486 1330 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) { 1490 1334 parsedValue = consumeLength(args, HTMLStandardMode, ValueRangeNonNegative); 1491 1335 } else { … … 1495 1339 parsedValue = consumeNumber(args, ValueRangeNonNegative); 1496 1340 if (parsedValue && filterType != CSSValueSaturate && filterType != CSSValueContrast) { 1497 bool isPercentage = toCSSPrimitiveValue(parsedValue)->isPercentage();1341 bool isPercentage = downcast<CSSPrimitiveValue>(*parsedValue).isPercentage(); 1498 1342 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); 1503 1345 } 1504 1346 } … … 1511 1353 } 1512 1354 1513 static CSSValue*consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context)1355 static RefPtr<CSSValue> consumeFilter(CSSParserTokenRange& range, const CSSParserContext& context) 1514 1356 { 1515 1357 if (range.peek().id() == CSSValueNone) 1516 1358 return consumeIdent(range); 1517 1359 1518 CSSValueList*list = CSSValueList::createSpaceSeparated();1360 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1519 1361 do { 1520 CSSValue*filterValue = consumeUrl(range);1362 RefPtr<CSSValue> filterValue = consumeUrl(range); 1521 1363 if (!filterValue) { 1522 1364 filterValue = consumeFilterFunction(range, context); … … 1524 1366 return nullptr; 1525 1367 } 1526 list->append( *filterValue);1368 list->append(filterValue.releaseNonNull()); 1527 1369 } while (!range.atEnd()); 1528 1370 return list; 1529 1371 } 1530 1372 1531 static CSSValue*consumeTextDecorationLine(CSSParserTokenRange& range)1373 static RefPtr<CSSValue> consumeTextDecorationLine(CSSParserTokenRange& range) 1532 1374 { 1533 1375 CSSValueID id = range.peek().id(); … … 1535 1377 return consumeIdent(range); 1536 1378 1537 CSSValueList*list = CSSValueList::createSpaceSeparated();1379 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1538 1380 while (true) { 1539 CSSPrimitiveValue*ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverline, CSSValueLineThrough>(range);1381 RefPtr<CSSPrimitiveValue> ident = consumeIdent<CSSValueBlink, CSSValueUnderline, CSSValueOverline, CSSValueLineThrough>(range); 1540 1382 if (!ident) 1541 1383 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()); 1545 1387 } 1546 1388 … … 1550 1392 } 1551 1393 1552 // none | strict | content | [ layout || style || paint || size ] 1553 static CSSValue* consumeContain(CSSParserTokenRange& range) 1394 static RefPtr<CSSValue> consumeTextEmphasisStyle(CSSParserTokenRange& range) 1554 1395 { 1555 1396 CSSValueID id = range.peek().id(); … … 1557 1398 return consumeIdent(range); 1558 1399 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)) 1636 1401 return textEmphasisStyle; 1637 1402 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); 1640 1405 if (!fill) 1641 1406 fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range); 1642 1407 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()); 1646 1411 return parsedValues; 1647 1412 } … … 1653 1418 } 1654 1419 1655 static CSSValue*consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode cssParserMode)1420 static RefPtr<CSSValue> consumeOutlineColor(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1656 1421 { 1657 1422 // Allow the special focus color even in HTML Standard parsing mode. … … 1661 1426 } 1662 1427 1663 static CSSPrimitiveValue*consumeLineWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)1428 static RefPtr<CSSPrimitiveValue> consumeLineWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) 1664 1429 { 1665 1430 CSSValueID id = range.peek().id(); … … 1669 1434 } 1670 1435 1671 static CSSPrimitiveValue*consumeBorderWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless)1436 static RefPtr<CSSPrimitiveValue> consumeBorderWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless) 1672 1437 { 1673 1438 return consumeLineWidth(range, cssParserMode, unitless); 1674 1439 } 1675 1440 1676 static CSSPrimitiveValue*consumeTextStrokeWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)1441 static RefPtr<CSSPrimitiveValue> consumeTextStrokeWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1677 1442 { 1678 1443 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); 1679 1444 } 1680 1445 1681 static CSSPrimitiveValue*consumeColumnRuleWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode)1446 static RefPtr<CSSPrimitiveValue> consumeColumnRuleWidth(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1682 1447 { 1683 1448 return consumeLineWidth(range, cssParserMode, UnitlessQuirk::Forbid); 1684 1449 } 1685 1450 1686 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSFunctionValue*& transformValue)1451 static bool consumeTranslate3d(CSSParserTokenRange& args, CSSParserMode cssParserMode, RefPtr<CSSFunctionValue>& transformValue) 1687 1452 { 1688 1453 unsigned numberOfArguments = 2; 1689 CSSValue* parsedValue = nullptr;1454 RefPtr<CSSValue> parsedValue; 1690 1455 do { 1691 1456 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll); … … 1703 1468 } 1704 1469 1705 static bool consumeNumbers(CSSParserTokenRange& args, CSSFunctionValue*& transformValue, unsigned numberOfArguments)1470 static bool consumeNumbers(CSSParserTokenRange& args, RefPtr<CSSFunctionValue>& transformValue, unsigned numberOfArguments) 1706 1471 { 1707 1472 do { 1708 CSSValue*parsedValue = consumeNumber(args, ValueRangeAll);1473 RefPtr<CSSPrimitiveValue> parsedValue = consumeNumber(args, ValueRangeAll); 1709 1474 if (!parsedValue) 1710 1475 return false; 1711 transformValue->append( *parsedValue);1476 transformValue->append(parsedValue.releaseNonNull()); 1712 1477 if (--numberOfArguments && !consumeCommaIncludingWhitespace(args)) 1713 1478 return false; … … 1716 1481 } 1717 1482 1718 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParserMode, CSSFunctionValue*& transformValue, bool useLegacyParsing)1719 { 1720 CSSPrimitiveValue*parsedValue = consumeLength(args, cssParserMode, ValueRangeNonNegative);1721 if (!parsedValue && useLegacyParsing) {1483 static bool consumePerspective(CSSParserTokenRange& args, CSSParserMode cssParserMode, RefPtr<CSSFunctionValue>& transformValue) 1484 { 1485 RefPtr<CSSPrimitiveValue> parsedValue = consumeLength(args, cssParserMode, ValueRangeNonNegative); 1486 if (!parsedValue) { 1722 1487 double perspective; 1723 1488 if (!consumeNumberRaw(args, perspective) || perspective < 0) 1724 1489 return false; 1725 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType ::Pixels);1490 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitTypes::CSS_PX); 1726 1491 } 1727 1492 if (!parsedValue) 1728 1493 return false; 1729 transformValue->append( *parsedValue);1494 transformValue->append(parsedValue.releaseNonNull()); 1730 1495 return true; 1731 1496 } 1732 1497 1733 static CSSValue* consumeTransformValue(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)1498 static RefPtr<CSSValue> consumeTransformValue(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1734 1499 { 1735 1500 CSSValueID functionId = range.peek().functionId(); … … 1739 1504 if (args.atEnd()) 1740 1505 return nullptr; 1741 CSSFunctionValue*transformValue = CSSFunctionValue::create(functionId);1742 CSSValue* parsedValue = nullptr;1506 RefPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(functionId); 1507 RefPtr<CSSValue> parsedValue; 1743 1508 switch (functionId) { 1744 1509 case CSSValueRotate: 1745 case CSSValueRotate X:1746 case CSSValueRotate Y:1747 case CSSValueRotate Z:1748 case CSSValueSkew X:1749 case CSSValueSkew Y:1510 case CSSValueRotatex: 1511 case CSSValueRotatey: 1512 case CSSValueRotatez: 1513 case CSSValueSkewx: 1514 case CSSValueSkewy: 1750 1515 case CSSValueSkew: 1751 parsedValue = consumeAngle(args );1516 parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid); 1752 1517 if (!parsedValue) 1753 1518 return nullptr; 1754 1519 if (functionId == CSSValueSkew && consumeCommaIncludingWhitespace(args)) { 1755 1520 transformValue->append(*parsedValue); 1756 parsedValue = consumeAngle(args );1521 parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid); 1757 1522 if (!parsedValue) 1758 1523 return nullptr; 1759 1524 } 1760 1525 break; 1761 case CSSValueScale X:1762 case CSSValueScale Y:1763 case CSSValueScale Z:1526 case CSSValueScalex: 1527 case CSSValueScaley: 1528 case CSSValueScalez: 1764 1529 case CSSValueScale: 1765 1530 parsedValue = consumeNumber(args, ValueRangeAll); … … 1774 1539 break; 1775 1540 case CSSValuePerspective: 1776 if (!consumePerspective(args, cssParserMode, transformValue , useLegacyParsing))1541 if (!consumePerspective(args, cssParserMode, transformValue)) 1777 1542 return nullptr; 1778 1543 break; 1779 case CSSValueTranslate X:1780 case CSSValueTranslate Y:1544 case CSSValueTranslatex: 1545 case CSSValueTranslatey: 1781 1546 case CSSValueTranslate: 1782 1547 parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeAll); … … 1790 1555 } 1791 1556 break; 1792 case CSSValueTranslate Z:1557 case CSSValueTranslatez: 1793 1558 parsedValue = consumeLength(args, cssParserMode, ValueRangeAll); 1794 1559 break; … … 1805 1570 if (!consumeNumbers(args, transformValue, 3) || !consumeCommaIncludingWhitespace(args)) 1806 1571 return nullptr; 1807 parsedValue = consumeAngle(args );1572 parsedValue = consumeAngle(args, cssParserMode, UnitlessQuirk::Forbid); 1808 1573 if (!parsedValue) 1809 1574 return nullptr; … … 1823 1588 } 1824 1589 1825 static CSSValue* consumeTransform(CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)1590 static RefPtr<CSSValue> consumeTransform(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1826 1591 { 1827 1592 if (range.peek().id() == CSSValueNone) 1828 1593 return consumeIdent(range); 1829 1594 1830 CSSValueList*list = CSSValueList::createSpaceSeparated();1595 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1831 1596 do { 1832 CSSValue* parsedTransformValue = consumeTransformValue(range, cssParserMode, useLegacyParsing);1597 RefPtr<CSSValue> parsedTransformValue = consumeTransformValue(range, cssParserMode); 1833 1598 if (!parsedTransformValue) 1834 1599 return nullptr; 1835 list->append( *parsedTransformValue);1600 list->append(parsedTransformValue.releaseNonNull()); 1836 1601 } while (!range.atEnd()); 1837 1602 … … 1840 1605 1841 1606 template <CSSValueID start, CSSValueID end> 1842 static CSSValue*consumePositionLonghand(CSSParserTokenRange& range, CSSParserMode cssParserMode)1607 static RefPtr<CSSValue> consumePositionLonghand(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1843 1608 { 1844 1609 if (range.peek().type() == IdentToken) { … … 1854 1619 return nullptr; 1855 1620 range.consumeIncludingWhitespace(); 1856 return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitType ::Percentage);1621 return CSSPrimitiveValue::create(percent, CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE); 1857 1622 } 1858 1623 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); 1859 1624 } 1860 1625 1861 static CSSValue*consumePositionX(CSSParserTokenRange& range, CSSParserMode cssParserMode)1626 static RefPtr<CSSValue> consumePositionX(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1862 1627 { 1863 1628 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParserMode); 1864 1629 } 1865 1630 1866 static CSSValue*consumePositionY(CSSParserTokenRange& range, CSSParserMode cssParserMode)1631 static RefPtr<CSSValue> consumePositionY(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1867 1632 { 1868 1633 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParserMode); 1869 1634 } 1870 1635 1871 static CSSValue*consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cssParserMode)1636 static RefPtr<CSSValue> consumePaintStroke(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1872 1637 { 1873 1638 if (range.peek().id() == CSSValueNone) 1874 1639 return consumeIdent(range); 1875 CSSURIValue*url = consumeUrl(range);1640 RefPtr<CSSPrimitiveValue> url = consumeUrl(range); 1876 1641 if (url) { 1877 CSSValue* parsedValue = nullptr;1642 RefPtr<CSSValue> parsedValue; 1878 1643 if (range.peek().id() == CSSValueNone) 1879 1644 parsedValue = consumeIdent(range); … … 1881 1646 parsedValue = consumeColor(range, cssParserMode); 1882 1647 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()); 1886 1651 return values; 1887 1652 } … … 1891 1656 } 1892 1657 1893 static CSSValue*consumePaintOrder(CSSParserTokenRange& range)1658 static RefPtr<CSSValue> consumePaintOrder(CSSParserTokenRange& range) 1894 1659 { 1895 1660 if (range.peek().id() == CSSValueNormal) … … 1897 1662 1898 1663 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; 1902 1667 do { 1903 1668 CSSValueID id = range.peek().id(); … … 1917 1682 // list after parsing. 1918 1683 CSSValueID firstPaintOrderType = paintTypeList.at(0); 1919 CSSValueList*paintOrderList = CSSValueList::createSpaceSeparated();1684 RefPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated(); 1920 1685 switch (firstPaintOrderType) { 1921 1686 case CSSValueFill: 1922 1687 case CSSValueStroke: 1923 paintOrderList->append(firstPaintOrderType == CSSValueFill ? *fill : *stroke);1688 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releaseNonNull() : stroke.releaseNonNull()); 1924 1689 if (paintTypeList.size() > 1) { 1925 1690 if (paintTypeList.at(1) == CSSValueMarkers) 1926 paintOrderList->append( *markers);1691 paintOrderList->append(markers.releaseNonNull()); 1927 1692 } 1928 1693 break; 1929 1694 case CSSValueMarkers: 1930 paintOrderList->append( *markers);1695 paintOrderList->append(markers.releaseNonNull()); 1931 1696 if (paintTypeList.size() > 1) { 1932 1697 if (paintTypeList.at(1) == CSSValueStroke) 1933 paintOrderList->append( *stroke);1698 paintOrderList->append(stroke.releaseNonNull()); 1934 1699 } 1935 1700 break; … … 1941 1706 } 1942 1707 1943 static CSSValue*consumeNoneOrURI(CSSParserTokenRange& range)1708 static RefPtr<CSSValue> consumeNoneOrURI(CSSParserTokenRange& range) 1944 1709 { 1945 1710 if (range.peek().id() == CSSValueNone) … … 1948 1713 } 1949 1714 1950 static CSSValue*consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode)1715 static RefPtr<CSSValue> consumeFlexBasis(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1951 1716 { 1952 1717 // FIXME: Support intrinsic dimensions too. … … 1956 1721 } 1957 1722 1958 static CSSValue*consumeStrokeDasharray(CSSParserTokenRange& range)1723 static RefPtr<CSSValue> consumeStrokeDasharray(CSSParserTokenRange& range) 1959 1724 { 1960 1725 CSSValueID id = range.peek().id(); … … 1962 1727 return consumeIdent(range); 1963 1728 1964 CSSValueList*dashes = CSSValueList::createCommaSeparated();1729 RefPtr<CSSValueList> dashes = CSSValueList::createCommaSeparated(); 1965 1730 do { 1966 CSSPrimitiveValue*dash = consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeNonNegative);1731 RefPtr<CSSPrimitiveValue> dash = consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeNonNegative); 1967 1732 if (!dash || (consumeCommaIncludingWhitespace(range) && range.atEnd())) 1968 1733 return nullptr; 1969 dashes->append( *dash);1734 dashes->append(dash.releaseNonNull()); 1970 1735 } while (!range.atEnd()); 1971 1736 return dashes; 1972 1737 } 1973 1738 1974 static CSSPrimitiveValue*consumeBaselineShift(CSSParserTokenRange& range)1739 static RefPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserTokenRange& range) 1975 1740 { 1976 1741 CSSValueID id = range.peek().id(); … … 1980 1745 } 1981 1746 1982 static CSSPrimitiveValue*consumeRxOrRy(CSSParserTokenRange& range)1747 static RefPtr<CSSPrimitiveValue> consumeRxOrRy(CSSParserTokenRange& range) 1983 1748 { 1984 1749 if (range.peek().id() == CSSValueAuto) … … 1987 1752 } 1988 1753 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)) {1754 static 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)) { 1993 1758 double num; 1994 1759 IntPoint hotSpot(-1, -1); … … 2005 1770 list = CSSValueList::createCommaSeparated(); 2006 1771 2007 list->append( *CSSCursorImageValue::create(image, hotSpotSpecified, hotSpot));1772 list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpotSpecified, hotSpot)); 2008 1773 if (!consumeCommaIncludingWhitespace(range)) 2009 1774 return nullptr; … … 2011 1776 2012 1777 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; 2020 1779 if (id == CSSValueHand) { 2021 1780 if (!inQuirksMode) // Non-standard behavior 2022 1781 return nullptr; 2023 cursorType = CSS PrimitiveValue::createIdentifier(CSSValuePointer);1782 cursorType = CSSValuePool::singleton().createIdentifierValue(CSSValuePointer); 2024 1783 range.consumeIncludingWhitespace(); 2025 1784 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSValueCopy || id == CSSValueNone) { … … 2031 1790 if (!list) 2032 1791 return cursorType; 2033 list->append( *cursorType);1792 list->append(cursorType.releaseNonNull()); 2034 1793 return list; 2035 1794 } 2036 1795 2037 static CSSValue*consumeAttr(CSSParserTokenRange args, CSSParserContext context)1796 static RefPtr<CSSValue> consumeAttr(CSSParserTokenRange args, CSSParserContext context) 2038 1797 { 2039 1798 if (args.peek().type() != IdentToken) 2040 1799 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(); 2043 1806 if (!args.atEnd()) 2044 1807 return nullptr; 2045 1808 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)); 2051 1811 return attrValue; 2052 1812 } 2053 1813 2054 static CSSValue*consumeCounterContent(CSSParserTokenRange args, bool counters)2055 { 2056 CSSCustomIdentValue*identifier = consumeCustomIdent(args);1814 static RefPtr<CSSValue> consumeCounterContent(CSSParserTokenRange args, bool counters) 1815 { 1816 RefPtr<CSSPrimitiveValue> identifier = consumeCustomIdent(args); 2057 1817 if (!identifier) 2058 1818 return nullptr; 2059 1819 2060 CSSStringValue* separator = nullptr;2061 if (!counters) {2062 separator = CSS StringValue::create(String());2063 }else {1820 RefPtr<CSSPrimitiveValue> separator; 1821 if (!counters) 1822 separator = CSSPrimitiveValue::create(String(), CSSPrimitiveValue::UnitTypes::CSS_STRING); 1823 else { 2064 1824 if (!consumeCommaIncludingWhitespace(args) || args.peek().type() != StringToken) 2065 1825 return nullptr; 2066 separator = CSS StringValue::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; 2070 1830 if (consumeCommaIncludingWhitespace(args)) { 2071 1831 CSSValueID id = args.peek().id(); … … 2073 1833 return nullptr; 2074 1834 listStyle = consumeIdent(args); 2075 } else { 2076 listStyle = CSSPrimitiveValue::createIdentifier(CSSValueDecimal); 2077 } 1835 } else 1836 listStyle = CSSValuePool::singleton().createIdentifierValue(CSSValueDecimal); 2078 1837 2079 1838 if (!args.atEnd()) 2080 1839 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 1845 static RefPtr<CSSValue> consumeContent(CSSParserTokenRange& range, CSSParserContext context) 2085 1846 { 2086 1847 if (identMatches<CSSValueNone, CSSValueNormal>(range.peek().id())) 2087 1848 return consumeIdent(range); 2088 1849 2089 CSSValueList*values = CSSValueList::createSpaceSeparated();1850 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 2090 1851 2091 1852 do { 2092 CSSValue*parsedValue = consumeImage(range, context);1853 RefPtr<CSSValue> parsedValue = consumeImage(range, context); 2093 1854 if (!parsedValue) 2094 1855 parsedValue = consumeIdent<CSSValueOpenQuote, CSSValueCloseQuote, CSSValueNoOpenQuote, CSSValueNoCloseQuote>(range); … … 2105 1866 return nullptr; 2106 1867 } 2107 values->append( *parsedValue);1868 values->append(parsedValue.releaseNonNull()); 2108 1869 } while (!range.atEnd()); 2109 1870 … … 2111 1872 } 2112 1873 2113 static CSSPrimitiveValue* consumePerspective(CSSParserTokenRange& range, CSSParserMode cssParserMode, CSSPropertyID unresolvedProperty)1874 static RefPtr<CSSPrimitiveValue> consumePerspective(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2114 1875 { 2115 1876 if (range.peek().id() == CSSValueNone) 2116 1877 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. 2119 1881 double perspective; 2120 1882 if (!consumeNumberRaw(range, perspective)) 2121 1883 return nullptr; 2122 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitType ::Pixels);1884 parsedValue = CSSPrimitiveValue::create(perspective, CSSPrimitiveValue::UnitTypes::CSS_PX); 2123 1885 } 2124 1886 if (parsedValue && (parsedValue->isCalculated() || parsedValue->doubleValue() > 0)) … … 2127 1889 } 2128 1890 2129 static CSSValueList*consumePositionList(CSSParserTokenRange& range, CSSParserMode cssParserMode)2130 { 2131 CSSValueList*positions = CSSValueList::createCommaSeparated();1891 static RefPtr<CSSValueList> consumePositionList(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1892 { 1893 RefPtr<CSSValueList> positions = CSSValueList::createCommaSeparated(); 2132 1894 do { 2133 CSSValue*position = consumePosition(range, cssParserMode, UnitlessQuirk::Forbid);1895 RefPtr<CSSValue> position = consumePosition(range, cssParserMode, UnitlessQuirk::Forbid); 2134 1896 if (!position) 2135 1897 return nullptr; 2136 positions->append( *position);1898 positions->append(position.releaseNonNull()); 2137 1899 } while (consumeCommaIncludingWhitespace(range)); 2138 1900 return positions; 2139 1901 } 2140 1902 2141 static CSSValue*consumeScrollSnapCoordinate(CSSParserTokenRange& range, CSSParserMode cssParserMode)1903 static RefPtr<CSSValue> consumeScrollSnapCoordinate(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2142 1904 { 2143 1905 if (range.peek().id() == CSSValueNone) … … 2146 1908 } 2147 1909 2148 static CSSValue*consumeScrollSnapPoints(CSSParserTokenRange& range, CSSParserMode cssParserMode)1910 static RefPtr<CSSValue> consumeScrollSnapPoints(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2149 1911 { 2150 1912 if (range.peek().id() == CSSValueNone) … … 2152 1914 if (range.peek().functionId() == CSSValueRepeat) { 2153 1915 CSSParserTokenRange args = consumeFunction(range); 2154 CSSPrimitiveValue*parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative);1916 RefPtr<CSSPrimitiveValue> parsedValue = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative); 2155 1917 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()); 2158 1920 return result; 2159 1921 } … … 2162 1924 } 2163 1925 2164 static CSSValue*consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParserMode cssParserMode)2165 { 2166 CSSValue*parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);1926 static RefPtr<CSSValue> consumeBorderRadiusCorner(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1927 { 1928 RefPtr<CSSPrimitiveValue> parsedValue1 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); 2167 1929 if (!parsedValue1) 2168 1930 return nullptr; 2169 CSSValue*parsedValue2 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);1931 RefPtr<CSSPrimitiveValue> parsedValue2 = consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); 2170 1932 if (!parsedValue2) 2171 1933 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 1937 static RefPtr<CSSPrimitiveValue> consumeVerticalAlign(CSSParserTokenRange& range, CSSParserMode cssParserMode) 1938 { 1939 RefPtr<CSSPrimitiveValue> parsedValue = consumeIdentRange(range, CSSValueBaseline, CSSValueWebkitBaselineMiddle); 2178 1940 if (!parsedValue) 2179 1941 parsedValue = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Allow); … … 2181 1943 } 2182 1944 2183 static CSSPrimitiveValue*consumeShapeRadius(CSSParserTokenRange& args, CSSParserMode cssParserMode)1945 static RefPtr<CSSPrimitiveValue> consumeShapeRadius(CSSParserTokenRange& args, CSSParserMode cssParserMode) 2184 1946 { 2185 1947 if (identMatches<CSSValueClosestSide, CSSValueFarthestSide>(args.peek().id())) … … 2188 1950 } 2189 1951 2190 static CSSBasicShapeCircleValue*consumeBasicShapeCircle(CSSParserTokenRange& args, const CSSParserContext& context)1952 static RefPtr<CSSBasicShapeCircle> consumeBasicShapeCircle(CSSParserTokenRange& args, const CSSParserContext& context) 2191 1953 { 2192 1954 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes 2193 1955 // 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()); 2197 1959 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()); 2204 1966 } 2205 1967 return shape; 2206 1968 } 2207 1969 2208 static CSSBasicShapeEllipseValue*consumeBasicShapeEllipse(CSSParserTokenRange& args, const CSSParserContext& context)1970 static RefPtr<CSSBasicShapeEllipse> consumeBasicShapeEllipse(CSSParserTokenRange& args, const CSSParserContext& context) 2209 1971 { 2210 1972 // spec: https://drafts.csswg.org/css-shapes/#supported-basic-shapes 2211 1973 // 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()); 2217 1979 } 2218 1980 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()); 2225 1987 } 2226 1988 return shape; 2227 1989 } 2228 1990 2229 static CSSBasicShapePolygonValue*consumeBasicShapePolygon(CSSParserTokenRange& args, const CSSParserContext& context)2230 { 2231 CSSBasicShapePolygonValue* shape = CSSBasicShapePolygonValue::create();1991 static RefPtr<CSSBasicShapePolygon> consumeBasicShapePolygon(CSSParserTokenRange& args, const CSSParserContext& context) 1992 { 1993 RefPtr<CSSBasicShapePolygon> shape = CSSBasicShapePolygon::create(); 2232 1994 if (identMatches<CSSValueEvenodd, CSSValueNonzero>(args.peek().id())) { 2233 1995 shape->setWindRule(args.consumeIncludingWhitespace().id() == CSSValueEvenodd ? RULE_EVENODD : RULE_NONZERO); … … 2237 1999 2238 2000 do { 2239 CSSPrimitiveValue* xLength = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);2001 RefPtr<CSSPrimitiveValue> xLength = consumeLengthOrPercent(args, context.mode, ValueRangeAll); 2240 2002 if (!xLength) 2241 2003 return nullptr; 2242 CSSPrimitiveValue* yLength = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);2004 RefPtr<CSSPrimitiveValue> yLength = consumeLengthOrPercent(args, context.mode, ValueRangeAll); 2243 2005 if (!yLength) 2244 2006 return nullptr; 2245 shape->appendPoint(xLength , yLength);2007 shape->appendPoint(xLength.releaseNonNull(), yLength.releaseNonNull()); 2246 2008 } while (consumeCommaIncludingWhitespace(args)); 2247 2009 return shape; 2248 2010 } 2249 2011 2250 static void complete4Sides( CSSPrimitiveValue*side[4])2012 static void complete4Sides(RefPtr<CSSPrimitiveValue> side[4]) 2251 2013 { 2252 2014 if (side[3]) … … 2260 2022 } 2261 2023 2262 static bool consumeRadii( CSSPrimitiveValue* horizontalRadii[4], CSSPrimitiveValue*verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing)2024 static bool consumeRadii(RefPtr<CSSPrimitiveValue> horizontalRadii[4], RefPtr<CSSPrimitiveValue> verticalRadii[4], CSSParserTokenRange& range, CSSParserMode cssParserMode, bool useLegacyParsing) 2263 2025 { 2264 2026 unsigned i = 0; … … 2297 2059 } 2298 2060 2299 static CSSBasicShapeInsetValue*consumeBasicShapeInset(CSSParserTokenRange& args, const CSSParserContext& context)2300 { 2301 CSSBasicShapeInsetValue* shape = CSSBasicShapeInsetValue::create();2302 CSSPrimitiveValue* top = consumeLengthOrPercent(args, context.mode(), ValueRangeAll);2061 static RefPtr<CSSBasicShapeInset> consumeBasicShapeInset(CSSParserTokenRange& args, const CSSParserContext& context) 2062 { 2063 RefPtr<CSSBasicShapeInset> shape = CSSBasicShapeInset::create(); 2064 RefPtr<CSSPrimitiveValue> top = consumeLengthOrPercent(args, context.mode, ValueRangeAll); 2303 2065 if (!top) 2304 2066 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; 2308 2070 if (right) { 2309 bottom = consumeLengthOrPercent(args, context.mode (), ValueRangeAll);2071 bottom = consumeLengthOrPercent(args, context.mode, ValueRangeAll); 2310 2072 if (bottom) 2311 left = consumeLengthOrPercent(args, context.mode (), ValueRangeAll);2073 left = consumeLengthOrPercent(args, context.mode, ValueRangeAll); 2312 2074 } 2313 2075 if (left) 2314 shape->updateShapeSize4Values(top , right, bottom, left);2076 shape->updateShapeSize4Values(top.releaseNonNull(), right.releaseNonNull(), bottom.releaseNonNull(), left.releaseNonNull()); 2315 2077 else if (bottom) 2316 shape->updateShapeSize3Values(top , right, bottom);2078 shape->updateShapeSize3Values(top.releaseNonNull(), right.releaseNonNull(), bottom.releaseNonNull()); 2317 2079 else if (right) 2318 shape->updateShapeSize2Values(top , right);2080 shape->updateShapeSize2Values(top.releaseNonNull(), right.releaseNonNull()); 2319 2081 else 2320 shape->updateShapeSize1Value(top );2082 shape->updateShapeSize1Value(top.releaseNonNull()); 2321 2083 2322 2084 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)); 2331 2093 } 2332 2094 return shape; 2333 2095 } 2334 2096 2335 static CSSValue*consumeBasicShape(CSSParserTokenRange& range, const CSSParserContext& context)2336 { 2337 CSSValue* shape = nullptr;2097 static RefPtr<CSSValue> consumeBasicShape(CSSParserTokenRange& range, const CSSParserContext& context) 2098 { 2099 RefPtr<CSSValue> result; 2338 2100 if (range.peek().type() != FunctionToken) 2339 2101 return nullptr; … … 2341 2103 CSSParserTokenRange rangeCopy = range; 2342 2104 CSSParserTokenRange args = consumeFunction(rangeCopy); 2105 2106 // FIXME-NEWPARSER: CSSBasicShape should be a CSSValue, and shapes should not be primitive values. 2107 RefPtr<CSSBasicShape> shape; 2343 2108 if (id == CSSValueCircle) 2344 2109 shape = consumeBasicShapeCircle(args, context); … … 2352 2117 return nullptr; 2353 2118 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 2123 static RefPtr<CSSValue> consumeWebkitClipPath(CSSParserTokenRange& range, const CSSParserContext& context) 2358 2124 { 2359 2125 if (range.peek().id() == CSSValueNone) 2360 2126 return consumeIdent(range); 2361 if ( CSSURIValue*url = consumeUrl(range))2127 if (RefPtr<CSSPrimitiveValue> url = consumeUrl(range)) 2362 2128 return url; 2363 2129 return consumeBasicShape(range, context); 2364 2130 } 2365 2131 2366 static CSSValue*consumeShapeOutside(CSSParserTokenRange& range, const CSSParserContext& context)2367 { 2368 if ( CSSValue*imageValue = consumeImageOrNone(range, context))2132 static RefPtr<CSSValue> consumeShapeOutside(CSSParserTokenRange& range, const CSSParserContext& context) 2133 { 2134 if (RefPtr<CSSValue> imageValue = consumeImageOrNone(range, context)) 2369 2135 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()); 2375 2141 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()); 2378 2144 } 2379 2145 } … … 2383 2149 } 2384 2150 2385 static CSSValue*consumeContentDistributionOverflowPosition(CSSParserTokenRange& range)2151 static RefPtr<CSSValue> consumeContentDistributionOverflowPosition(CSSParserTokenRange& range) 2386 2152 { 2387 2153 if (identMatches<CSSValueNormal, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id())) … … 2422 2188 } 2423 2189 2424 static CSSPrimitiveValue*consumeBorderImageRepeatKeyword(CSSParserTokenRange& range)2190 static RefPtr<CSSPrimitiveValue> consumeBorderImageRepeatKeyword(CSSParserTokenRange& range) 2425 2191 { 2426 2192 return consumeIdent<CSSValueStretch, CSSValueRepeat, CSSValueSpace, CSSValueRound>(range); 2427 2193 } 2428 2194 2429 static CSSValue*consumeBorderImageRepeat(CSSParserTokenRange& range)2430 { 2431 CSSPrimitiveValue*horizontal = consumeBorderImageRepeatKeyword(range);2195 static RefPtr<CSSValue> consumeBorderImageRepeat(CSSParserTokenRange& range) 2196 { 2197 RefPtr<CSSPrimitiveValue> horizontal = consumeBorderImageRepeatKeyword(range); 2432 2198 if (!horizontal) 2433 2199 return nullptr; 2434 CSSPrimitiveValue*vertical = consumeBorderImageRepeatKeyword(range);2200 RefPtr<CSSPrimitiveValue> vertical = consumeBorderImageRepeatKeyword(range); 2435 2201 if (!vertical) 2436 2202 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 2206 static RefPtr<CSSValue> consumeBorderImageSlice(CSSPropertyID property, CSSParserTokenRange& range) 2441 2207 { 2442 2208 bool fill = consumeIdent<CSSValueFill>(range); 2443 CSSPrimitiveValue*slices[4] = { 0 };2209 RefPtr<CSSPrimitiveValue> slices[4] = { 0 }; 2444 2210 2445 2211 for (size_t index = 0; index < 4; ++index) { 2446 CSSPrimitiveValue*value = consumePercent(range, ValueRangeNonNegative);2212 RefPtr<CSSPrimitiveValue> value = consumePercent(range, ValueRangeNonNegative); 2447 2213 if (!value) 2448 2214 value = consumeNumber(range, ValueRangeNonNegative); … … 2463 2229 if (property == CSSPropertyWebkitBorderImage || property == CSSPropertyWebkitMaskBoxImage || property == CSSPropertyWebkitBoxReflect) 2464 2230 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 2244 static RefPtr<CSSValue> consumeBorderImageOutset(CSSParserTokenRange& range) 2245 { 2246 RefPtr<CSSPrimitiveValue> outsets[4] = { 0 }; 2247 2248 RefPtr<CSSPrimitiveValue> value; 2473 2249 for (size_t index = 0; index < 4; ++index) { 2474 2250 value = consumeNumber(range, ValueRangeNonNegative); … … 2482 2258 return nullptr; 2483 2259 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 2271 static RefPtr<CSSValue> consumeBorderImageWidth(CSSParserTokenRange& range) 2272 { 2273 RefPtr<CSSPrimitiveValue> widths[4]; 2274 2275 RefPtr<CSSPrimitiveValue> value; 2492 2276 for (size_t index = 0; index < 4; ++index) { 2493 2277 value = consumeNumber(range, ValueRangeNonNegative); … … 2503 2287 return nullptr; 2504 2288 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 2300 static 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) 2510 2302 { 2511 2303 do { … … 2544 2336 } 2545 2337 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;2338 static 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; 2553 2345 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)); 2555 2347 return nullptr; 2556 2348 } 2557 2349 2558 static CSSValue*consumeReflect(CSSParserTokenRange& range, const CSSParserContext& context)2559 { 2560 CSSPrimitiveValue*direction = consumeIdent<CSSValueAbove, CSSValueBelow, CSSValueLeft, CSSValueRight>(range);2350 static RefPtr<CSSValue> consumeReflect(CSSParserTokenRange& range, const CSSParserContext& context) 2351 { 2352 RefPtr<CSSPrimitiveValue> direction = consumeIdent<CSSValueAbove, CSSValueBelow, CSSValueLeft, CSSValueRight>(range); 2561 2353 if (!direction) 2562 2354 return nullptr; 2563 2355 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); 2569 2361 if (!offset) 2570 2362 return nullptr; 2571 2363 } 2572 2364 2573 CSSValue* mask = nullptr;2365 RefPtr<CSSValue> mask; 2574 2366 if (!range.atEnd()) { 2575 2367 mask = consumeWebkitBorderImage(CSSPropertyWebkitBoxReflect, range, context); … … 2577 2369 return nullptr; 2578 2370 } 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) 2375 static RefPtr<CSSValue> consumeImageOrientation(CSSParserTokenRange& range, CSSParserMode cssParserMode, UnitlessQuirk unitless = UnitlessQuirk::Forbid) 2376 { 2593 2377 if (range.peek().type() != NumberToken) { 2594 CSSPrimitiveValue* angle = consumeAngle(range);2378 RefPtr<CSSPrimitiveValue> angle = consumeAngle(range, cssParserMode, unitless); 2595 2379 if (angle && angle->doubleValue() == 0) 2596 2380 return angle; … … 2598 2382 return nullptr; 2599 2383 } 2600 2601 static CSSValue* consumeBackgroundBlendMode(CSSParserTokenRange& range) 2384 #endif 2385 2386 static RefPtr<CSSPrimitiveValue> consumeBackgroundBlendMode(CSSParserTokenRange& range) 2602 2387 { 2603 2388 CSSValueID id = range.peek().id(); … … 2607 2392 } 2608 2393 2609 static CSSValue*consumeBackgroundAttachment(CSSParserTokenRange& range)2394 static RefPtr<CSSPrimitiveValue> consumeBackgroundAttachment(CSSParserTokenRange& range) 2610 2395 { 2611 2396 return consumeIdent<CSSValueScroll, CSSValueFixed, CSSValueLocal>(range); 2612 2397 } 2613 2398 2614 static CSSValue*consumeBackgroundBox(CSSParserTokenRange& range)2399 static RefPtr<CSSPrimitiveValue> consumeBackgroundBox(CSSParserTokenRange& range) 2615 2400 { 2616 2401 return consumeIdent<CSSValueBorderBox, CSSValuePaddingBox, CSSValueContentBox>(range); 2617 2402 } 2618 2403 2619 static CSSValue*consumeBackgroundComposite(CSSParserTokenRange& range)2404 static RefPtr<CSSPrimitiveValue> consumeBackgroundComposite(CSSParserTokenRange& range) 2620 2405 { 2621 2406 return consumeIdentRange(range, CSSValueClear, CSSValuePlusLighter); 2622 2407 } 2623 2408 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) 2409 static RefPtr<CSSPrimitiveValue> consumePrefixedBackgroundBox(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& /*context*/) 2631 2410 { 2632 2411 // 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)) 2634 2413 return value; 2635 2414 if ((property == CSSPropertyWebkitBackgroundClip || property == CSSPropertyWebkitMaskClip) && range.peek().id() == CSSValueText) … … 2638 2417 } 2639 2418 2640 static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, CSSParserMode cssParserMode)2419 static RefPtr<CSSPrimitiveValue> consumeBackgroundSize(CSSPropertyID property, CSSParserTokenRange& range, CSSParserMode cssParserMode) 2641 2420 { 2642 2421 if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id())) 2643 2422 return consumeIdent(range); 2644 2423 2645 CSSPrimitiveValue*horizontal = consumeIdent<CSSValueAuto>(range);2424 RefPtr<CSSPrimitiveValue> horizontal = consumeIdent<CSSValueAuto>(range); 2646 2425 if (!horizontal) 2647 2426 horizontal = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); 2648 2427 2649 CSSPrimitiveValue* vertical = nullptr;2428 RefPtr<CSSPrimitiveValue> vertical; 2650 2429 if (!range.atEnd()) { 2651 2430 if (range.peek().id() == CSSValueAuto) // `auto' is the default … … 2653 2432 else 2654 2433 vertical = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQuirk::Forbid); 2655 } else if ( unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) {2434 } else if (!vertical && property == CSSPropertyWebkitBackgroundSize) { 2656 2435 // Legacy syntax: "-webkit-background-size: 10px" is equivalent to "background-size: 10px 10px". 2657 2436 vertical = horizontal; … … 2659 2438 if (!vertical) 2660 2439 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 2443 static RefPtr<CSSValueList> consumeGridAutoFlow(CSSParserTokenRange& range) 2444 { 2445 RefPtr<CSSPrimitiveValue> rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range); 2446 RefPtr<CSSPrimitiveValue> denseAlgorithm = consumeIdent<CSSValueDense>(range); 2668 2447 if (!rowOrColumnValue) { 2669 2448 rowOrColumnValue = consumeIdent<CSSValueRow, CSSValueColumn>(range); … … 2671 2450 return nullptr; 2672 2451 } 2673 CSSValueList*parsedValues = CSSValueList::createSpaceSeparated();2452 RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); 2674 2453 if (rowOrColumnValue) 2675 parsedValues->append( *rowOrColumnValue);2454 parsedValues->append(rowOrColumnValue.releaseNonNull()); 2676 2455 if (denseAlgorithm) 2677 parsedValues->append( *denseAlgorithm);2456 parsedValues->append(denseAlgorithm.releaseNonNull()); 2678 2457 return parsedValues; 2679 2458 } 2680 2459 2681 static CSSValue* consumeBackgroundComponent(CSSPropertyID unresolvedProperty, CSSParserTokenRange& range, const CSSParserContext& context)2682 { 2683 switch ( unresolvedProperty) {2460 static RefPtr<CSSValue> consumeBackgroundComponent(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context) 2461 { 2462 switch (property) { 2684 2463 case CSSPropertyBackgroundClip: 2685 2464 return consumeBackgroundBox(range); … … 2692 2471 case CSSPropertyWebkitMaskComposite: 2693 2472 return consumeBackgroundComposite(range); 2694 case CSSPropertyMaskSourceType:2695 return consumeMaskSourceType(range);2696 2473 case CSSPropertyWebkitBackgroundClip: 2697 2474 case CSSPropertyWebkitBackgroundOrigin: 2698 2475 case CSSPropertyWebkitMaskClip: 2699 2476 case CSSPropertyWebkitMaskOrigin: 2700 return consumePrefixedBackgroundBox( unresolvedProperty, range, context);2477 return consumePrefixedBackgroundBox(property, range, context); 2701 2478 case CSSPropertyBackgroundImage: 2702 2479 case CSSPropertyWebkitMaskImage: … … 2704 2481 case CSSPropertyBackgroundPositionX: 2705 2482 case CSSPropertyWebkitMaskPositionX: 2706 return consumePositionX(range, context.mode ());2483 return consumePositionX(range, context.mode); 2707 2484 case CSSPropertyBackgroundPositionY: 2708 2485 case CSSPropertyWebkitMaskPositionY: 2709 return consumePositionY(range, context.mode ());2486 return consumePositionY(range, context.mode); 2710 2487 case CSSPropertyBackgroundSize: 2711 case CSSProperty AliasWebkitBackgroundSize:2488 case CSSPropertyWebkitBackgroundSize: 2712 2489 case CSSPropertyWebkitMaskSize: 2713 return consumeBackgroundSize( unresolvedProperty, range, context.mode());2490 return consumeBackgroundSize(property, range, context.mode); 2714 2491 case CSSPropertyBackgroundColor: 2715 return consumeColor(range, context.mode ());2492 return consumeColor(range, context.mode); 2716 2493 default: 2717 2494 break; … … 2720 2497 } 2721 2498 2722 static void addBackgroundValue( CSSValue*& list, CSSValue*value)2499 static void addBackgroundValue(RefPtr<CSSValue>& list, Ref<CSSValue>&& value) 2723 2500 { 2724 2501 if (list) { 2725 2502 if (!list->isBaseValueList()) { 2726 CSSValue*firstValue = list;2503 RefPtr<CSSValue> firstValue = list; 2727 2504 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)); 2731 2508 } else { 2732 2509 // 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 2514 static RefPtr<CSSValue> consumeCommaSeparatedBackgroundComponent(CSSPropertyID property, CSSParserTokenRange& range, const CSSParserContext& context) 2515 { 2516 RefPtr<CSSValue> result; 2740 2517 do { 2741 CSSValue* value = consumeBackgroundComponent(unresolvedProperty, range, context);2518 RefPtr<CSSValue> value = consumeBackgroundComponent(property, range, context); 2742 2519 if (!value) 2743 2520 return nullptr; 2744 addBackgroundValue(result, value );2521 addBackgroundValue(result, value.releaseNonNull()); 2745 2522 } while (consumeCommaIncludingWhitespace(range)); 2746 2523 return result; 2747 2524 } 2748 2525 2749 static CSSPrimitiveValue*consumeSelfPositionKeyword(CSSParserTokenRange& range)2526 static RefPtr<CSSPrimitiveValue> consumeSelfPositionKeyword(CSSParserTokenRange& range) 2750 2527 { 2751 2528 CSSValueID id = range.peek().id(); … … 2757 2534 } 2758 2535 2759 static CSSValue*consumeSelfPositionOverflowPosition(CSSParserTokenRange& range)2536 static RefPtr<CSSValue> consumeSelfPositionOverflowPosition(CSSParserTokenRange& range) 2760 2537 { 2761 2538 if (identMatches<CSSValueAuto, CSSValueNormal, CSSValueStretch, CSSValueBaseline, CSSValueLastBaseline>(range.peek().id())) 2762 2539 return consumeIdent(range); 2763 2540 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); 2766 2543 if (!selfPosition) 2767 2544 return nullptr; … … 2769 2546 overflowPosition = consumeIdent<CSSValueUnsafe, CSSValueSafe>(range); 2770 2547 if (overflowPosition) 2771 return CSSValuePair::create(selfPosition, overflowPosition, CSSValuePair::DropIdenticalValues);2548 return createPrimitiveValuePair(selfPosition.releaseNonNull(), overflowPosition.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce); 2772 2549 return selfPosition; 2773 2550 } 2774 2551 2775 static CSSValue*consumeAlignItems(CSSParserTokenRange& range)2552 static RefPtr<CSSValue> consumeAlignItems(CSSParserTokenRange& range) 2776 2553 { 2777 2554 // align-items property does not allow the 'auto' value. … … 2781 2558 } 2782 2559 2783 static CSSValue*consumeJustifyItems(CSSParserTokenRange& range)2560 static RefPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& range) 2784 2561 { 2785 2562 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); 2788 2565 if (!legacy) 2789 2566 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); 2790 2567 if (legacy && positionKeyword) { 2791 2568 range = rangeCopy; 2792 return CSSValuePair::create(legacy, positionKeyword, CSSValuePair::DropIdenticalValues);2569 return createPrimitiveValuePair(legacy.releaseNonNull(), positionKeyword.releaseNonNull(), Pair::IdenticalValueEncoding::Coalesce); 2793 2570 } 2794 2571 return consumeSelfPositionOverflowPosition(range); 2795 2572 } 2796 2573 2797 static CSSValue*consumeFitContent(CSSParserTokenRange& range, CSSParserMode cssParserMode)2574 static RefPtr<CSSValue> consumeFitContent(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2798 2575 { 2799 2576 CSSParserTokenRange rangeCopy = range; 2800 2577 CSSParserTokenRange args = consumeFunction(rangeCopy); 2801 CSSPrimitiveValue*length = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow);2578 RefPtr<CSSPrimitiveValue> length = consumeLengthOrPercent(args, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow); 2802 2579 if (!length || !args.atEnd()) 2803 2580 return nullptr; 2804 2581 range = rangeCopy; 2805 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueFitContent);2806 result->append( *length);2582 RefPtr<CSSFunctionValue> result = CSSFunctionValue::create(CSSValueWebkitFitContent); 2583 result->append(length.releaseNonNull()); 2807 2584 return result; 2808 2585 } 2809 2586 2810 static CSSCustomIdentValue*consumeCustomIdentForGridLine(CSSParserTokenRange& range)2587 static RefPtr<CSSPrimitiveValue> consumeCustomIdentForGridLine(CSSParserTokenRange& range) 2811 2588 { 2812 2589 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) … … 2815 2592 } 2816 2593 2817 static CSSValue*consumeGridLine(CSSParserTokenRange& range)2594 static RefPtr<CSSValue> consumeGridLine(CSSParserTokenRange& range) 2818 2595 { 2819 2596 if (range.peek().id() == CSSValueAuto) 2820 2597 return consumeIdent(range); 2821 2598 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); 2825 2602 if (numericValue) { 2826 2603 gridLineName = consumeCustomIdentForGridLine(range); … … 2853 2630 return nullptr; // An <integer> value of zero makes the declaration invalid. 2854 2631 2855 CSSValueList*values = CSSValueList::createSpaceSeparated();2632 RefPtr<CSSValueList> values = CSSValueList::createSpaceSeparated(); 2856 2633 if (spanValue) 2857 values->append( *spanValue);2634 values->append(spanValue.releaseNonNull()); 2858 2635 if (numericValue) 2859 values->append( *numericValue);2636 values->append(numericValue.releaseNonNull()); 2860 2637 if (gridLineName) 2861 values->append( *gridLineName);2638 values->append(gridLineName.releaseNonNull()); 2862 2639 ASSERT(values->length()); 2863 2640 return values; … … 2867 2644 { 2868 2645 CSSValueID valueID = primitiveValue.valueID(); 2869 if (valueID == CSSValue MinContent || valueID == CSSValueMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex())2646 if (valueID == CSSValueWebkitMinContent || valueID == CSSValueWebkitMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex()) 2870 2647 return false; 2871 2648 … … 2876 2653 { 2877 2654 if (value.isPrimitiveValue()) 2878 return isGridTrackFixedSized( toCSSPrimitiveValue(value));2655 return isGridTrackFixedSized(downcast<CSSPrimitiveValue>(value)); 2879 2656 2880 2657 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) 2883 2660 return false; 2884 2661 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); 2888 2665 } 2889 2666 … … 2982 2759 } 2983 2760 2984 static CSSPrimitiveValue*consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode)2761 static RefPtr<CSSPrimitiveValue> consumeGridBreadth(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2985 2762 { 2986 2763 const CSSParserToken& token = range.peek(); 2987 if (identMatches<CSSValue MinContent, 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) { 2990 2767 if (range.peek().numericValue() < 0) 2991 2768 return nullptr; 2992 return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitType ::Fraction);2769 return CSSPrimitiveValue::create(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_FR); 2993 2770 } 2994 2771 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative, UnitlessQuirk::Allow); 2995 2772 } 2996 2773 2997 static CSSValue*consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode)2774 static RefPtr<CSSValue> consumeGridTrackSize(CSSParserTokenRange& range, CSSParserMode cssParserMode) 2998 2775 { 2999 2776 const CSSParserToken& token = range.peek(); … … 3004 2781 CSSParserTokenRange rangeCopy = range; 3005 2782 CSSParserTokenRange args = consumeFunction(rangeCopy); 3006 CSSPrimitiveValue*minTrackBreadth = consumeGridBreadth(args, cssParserMode);2783 RefPtr<CSSPrimitiveValue> minTrackBreadth = consumeGridBreadth(args, cssParserMode); 3007 2784 if (!minTrackBreadth || minTrackBreadth->isFlex() || !consumeCommaIncludingWhitespace(args)) 3008 2785 return nullptr; 3009 CSSPrimitiveValue*maxTrackBreadth = consumeGridBreadth(args, cssParserMode);2786 RefPtr<CSSPrimitiveValue> maxTrackBreadth = consumeGridBreadth(args, cssParserMode); 3010 2787 if (!maxTrackBreadth || !args.atEnd()) 3011 2788 return nullptr; 3012 2789 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()); 3016 2793 return result; 3017 2794 } 3018 2795 3019 if (token.functionId() == CSSValue FitContent)2796 if (token.functionId() == CSSValueWebkitFitContent) 3020 2797 return consumeFitContent(range, cssParserMode); 3021 2798 … … 3024 2801 3025 2802 // Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a new one. 3026 static CSSGridLineNamesValue*consumeGridLineNames(CSSParserTokenRange& range, CSSGridLineNamesValue* lineNames = nullptr)2803 static RefPtr<CSSGridLineNamesValue> consumeGridLineNames(CSSParserTokenRange& range, CSSGridLineNamesValue* lineNames = nullptr) 3027 2804 { 3028 2805 CSSParserTokenRange rangeCopy = range; 3029 2806 if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken) 3030 2807 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()); 3035 2814 if (rangeCopy.consumeIncludingWhitespace().type() != RightBracketToken) 3036 2815 return nullptr; 3037 2816 range = rangeCopy; 3038 return lineNames;2817 return result; 3039 2818 } 3040 2819 … … 3046 2825 size_t repetitions = 1; 3047 2826 isAutoRepeat = identMatches<CSSValueAutoFill, CSSValueAutoFit>(args.peek().id()); 3048 CSSValueList*repeatedValues;3049 if (isAutoRepeat) {2827 RefPtr<CSSValueList> repeatedValues; 2828 if (isAutoRepeat) 3050 2829 repeatedValues = CSSGridAutoRepeatValue::create(args.consumeIncludingWhitespace().id()); 3051 }else {2830 else { 3052 2831 // FIXME: a consumeIntegerRaw would be more efficient here. 3053 CSSPrimitiveValue*repetition = consumePositiveInteger(args);2832 RefPtr<CSSPrimitiveValue> repetition = consumePositiveInteger(args); 3054 2833 if (!repetition) 3055 2834 return false; … … 3059 2838 if (!consumeCommaIncludingWhitespace(args)) 3060 2839 return false; 3061 CSSGridLineNamesValue*lineNames = consumeGridLineNames(args);2840 RefPtr<CSSGridLineNamesValue> lineNames = consumeGridLineNames(args); 3062 2841 if (lineNames) 3063 repeatedValues->append( *lineNames);2842 repeatedValues->append(lineNames.releaseNonNull()); 3064 2843 3065 2844 size_t numberOfTracks = 0; 3066 2845 while (!args.atEnd()) { 3067 CSSValue*trackSize = consumeGridTrackSize(args, cssParserMode);2846 RefPtr<CSSValue> trackSize = consumeGridTrackSize(args, cssParserMode); 3068 2847 if (!trackSize) 3069 2848 return false; … … 3074 2853 lineNames = consumeGridLineNames(args); 3075 2854 if (lineNames) 3076 repeatedValues->append( *lineNames);2855 repeatedValues->append(lineNames.releaseNonNull()); 3077 2856 } 3078 2857 // We should have found at least one <track-size> or else it is not a valid <track-list>. … … 3080 2859 return false; 3081 2860 3082 if (isAutoRepeat) {3083 list.append( *repeatedValues);3084 }else {2861 if (isAutoRepeat) 2862 list.append(repeatedValues.releaseNonNull()); 2863 else { 3085 2864 // We clamp the repetitions to a multiple of the repeat() track list's size, while staying below the max grid size. 3086 2865 repetitions = std::min(repetitions, kGridMaxTracks / numberOfTracks); 3087 2866 for (size_t i = 0; i < repetitions; ++i) { 3088 2867 for (size_t j = 0; j < repeatedValues->length(); ++j) 3089 list.append( repeatedValues->item(j));2868 list.append(adoptRef(*repeatedValues->item(j))); 3090 2869 } 3091 2870 } … … 3095 2874 enum TrackListType { GridTemplate, GridTemplateNoRepeat, GridAuto }; 3096 2875 3097 static CSSValue*consumeGridTrackList(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackListType trackListType)2876 static RefPtr<CSSValue> consumeGridTrackList(CSSParserTokenRange& range, CSSParserMode cssParserMode, TrackListType trackListType) 3098 2877 { 3099 2878 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); 3102 2881 if (lineNames) { 3103 2882 if (!allowGridLineNames) 3104 2883 return nullptr; 3105 values->append( *lineNames);2884 values->append(lineNames.releaseNonNull()); 3106 2885 } 3107 2886 … … 3119 2898 return nullptr; 3120 2899 seenAutoRepeat = seenAutoRepeat || isAutoRepeat; 3121 } else if ( CSSValue*value = consumeGridTrackSize(range, cssParserMode)) {2900 } else if (RefPtr<CSSValue> value = consumeGridTrackSize(range, cssParserMode)) { 3122 2901 if (allTracksAreFixedSized) 3123 2902 allTracksAreFixedSized = isGridTrackFixedSized(*value); 3124 values->append( *value);2903 values->append(value.releaseNonNull()); 3125 2904 } else { 3126 2905 return nullptr; … … 3138 2917 } 3139 2918 3140 static CSSValue*consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range, CSSParserMode cssParserMode)2919 static RefPtr<CSSValue> consumeGridTemplatesRowsOrColumns(CSSParserTokenRange& range, CSSParserMode cssParserMode) 3141 2920 { 3142 2921 if (range.peek().id() == CSSValueNone) … … 3145 2924 } 3146 2925 3147 static CSSValue*consumeGridTemplateAreas(CSSParserTokenRange& range)2926 static RefPtr<CSSValue> consumeGridTemplateAreas(CSSParserTokenRange& range) 3148 2927 { 3149 2928 if (range.peek().id() == CSSValueNone) … … 3166 2945 } 3167 2946 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); 2947 RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSSPropertyID currentShorthand) 2948 { 3209 2949 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; 3213 2952 return consumeIdent(m_range); 3214 2953 } … … 3220 2959 case CSSPropertyQuotes: 3221 2960 return consumeQuotes(m_range); 3222 case CSSPropertyWebkitHighlight:3223 return consumeWebkitHighlight(m_range);3224 2961 case CSSPropertyFontVariantCaps: 3225 2962 return consumeFontVariantCaps(m_range); … … 3236 2973 case CSSPropertyLetterSpacing: 3237 2974 case CSSPropertyWordSpacing: 3238 return consumeSpacing(m_range, m_context.mode ());2975 return consumeSpacing(m_range, m_context.mode); 3239 2976 case CSSPropertyTabSize: 3240 return consumeTabSize(m_range, m_context.mode ());3241 case CSSProperty TextSizeAdjust: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); 3243 2980 case CSSPropertyFontSize: 3244 return consumeFontSize(m_range, m_context.mode (), UnitlessQuirk::Allow);2981 return consumeFontSize(m_range, m_context.mode, UnitlessQuirk::Allow); 3245 2982 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); 3253 2984 case CSSPropertyWebkitBorderHorizontalSpacing: 3254 2985 case CSSPropertyWebkitBorderVerticalSpacing: 3255 return consumeLength(m_range, m_context.mode (), ValueRangeNonNegative);2986 return consumeLength(m_range, m_context.mode, ValueRangeNonNegative); 3256 2987 case CSSPropertyCounterIncrement: 3257 2988 case CSSPropertyCounterReset: 3258 2989 return consumeCounter(m_range, property == CSSPropertyCounterIncrement ? 1 : 0); 3259 2990 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); 3263 2992 case CSSPropertyTextIndent: 3264 return consumeTextIndent(m_range, m_context.mode ());2993 return consumeTextIndent(m_range, m_context.mode); 3265 2994 case CSSPropertyMaxWidth: 3266 2995 case CSSPropertyMaxHeight: … … 3287 3016 case CSSPropertyRight: 3288 3017 case CSSPropertyTop: 3289 return consumeMarginOrOffset(m_range, m_context.mode (), UnitlessQuirk::Allow);3018 return consumeMarginOrOffset(m_range, m_context.mode, UnitlessQuirk::Allow); 3290 3019 case CSSPropertyWebkitMarginStart: 3291 3020 case CSSPropertyWebkitMarginEnd: 3292 3021 case CSSPropertyWebkitMarginBefore: 3293 3022 case CSSPropertyWebkitMarginAfter: 3294 return consumeMarginOrOffset(m_range, m_context.mode (), UnitlessQuirk::Forbid);3023 return consumeMarginOrOffset(m_range, m_context.mode, UnitlessQuirk::Forbid); 3295 3024 case CSSPropertyPaddingTop: 3296 3025 case CSSPropertyPaddingRight: 3297 3026 case CSSPropertyPaddingBottom: 3298 3027 case CSSPropertyPaddingLeft: 3299 return consumeLengthOrPercent(m_range, m_context.mode (), ValueRangeNonNegative, UnitlessQuirk::Allow);3028 return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Allow); 3300 3029 case CSSPropertyWebkitPaddingStart: 3301 3030 case CSSPropertyWebkitPaddingEnd: 3302 3031 case CSSPropertyWebkitPaddingBefore: 3303 3032 case CSSPropertyWebkitPaddingAfter: 3304 return consumeLengthOrPercent(m_range, m_context.mode (), ValueRangeNonNegative, UnitlessQuirk::Forbid);3033 return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative, UnitlessQuirk::Forbid); 3305 3034 case CSSPropertyClip: 3306 return consumeClip(m_range, m_context.mode()); 3035 return consumeClip(m_range, m_context.mode); 3036 #if ENABLE(TOUCH_EVENTS) 3307 3037 case CSSPropertyTouchAction: 3308 3038 return consumeTouchAction(m_range); 3309 case CSSPropertyScrollSnapDestination: 3039 #endif 3310 3040 case CSSPropertyObjectPosition: 3311 3041 case CSSPropertyPerspectiveOrigin: 3312 return consumePosition(m_range, m_context.mode (), UnitlessQuirk::Forbid);3042 return consumePosition(m_range, m_context.mode, UnitlessQuirk::Forbid); 3313 3043 case CSSPropertyWebkitLineClamp: 3314 3044 return consumeLineClamp(m_range); 3315 3045 case CSSPropertyWebkitFontSizeDelta: 3316 return consumeLength(m_range, m_context.mode (), ValueRangeAll, UnitlessQuirk::Allow);3046 return consumeLength(m_range, m_context.mode, ValueRangeAll, UnitlessQuirk::Allow); 3317 3047 case CSSPropertyWebkitHyphenateCharacter: 3318 3048 case CSSPropertyWebkitLocale: … … 3323 3053 return consumeColumnCount(m_range); 3324 3054 case CSSPropertyColumnGap: 3325 return consumeColumnGap(m_range, m_context.mode ());3055 return consumeColumnGap(m_range, m_context.mode); 3326 3056 case CSSPropertyColumnSpan: 3327 3057 return consumeColumnSpan(m_range); … … 3340 3070 case CSSPropertyAnimationTimingFunction: 3341 3071 case CSSPropertyTransitionTimingFunction: 3342 return consumeAnimationPropertyList(property, m_range, m_context , unresolvedProperty == CSSPropertyAliasWebkitAnimationName);3072 return consumeAnimationPropertyList(property, m_range, m_context); 3343 3073 case CSSPropertyGridColumnGap: 3344 3074 case CSSPropertyGridRowGap: 3345 return consumeLength(m_range, m_context.mode (), ValueRangeNonNegative);3346 case CSSProperty ShapeMargin:3347 return consumeLengthOrPercent(m_range, m_context.mode (), ValueRangeNonNegative);3348 case CSSProperty ShapeImageThreshold:3075 return consumeLength(m_range, m_context.mode, ValueRangeNonNegative); 3076 case CSSPropertyWebkitShapeMargin: 3077 return consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative); 3078 case CSSPropertyWebkitShapeImageThreshold: 3349 3079 return consumeNumber(m_range, ValueRangeAll); 3350 3080 case CSSPropertyWebkitBoxOrdinalGroup: … … 3352 3082 case CSSPropertyWidows: 3353 3083 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); 3357 3086 case CSSPropertyWebkitTextStrokeWidth: 3358 return consumeTextStrokeWidth(m_range, m_context.mode ());3087 return consumeTextStrokeWidth(m_range, m_context.mode); 3359 3088 case CSSPropertyWebkitTextFillColor: 3089 #if ENABLE(TOUCH_EVENTS) 3360 3090 case CSSPropertyWebkitTapHighlightColor: 3091 #endif 3361 3092 case CSSPropertyWebkitTextEmphasisColor: 3362 3093 case CSSPropertyWebkitBorderStartColor: … … 3369 3100 case CSSPropertyLightingColor: 3370 3101 case CSSPropertyColumnRuleColor: 3371 return consumeColor(m_range, m_context.mode ());3102 return consumeColor(m_range, m_context.mode); 3372 3103 case CSSPropertyColor: 3373 3104 case CSSPropertyBackgroundColor: 3374 return consumeColor(m_range, m_context.mode (), inQuirksMode());3105 return consumeColor(m_range, m_context.mode, inQuirksMode()); 3375 3106 case CSSPropertyWebkitBorderStartWidth: 3376 3107 case CSSPropertyWebkitBorderEndWidth: 3377 3108 case CSSPropertyWebkitBorderBeforeWidth: 3378 3109 case CSSPropertyWebkitBorderAfterWidth: 3379 return consumeBorderWidth(m_range, m_context.mode (), UnitlessQuirk::Forbid);3110 return consumeBorderWidth(m_range, m_context.mode, UnitlessQuirk::Forbid); 3380 3111 case CSSPropertyBorderBottomColor: 3381 3112 case CSSPropertyBorderLeftColor: … … 3384 3115 bool allowQuirkyColors = inQuirksMode() 3385 3116 && (currentShorthand == CSSPropertyInvalid || currentShorthand == CSSPropertyBorderColor); 3386 return consumeColor(m_range, m_context.mode (), allowQuirkyColors);3117 return consumeColor(m_range, m_context.mode, allowQuirkyColors); 3387 3118 } 3388 3119 case CSSPropertyBorderBottomWidth: … … 3393 3124 && (currentShorthand == CSSPropertyInvalid || currentShorthand == CSSPropertyBorderWidth); 3394 3125 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); 3396 3127 } 3397 3128 case CSSPropertyZIndex: … … 3399 3130 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS3, so treat as CSS3 3400 3131 case CSSPropertyBoxShadow: 3401 return consumeShadow(m_range, m_context.mode (), property == CSSPropertyBoxShadow);3132 return consumeShadow(m_range, m_context.mode, property == CSSPropertyBoxShadow); 3402 3133 case CSSPropertyFilter: 3403 case CSSProperty BackdropFilter:3134 case CSSPropertyWebkitBackdropFilter: 3404 3135 return consumeFilter(m_range, m_context); 3405 3136 case CSSPropertyTextDecoration: 3406 ASSERT(!RuntimeEnabledFeatures::css3TextDecorationsEnabled());3407 // fallthrough3408 3137 case CSSPropertyWebkitTextDecorationsInEffect: 3409 case CSSProperty TextDecorationLine:3138 case CSSPropertyWebkitTextDecorationLine: 3410 3139 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);3418 3140 case CSSPropertyWebkitTextEmphasisStyle: 3419 3141 return consumeTextEmphasisStyle(m_range); 3420 3142 case CSSPropertyOutlineColor: 3421 return consumeOutlineColor(m_range, m_context.mode ());3143 return consumeOutlineColor(m_range, m_context.mode); 3422 3144 case CSSPropertyOutlineOffset: 3423 return consumeLength(m_range, m_context.mode (), ValueRangeAll);3145 return consumeLength(m_range, m_context.mode, ValueRangeAll); 3424 3146 case CSSPropertyOutlineWidth: 3425 return consumeLineWidth(m_range, m_context.mode (), UnitlessQuirk::Forbid);3147 return consumeLineWidth(m_range, m_context.mode, UnitlessQuirk::Forbid); 3426 3148 case CSSPropertyTransform: 3427 return consumeTransform(m_range, m_context.mode (), unresolvedProperty == CSSPropertyAliasWebkitTransform);3428 case CSSProperty WebkitTransformOriginX:3429 case CSSProperty WebkitPerspectiveOriginX:3430 return consumePositionX(m_range, m_context.mode ());3431 case CSSProperty WebkitTransformOriginY:3432 case CSSProperty WebkitPerspectiveOriginY:3433 return consumePositionY(m_range, m_context.mode ());3434 case CSSProperty WebkitTransformOriginZ: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); 3436 3158 case CSSPropertyFill: 3437 3159 case CSSPropertyStroke: 3438 return consumePaintStroke(m_range, m_context.mode ());3160 return consumePaintStroke(m_range, m_context.mode); 3439 3161 case CSSPropertyPaintOrder: 3440 3162 return consumePaintOrder(m_range); … … 3446 3168 return consumeNoneOrURI(m_range); 3447 3169 case CSSPropertyFlexBasis: 3448 return consumeFlexBasis(m_range, m_context.mode ());3170 return consumeFlexBasis(m_range, m_context.mode); 3449 3171 case CSSPropertyFlexGrow: 3450 3172 case CSSPropertyFlexShrink: … … 3453 3175 return consumeStrokeDasharray(m_range); 3454 3176 case CSSPropertyColumnRuleWidth: 3455 return consumeColumnRuleWidth(m_range, m_context.mode ());3177 return consumeColumnRuleWidth(m_range, m_context.mode); 3456 3178 case CSSPropertyStrokeOpacity: 3457 3179 case CSSPropertyFillOpacity: … … 3478 3200 case CSSPropertyCursor: 3479 3201 return consumeCursor(m_range, m_context, inQuirksMode()); 3480 case CSSPropertyContain:3481 return consumeContain(m_range);3482 3202 case CSSPropertyTransformOrigin: 3483 return consumeTransformOrigin(m_range, m_context.mode (), UnitlessQuirk::Forbid);3203 return consumeTransformOrigin(m_range, m_context.mode, UnitlessQuirk::Forbid); 3484 3204 case CSSPropertyContent: 3485 3205 return consumeContent(m_range, m_context); … … 3489 3209 return consumeImageOrNone(m_range, m_context); 3490 3210 case CSSPropertyPerspective: 3491 return consumePerspective(m_range, m_context.mode (), unresolvedProperty);3492 case CSSProperty ScrollSnapCoordinate:3493 return consumeScrollSnapCoordinate(m_range, m_context.mode ());3494 case CSSProperty ScrollSnapPointsX:3495 case CSSProperty ScrollSnapPointsY: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); 3497 3217 case CSSPropertyBorderTopRightRadius: 3498 3218 case CSSPropertyBorderTopLeftRadius: 3499 3219 case CSSPropertyBorderBottomLeftRadius: 3500 3220 case CSSPropertyBorderBottomRightRadius: 3501 return consumeBorderRadiusCorner(m_range, m_context.mode ());3221 return consumeBorderRadiusCorner(m_range, m_context.mode); 3502 3222 case CSSPropertyWebkitBoxFlexGroup: 3503 3223 return consumeInteger(m_range, 0); 3504 3224 case CSSPropertyOrder: 3505 3225 return consumeInteger(m_range); 3506 case CSSProperty TextUnderlinePosition:3226 case CSSPropertyWebkitTextUnderlinePosition: 3507 3227 // auto | [ under || [ left | right ] ], but we only support auto | under for now 3508 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled());3509 3228 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range); 3510 3229 case CSSPropertyVerticalAlign: 3511 return consumeVerticalAlign(m_range, m_context.mode ());3512 case CSSProperty ShapeOutside:3230 return consumeVerticalAlign(m_range, m_context.mode); 3231 case CSSPropertyWebkitShapeOutside: 3513 3232 return consumeShapeOutside(m_range, m_context); 3514 3233 case CSSPropertyWebkitClipPath: … … 3516 3235 case CSSPropertyJustifyContent: 3517 3236 case CSSPropertyAlignContent: 3518 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3519 3237 return consumeContentDistributionOverflowPosition(m_range); 3520 3238 case CSSPropertyBorderImageRepeat: … … 3534 3252 case CSSPropertyWebkitBoxReflect: 3535 3253 return consumeReflect(m_range, m_context); 3536 case CSSPropertyFontSizeAdjust: 3537 ASSERT(RuntimeEnabledFeatures::cssFontSizeAdjustEnabled()); 3538 return consumeFontSizeAdjust(m_range); 3254 #if ENABLE(CSS_IMAGE_ORIENTATION) 3539 3255 case CSSPropertyImageOrientation: 3540 ASSERT(RuntimeEnabledFeatures::imageOrientationEnabled());3541 3256 return consumeImageOrientation(m_range); 3257 #endif 3542 3258 case CSSPropertyBackgroundAttachment: 3543 3259 case CSSPropertyBackgroundBlendMode: … … 3548 3264 case CSSPropertyBackgroundPositionY: 3549 3265 case CSSPropertyBackgroundSize: 3550 case CSSPropertyMaskSourceType:3551 3266 case CSSPropertyWebkitBackgroundClip: 3552 3267 case CSSPropertyWebkitBackgroundOrigin: … … 3558 3273 case CSSPropertyWebkitMaskPositionY: 3559 3274 case CSSPropertyWebkitMaskSize: 3560 return consumeCommaSeparatedBackgroundComponent( unresolvedProperty, m_range, m_context);3275 return consumeCommaSeparatedBackgroundComponent(property, m_range, m_context); 3561 3276 case CSSPropertyWebkitMaskRepeatX: 3562 3277 case CSSPropertyWebkitMaskRepeatY: 3563 3278 return nullptr; 3564 3279 case CSSPropertyAlignItems: 3565 DCHECK(RuntimeEnabledFeatures::cssGridLayoutEnabled());3566 3280 return consumeAlignItems(m_range); 3567 3281 case CSSPropertyJustifySelf: 3568 3282 case CSSPropertyAlignSelf: 3569 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3570 3283 return consumeSelfPositionOverflowPosition(m_range); 3571 3284 case CSSPropertyJustifyItems: 3572 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3573 3285 return consumeJustifyItems(m_range); 3574 3286 case CSSPropertyGridColumnEnd: … … 3576 3288 case CSSPropertyGridRowEnd: 3577 3289 case CSSPropertyGridRowStart: 3578 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3579 3290 return consumeGridLine(m_range); 3580 3291 case CSSPropertyGridAutoColumns: 3581 3292 case CSSPropertyGridAutoRows: 3582 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3583 return consumeGridTrackList(m_range, m_context.mode(), GridAuto); 3293 return consumeGridTrackList(m_range, m_context.mode, GridAuto); 3584 3294 case CSSPropertyGridTemplateColumns: 3585 3295 case CSSPropertyGridTemplateRows: 3586 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 3587 return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode()); 3296 return consumeGridTemplatesRowsOrColumns(m_range, m_context.mode); 3588 3297 case CSSPropertyGridTemplateAreas: 3589 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3590 3298 return consumeGridTemplateAreas(m_range); 3591 3299 case CSSPropertyGridAutoFlow: 3592 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());3593 3300 return consumeGridAutoFlow(m_range); 3594 3301 default: … … 3597 3304 } 3598 3305 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(); 3306 static RefPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParserTokenRange& range) 3307 { 3308 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); 3607 3309 3608 3310 do { … … 3615 3317 if (start > end) 3616 3318 return nullptr; 3617 values->append( *CSSUnicodeRangeValue::create(start, end));3319 values->append(CSSUnicodeRangeValue::create(start, end)); 3618 3320 } while (consumeCommaIncludingWhitespace(range)); 3619 3321 … … 3621 3323 } 3622 3324 3623 static CSSValue*consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)3325 static RefPtr<CSSValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context) 3624 3326 { 3625 3327 String url = consumeUrlAsStringView(range).toString(); 3626 3328 if (url.isNull()) 3627 3329 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)); 3630 3332 3631 3333 if (range.peek().functionId() != CSSValueFormat) … … 3642 3344 } 3643 3345 3644 static CSSValue* consumeFontFaceSrcLocal(CSSParserTokenRange& range, const CSSParserContext& context)3346 static RefPtr<CSSValue> consumeFontFaceSrcLocal(CSSParserTokenRange& range) 3645 3347 { 3646 3348 CSSParserTokenRange args = consumeFunction(range); 3647 ContentSecurityPolicyDisposition shouldCheckContentSecurityPolicy = context.shouldCheckContentSecurityPolicy();3648 3349 if (args.peek().type() == StringToken) { 3649 3350 const CSSParserToken& arg = args.consumeIncludingWhitespace(); 3650 3351 if (!args.atEnd()) 3651 3352 return nullptr; 3652 return CSSFontFaceSrcValue::createLocal(arg.value().toString() , shouldCheckContentSecurityPolicy);3353 return CSSFontFaceSrcValue::createLocal(arg.value().toString()); 3653 3354 } 3654 3355 if (args.peek().type() == IdentToken) { … … 3656 3357 if (!args.atEnd()) 3657 3358 return nullptr; 3658 return CSSFontFaceSrcValue::createLocal(familyName , shouldCheckContentSecurityPolicy);3359 return CSSFontFaceSrcValue::createLocal(familyName); 3659 3360 } 3660 3361 return nullptr; 3661 3362 } 3662 3363 3663 static CSSValueList*consumeFontFaceSrc(CSSParserTokenRange& range, const CSSParserContext& context)3664 { 3665 CSSValueList*values = CSSValueList::createCommaSeparated();3364 static RefPtr<CSSValueList> consumeFontFaceSrc(CSSParserTokenRange& range, const CSSParserContext& context) 3365 { 3366 RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated(); 3666 3367 3667 3368 do { 3668 3369 const CSSParserToken& token = range.peek(); 3669 CSSValue* parsedValue = nullptr;3370 RefPtr<CSSValue> parsedValue; 3670 3371 if (token.functionId() == CSSValueLocal) 3671 parsedValue = consumeFontFaceSrcLocal(range , context);3372 parsedValue = consumeFontFaceSrcLocal(range); 3672 3373 else 3673 3374 parsedValue = consumeFontFaceSrcURI(range, context); 3674 3375 if (!parsedValue) 3675 3376 return nullptr; 3676 values->append( *parsedValue);3377 values->append(parsedValue.releaseNonNull()); 3677 3378 } while (consumeCommaIncludingWhitespace(range)); 3678 3379 return values; … … 3681 3382 bool CSSPropertyParser::parseFontFaceDescriptor(CSSPropertyID propId) 3682 3383 { 3683 CSSValue* parsedValue = nullptr;3384 RefPtr<CSSValue> parsedValue; 3684 3385 switch (propId) { 3685 3386 case CSSPropertyFontFamily: … … 3694 3395 parsedValue = consumeFontFaceUnicodeRange(m_range); 3695 3396 break; 3696 case CSSPropertyFontDisplay:3697 parsedValue = consumeFontDisplay(m_range);3698 break;3699 3397 case CSSPropertyFontStretch: 3700 3398 case CSSPropertyFontStyle: { 3701 3399 CSSValueID id = m_range.consumeIncludingWhitespace().id(); 3702 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode ()))3703 return false; 3704 parsedValue = CSS PrimitiveValue::createIdentifier(id);3400 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(propId, id, m_context.mode)) 3401 return false; 3402 parsedValue = CSSValuePool::singleton().createIdentifierValue(id); 3705 3403 break; 3706 3404 } … … 3731 3429 if (!m_range.atEnd()) 3732 3430 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 3752 3448 return true; 3753 3449 } … … 3763 3459 } 3764 3460 // 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; 3769 3465 while (!m_range.atEnd()) { 3770 3466 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)) { 3772 3468 fontStyle = consumeIdent(m_range); 3773 3469 continue; … … 3785 3481 continue; 3786 3482 } 3787 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode ()))3483 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyFontStretch, id, m_context.mode)) 3788 3484 fontStretch = consumeIdent(m_range); 3789 3485 else … … 3794 3490 return false; 3795 3491 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); 3803 3499 3804 3500 // 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); 3806 3502 if (!fontSize || m_range.atEnd()) 3807 3503 return false; … … 3810 3506 3811 3507 if (consumeSlashIncludingWhitespace(m_range)) { 3812 CSSPrimitiveValue* lineHeight = consumeLineHeight(m_range, m_context.mode());3508 RefPtr<CSSPrimitiveValue> lineHeight = consumeLineHeight(m_range, m_context.mode); 3813 3509 if (!lineHeight) 3814 3510 return false; 3815 addProperty(CSSPropertyLineHeight, CSSPropertyFont, *lineHeight, important);3511 addProperty(CSSPropertyLineHeight, CSSPropertyFont, lineHeight.releaseNonNull(), important); 3816 3512 } else { 3817 addProperty(CSSPropertyLineHeight, CSSPropertyFont, *CSSPrimitiveValue::createIdentifier(CSSValueNormal), important);3513 addProperty(CSSPropertyLineHeight, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important); 3818 3514 } 3819 3515 3820 3516 // Font family must come now. 3821 CSSValue*parsedFamilyValue = consumeFontFamily(m_range);3517 RefPtr<CSSValue> parsedFamilyValue = consumeFontFamily(m_range); 3822 3518 if (!parsedFamilyValue) 3823 3519 return false; 3824 3520 3825 addProperty(CSSPropertyFontFamily, CSSPropertyFont, *parsedFamilyValue, important);3521 addProperty(CSSPropertyFontFamily, CSSPropertyFont, parsedFamilyValue.releaseNonNull(), important); 3826 3522 3827 3523 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires that … … 3834 3530 { 3835 3531 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); 3838 3534 return m_range.atEnd(); 3839 3535 } 3840 3536 3841 CSSPrimitiveValue* capsValue = nullptr;3537 RefPtr<CSSPrimitiveValue> capsValue; 3842 3538 FontVariantLigaturesParser ligaturesParser; 3843 3539 FontVariantNumericParser numericParser; … … 3871 3567 } while (!m_range.atEnd()); 3872 3568 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); 3876 3572 return true; 3877 3573 } … … 3879 3575 bool CSSPropertyParser::consumeBorderSpacing(bool important) 3880 3576 { 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); 3882 3578 if (!horizontalSpacing) 3883 3579 return false; 3884 CSSValue*verticalSpacing = horizontalSpacing;3580 RefPtr<CSSValue> verticalSpacing = horizontalSpacing; 3885 3581 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); 3887 3583 if (!verticalSpacing || !m_range.atEnd()) 3888 3584 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); 3891 3587 return true; 3892 3588 } 3893 3589 3894 static CSSValue* consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSSPropertyID propId, CSSParserMode cssParserMode) 3590 #if ENABLE(CSS_DEVICE_ADAPTATION) 3591 3592 static RefPtr<CSSValue> consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSSPropertyID propId, CSSParserMode cssParserMode) 3895 3593 { 3896 3594 CSSValueID id = range.peek().id(); … … 3900 3598 case CSSPropertyMinHeight: 3901 3599 case CSSPropertyMaxHeight: 3902 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom)3600 if (id == CSSValueAuto) 3903 3601 return consumeIdent(range); 3904 3602 return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative); … … 3908 3606 if (id == CSSValueAuto) 3909 3607 return consumeIdent(range); 3910 CSSValue*parsedValue = consumeNumber(range, ValueRangeNonNegative);3608 RefPtr<CSSValue> parsedValue = consumeNumber(range, ValueRangeNonNegative); 3911 3609 if (parsedValue) 3912 3610 return parsedValue; … … 3928 3626 bool CSSPropertyParser::parseViewportDescriptor(CSSPropertyID propId, bool important) 3929 3627 { 3930 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled() || isUASheetBehavior(m_context.mode()));3931 3932 3628 switch (propId) { 3933 3629 case CSSPropertyWidth: { 3934 CSSValue* minWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMinWidth, m_context.mode());3630 RefPtr<CSSValue> minWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMinWidth, m_context.mode); 3935 3631 if (!minWidth) 3936 3632 return false; 3937 CSSValue*maxWidth = minWidth;3633 RefPtr<CSSValue> maxWidth = minWidth; 3938 3634 if (!m_range.atEnd()) 3939 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWidth, m_context.mode ());3635 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWidth, m_context.mode); 3940 3636 if (!maxWidth || !m_range.atEnd()) 3941 3637 return false; … … 3945 3641 } 3946 3642 case CSSPropertyHeight: { 3947 CSSValue* minHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMinHeight, m_context.mode());3643 RefPtr<CSSValue> minHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMinHeight, m_context.mode); 3948 3644 if (!minHeight) 3949 3645 return false; 3950 CSSValue*maxHeight = minHeight;3646 RefPtr<CSSValue> maxHeight = minHeight; 3951 3647 if (!m_range.atEnd()) 3952 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxHeight, m_context.mode ());3648 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxHeight, m_context.mode); 3953 3649 if (!maxHeight || !m_range.atEnd()) 3954 3650 return false; … … 3966 3662 case CSSPropertyUserZoom: 3967 3663 case CSSPropertyOrientation: { 3968 CSSValue* parsedValue = consumeSingleViewportDescriptor(m_range, propId, m_context.mode());3664 RefPtr<CSSValue> parsedValue = consumeSingleViewportDescriptor(m_range, propId, m_context.mode); 3969 3665 if (!parsedValue || !m_range.atEnd()) 3970 3666 return false; 3971 addProperty(propId, CSSPropertyInvalid, *parsedValue, important);3667 addProperty(propId, CSSPropertyInvalid, parsedValue.releaseNonNull(), important); 3972 3668 return true; 3973 3669 } … … 3977 3673 } 3978 3674 3979 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSValue*& columnWidth, CSSValue*& columnCount) 3675 #endif 3676 3677 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, RefPtr<CSSValue>& columnWidth, RefPtr<CSSValue>& columnCount) 3980 3678 { 3981 3679 if (range.peek().id() == CSSValueAuto) { … … 3995 3693 bool CSSPropertyParser::consumeColumns(bool important) 3996 3694 { 3997 CSSValue* columnWidth = nullptr;3998 CSSValue* columnCount = nullptr;3695 RefPtr<CSSValue> columnWidth; 3696 RefPtr<CSSValue> columnCount; 3999 3697 if (!consumeColumnWidthOrCount(m_range, columnWidth, columnCount)) 4000 3698 return false; … … 4003 3701 return false; 4004 3702 if (!columnWidth) 4005 columnWidth = CSS PrimitiveValue::createIdentifier(CSSValueAuto);3703 columnWidth = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4006 3704 if (!columnCount) 4007 columnCount = CSS PrimitiveValue::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); 4010 3708 return true; 4011 3709 } … … 4014 3712 { 4015 3713 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]; 4017 3715 const CSSPropertyID* shorthandProperties = shorthand.properties(); 4018 3716 do { … … 4031 3729 for (size_t i = 0; i < shorthand.length(); ++i) { 4032 3730 if (longhands[i]) 4033 addProperty(shorthandProperties[i], shorthand.id(), *longhands[i], important);3731 addProperty(shorthandProperties[i], shorthand.id(), longhands[i].releaseNonNull(), important); 4034 3732 else 4035 addProperty(shorthandProperties[i], shorthand.id(), *CSSInitialValue::createLegacyImplicit(), important);3733 addProperty(shorthandProperties[i], shorthand.id(), CSSValuePool::singleton().createImplicitInitialValue(), important); 4036 3734 } 4037 3735 return true; … … 4043 3741 double flexGrow = unsetValue; 4044 3742 double flexShrink = unsetValue; 4045 CSSPrimitiveValue* flexBasis = nullptr;3743 RefPtr<CSSPrimitiveValue> flexBasis; 4046 3744 4047 3745 if (m_range.peek().id() == CSSValueNone) { 4048 3746 flexGrow = 0; 4049 3747 flexShrink = 0; 4050 flexBasis = CSS PrimitiveValue::createIdentifier(CSSValueAuto);3748 flexBasis = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4051 3749 m_range.consumeIncludingWhitespace(); 4052 3750 } else { … … 4062 3760 flexShrink = num; 4063 3761 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); 4065 3763 else 4066 3764 return false; … … 4069 3767 flexBasis = consumeIdent(m_range); 4070 3768 if (!flexBasis) 4071 flexBasis = consumeLengthOrPercent(m_range, m_context.mode (), ValueRangeNonNegative);3769 flexBasis = consumeLengthOrPercent(m_range, m_context.mode, ValueRangeNonNegative); 4072 3770 if (index == 2 && !m_range.atEnd()) 4073 3771 return false; … … 4081 3779 flexShrink = 1; 4082 3780 if (!flexBasis) 4083 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType ::Percentage);3781 flexBasis = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE); 4084 3782 } 4085 3783 4086 3784 if (!m_range.atEnd()) 4087 3785 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); 4091 3789 return true; 4092 3790 } … … 4094 3792 bool CSSPropertyParser::consumeBorder(bool important) 4095 3793 { 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; 4099 3797 4100 3798 while (!width || !style || !color) { 4101 3799 if (!width) { 4102 width = consumeLineWidth(m_range, m_context.mode (), UnitlessQuirk::Forbid);3800 width = consumeLineWidth(m_range, m_context.mode, UnitlessQuirk::Forbid); 4103 3801 if (width) 4104 3802 continue; … … 4110 3808 } 4111 3809 if (!color) { 4112 color = consumeColor(m_range, m_context.mode ());3810 color = consumeColor(m_range, m_context.mode); 4113 3811 if (color) 4114 3812 continue; … … 4121 3819 4122 3820 if (!width) 4123 width = CSS InitialValue::createLegacyImplicit();3821 width = CSSValuePool::singleton().createImplicitInitialValue(); 4124 3822 if (!style) 4125 style = CSS InitialValue::createLegacyImplicit();3823 style = CSSValuePool::singleton().createImplicitInitialValue(); 4126 3824 if (!color) 4127 color = CSS InitialValue::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); 4133 3831 4134 3832 return m_range.atEnd(); … … 4139 3837 ASSERT(shorthand.length() == 4); 4140 3838 const CSSPropertyID* longhands = shorthand.properties(); 4141 const CSSValue*top = parseSingleValue(longhands[0], shorthand.id());3839 RefPtr<CSSValue> top = parseSingleValue(longhands[0], shorthand.id()); 4142 3840 if (!top) 4143 3841 return false; 4144 3842 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; 4148 3846 if (right) { 4149 3847 bottom = parseSingleValue(longhands[2], shorthand.id()); … … 4159 3857 left = right; 4160 3858 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); 4165 3863 4166 3864 return m_range.atEnd(); … … 4169 3867 bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool important) 4170 3868 { 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 4176 3875 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(); 4177 3886 switch (property) { 4178 3887 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); 4184 3893 return true; 4185 3894 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); 4191 3900 return true; 4192 3901 default: … … 4238 3947 // shorthands for their break-(after|before|inside) counterparts. We'll do the same for the 4239 3948 // non-standard properties -webkit-column-break-(after|before|inside). 4240 CSSPrimitiveValue*keyword = consumeIdent(m_range);3949 RefPtr<CSSPrimitiveValue> keyword = consumeIdent(m_range); 4241 3950 if (!keyword) 4242 3951 return false; … … 4264 3973 4265 3974 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); 4266 addProperty(genericBreakProperty, property, *CSSPrimitiveValue::createIdentifier(value), important);3975 addProperty(genericBreakProperty, property, CSSValuePool::singleton().createIdentifierValue(value), important); 4267 3976 return true; 4268 3977 } 4269 3978 4270 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& resultY)3979 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless, RefPtr<CSSValue>& resultX, RefPtr<CSSValue>& resultY) 4271 3980 { 4272 3981 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()); 4279 3988 } while (consumeCommaIncludingWhitespace(range)); 4280 3989 return true; 4281 3990 } 4282 3991 4283 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, CSSValue*& value1, CSSValue*& value2, bool& implicit)3992 static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, RefPtr<CSSPrimitiveValue>& value1, RefPtr<CSSPrimitiveValue>& value2, bool& implicit) 4284 3993 { 4285 3994 if (consumeIdent<CSSValueRepeatX>(range)) { 4286 value1 = CSS PrimitiveValue::createIdentifier(CSSValueRepeat);4287 value2 = CSS PrimitiveValue::createIdentifier(CSSValueNoRepeat);3995 value1 = CSSValuePool::singleton().createIdentifierValue(CSSValueRepeat); 3996 value2 = CSSValuePool::singleton().createIdentifierValue(CSSValueNoRepeat); 4288 3997 implicit = true; 4289 3998 return true; 4290 3999 } 4291 4000 if (consumeIdent<CSSValueRepeatY>(range)) { 4292 value1 = CSS PrimitiveValue::createIdentifier(CSSValueNoRepeat);4293 value2 = CSS PrimitiveValue::createIdentifier(CSSValueRepeat);4001 value1 = CSSValuePool::singleton().createIdentifierValue(CSSValueNoRepeat); 4002 value2 = CSSValuePool::singleton().createIdentifierValue(CSSValueRepeat); 4294 4003 implicit = true; 4295 4004 return true; … … 4307 4016 } 4308 4017 4309 static bool consumeRepeatStyle(CSSParserTokenRange& range, CSSValue*& resultX, CSSValue*& resultY, bool& implicit)4018 static bool consumeRepeatStyle(CSSParserTokenRange& range, RefPtr<CSSValue>& resultX, RefPtr<CSSValue>& resultY, bool& implicit) 4310 4019 { 4311 4020 do { 4312 CSSValue* repeatX = nullptr;4313 CSSValue* repeatY = nullptr;4021 RefPtr<CSSPrimitiveValue> repeatX; 4022 RefPtr<CSSPrimitiveValue> repeatY; 4314 4023 if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit)) 4315 4024 return false; 4316 addBackgroundValue(resultX, repeatX );4317 addBackgroundValue(resultY, repeatY );4025 addBackgroundValue(resultX, repeatX.releaseNonNull()); 4026 addBackgroundValue(resultY, repeatY.releaseNonNull()); 4318 4027 } while (consumeCommaIncludingWhitespace(range)); 4319 4028 return true; … … 4325 4034 { 4326 4035 const unsigned longhandCount = shorthand.length(); 4327 CSSValue* longhands[10] = { 0 };4036 RefPtr<CSSValue> longhands[10]; 4328 4037 ASSERT(longhandCount <= 10); 4329 4038 … … 4331 4040 do { 4332 4041 bool parsedLonghand[10] = { false }; 4333 CSSValue* originValue = nullptr;4042 RefPtr<CSSValue> originValue; 4334 4043 do { 4335 4044 bool foundProperty = false; … … 4338 4047 continue; 4339 4048 4340 CSSValue* value = nullptr;4341 CSSValue* valueY = nullptr;4049 RefPtr<CSSValue> value; 4050 RefPtr<CSSValue> valueY; 4342 4051 CSSPropertyID property = shorthand.properties()[i]; 4343 4052 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; 4345 4058 } else if (property == CSSPropertyBackgroundPositionX || property == CSSPropertyWebkitMaskPositionX) { 4346 4059 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)) 4348 4063 continue; 4064 value = primitiveValue; 4065 valueY = primitiveValueY; 4349 4066 m_range = rangeCopy; 4350 4067 } else if (property == CSSPropertyBackgroundSize || property == CSSPropertyWebkitMaskSize) { 4351 4068 if (!consumeSlashIncludingWhitespace(m_range)) 4352 4069 continue; 4353 value = consumeBackgroundSize(property, m_range, m_context.mode ());4070 value = consumeBackgroundSize(property, m_range, m_context.mode); 4354 4071 if (!value || !parsedLonghand[i - 1]) // Position must have been parsed in the current layer. 4355 4072 return false; … … 4365 4082 parsedLonghand[i] = true; 4366 4083 foundProperty = true; 4367 addBackgroundValue(longhands[i], value );4084 addBackgroundValue(longhands[i], value.releaseNonNull()); 4368 4085 if (valueY) { 4369 4086 parsedLonghand[i + 1] = true; 4370 addBackgroundValue(longhands[i + 1], valueY );4087 addBackgroundValue(longhands[i + 1], valueY.releaseNonNull()); 4371 4088 } 4372 4089 } … … 4385 4102 } 4386 4103 if ((property == CSSPropertyBackgroundClip || property == CSSPropertyWebkitMaskClip) && !parsedLonghand[i] && originValue) { 4387 addBackgroundValue(longhands[i], originValue );4104 addBackgroundValue(longhands[i], originValue.releaseNonNull()); 4388 4105 continue; 4389 4106 } 4390 4107 if (!parsedLonghand[i]) 4391 addBackgroundValue(longhands[i], CSS InitialValue::createLegacyImplicit());4108 addBackgroundValue(longhands[i], CSSValuePool::singleton().createImplicitInitialValue()); 4392 4109 } 4393 4110 } while (consumeCommaIncludingWhitespace(m_range)); … … 4397 4114 for (size_t i = 0; i < longhandCount; ++i) { 4398 4115 CSSPropertyID property = shorthand.properties()[i]; 4399 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.useLegacyBackgroundSizeShorthandBehavior ())4116 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.useLegacyBackgroundSizeShorthandBehavior) 4400 4117 continue; 4401 4118 addProperty(property, shorthand.id(), *longhands[i], important, implicit); … … 4406 4123 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthandId, bool important) 4407 4124 { 4408 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());4409 4125 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); 4410 4126 ASSERT(shorthand.length() == 2); 4411 CSSValue*startValue = consumeGridLine(m_range);4127 RefPtr<CSSValue> startValue = consumeGridLine(m_range); 4412 4128 if (!startValue) 4413 4129 return false; 4414 4130 4415 CSSValue* endValue = nullptr;4131 RefPtr<CSSValue> endValue; 4416 4132 if (consumeSlashIncludingWhitespace(m_range)) { 4417 4133 endValue = consumeGridLine(m_range); … … 4419 4135 return false; 4420 4136 } else { 4421 endValue = startValue->isCustomIdentValue() ? startValue : CSS PrimitiveValue::createIdentifier(CSSValueAuto);4137 endValue = startValue->isCustomIdentValue() ? startValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4422 4138 } 4423 4139 if (!m_range.atEnd()) 4424 4140 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); 4427 4143 return true; 4428 4144 } … … 4430 4146 bool CSSPropertyParser::consumeGridAreaShorthand(bool important) 4431 4147 { 4432 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); 4433 ASSERT(gridAreaShorthand().length() == 4); 4434 CSSValue* rowStartValue = consumeGridLine(m_range); 4148 RefPtr<CSSValue> rowStartValue = consumeGridLine(m_range); 4435 4149 if (!rowStartValue) 4436 4150 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; 4440 4154 if (consumeSlashIncludingWhitespace(m_range)) { 4441 4155 columnStartValue = consumeGridLine(m_range); … … 4456 4170 return false; 4457 4171 if (!columnStartValue) 4458 columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSS PrimitiveValue::createIdentifier(CSSValueAuto);4172 columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4459 4173 if (!rowEndValue) 4460 rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSS PrimitiveValue::createIdentifier(CSSValueAuto);4174 rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4461 4175 if (!columnEndValue) 4462 columnEndValue = columnStartValue->isCustomIdentValue() ? columnStartValue : CSS PrimitiveValue::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); 4468 4182 return true; 4469 4183 } … … 4474 4188 size_t rowCount = 0; 4475 4189 size_t columnCount = 0; 4476 CSSValueList*templateRows = CSSValueList::createSpaceSeparated();4190 RefPtr<CSSValueList> templateRows = CSSValueList::createSpaceSeparated(); 4477 4191 4478 4192 // Persists between loop iterations so we can use the same value for 4479 4193 // consecutive <line-names> values 4480 CSSGridLineNamesValue* lineNames = nullptr;4194 RefPtr<CSSGridLineNamesValue> lineNames; 4481 4195 4482 4196 do { 4483 4197 // Handle leading <custom-ident>*. 4484 4198 bool hasPreviousLineNames = lineNames; 4485 lineNames = consumeGridLineNames(m_range, lineNames );4199 lineNames = consumeGridLineNames(m_range, lineNames.get()); 4486 4200 if (lineNames && !hasPreviousLineNames) 4487 4201 templateRows->append(*lineNames); … … 4493 4207 4494 4208 // 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); 4496 4210 if (!value) 4497 value = CSS PrimitiveValue::createIdentifier(CSSValueAuto);4211 value = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4498 4212 templateRows->append(*value); 4499 4213 … … 4501 4215 lineNames = consumeGridLineNames(m_range); 4502 4216 if (lineNames) 4503 templateRows->append( *lineNames);4217 templateRows->append(lineNames.releaseNonNull()); 4504 4218 } while (!m_range.atEnd() && !(m_range.peek().type() == DelimiterToken && m_range.peek().delimiter() == '/')); 4505 4219 4506 CSSValue* columnsValue = nullptr;4220 RefPtr<CSSValue> columnsValue; 4507 4221 if (!m_range.atEnd()) { 4508 4222 if (!consumeSlashIncludingWhitespace(m_range)) 4509 4223 return false; 4510 columnsValue = consumeGridTrackList(m_range, m_context.mode (), GridTemplateNoRepeat);4224 columnsValue = consumeGridTrackList(m_range, m_context.mode, GridTemplateNoRepeat); 4511 4225 if (!columnsValue || !m_range.atEnd()) 4512 4226 return false; 4513 4227 } else { 4514 columnsValue = CSS PrimitiveValue::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); 4519 4233 return true; 4520 4234 } … … 4522 4236 bool CSSPropertyParser::consumeGridTemplateShorthand(CSSPropertyID shorthandId, bool important) 4523 4237 { 4524 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());4525 ASSERT(gridTemplateShorthand().length() == 3);4526 4527 4238 CSSParserTokenRange rangeCopy = m_range; 4528 CSSValue*rowsValue = consumeIdent<CSSValueNone>(m_range);4239 RefPtr<CSSValue> rowsValue = consumeIdent<CSSValueNone>(m_range); 4529 4240 4530 4241 // 1- 'none' case. 4531 4242 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); 4535 4246 return true; 4536 4247 } … … 4538 4249 // 2- <grid-template-rows> / <grid-template-columns> 4539 4250 if (!rowsValue) 4540 rowsValue = consumeGridTrackList(m_range, m_context.mode (), GridTemplate);4251 rowsValue = consumeGridTrackList(m_range, m_context.mode, GridTemplate); 4541 4252 4542 4253 if (rowsValue) { 4543 4254 if (!consumeSlashIncludingWhitespace(m_range)) 4544 4255 return false; 4545 CSSValue* columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_context.mode());4256 RefPtr<CSSValue> columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_context.mode); 4546 4257 if (!columnsValue || !m_range.atEnd()) 4547 4258 return false; 4548 4259 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); 4552 4263 return true; 4553 4264 } … … 4560 4271 bool CSSPropertyParser::consumeGridShorthand(bool important) 4561 4272 { 4562 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());4563 4273 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); 4564 4274 … … 4569 4279 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 4570 4280 // 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); 4576 4286 return true; 4577 4287 } … … 4580 4290 4581 4291 // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ] 4582 CSSValueList*gridAutoFlow = consumeGridAutoFlow(m_range);4292 RefPtr<CSSValueList> gridAutoFlow = consumeGridAutoFlow(m_range); 4583 4293 if (!gridAutoFlow) 4584 4294 return false; 4585 4295 4586 CSSValue* autoColumnsValue = nullptr;4587 CSSValue* autoRowsValue = nullptr;4296 RefPtr<CSSValue> autoColumnsValue; 4297 RefPtr<CSSValue> autoRowsValue; 4588 4298 4589 4299 if (!m_range.atEnd()) { 4590 autoRowsValue = consumeGridTrackList(m_range, m_context.mode (), GridAuto);4300 autoRowsValue = consumeGridTrackList(m_range, m_context.mode, GridAuto); 4591 4301 if (!autoRowsValue) 4592 4302 return false; 4593 4303 if (consumeSlashIncludingWhitespace(m_range)) { 4594 autoColumnsValue = consumeGridTrackList(m_range, m_context.mode (), GridAuto);4304 autoColumnsValue = consumeGridTrackList(m_range, m_context.mode, GridAuto); 4595 4305 if (!autoColumnsValue) 4596 4306 return false; … … 4600 4310 } else { 4601 4311 // Other omitted values are set to their initial values. 4602 autoColumnsValue = CSS InitialValue::createLegacyImplicit();4603 autoRowsValue = CSS InitialValue::createLegacyImplicit();4312 autoColumnsValue = CSSValuePool::singleton().createImplicitInitialValue(); 4313 autoRowsValue = CSSValuePool::singleton().createImplicitInitialValue(); 4604 4314 } 4605 4315 … … 4610 4320 // It can only be specified the explicit or the implicit grid properties in a single grid declaration. 4611 4321 // 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); 4620 4330 return true; 4621 4331 } 4622 4332 4623 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool important) 4624 { 4625 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 4626 4333 bool CSSPropertyParser::parseShorthand(CSSPropertyID property, bool important) 4334 { 4627 4335 switch (property) { 4628 4336 case CSSPropertyWebkitMarginCollapse: { 4629 4337 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); 4634 4342 if (m_range.atEnd()) { 4635 addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, *beforeCollapse, important);4343 addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMarginCollapse, beforeCollapse.releaseNonNull(), important); 4636 4344 return true; 4637 4345 } 4638 4346 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); 4642 4350 return true; 4643 4351 } 4644 4352 case CSSPropertyOverflow: { 4645 4353 CSSValueID id = m_range.consumeIncludingWhitespace().id(); 4646 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode ()))4354 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverflowY, id, m_context.mode)) 4647 4355 return false; 4648 4356 if (!m_range.atEnd()) 4649 4357 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; 4653 4360 4654 4361 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. If this value has been … … 4657 4364 // paged-x or paged-y, then overflow-x and overflow-y should have the same value. 4658 4365 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) 4659 overflowXValue = CSS PrimitiveValue::createIdentifier(CSSValueAuto);4366 overflowXValue = CSSValuePool::singleton().createIdentifierValue(CSSValueAuto); 4660 4367 else 4661 4368 overflowXValue = overflowYValue; … … 4677 4384 return consumeColumns(important); 4678 4385 case CSSPropertyAnimation: 4679 return consumeAnimationShorthand(animationShorthandForParsing(), unresolvedProperty == CSSPropertyAliasWebkitAnimation,important);4386 return consumeAnimationShorthand(animationShorthandForParsing(), important); 4680 4387 case CSSPropertyTransition: 4681 return consumeAnimationShorthand(transitionShorthandForParsing(), false,important);4388 return consumeAnimationShorthand(transitionShorthandForParsing(), important); 4682 4389 case CSSPropertyTextDecoration: 4683 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); 4684 return consumeShorthandGreedily(textDecorationShorthand(), important); 4390 return consumeShorthandGreedily(webkitTextDecorationShorthand(), important); 4685 4391 case CSSPropertyMargin: 4686 4392 return consume4Values(marginShorthand(), important); 4687 4393 case CSSPropertyPadding: 4688 4394 return consume4Values(paddingShorthand(), important); 4689 case CSSPropertyMotion:4690 return consumeShorthandGreedily(motionShorthand(), important);4691 4395 case CSSPropertyWebkitTextEmphasis: 4692 4396 return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important); … … 4704 4408 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); 4705 4409 case CSSPropertyMarker: { 4706 const CSSValue*marker = parseSingleValue(CSSPropertyMarkerStart);4410 RefPtr<CSSValue> marker = parseSingleValue(CSSPropertyMarkerStart); 4707 4411 if (!marker || !m_range.atEnd()) 4708 4412 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); 4712 4416 return true; 4713 4417 } … … 4721 4425 return consumeShorthandGreedily(listStyleShorthand(), important); 4722 4426 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); 4731 4435 return true; 4732 4436 } … … 4759 4463 case CSSPropertyWebkitMaskPosition: 4760 4464 case CSSPropertyBackgroundPosition: { 4761 CSSValue* resultX = nullptr;4762 CSSValue* resultY = nullptr;4465 RefPtr<CSSValue> resultX; 4466 RefPtr<CSSValue> resultY; 4763 4467 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow, resultX, resultY) || !m_range.atEnd()) 4764 4468 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); 4767 4471 return true; 4768 4472 } 4769 4473 case CSSPropertyBackgroundRepeat: 4770 4474 case CSSPropertyWebkitMaskRepeat: { 4771 CSSValue* resultX = nullptr;4772 CSSValue* resultY = nullptr;4475 RefPtr<CSSValue> resultX; 4476 RefPtr<CSSValue> resultY; 4773 4477 bool implicit = false; 4774 4478 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range.atEnd()) 4775 4479 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); 4778 4482 return true; 4779 4483 } … … 4783 4487 return consumeBackgroundShorthand(webkitMaskShorthand(), important); 4784 4488 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); 4788 4491 if (!rowGap || !m_range.atEnd()) 4789 4492 return false; 4790 4493 if (!columnGap) 4791 4494 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); 4794 4497 return true; 4795 4498 } … … 4807 4510 } 4808 4511 } 4809 */4810 4512 4811 4513 } // namespace WebCore -
trunk/Source/WebCore/css/parser/CSSPropertyParser.h
r205660 r207479 45 45 46 46 // 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&); 48 48 49 49 private: … … 52 52 53 53 // 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); 57 57 58 58 bool inQuirksMode() const { return m_context.mode == HTMLQuirksMode; } … … 61 61 bool parseFontFaceDescriptor(CSSPropertyID); 62 62 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); 65 65 66 66 bool consumeBorder(bool important); … … 71 71 72 72 // Legacy parsing allows <string>s for animation-name 73 bool consumeAnimationShorthand(const StylePropertyShorthand&, bool useLegacyParsing, boolimportant);73 bool consumeAnimationShorthand(const StylePropertyShorthand&, bool important); 74 74 bool consumeBackgroundShorthand(const StylePropertyShorthand&, bool important); 75 75 … … 103 103 }; 104 104 105 CSSPropertyID unresolvedCSSPropertyID(StringView);105 CSSPropertyID cssPropertyID(StringView); 106 106 CSSValueID cssValueKeywordID(StringView); 107 107 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r207396 r207479 324 324 if (range.peek().type() != IdentToken) 325 325 return nullptr; 326 return CSS PrimitiveValue::createIdentifier(range.consumeIncludingWhitespace().id());326 return CSSValuePool::singleton().createIdentifierValue(range.consumeIncludingWhitespace().id()); 327 327 } 328 328 … … 334 334 } 335 335 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). 339 RefPtr<CSSPrimitiveValue> consumeCustomIdent(CSSParserTokenRange& range) 337 340 { 338 341 if (range.peek().type() != IdentToken || isCSSWideKeyword(range.peek().id())) 339 342 return nullptr; 340 return CSS CustomIdentValue::create(range.consumeIncludingWhitespace().value().toString());343 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING); 341 344 } 342 345 … … 345 348 if (range.peek().type() != StringToken) 346 349 return nullptr; 347 return CSS PrimitiveValue::create(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING);350 return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().value().toString(), CSSPrimitiveValue::UnitTypes::CSS_STRING); 348 351 } 349 352 … … 1035 1038 1036 1039 RefPtr<CSSValue> image = CSSImageValue::create(completeURL(context, urlValue)); 1037 imageSet->append( *image);1040 imageSet->append(image.releaseNonNull()); 1038 1041 1039 1042 const CSSParserToken& token = args.consumeIncludingWhitespace(); -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.h
r206043 r207479 72 72 template<CSSValueID... allowedIdents> RefPtr<CSSPrimitiveValue> consumeIdent(CSSParserTokenRange&); 73 73 74 RefPtr<CSS CustomIdentValue> consumeCustomIdent(CSSParserTokenRange&);74 RefPtr<CSSPrimitiveValue> consumeCustomIdent(CSSParserTokenRange&); 75 75 RefPtr<CSSPrimitiveValue> consumeString(CSSParserTokenRange&); 76 76 StringView consumeUrlAsStringView(CSSParserTokenRange&);
Note: See TracChangeset
for help on using the changeset viewer.