Chromium Code Reviews| 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 functionArgs) | |
| 2145 { | |
| 2146 if (functionArgs.atEnd()) | |
| 2147 return nullptr; | |
| 2148 | |
| 2149 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | |
| 2150 | |
| 2151 while (!functionArgs.atEnd()) { | |
|
Timothy Loh
2015/12/02 23:59:10
Can't we use the same loop as everywhere else for
rwlbuis
2015/12/03 04:03:22
Done.
| |
| 2152 AtomicString urlValue(consumeUrl(functionArgs)); | |
| 2153 if (urlValue.isNull()) | |
| 2154 return nullptr; | |
| 2155 | |
| 2156 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(url Value, completeURL(urlValue)); | |
| 2157 imageSet->append(image); | |
| 2158 | |
| 2159 const CSSParserToken& token = functionArgs.consumeIncludingWhitespace(); | |
| 2160 | |
| 2161 if (token.type() != DimensionToken) | |
| 2162 return nullptr; | |
| 2163 if (String(token.value()) != "x") | |
| 2164 return nullptr; | |
| 2165 ASSERT(token.unitType() == CSSPrimitiveValue::UnitType::Unknown); | |
| 2166 double imageScaleFactor = token.numericValue(); | |
| 2167 if (imageScaleFactor <= 0) | |
| 2168 return nullptr; | |
| 2169 imageSet->append(cssValuePool().createValue(imageScaleFactor, CSSPrimiti veValue::UnitType::Number)); | |
| 2170 | |
| 2171 if (functionArgs.atEnd()) | |
| 2172 break; | |
| 2173 | |
| 2174 if (!consumeCommaIncludingWhitespace(functionArgs)) | |
| 2175 return nullptr; | |
| 2176 } | |
| 2177 return imageSet.release(); | |
| 2178 } | |
| 2179 | |
| 2180 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeCursor(CSSParserToken Range& range) | |
| 2181 { | |
| 2182 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | |
| 2183 while (!range.atEnd()) { | |
| 2184 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | |
| 2185 AtomicString uri(consumeUrl(range)); | |
| 2186 if (!uri.isNull()) { | |
| 2187 image = createCSSImageValueWithReferrer(uri, completeURL(uri)); | |
| 2188 } else if (range.peek().type() == FunctionToken && range.peek().function Id() == CSSValueWebkitImageSet) { | |
| 2189 image = consumeImageSet(consumeFunction(range)); | |
| 2190 if (!image) | |
| 2191 break; | |
| 2192 } else { | |
| 2193 break; | |
| 2194 } | |
| 2195 | |
| 2196 double num; | |
| 2197 IntPoint hotSpot(-1, -1); | |
| 2198 bool hotSpotSpecified = false; | |
| 2199 if (consumeNumberRaw(range, num)) { | |
| 2200 hotSpot.setX(int(num)); | |
| 2201 if (!consumeNumberRaw(range, num)) | |
| 2202 return nullptr; | |
| 2203 hotSpot.setY(int(num)); | |
| 2204 hotSpotSpecified = true; | |
| 2205 } | |
| 2206 | |
| 2207 if (!list) | |
| 2208 list = CSSValueList::createCommaSeparated(); | |
| 2209 | |
| 2210 list->append(CSSCursorImageValue::create(image, hotSpotSpecified, hotSpo t)); | |
| 2211 | |
| 2212 if (!consumeCommaIncludingWhitespace(range)) | |
| 2213 return nullptr; | |
| 2214 } | |
| 2215 | |
| 2216 CSSValueID id = range.peek().id(); | |
| 2217 if (!range.atEnd() && m_context.useCounter()) { | |
| 2218 if (id == CSSValueWebkitZoomIn) | |
| 2219 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); | |
| 2220 else if (id == CSSValueWebkitZoomOut) | |
| 2221 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut); | |
| 2222 } | |
| 2223 RefPtrWillBeRawPtr<CSSValue> cursorType; | |
| 2224 if (id == CSSValueHand) { | |
| 2225 if (inQuirksMode()) // Non-standard behavior | |
| 2226 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer); | |
| 2227 range.consumeIncludingWhitespace(); | |
| 2228 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV alueCopy || id == CSSValueNone) { | |
| 2229 cursorType = consumeIdent(range); | |
| 2230 } | |
| 2231 | |
| 2232 if (!list) | |
| 2233 return cursorType.release(); | |
| 2234 if (cursorType) | |
| 2235 list->append(cursorType.release()); | |
| 2236 return list.release(); | |
| 2237 } | |
| 2238 | |
| 2142 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) | 2239 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) |
| 2143 { | 2240 { |
| 2144 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 2241 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 2145 switch (property) { | 2242 switch (property) { |
| 2146 case CSSPropertyWillChange: | 2243 case CSSPropertyWillChange: |
| 2147 return consumeWillChange(m_range); | 2244 return consumeWillChange(m_range); |
| 2148 case CSSPropertyPage: | 2245 case CSSPropertyPage: |
| 2149 return consumePage(m_range); | 2246 return consumePage(m_range); |
| 2150 case CSSPropertyQuotes: | 2247 case CSSPropertyQuotes: |
| 2151 return consumeQuotes(m_range); | 2248 return consumeQuotes(m_range); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2346 case CSSPropertyStrokeWidth: | 2443 case CSSPropertyStrokeWidth: |
| 2347 case CSSPropertyStrokeDashoffset: | 2444 case CSSPropertyStrokeDashoffset: |
| 2348 case CSSPropertyCx: | 2445 case CSSPropertyCx: |
| 2349 case CSSPropertyCy: | 2446 case CSSPropertyCy: |
| 2350 case CSSPropertyX: | 2447 case CSSPropertyX: |
| 2351 case CSSPropertyY: | 2448 case CSSPropertyY: |
| 2352 case CSSPropertyR: | 2449 case CSSPropertyR: |
| 2353 case CSSPropertyRx: | 2450 case CSSPropertyRx: |
| 2354 case CSSPropertyRy: | 2451 case CSSPropertyRy: |
| 2355 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid); | 2452 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid); |
| 2453 case CSSPropertyCursor: | |
| 2454 return consumeCursor(m_range); | |
| 2356 default: | 2455 default: |
| 2357 return nullptr; | 2456 return nullptr; |
| 2358 } | 2457 } |
| 2359 } | 2458 } |
| 2360 | 2459 |
| 2361 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) | 2460 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) |
| 2362 { | 2461 { |
| 2363 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); | 2462 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); |
| 2364 | 2463 |
| 2365 do { | 2464 do { |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2943 return consumeShorthandGreedily(flexFlowShorthand(), important); | 3042 return consumeShorthandGreedily(flexFlowShorthand(), important); |
| 2944 case CSSPropertyWebkitColumnRule: | 3043 case CSSPropertyWebkitColumnRule: |
| 2945 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); | 3044 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); |
| 2946 default: | 3045 default: |
| 2947 m_currentShorthand = oldShorthand; | 3046 m_currentShorthand = oldShorthand; |
| 2948 return false; | 3047 return false; |
| 2949 } | 3048 } |
| 2950 } | 3049 } |
| 2951 | 3050 |
| 2952 } // namespace blink | 3051 } // namespace blink |
| OLD | NEW |