Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 1457873002: Move cursor property into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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));
Timothy Loh 2015/12/03 04:10:25 This needs to check args.atEnd() right after the l
2168 range = rangeCopy;
2169 return imageSet.release();
2170 }
2171
2172 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::consumeCursor(CSSParserToken Range& range)
2173 {
2174 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
2175 while (!range.atEnd()) {
2176 RefPtrWillBeRawPtr<CSSValue> image = nullptr;
2177 AtomicString uri(consumeUrl(range));
2178 if (!uri.isNull()) {
2179 image = createCSSImageValueWithReferrer(uri, completeURL(uri));
2180 } else if (range.peek().type() == FunctionToken && range.peek().function Id() == CSSValueWebkitImageSet) {
2181 image = consumeImageSet(range);
2182 if (!image)
2183 return nullptr;
2184 } else {
2185 break;
2186 }
2187
2188 double num;
2189 IntPoint hotSpot(-1, -1);
2190 bool hotSpotSpecified = false;
2191 if (consumeNumberRaw(range, num)) {
2192 hotSpot.setX(int(num));
2193 if (!consumeNumberRaw(range, num))
2194 return nullptr;
2195 hotSpot.setY(int(num));
2196 hotSpotSpecified = true;
2197 }
2198
2199 if (!list)
2200 list = CSSValueList::createCommaSeparated();
2201
2202 list->append(CSSCursorImageValue::create(image, hotSpotSpecified, hotSpo t));
2203 if (!consumeCommaIncludingWhitespace(range))
2204 return nullptr;
2205 }
2206
2207 CSSValueID id = range.peek().id();
2208 if (!range.atEnd() && m_context.useCounter()) {
2209 if (id == CSSValueWebkitZoomIn)
2210 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
2211 else if (id == CSSValueWebkitZoomOut)
2212 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut);
2213 }
2214 RefPtrWillBeRawPtr<CSSValue> cursorType;
2215 if (id == CSSValueHand) {
2216 if (inQuirksMode()) // Non-standard behavior
2217 cursorType = cssValuePool().createIdentifierValue(CSSValuePointer);
2218 range.consumeIncludingWhitespace();
2219 } else if ((id >= CSSValueAuto && id <= CSSValueWebkitZoomOut) || id == CSSV alueCopy || id == CSSValueNone) {
2220 cursorType = consumeIdent(range);
2221 }
2222
2223 if (!list)
2224 return cursorType.release();
2225 if (cursorType)
2226 list->append(cursorType.release());
2227 return list.release();
2228 }
2229
2142 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) 2230 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty)
2143 { 2231 {
2144 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); 2232 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
2145 switch (property) { 2233 switch (property) {
2146 case CSSPropertyWillChange: 2234 case CSSPropertyWillChange:
2147 return consumeWillChange(m_range); 2235 return consumeWillChange(m_range);
2148 case CSSPropertyPage: 2236 case CSSPropertyPage:
2149 return consumePage(m_range); 2237 return consumePage(m_range);
2150 case CSSPropertyQuotes: 2238 case CSSPropertyQuotes:
2151 return consumeQuotes(m_range); 2239 return consumeQuotes(m_range);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 case CSSPropertyStrokeWidth: 2434 case CSSPropertyStrokeWidth:
2347 case CSSPropertyStrokeDashoffset: 2435 case CSSPropertyStrokeDashoffset:
2348 case CSSPropertyCx: 2436 case CSSPropertyCx:
2349 case CSSPropertyCy: 2437 case CSSPropertyCy:
2350 case CSSPropertyX: 2438 case CSSPropertyX:
2351 case CSSPropertyY: 2439 case CSSPropertyY:
2352 case CSSPropertyR: 2440 case CSSPropertyR:
2353 case CSSPropertyRx: 2441 case CSSPropertyRx:
2354 case CSSPropertyRy: 2442 case CSSPropertyRy:
2355 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid); 2443 return consumeLengthOrPercent(m_range, SVGAttributeMode, ValueRangeAll, UnitlessQuirk::Forbid);
2444 case CSSPropertyCursor:
2445 return consumeCursor(m_range);
2356 default: 2446 default:
2357 return nullptr; 2447 return nullptr;
2358 } 2448 }
2359 } 2449 }
2360 2450
2361 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) 2451 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range)
2362 { 2452 {
2363 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); 2453 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated ();
2364 2454
2365 do { 2455 do {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 return consumeShorthandGreedily(flexFlowShorthand(), important); 3033 return consumeShorthandGreedily(flexFlowShorthand(), important);
2944 case CSSPropertyWebkitColumnRule: 3034 case CSSPropertyWebkitColumnRule:
2945 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important); 3035 return consumeShorthandGreedily(webkitColumnRuleShorthand(), important);
2946 default: 3036 default:
2947 m_currentShorthand = oldShorthand; 3037 m_currentShorthand = oldShorthand;
2948 return false; 3038 return false;
2949 } 3039 }
2950 } 3040 }
2951 3041
2952 } // namespace blink 3042 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698