| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 case CSSPropertyBackgroundColor: // <color> | inherit | 363 case CSSPropertyBackgroundColor: // <color> | inherit |
| 373 case CSSPropertyBorderTopColor: // <color> | inherit | 364 case CSSPropertyBorderTopColor: // <color> | inherit |
| 374 case CSSPropertyBorderRightColor: | 365 case CSSPropertyBorderRightColor: |
| 375 case CSSPropertyBorderBottomColor: | 366 case CSSPropertyBorderBottomColor: |
| 376 case CSSPropertyBorderLeftColor: | 367 case CSSPropertyBorderLeftColor: |
| 377 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && (!inS
horthand() || m_currentShorthand == CSSPropertyBorderColor)); | 368 parsedValue = parseColor(m_valueList->current(), inQuirksMode() && (!inS
horthand() || m_currentShorthand == CSSPropertyBorderColor)); |
| 378 if (parsedValue) | 369 if (parsedValue) |
| 379 m_valueList->next(); | 370 m_valueList->next(); |
| 380 break; | 371 break; |
| 381 | 372 |
| 382 case CSSPropertyCursor: { | |
| 383 // Grammar defined by CSS3 UI and modified by CSS4 images: | |
| 384 // [ [<image> [<x> <y>]?,]* | |
| 385 // [ auto | crosshair | default | pointer | progress | move | e-resize |
ne-resize | | |
| 386 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | |
| 387 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | |
| 388 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | | |
| 389 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit | |
| 390 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | |
| 391 while (value) { | |
| 392 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | |
| 393 if (value->m_unit == CSSParserValue::URI) { | |
| 394 AtomicString uri = value->string; | |
| 395 if (!uri.isNull()) | |
| 396 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); | |
| 397 } else if (value->m_unit == CSSParserValue::Function && value->funct
ion->id == CSSValueWebkitImageSet) { | |
| 398 image = parseImageSet(m_valueList); | |
| 399 if (!image) | |
| 400 break; | |
| 401 } else | |
| 402 break; | |
| 403 | |
| 404 Vector<int> coords; | |
| 405 value = m_valueList->next(); | |
| 406 while (value && validUnit(value, FNumber)) { | |
| 407 coords.append(int(value->fValue)); | |
| 408 value = m_valueList->next(); | |
| 409 } | |
| 410 bool hotSpotSpecified = false; | |
| 411 IntPoint hotSpot(-1, -1); | |
| 412 int nrcoords = coords.size(); | |
| 413 if (nrcoords > 0 && nrcoords != 2) | |
| 414 return false; | |
| 415 if (nrcoords == 2) { | |
| 416 hotSpotSpecified = true; | |
| 417 hotSpot = IntPoint(coords[0], coords[1]); | |
| 418 } | |
| 419 | |
| 420 if (!list) | |
| 421 list = CSSValueList::createCommaSeparated(); | |
| 422 | |
| 423 if (image) | |
| 424 list->append(CSSCursorImageValue::create(image, hotSpotSpecified
, hotSpot)); | |
| 425 | |
| 426 if (!consumeComma(m_valueList)) | |
| 427 return false; | |
| 428 value = m_valueList->current(); | |
| 429 } | |
| 430 if (value && m_context.useCounter()) { | |
| 431 if (value->id == CSSValueWebkitZoomIn) | |
| 432 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomIn); | |
| 433 else if (value->id == CSSValueWebkitZoomOut) | |
| 434 m_context.useCounter()->count(UseCounter::PrefixedCursorZoomOut)
; | |
| 435 } | |
| 436 if (list) { | |
| 437 if (!value) | |
| 438 return false; | |
| 439 if (inQuirksMode() && value->id == CSSValueHand) // MSIE 5 compatibi
lity :/ | |
| 440 list->append(cssValuePool().createIdentifierValue(CSSValuePointe
r)); | |
| 441 else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkitZo
omOut) || value->id == CSSValueCopy || value->id == CSSValueNone) | |
| 442 list->append(cssValuePool().createIdentifierValue(value->id)); | |
| 443 m_valueList->next(); | |
| 444 parsedValue = list.release(); | |
| 445 break; | |
| 446 } else if (value) { | |
| 447 id = value->id; | |
| 448 if (inQuirksMode() && value->id == CSSValueHand) { // MSIE 5 compati
bility :/ | |
| 449 id = CSSValuePointer; | |
| 450 validPrimitive = true; | |
| 451 } else if ((value->id >= CSSValueAuto && value->id <= CSSValueWebkit
ZoomOut) || value->id == CSSValueCopy || value->id == CSSValueNone) | |
| 452 validPrimitive = true; | |
| 453 } else { | |
| 454 ASSERT_NOT_REACHED(); | |
| 455 return false; | |
| 456 } | |
| 457 break; | |
| 458 } | |
| 459 case CSSPropertyImageOrientation: | 373 case CSSPropertyImageOrientation: |
| 460 if (RuntimeEnabledFeatures::imageOrientationEnabled()) | 374 if (RuntimeEnabledFeatures::imageOrientationEnabled()) |
| 461 validPrimitive = value->id == CSSValueFromImage || (value->unit() !=
CSSPrimitiveValue::UnitType::Number && validUnit(value, FAngle) && value->fValu
e == 0); | 375 validPrimitive = value->id == CSSValueFromImage || (value->unit() !=
CSSPrimitiveValue::UnitType::Number && validUnit(value, FAngle) && value->fValu
e == 0); |
| 462 break; | 376 break; |
| 463 | 377 |
| 464 case CSSPropertyBackgroundBlendMode: | 378 case CSSPropertyBackgroundBlendMode: |
| 465 case CSSPropertyBackgroundAttachment: | 379 case CSSPropertyBackgroundAttachment: |
| 466 case CSSPropertyBackgroundClip: | 380 case CSSPropertyBackgroundClip: |
| 467 case CSSPropertyWebkitBackgroundClip: | 381 case CSSPropertyWebkitBackgroundClip: |
| 468 case CSSPropertyWebkitBackgroundComposite: | 382 case CSSPropertyWebkitBackgroundComposite: |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 case CSSPropertyStrokeDashoffset: | 947 case CSSPropertyStrokeDashoffset: |
| 1034 case CSSPropertyCx: | 948 case CSSPropertyCx: |
| 1035 case CSSPropertyCy: | 949 case CSSPropertyCy: |
| 1036 case CSSPropertyX: | 950 case CSSPropertyX: |
| 1037 case CSSPropertyY: | 951 case CSSPropertyY: |
| 1038 case CSSPropertyR: | 952 case CSSPropertyR: |
| 1039 case CSSPropertyRx: | 953 case CSSPropertyRx: |
| 1040 case CSSPropertyRy: | 954 case CSSPropertyRy: |
| 1041 case CSSPropertyScale: | 955 case CSSPropertyScale: |
| 1042 case CSSPropertyTranslate: | 956 case CSSPropertyTranslate: |
| 957 case CSSPropertyCursor: |
| 1043 validPrimitive = false; | 958 validPrimitive = false; |
| 1044 break; | 959 break; |
| 1045 | 960 |
| 1046 case CSSPropertyScrollSnapPointsX: | 961 case CSSPropertyScrollSnapPointsX: |
| 1047 case CSSPropertyScrollSnapPointsY: | 962 case CSSPropertyScrollSnapPointsY: |
| 1048 parsedValue = parseScrollSnapPoints(); | 963 parsedValue = parseScrollSnapPoints(); |
| 1049 break; | 964 break; |
| 1050 case CSSPropertyScrollSnapCoordinate: | 965 case CSSPropertyScrollSnapCoordinate: |
| 1051 parsedValue = parseScrollSnapCoordinate(); | 966 parsedValue = parseScrollSnapCoordinate(); |
| 1052 break; | 967 break; |
| (...skipping 4191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5244 | 5159 |
| 5245 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); | 5160 return string.is8Bit() ? cssValueKeywordID(string.characters8(), length) : c
ssValueKeywordID(string.characters16(), length); |
| 5246 } | 5161 } |
| 5247 | 5162 |
| 5248 bool CSSPropertyParser::isSystemColor(CSSValueID id) | 5163 bool CSSPropertyParser::isSystemColor(CSSValueID id) |
| 5249 { | 5164 { |
| 5250 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; | 5165 return (id >= CSSValueActiveborder && id <= CSSValueWindowtext) || id == CSS
ValueMenu; |
| 5251 } | 5166 } |
| 5252 | 5167 |
| 5253 } // namespace blink | 5168 } // namespace blink |
| OLD | NEW |