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

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

Issue 1457873002: Move cursor property into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase once more 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 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/css/parser/CSSPropertyParser.h" 28 #include "core/css/parser/CSSPropertyParser.h"
29 29
30 #include "core/StylePropertyShorthand.h" 30 #include "core/StylePropertyShorthand.h"
31 #include "core/css/CSSBasicShapeValues.h" 31 #include "core/css/CSSBasicShapeValues.h"
32 #include "core/css/CSSBorderImage.h" 32 #include "core/css/CSSBorderImage.h"
33 #include "core/css/CSSContentDistributionValue.h" 33 #include "core/css/CSSContentDistributionValue.h"
34 #include "core/css/CSSCounterValue.h" 34 #include "core/css/CSSCounterValue.h"
35 #include "core/css/CSSCrossfadeValue.h" 35 #include "core/css/CSSCrossfadeValue.h"
36 #include "core/css/CSSCursorImageValue.h"
37 #include "core/css/CSSCustomIdentValue.h" 36 #include "core/css/CSSCustomIdentValue.h"
38 #include "core/css/CSSFunctionValue.h" 37 #include "core/css/CSSFunctionValue.h"
39 #include "core/css/CSSGridLineNamesValue.h" 38 #include "core/css/CSSGridLineNamesValue.h"
40 #include "core/css/CSSImageSetValue.h" 39 #include "core/css/CSSImageSetValue.h"
41 #include "core/css/CSSImageValue.h"
42 #include "core/css/CSSPrimitiveValueMappings.h" 40 #include "core/css/CSSPrimitiveValueMappings.h"
43 #include "core/css/CSSProperty.h" 41 #include "core/css/CSSProperty.h"
44 #include "core/css/CSSPropertyMetadata.h" 42 #include "core/css/CSSPropertyMetadata.h"
45 #include "core/css/CSSQuadValue.h" 43 #include "core/css/CSSQuadValue.h"
46 #include "core/css/CSSReflectValue.h" 44 #include "core/css/CSSReflectValue.h"
47 #include "core/css/CSSShadowValue.h" 45 #include "core/css/CSSShadowValue.h"
48 #include "core/css/CSSStringValue.h" 46 #include "core/css/CSSStringValue.h"
49 #include "core/css/CSSTimingFunctionValue.h" 47 #include "core/css/CSSTimingFunctionValue.h"
50 #include "core/css/CSSURIValue.h" 48 #include "core/css/CSSURIValue.h"
51 #include "core/css/CSSValuePair.h" 49 #include "core/css/CSSValuePair.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParser Value::Identifier); 251 ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParser Value::Identifier);
254 return CSSStringValue::create(value->string); 252 return CSSStringValue::create(value->string);
255 } 253 }
256 254
257 inline PassRefPtrWillBeRawPtr<CSSCustomIdentValue> CSSPropertyParser::createPrim itiveCustomIdentValue(CSSParserValue* value) 255 inline PassRefPtrWillBeRawPtr<CSSCustomIdentValue> CSSPropertyParser::createPrim itiveCustomIdentValue(CSSParserValue* value)
258 { 256 {
259 ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParser Value::Identifier); 257 ASSERT(value->m_unit == CSSParserValue::String || value->m_unit == CSSParser Value::Identifier);
260 return CSSCustomIdentValue::create(value->string); 258 return CSSCustomIdentValue::create(value->string);
261 } 259 }
262 260
263 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi thReferrer(const AtomicString& rawValue, const KURL& url)
264 {
265 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur l);
266 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer());
267 return imageValue;
268 }
269
270 static inline bool isComma(CSSParserValue* value) 261 static inline bool isComma(CSSParserValue* value)
271 { 262 {
272 ASSERT(value); 263 ASSERT(value);
273 return value->m_unit == CSSParserValue::Operator && value->iValue == ','; 264 return value->m_unit == CSSParserValue::Operator && value->iValue == ',';
274 } 265 }
275 266
276 static bool consumeComma(CSSParserValueList* valueList) 267 static bool consumeComma(CSSParserValueList* valueList)
277 { 268 {
278 CSSParserValue* value = valueList->current(); 269 CSSParserValue* value = valueList->current();
279 if (!value || !isComma(value)) 270 if (!value || !isComma(value))
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 case CSSPropertyBackgroundColor: // <color> | inherit 372 case CSSPropertyBackgroundColor: // <color> | inherit
382 case CSSPropertyBorderTopColor: // <color> | inherit 373 case CSSPropertyBorderTopColor: // <color> | inherit
383 case CSSPropertyBorderRightColor: 374 case CSSPropertyBorderRightColor:
384 case CSSPropertyBorderBottomColor: 375 case CSSPropertyBorderBottomColor:
385 case CSSPropertyBorderLeftColor: 376 case CSSPropertyBorderLeftColor:
386 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && (!inS horthand() || m_currentShorthand == CSSPropertyBorderColor)); 377 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && (!inS horthand() || m_currentShorthand == CSSPropertyBorderColor));
387 if (parsedValue) 378 if (parsedValue)
388 m_valueList->next(); 379 m_valueList->next();
389 break; 380 break;
390 381
391 case CSSPropertyCursor: {
392 // Grammar defined by CSS3 UI and modified by CSS4 images:
393 // [ [<image> [<x> <y>]?,]*
394 // [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
395 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | ew-resize |
396 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex t | wait | help |
397 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al lowed | all-scroll |
398 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i n | -webkit-zoom-out ] ] | inherit
399 RefPtrWillBeRawPtr<CSSValueList> list = nullptr;
400 while (value) {
401 RefPtrWillBeRawPtr<CSSValue> image = nullptr;
402 if (value->m_unit == CSSParserValue::URI) {
403 AtomicString uri = value->string;
404 if (!uri.isNull())
405 image = createCSSImageValueWithReferrer(uri, completeURL(uri ));
406 } else if (value->m_unit == CSSParserValue::Function && value->funct ion->id == CSSValueWebkitImageSet) {
407 image = parseImageSet(m_valueList);
408 if (!image)
409 break;
410 } else
411 break;
412
413 Vector<int> coords;
414 value = m_valueList->next();
415 while (value && validUnit(value, FNumber)) {
416 coords.append(int(value->fValue));
417 value = m_valueList->next();
418 }
419 bool hotSpotSpecified = false;
420 IntPoint hotSpot(-1, -1);
421 int nrcoords = coords.size();
422 if (nrcoords > 0 && nrcoords != 2)
423 return false;
424 if (nrcoords == 2) {
425 hotSpotSpecified = true;
426 hotSpot = IntPoint(coords[0], coords[1]);
427 }
428
429 if (!list)
430 list = CSSValueList::createCommaSeparated();
431
432 if (image)
433 list->append(CSSCursorImageValue::create(image, hotSpotSpecified , hotSpot));
434
435 if (!consumeComma(m_valueList))
436 return false;
437 value = m_valueList->current();
438 }
439 if (value && m_context.useCounter()) {
440 if (value->id == CSSValueWebkitZoomIn)
441 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn);
442 else if (value->id == CSSValueWebkitZoomOut)
443 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut) ;
444 }
445 if (list) {
446 if (!value)
447 return false;
448 if (inQuirksMode() && value->id == CSSValueHand) // MSIE 5 compatibi lity :/
449 list->append(cssValuePool().createIdentifierValue(CSSValuePointe r));
450 else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitZo omOut) || value->id == CSSValueCopy || value->id == CSSValueNone)
451 list->append(cssValuePool().createIdentifierValue(value->id));
452 m_valueList->next();
453 parsedValue = list.release();
454 break;
455 } else if (value) {
456 id = value->id;
457 if (inQuirksMode() && value->id == CSSValueHand) { // MSIE 5 compati bility :/
458 id = CSSValuePointer;
459 validPrimitive = true;
460 } else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkit ZoomOut) || value->id == CSSValueCopy || value->id == CSSValueNone)
461 validPrimitive = true;
462 } else {
463 ASSERT_NOT_REACHED();
464 return false;
465 }
466 break;
467 }
468 case CSSPropertyImageOrientation: 382 case CSSPropertyImageOrientation:
469 if (RuntimeEnabledFeatures::imageOrientationEnabled()) 383 if (RuntimeEnabledFeatures::imageOrientationEnabled())
470 validPrimitive = value->id == CSSValueFromImage || (value->unit() != CSSPrimitiveValue::UnitType::Number && validUnit(value, FAngle) && value->fValu e == 0); 384 validPrimitive = value->id == CSSValueFromImage || (value->unit() != CSSPrimitiveValue::UnitType::Number && validUnit(value, FAngle) && value->fValu e == 0);
471 break; 385 break;
472 386
473 case CSSPropertyBackgroundBlendMode: 387 case CSSPropertyBackgroundBlendMode:
474 case CSSPropertyBackgroundAttachment: 388 case CSSPropertyBackgroundAttachment:
475 case CSSPropertyBackgroundClip: 389 case CSSPropertyBackgroundClip:
476 case CSSPropertyWebkitBackgroundClip: 390 case CSSPropertyWebkitBackgroundClip:
477 case CSSPropertyWebkitBackgroundComposite: 391 case CSSPropertyWebkitBackgroundComposite:
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 case CSSPropertyStrokeDashoffset: 971 case CSSPropertyStrokeDashoffset:
1058 case CSSPropertyCx: 972 case CSSPropertyCx:
1059 case CSSPropertyCy: 973 case CSSPropertyCy:
1060 case CSSPropertyX: 974 case CSSPropertyX:
1061 case CSSPropertyY: 975 case CSSPropertyY:
1062 case CSSPropertyR: 976 case CSSPropertyR:
1063 case CSSPropertyRx: 977 case CSSPropertyRx:
1064 case CSSPropertyRy: 978 case CSSPropertyRy:
1065 case CSSPropertyScale: 979 case CSSPropertyScale:
1066 case CSSPropertyTranslate: 980 case CSSPropertyTranslate:
981 case CSSPropertyCursor:
1067 validPrimitive = false; 982 validPrimitive = false;
1068 break; 983 break;
1069 984
1070 case CSSPropertyScrollSnapPointsX: 985 case CSSPropertyScrollSnapPointsX:
1071 case CSSPropertyScrollSnapPointsY: 986 case CSSPropertyScrollSnapPointsY:
1072 parsedValue = parseScrollSnapPoints(); 987 parsedValue = parseScrollSnapPoints();
1073 break; 988 break;
1074 case CSSPropertyScrollSnapCoordinate: 989 case CSSPropertyScrollSnapCoordinate:
1075 parsedValue = parseScrollSnapCoordinate(); 990 parsedValue = parseScrollSnapCoordinate();
1076 break; 991 break;
(...skipping 4187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5264 5179
5265 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c ssValueKeywordID(string.characters16(), length); 5180 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c ssValueKeywordID(string.characters16(), length);
5266 } 5181 }
5267 5182
5268 bool CSSPropertyParser::isSystemColor(CSSValueID id) 5183 bool CSSPropertyParser::isSystemColor(CSSValueID id)
5269 { 5184 {
5270 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS ValueMenu; 5185 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS ValueMenu;
5271 } 5186 }
5272 5187
5273 } // namespace blink 5188 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698