| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
| 7 | 7 |
| 8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
| 9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
| 10 #include "core/css/CSSCursorImageValue.h" | 10 #include "core/css/CSSCursorImageValue.h" |
| (...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) | 2172 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) |
| 2173 { | 2173 { |
| 2174 CSSValueID id = range.peek().id(); | 2174 CSSValueID id = range.peek().id(); |
| 2175 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 2175 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
| 2176 return consumeIdent(range); | 2176 return consumeIdent(range); |
| 2177 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, Unitle
ssQuirk::Forbid); | 2177 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, Unitle
ssQuirk::Forbid); |
| 2178 } | 2178 } |
| 2179 | 2179 |
| 2180 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeImageSet(CSSParserTok
enRange& range) | 2180 static PassRefPtrWillBeRawPtr<CSSValue> consumeImageSet(CSSParserTokenRange& ran
ge, CSSParserContext context) |
| 2181 { | 2181 { |
| 2182 CSSParserTokenRange rangeCopy = range; | 2182 CSSParserTokenRange rangeCopy = range; |
| 2183 CSSParserTokenRange args = consumeFunction(rangeCopy); | 2183 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 2184 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 2184 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
| 2185 do { | 2185 do { |
| 2186 AtomicString urlValue(consumeUrl(args)); | 2186 AtomicString urlValue(consumeUrl(args)); |
| 2187 if (urlValue.isNull()) | 2187 if (urlValue.isNull()) |
| 2188 return nullptr; | 2188 return nullptr; |
| 2189 | 2189 |
| 2190 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(url
Value, completeURL(urlValue)); | 2190 RefPtrWillBeRawPtr<CSSValue> image = CSSPropertyParser::createCSSImageVa
lueWithReferrer(urlValue, context); |
| 2191 imageSet->append(image); | 2191 imageSet->append(image); |
| 2192 | 2192 |
| 2193 const CSSParserToken& token = args.consumeIncludingWhitespace(); | 2193 const CSSParserToken& token = args.consumeIncludingWhitespace(); |
| 2194 if (token.type() != DimensionToken) | 2194 if (token.type() != DimensionToken) |
| 2195 return nullptr; | 2195 return nullptr; |
| 2196 if (String(token.value()) != "x") | 2196 if (String(token.value()) != "x") |
| 2197 return nullptr; | 2197 return nullptr; |
| 2198 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); | 2198 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); |
| 2199 double imageScaleFactor = token.numericValue(); | 2199 double imageScaleFactor = token.numericValue(); |
| 2200 if (imageScaleFactor <= 0) | 2200 if (imageScaleFactor <= 0) |
| 2201 return nullptr; | 2201 return nullptr; |
| 2202 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::UnitType::Number)); | 2202 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::UnitType::Number)); |
| 2203 } while (consumeCommaIncludingWhitespace(args)); | 2203 } while (consumeCommaIncludingWhitespace(args)); |
| 2204 if (!args.atEnd()) | 2204 if (!args.atEnd()) |
| 2205 return nullptr; | 2205 return nullptr; |
| 2206 range = rangeCopy; | 2206 range = rangeCopy; |
| 2207 return imageSet.release(); | 2207 return imageSet.release(); |
| 2208 } | 2208 } |
| 2209 | 2209 |
| 2210 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeCursor(CSSParserToken
Range& range) | 2210 static PassRefPtrWillBeRawPtr<CSSValue> consumeCursor(CSSParserTokenRange& range
, CSSParserContext context, bool inQuirksMode) |
| 2211 { | 2211 { |
| 2212 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 2212 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
| 2213 while (!range.atEnd()) { | 2213 while (!range.atEnd()) { |
| 2214 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | 2214 RefPtrWillBeRawPtr<CSSValue> image = nullptr; |
| 2215 AtomicString uri(consumeUrl(range)); | 2215 AtomicString uri(consumeUrl(range)); |
| 2216 if (!uri.isNull()) { | 2216 if (!uri.isNull()) { |
| 2217 image = createCSSImageValueWithReferrer(uri, completeURL(uri)); | 2217 image = CSSPropertyParser::createCSSImageValueWithReferrer(uri, cont
ext); |
| 2218 } else if (range.peek().type() == FunctionToken && range.peek().function
Id() == CSSValueWebkitImageSet) { | 2218 } else if (range.peek().type() == FunctionToken && range.peek().function
Id() == CSSValueWebkitImageSet) { |
| 2219 image = consumeImageSet(range); | 2219 image = consumeImageSet(range, context); |
| 2220 if (!image) | 2220 if (!image) |
| 2221 return nullptr; | 2221 return nullptr; |
| 2222 } else { | 2222 } else { |
| 2223 break; | 2223 break; |
| 2224 } | 2224 } |
| 2225 | 2225 |
| 2226 double num; | 2226 double num; |
| 2227 IntPoint hotSpot(-1, -1); | 2227 IntPoint hotSpot(-1, -1); |
| 2228 bool hotSpotSpecified = false; | 2228 bool hotSpotSpecified = false; |
| 2229 if (consumeNumberRaw(range, num)) { | 2229 if (consumeNumberRaw(range, num)) { |
| 2230 hotSpot.setX(int(num)); | 2230 hotSpot.setX(int(num)); |
| 2231 if (!consumeNumberRaw(range, num)) | 2231 if (!consumeNumberRaw(range, num)) |
| 2232 return nullptr; | 2232 return nullptr; |
| 2233 hotSpot.setY(int(num)); | 2233 hotSpot.setY(int(num)); |
| 2234 hotSpotSpecified = true; | 2234 hotSpotSpecified = true; |
| 2235 } | 2235 } |
| 2236 | 2236 |
| 2237 if (!list) | 2237 if (!list) |
| 2238 list = CSSValueList::createCommaSeparated(); | 2238 list = CSSValueList::createCommaSeparated(); |
| 2239 | 2239 |
| 2240 list->append(CSSCursorImageValue::create(image, hotSpotSpecified, hotSpo
t)); | 2240 list->append(CSSCursorImageValue::create(image, hotSpotSpecified, hotSpo
t)); |
| 2241 if (!consumeCommaIncludingWhitespace(range)) | 2241 if (!consumeCommaIncludingWhitespace(range)) |
| 2242 return nullptr; | 2242 return nullptr; |
| 2243 } | 2243 } |
| 2244 | 2244 |
| 2245 CSSValueID id = range.peek().id(); | 2245 CSSValueID id = range.peek().id(); |
| 2246 if (!range.atEnd() && m_context.useCounter()) { | 2246 if (!range.atEnd() && context.useCounter()) { |
| 2247 if (id == CSSValueWebkitZoomIn) | 2247 if (id == CSSValueWebkitZoomIn) |
| 2248 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); | 2248 context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); |
| 2249 else if (id == CSSValueWebkitZoomOut) | 2249 else if (id == CSSValueWebkitZoomOut) |
| 2250 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); | 2250 context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); |
| 2251 } | 2251 } |
| 2252 RefPtrWillBeRawPtr<CSSValue> cursorType = nullptr; | 2252 RefPtrWillBeRawPtr<CSSValue> cursorType = nullptr; |
| 2253 if (id == CSSValueHand) { | 2253 if (id == CSSValueHand) { |
| 2254 if (inQuirksMode()) // Non-standard behavior | 2254 if (inQuirksMode) // Non-standard behavior |
| 2255 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); | 2255 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); |
| 2256 range.consumeIncludingWhitespace(); | 2256 range.consumeIncludingWhitespace(); |
| 2257 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV
alueCopy || id == CSSValueNone) { | 2257 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV
alueCopy || id == CSSValueNone) { |
| 2258 cursorType = consumeIdent(range); | 2258 cursorType = consumeIdent(range); |
| 2259 } | 2259 } |
| 2260 | 2260 |
| 2261 if (!list) | 2261 if (!list) |
| 2262 return cursorType.release(); | 2262 return cursorType.release(); |
| 2263 if (cursorType) | 2263 if (cursorType) |
| 2264 list->append(cursorType.release()); | 2264 list->append(cursorType.release()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2474 case CSSPropertyStrokeDashoffset: | 2474 case CSSPropertyStrokeDashoffset: |
| 2475 case CSSPropertyCx: | 2475 case CSSPropertyCx: |
| 2476 case CSSPropertyCy: | 2476 case CSSPropertyCy: |
| 2477 case CSSPropertyX: | 2477 case CSSPropertyX: |
| 2478 case CSSPropertyY: | 2478 case CSSPropertyY: |
| 2479 case CSSPropertyR: | 2479 case CSSPropertyR: |
| 2480 case CSSPropertyRx: | 2480 case CSSPropertyRx: |
| 2481 case CSSPropertyRy: | 2481 case CSSPropertyRy: |
| 2482 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll,
UnitlessQuirk::Forbid); | 2482 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll,
UnitlessQuirk::Forbid); |
| 2483 case CSSPropertyCursor: | 2483 case CSSPropertyCursor: |
| 2484 return consumeCursor(m_range); | 2484 return consumeCursor(m_range, m_context, inQuirksMode()); |
| 2485 case CSSPropertyContain: | 2485 case CSSPropertyContain: |
| 2486 return consumeContain(m_range); | 2486 return consumeContain(m_range); |
| 2487 case CSSPropertyTransformOrigin: | 2487 case CSSPropertyTransformOrigin: |
| 2488 return consumeTransformOrigin(m_range, m_context.mode(), UnitlessQuirk::
Forbid); | 2488 return consumeTransformOrigin(m_range, m_context.mode(), UnitlessQuirk::
Forbid); |
| 2489 default: | 2489 default: |
| 2490 return nullptr; | 2490 return nullptr; |
| 2491 } | 2491 } |
| 2492 } | 2492 } |
| 2493 | 2493 |
| 2494 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 2494 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2508 } while (consumeCommaIncludingWhitespace(range)); | 2508 } while (consumeCommaIncludingWhitespace(range)); |
| 2509 | 2509 |
| 2510 return values.release(); | 2510 return values.release(); |
| 2511 } | 2511 } |
| 2512 | 2512 |
| 2513 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeFontFaceSrcURI() | 2513 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeFontFaceSrcURI() |
| 2514 { | 2514 { |
| 2515 String url = consumeUrl(m_range); | 2515 String url = consumeUrl(m_range); |
| 2516 if (url.isNull()) | 2516 if (url.isNull()) |
| 2517 return nullptr; | 2517 return nullptr; |
| 2518 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(url), m_context.shouldCheckContentSecurityPolicy())); | 2518 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(m_context.completeURL(url), m_context.shouldCheckContentSecurityPolicy())); |
| 2519 uriValue->setReferrer(m_context.referrer()); | 2519 uriValue->setReferrer(m_context.referrer()); |
| 2520 | 2520 |
| 2521 if (m_range.peek().functionId() != CSSValueFormat) | 2521 if (m_range.peek().functionId() != CSSValueFormat) |
| 2522 return uriValue.release(); | 2522 return uriValue.release(); |
| 2523 | 2523 |
| 2524 // FIXME: https://drafts.csswg.org/css-fonts says that format() contains a c
omma-separated list of strings, | 2524 // FIXME: https://drafts.csswg.org/css-fonts says that format() contains a c
omma-separated list of strings, |
| 2525 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. | 2525 // but CSSFontFaceSrcValue stores only one format. Allowing one format for n
ow. |
| 2526 // FIXME: IdentToken should not be supported here. | 2526 // FIXME: IdentToken should not be supported here. |
| 2527 CSSParserTokenRange args = consumeFunction(m_range); | 2527 CSSParserTokenRange args = consumeFunction(m_range); |
| 2528 const CSSParserToken& arg = args.consumeIncludingWhitespace(); | 2528 const CSSParserToken& arg = args.consumeIncludingWhitespace(); |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3076 return consumeShorthandGreedily(flexFlowShorthand(), important); | 3076 return consumeShorthandGreedily(flexFlowShorthand(), important); |
| 3077 case CSSPropertyWebkitColumnRule: | 3077 case CSSPropertyWebkitColumnRule: |
| 3078 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); | 3078 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); |
| 3079 default: | 3079 default: |
| 3080 m_currentShorthand = oldShorthand; | 3080 m_currentShorthand = oldShorthand; |
| 3081 return false; | 3081 return false; |
| 3082 } | 3082 } |
| 3083 } | 3083 } |
| 3084 | 3084 |
| 3085 } // namespace blink | 3085 } // namespace blink |
| OLD | NEW |