| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSPropertyParser.h" | 5 #include "core/css/parser/CSSPropertyParser.h" |
| 6 | 6 |
| 7 #include "core/StylePropertyShorthand.h" | 7 #include "core/StylePropertyShorthand.h" |
| 8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
| 9 #include "core/css/CSSCounterValue.h" | 9 #include "core/css/CSSCounterValue.h" |
| 10 #include "core/css/CSSCrossfadeValue.h" | 10 #include "core/css/CSSCrossfadeValue.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 return id == head || identMatches<tail...>(id); | 288 return id == head || identMatches<tail...>(id); |
| 289 } | 289 } |
| 290 | 290 |
| 291 template<CSSValueID... names> PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeI
dent(CSSParserTokenRange& range) | 291 template<CSSValueID... names> PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeI
dent(CSSParserTokenRange& range) |
| 292 { | 292 { |
| 293 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) | 293 if (range.peek().type() != IdentToken || !identMatches<names...>(range.peek(
).id())) |
| 294 return nullptr; | 294 return nullptr; |
| 295 return cssValuePool().createIdentifierValue(range.consumeIncludingWhitespace
().id()); | 295 return cssValuePool().createIdentifierValue(range.consumeIncludingWhitespace
().id()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeIdentRange(CSSParserToke
nRange& range, CSSValueID lower, CSSValueID upper) |
| 299 { |
| 300 if (range.peek().id() < lower || range.peek().id() > upper) |
| 301 return nullptr; |
| 302 return consumeIdent(range); |
| 303 } |
| 304 |
| 298 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserT
okenRange& range) | 305 static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> consumeCustomIdent(CSSParserT
okenRange& range) |
| 299 { | 306 { |
| 300 if (range.peek().type() != IdentToken) | 307 if (range.peek().type() != IdentToken) |
| 301 return nullptr; | 308 return nullptr; |
| 302 return CSSCustomIdentValue::create(range.consumeIncludingWhitespace().value(
)); | 309 return CSSCustomIdentValue::create(range.consumeIncludingWhitespace().value(
)); |
| 303 } | 310 } |
| 304 | 311 |
| 305 static PassRefPtrWillBeRawPtr<CSSStringValue> consumeString(CSSParserTokenRange&
range) | 312 static PassRefPtrWillBeRawPtr<CSSStringValue> consumeString(CSSParserTokenRange&
range) |
| 306 { | 313 { |
| 307 if (range.peek().type() != StringToken) | 314 if (range.peek().type() != StringToken) |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 if (range.peek().type() != IdentToken) | 1107 if (range.peek().type() != IdentToken) |
| 1101 return nullptr; | 1108 return nullptr; |
| 1102 String familyName = concatenateFamilyName(range); | 1109 String familyName = concatenateFamilyName(range); |
| 1103 if (familyName.isNull()) | 1110 if (familyName.isNull()) |
| 1104 return nullptr; | 1111 return nullptr; |
| 1105 return cssValuePool().createFontFamilyValue(familyName); | 1112 return cssValuePool().createFontFamilyValue(familyName); |
| 1106 } | 1113 } |
| 1107 | 1114 |
| 1108 static PassRefPtrWillBeRawPtr<CSSValue> consumeGenericFamily(CSSParserTokenRange
& range) | 1115 static PassRefPtrWillBeRawPtr<CSSValue> consumeGenericFamily(CSSParserTokenRange
& range) |
| 1109 { | 1116 { |
| 1110 return consumeIdent<CSSValueSerif, CSSValueSansSerif, CSSValueCursive, CSSVa
lueFantasy, CSSValueMonospace, CSSValueWebkitBody>(range); | 1117 return consumeIdentRange(range, CSSValueSerif, CSSValueWebkitBody); |
| 1111 } | 1118 } |
| 1112 | 1119 |
| 1113 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFamily(CSSParserTokenRang
e& range) | 1120 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFamily(CSSParserTokenRang
e& range) |
| 1114 { | 1121 { |
| 1115 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; | 1122 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createCommaSeparated()
; |
| 1116 do { | 1123 do { |
| 1117 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 1124 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 1118 if ((parsedValue = consumeGenericFamily(range))) { | 1125 if ((parsedValue = consumeGenericFamily(range))) { |
| 1119 list->append(parsedValue); | 1126 list->append(parsedValue); |
| 1120 } else if ((parsedValue = consumeFamilyName(range))) { | 1127 } else if ((parsedValue = consumeFamilyName(range))) { |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 percent = 0; | 2191 percent = 0; |
| 2185 else if (id == CSSValueCenter) | 2192 else if (id == CSSValueCenter) |
| 2186 percent = 50; | 2193 percent = 50; |
| 2187 else if (id == end) | 2194 else if (id == end) |
| 2188 percent = 100; | 2195 percent = 100; |
| 2189 else | 2196 else |
| 2190 return nullptr; | 2197 return nullptr; |
| 2191 range.consumeIncludingWhitespace(); | 2198 range.consumeIncludingWhitespace(); |
| 2192 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); | 2199 return cssValuePool().createValue(percent, CSSPrimitiveValue::UnitType::
Percentage); |
| 2193 } | 2200 } |
| 2194 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, UnitlessQ
uirk::Forbid); | 2201 return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll); |
| 2195 } | 2202 } |
| 2196 | 2203 |
| 2197 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionX(CSSParserTokenRange& ra
nge, CSSParserMode cssParserMode) | 2204 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionX(CSSParserTokenRange& ra
nge, CSSParserMode cssParserMode) |
| 2198 { | 2205 { |
| 2199 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser
Mode); | 2206 return consumePositionLonghand<CSSValueLeft, CSSValueRight>(range, cssParser
Mode); |
| 2200 } | 2207 } |
| 2201 | 2208 |
| 2202 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionY(CSSParserTokenRange& ra
nge, CSSParserMode cssParserMode) | 2209 static PassRefPtrWillBeRawPtr<CSSValue> consumePositionY(CSSParserTokenRange& ra
nge, CSSParserMode cssParserMode) |
| 2203 { | 2210 { |
| 2204 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser
Mode); | 2211 return consumePositionLonghand<CSSValueTop, CSSValueBottom>(range, cssParser
Mode); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 dashes->append(dash.release()); | 2316 dashes->append(dash.release()); |
| 2310 } while (!range.atEnd()); | 2317 } while (!range.atEnd()); |
| 2311 return dashes.release(); | 2318 return dashes.release(); |
| 2312 } | 2319 } |
| 2313 | 2320 |
| 2314 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) | 2321 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) |
| 2315 { | 2322 { |
| 2316 CSSValueID id = range.peek().id(); | 2323 CSSValueID id = range.peek().id(); |
| 2317 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 2324 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
| 2318 return consumeIdent(range); | 2325 return consumeIdent(range); |
| 2319 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, Unitle
ssQuirk::Forbid); | 2326 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll); |
| 2320 } | 2327 } |
| 2321 | 2328 |
| 2322 static PassRefPtrWillBeRawPtr<CSSValue> consumeImageSet(CSSParserTokenRange& ran
ge, const CSSParserContext& context) | 2329 static PassRefPtrWillBeRawPtr<CSSValue> consumeImageSet(CSSParserTokenRange& ran
ge, const CSSParserContext& context) |
| 2323 { | 2330 { |
| 2324 CSSParserTokenRange rangeCopy = range; | 2331 CSSParserTokenRange rangeCopy = range; |
| 2325 CSSParserTokenRange args = consumeFunction(rangeCopy); | 2332 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 2326 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 2333 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
| 2327 do { | 2334 do { |
| 2328 AtomicString urlValue(consumeUrl(args)); | 2335 AtomicString urlValue(consumeUrl(args)); |
| 2329 if (urlValue.isNull()) | 2336 if (urlValue.isNull()) |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2927 { | 2934 { |
| 2928 RefPtrWillBeRawPtr<CSSValue> parsedValue1 = consumeLengthOrPercent(range, cs
sParserMode, ValueRangeNonNegative); | 2935 RefPtrWillBeRawPtr<CSSValue> parsedValue1 = consumeLengthOrPercent(range, cs
sParserMode, ValueRangeNonNegative); |
| 2929 if (!parsedValue1) | 2936 if (!parsedValue1) |
| 2930 return nullptr; | 2937 return nullptr; |
| 2931 RefPtrWillBeRawPtr<CSSValue> parsedValue2 = consumeLengthOrPercent(range, cs
sParserMode, ValueRangeNonNegative); | 2938 RefPtrWillBeRawPtr<CSSValue> parsedValue2 = consumeLengthOrPercent(range, cs
sParserMode, ValueRangeNonNegative); |
| 2932 if (!parsedValue2) | 2939 if (!parsedValue2) |
| 2933 parsedValue2 = parsedValue1; | 2940 parsedValue2 = parsedValue1; |
| 2934 return CSSValuePair::create(parsedValue1.release(), parsedValue2.release(),
CSSValuePair::DropIdenticalValues); | 2941 return CSSValuePair::create(parsedValue1.release(), parsedValue2.release(),
CSSValuePair::DropIdenticalValues); |
| 2935 } | 2942 } |
| 2936 | 2943 |
| 2944 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeVerticalAlign(CSSParserT
okenRange& range, CSSParserMode cssParserMode) |
| 2945 { |
| 2946 RefPtrWillBeRawPtr<CSSPrimitiveValue> parsedValue = consumeIdentRange(range,
CSSValueBaseline, CSSValueWebkitBaselineMiddle); |
| 2947 if (!parsedValue) |
| 2948 parsedValue = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll
, UnitlessQuirk::Allow); |
| 2949 return parsedValue.release(); |
| 2950 } |
| 2951 |
| 2937 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 2952 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
| 2938 { | 2953 { |
| 2939 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 2954 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 2940 switch (property) { | 2955 switch (property) { |
| 2941 case CSSPropertyWillChange: | 2956 case CSSPropertyWillChange: |
| 2942 return consumeWillChange(m_range); | 2957 return consumeWillChange(m_range); |
| 2943 case CSSPropertyPage: | 2958 case CSSPropertyPage: |
| 2944 return consumePage(m_range); | 2959 return consumePage(m_range); |
| 2945 case CSSPropertyQuotes: | 2960 case CSSPropertyQuotes: |
| 2946 return consumeQuotes(m_range); | 2961 return consumeQuotes(m_range); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 case CSSPropertyFlexShrink: | 3162 case CSSPropertyFlexShrink: |
| 3148 return consumeNumber(m_range, ValueRangeNonNegative); | 3163 return consumeNumber(m_range, ValueRangeNonNegative); |
| 3149 case CSSPropertyStrokeDasharray: | 3164 case CSSPropertyStrokeDasharray: |
| 3150 return consumeStrokeDasharray(m_range); | 3165 return consumeStrokeDasharray(m_range); |
| 3151 case CSSPropertyWebkitColumnRuleWidth: | 3166 case CSSPropertyWebkitColumnRuleWidth: |
| 3152 return consumeColumnRuleWidth(m_range, m_context.mode()); | 3167 return consumeColumnRuleWidth(m_range, m_context.mode()); |
| 3153 case CSSPropertyStrokeOpacity: | 3168 case CSSPropertyStrokeOpacity: |
| 3154 case CSSPropertyFillOpacity: | 3169 case CSSPropertyFillOpacity: |
| 3155 case CSSPropertyStopOpacity: | 3170 case CSSPropertyStopOpacity: |
| 3156 case CSSPropertyFloodOpacity: | 3171 case CSSPropertyFloodOpacity: |
| 3172 case CSSPropertyOpacity: |
| 3173 case CSSPropertyWebkitBoxFlex: |
| 3157 return consumeNumber(m_range, ValueRangeAll); | 3174 return consumeNumber(m_range, ValueRangeAll); |
| 3158 case CSSPropertyBaselineShift: | 3175 case CSSPropertyBaselineShift: |
| 3159 return consumeBaselineShift(m_range); | 3176 return consumeBaselineShift(m_range); |
| 3160 case CSSPropertyStrokeMiterlimit: | 3177 case CSSPropertyStrokeMiterlimit: |
| 3161 return consumeNumber(m_range, ValueRangeNonNegative); | 3178 return consumeNumber(m_range, ValueRangeNonNegative); |
| 3162 case CSSPropertyStrokeWidth: | 3179 case CSSPropertyStrokeWidth: |
| 3163 case CSSPropertyStrokeDashoffset: | 3180 case CSSPropertyStrokeDashoffset: |
| 3164 case CSSPropertyCx: | 3181 case CSSPropertyCx: |
| 3165 case CSSPropertyCy: | 3182 case CSSPropertyCy: |
| 3166 case CSSPropertyX: | 3183 case CSSPropertyX: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3184 case CSSPropertyScrollSnapCoordinate: | 3201 case CSSPropertyScrollSnapCoordinate: |
| 3185 return consumeScrollSnapCoordinate(m_range, m_context.mode()); | 3202 return consumeScrollSnapCoordinate(m_range, m_context.mode()); |
| 3186 case CSSPropertyScrollSnapPointsX: | 3203 case CSSPropertyScrollSnapPointsX: |
| 3187 case CSSPropertyScrollSnapPointsY: | 3204 case CSSPropertyScrollSnapPointsY: |
| 3188 return consumeScrollSnapPoints(m_range, m_context.mode()); | 3205 return consumeScrollSnapPoints(m_range, m_context.mode()); |
| 3189 case CSSPropertyBorderTopRightRadius: | 3206 case CSSPropertyBorderTopRightRadius: |
| 3190 case CSSPropertyBorderTopLeftRadius: | 3207 case CSSPropertyBorderTopLeftRadius: |
| 3191 case CSSPropertyBorderBottomLeftRadius: | 3208 case CSSPropertyBorderBottomLeftRadius: |
| 3192 case CSSPropertyBorderBottomRightRadius: | 3209 case CSSPropertyBorderBottomRightRadius: |
| 3193 return consumeBorderRadiusCorner(m_range, m_context.mode()); | 3210 return consumeBorderRadiusCorner(m_range, m_context.mode()); |
| 3211 case CSSPropertyWebkitBoxFlexGroup: |
| 3212 return consumeInteger(m_range, 0); |
| 3213 case CSSPropertyOrder: |
| 3214 return consumeInteger(m_range); |
| 3215 case CSSPropertyTextUnderlinePosition: |
| 3216 // auto | [ under || [ left | right ] ], but we only support auto | unde
r for now |
| 3217 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); |
| 3218 return consumeIdent<CSSValueAuto, CSSValueUnder>(m_range); |
| 3219 case CSSPropertyVerticalAlign: |
| 3220 return consumeVerticalAlign(m_range, m_context.mode()); |
| 3194 default: | 3221 default: |
| 3195 return nullptr; | 3222 return nullptr; |
| 3196 } | 3223 } |
| 3197 } | 3224 } |
| 3198 | 3225 |
| 3199 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 3226 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
| 3200 { | 3227 { |
| 3201 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 3228 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
| 3202 | 3229 |
| 3203 do { | 3230 do { |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3840 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(hori
zontalRadii[3].release(), verticalRadii[3].release(), CSSValuePair::DropIdentica
lValues), important); | 3867 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(hori
zontalRadii[3].release(), verticalRadii[3].release(), CSSValuePair::DropIdentica
lValues), important); |
| 3841 return true; | 3868 return true; |
| 3842 } | 3869 } |
| 3843 default: | 3870 default: |
| 3844 m_currentShorthand = oldShorthand; | 3871 m_currentShorthand = oldShorthand; |
| 3845 return false; | 3872 return false; |
| 3846 } | 3873 } |
| 3847 } | 3874 } |
| 3848 | 3875 |
| 3849 } // namespace blink | 3876 } // namespace blink |
| OLD | NEW |