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/CSSCustomIdentValue.h" | 11 #include "core/css/CSSCustomIdentValue.h" |
11 #include "core/css/CSSFontFaceSrcValue.h" | 12 #include "core/css/CSSFontFaceSrcValue.h" |
12 #include "core/css/CSSFontFeatureValue.h" | 13 #include "core/css/CSSFontFeatureValue.h" |
13 #include "core/css/CSSFunctionValue.h" | 14 #include "core/css/CSSFunctionValue.h" |
| 15 #include "core/css/CSSImageSetValue.h" |
14 #include "core/css/CSSPathValue.h" | 16 #include "core/css/CSSPathValue.h" |
15 #include "core/css/CSSPrimitiveValueMappings.h" | 17 #include "core/css/CSSPrimitiveValueMappings.h" |
16 #include "core/css/CSSQuadValue.h" | 18 #include "core/css/CSSQuadValue.h" |
17 #include "core/css/CSSSVGDocumentValue.h" | 19 #include "core/css/CSSSVGDocumentValue.h" |
18 #include "core/css/CSSShadowValue.h" | 20 #include "core/css/CSSShadowValue.h" |
19 #include "core/css/CSSStringValue.h" | 21 #include "core/css/CSSStringValue.h" |
20 #include "core/css/CSSTimingFunctionValue.h" | 22 #include "core/css/CSSTimingFunctionValue.h" |
21 #include "core/css/CSSURIValue.h" | 23 #include "core/css/CSSURIValue.h" |
22 #include "core/css/CSSUnicodeRangeValue.h" | 24 #include "core/css/CSSUnicodeRangeValue.h" |
23 #include "core/css/CSSValuePair.h" | 25 #include "core/css/CSSValuePair.h" |
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 } | 2134 } |
2133 | 2135 |
2134 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) | 2136 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> consumeBaselineShift(CSSParserT
okenRange& range) |
2135 { | 2137 { |
2136 CSSValueID id = range.peek().id(); | 2138 CSSValueID id = range.peek().id(); |
2137 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) | 2139 if (id == CSSValueBaseline || id == CSSValueSub || id == CSSValueSuper) |
2138 return consumeIdent(range); | 2140 return consumeIdent(range); |
2139 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, Unitle
ssQuirk::Forbid); | 2141 return consumeLengthOrPercent(range, SVGAttributeMode, ValueRangeAll, Unitle
ssQuirk::Forbid); |
2140 } | 2142 } |
2141 | 2143 |
| 2144 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeImageSet(CSSParserTok
enRange& range) |
| 2145 { |
| 2146 CSSParserTokenRange rangeCopy = range; |
| 2147 CSSParserTokenRange args = consumeFunction(rangeCopy); |
| 2148 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
| 2149 do { |
| 2150 AtomicString urlValue(consumeUrl(args)); |
| 2151 if (urlValue.isNull()) |
| 2152 return nullptr; |
| 2153 |
| 2154 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(url
Value, completeURL(urlValue)); |
| 2155 imageSet->append(image); |
| 2156 |
| 2157 const CSSParserToken& token = args.consumeIncludingWhitespace(); |
| 2158 if (token.type() != DimensionToken) |
| 2159 return nullptr; |
| 2160 if (String(token.value()) != "x") |
| 2161 return nullptr; |
| 2162 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); |
| 2163 double imageScaleFactor = token.numericValue(); |
| 2164 if (imageScaleFactor <= 0) |
| 2165 return nullptr; |
| 2166 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti
veValue::UnitType::Number)); |
| 2167 } while (consumeCommaIncludingWhitespace(args)); |
| 2168 if (!args.atEnd()) |
| 2169 return nullptr; |
| 2170 range = rangeCopy; |
| 2171 return imageSet.release(); |
| 2172 } |
| 2173 |
| 2174 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeCursor(CSSParserToken
Range& range) |
| 2175 { |
| 2176 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
| 2177 while (!range.atEnd()) { |
| 2178 RefPtrWillBeRawPtr<CSSValue> image = nullptr; |
| 2179 AtomicString uri(consumeUrl(range)); |
| 2180 if (!uri.isNull()) { |
| 2181 image = createCSSImageValueWithReferrer(uri, completeURL(uri)); |
| 2182 } else if (range.peek().type() == FunctionToken && range.peek().function
Id() == CSSValueWebkitImageSet) { |
| 2183 image = consumeImageSet(range); |
| 2184 if (!image) |
| 2185 return nullptr; |
| 2186 } else { |
| 2187 break; |
| 2188 } |
| 2189 |
| 2190 double num; |
| 2191 IntPoint hotSpot(-1, -1); |
| 2192 bool hotSpotSpecified = false; |
| 2193 if (consumeNumberRaw(range, num)) { |
| 2194 hotSpot.setX(int(num)); |
| 2195 if (!consumeNumberRaw(range, num)) |
| 2196 return nullptr; |
| 2197 hotSpot.setY(int(num)); |
| 2198 hotSpotSpecified = true; |
| 2199 } |
| 2200 |
| 2201 if (!list) |
| 2202 list = CSSValueList::createCommaSeparated(); |
| 2203 |
| 2204 list->append(CSSCursorImageValue::create(image, hotSpotSpecified, hotSpo
t)); |
| 2205 if (!consumeCommaIncludingWhitespace(range)) |
| 2206 return nullptr; |
| 2207 } |
| 2208 |
| 2209 CSSValueID id = range.peek().id(); |
| 2210 if (!range.atEnd() && m_context.useCounter()) { |
| 2211 if (id == CSSValueWebkitZoomIn) |
| 2212 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); |
| 2213 else if (id == CSSValueWebkitZoomOut) |
| 2214 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); |
| 2215 } |
| 2216 RefPtrWillBeRawPtr<CSSValue> cursorType; |
| 2217 if (id == CSSValueHand) { |
| 2218 if (inQuirksMode()) // Non-standard behavior |
| 2219 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); |
| 2220 range.consumeIncludingWhitespace(); |
| 2221 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV
alueCopy || id == CSSValueNone) { |
| 2222 cursorType = consumeIdent(range); |
| 2223 } |
| 2224 |
| 2225 if (!list) |
| 2226 return cursorType.release(); |
| 2227 if (cursorType) |
| 2228 list->append(cursorType.release()); |
| 2229 return list.release(); |
| 2230 } |
| 2231 |
2142 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 2232 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
2143 { | 2233 { |
2144 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 2234 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
2145 switch (property) { | 2235 switch (property) { |
2146 case CSSPropertyWillChange: | 2236 case CSSPropertyWillChange: |
2147 return consumeWillChange(m_range); | 2237 return consumeWillChange(m_range); |
2148 case CSSPropertyPage: | 2238 case CSSPropertyPage: |
2149 return consumePage(m_range); | 2239 return consumePage(m_range); |
2150 case CSSPropertyQuotes: | 2240 case CSSPropertyQuotes: |
2151 return consumeQuotes(m_range); | 2241 return consumeQuotes(m_range); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 case CSSPropertyStrokeWidth: | 2436 case CSSPropertyStrokeWidth: |
2347 case CSSPropertyStrokeDashoffset: | 2437 case CSSPropertyStrokeDashoffset: |
2348 case CSSPropertyCx: | 2438 case CSSPropertyCx: |
2349 case CSSPropertyCy: | 2439 case CSSPropertyCy: |
2350 case CSSPropertyX: | 2440 case CSSPropertyX: |
2351 case CSSPropertyY: | 2441 case CSSPropertyY: |
2352 case CSSPropertyR: | 2442 case CSSPropertyR: |
2353 case CSSPropertyRx: | 2443 case CSSPropertyRx: |
2354 case CSSPropertyRy: | 2444 case CSSPropertyRy: |
2355 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll,
UnitlessQuirk::Forbid); | 2445 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll,
UnitlessQuirk::Forbid); |
| 2446 case CSSPropertyCursor: |
| 2447 return consumeCursor(m_range); |
2356 default: | 2448 default: |
2357 return nullptr; | 2449 return nullptr; |
2358 } | 2450 } |
2359 } | 2451 } |
2360 | 2452 |
2361 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 2453 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
2362 { | 2454 { |
2363 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 2455 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
2364 | 2456 |
2365 do { | 2457 do { |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 return consumeShorthandGreedily(flexFlowShorthand(), important); | 3035 return consumeShorthandGreedily(flexFlowShorthand(), important); |
2944 case CSSPropertyWebkitColumnRule: | 3036 case CSSPropertyWebkitColumnRule: |
2945 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); | 3037 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); |
2946 default: | 3038 default: |
2947 m_currentShorthand = oldShorthand; | 3039 m_currentShorthand = oldShorthand; |
2948 return false; | 3040 return false; |
2949 } | 3041 } |
2950 } | 3042 } |
2951 | 3043 |
2952 } // namespace blink | 3044 } // namespace blink |
OLD | NEW |