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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); | 313 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); |
314 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitType>(value->unit)); | 314 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitType>(value->unit)); |
315 } | 315 } |
316 | 316 |
317 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveStringValue(CSSParserValue* value) | 317 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveStringValue(CSSParserValue* value) |
318 { | 318 { |
319 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); | 319 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); |
320 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); | 320 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); |
321 } | 321 } |
322 | 322 |
| 323 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi
thReferrer(const String& rawValue, const KURL& url) |
| 324 { |
| 325 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur
l); |
| 326 toCSSImageValue(imageValue.get())->setReferrer(m_context.referrer()); |
| 327 return imageValue; |
| 328 } |
| 329 |
323 static inline bool isComma(CSSParserValue* value) | 330 static inline bool isComma(CSSParserValue* value) |
324 { | 331 { |
325 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; | 332 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; |
326 } | 333 } |
327 | 334 |
328 static inline bool isForwardSlashOperator(CSSParserValue* value) | 335 static inline bool isForwardSlashOperator(CSSParserValue* value) |
329 { | 336 { |
330 ASSERT(value); | 337 ASSERT(value); |
331 return value->unit == CSSParserValue::Operator && value->iValue == '/'; | 338 return value->unit == CSSParserValue::Operator && value->iValue == '/'; |
332 } | 339 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 593 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
587 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | 594 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | |
588 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | | 595 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | all-scroll | |
589 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit | 596 // zoom-in | zoom-out | -webkit-grab | -webkit-grabbing | -webkit-zoom-i
n | -webkit-zoom-out ] ] | inherit |
590 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 597 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
591 while (value) { | 598 while (value) { |
592 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | 599 RefPtrWillBeRawPtr<CSSValue> image = nullptr; |
593 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 600 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
594 String uri = value->string; | 601 String uri = value->string; |
595 if (!uri.isNull()) | 602 if (!uri.isNull()) |
596 image = CSSImageValue::create(uri, completeURL(uri)); | 603 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); |
597 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { | 604 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { |
598 image = parseImageSet(m_valueList.get()); | 605 image = parseImageSet(m_valueList.get()); |
599 if (!image) | 606 if (!image) |
600 break; | 607 break; |
601 } else | 608 } else |
602 break; | 609 break; |
603 | 610 |
604 Vector<int> coords; | 611 Vector<int> coords; |
605 value = m_valueList->next(); | 612 value = m_valueList->next(); |
606 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { | 613 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 } | 718 } |
712 case CSSPropertyObjectPosition: | 719 case CSSPropertyObjectPosition: |
713 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject
Position(important); | 720 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject
Position(important); |
714 case CSSPropertyListStyleImage: // <uri> | none | inherit | 721 case CSSPropertyListStyleImage: // <uri> | none | inherit |
715 case CSSPropertyBorderImageSource: | 722 case CSSPropertyBorderImageSource: |
716 case CSSPropertyWebkitMaskBoxImageSource: | 723 case CSSPropertyWebkitMaskBoxImageSource: |
717 if (id == CSSValueNone) { | 724 if (id == CSSValueNone) { |
718 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); | 725 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); |
719 m_valueList->next(); | 726 m_valueList->next(); |
720 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { | 727 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
721 parsedValue = CSSImageValue::create(value->string, completeURL(value
->string)); | 728 parsedValue = createCSSImageValueWithReferrer(value->string, complet
eURL(value->string)); |
722 m_valueList->next(); | 729 m_valueList->next(); |
723 } else if (isGeneratedImageValue(value)) { | 730 } else if (isGeneratedImageValue(value)) { |
724 if (parseGeneratedImage(m_valueList.get(), parsedValue)) | 731 if (parseGeneratedImage(m_valueList.get(), parsedValue)) |
725 m_valueList->next(); | 732 m_valueList->next(); |
726 else | 733 else |
727 return false; | 734 return false; |
728 } | 735 } |
729 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "-webkit-image-set(")) { | 736 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "-webkit-image-set(")) { |
730 parsedValue = parseImageSet(m_valueList.get()); | 737 parsedValue = parseImageSet(m_valueList.get()); |
731 if (!parsedValue) | 738 if (!parsedValue) |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 // in CSS 2.1 this got somewhat reduced: | 2255 // in CSS 2.1 this got somewhat reduced: |
2249 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2256 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
2250 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important) | 2257 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important) |
2251 { | 2258 { |
2252 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 2259 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
2253 | 2260 |
2254 while (CSSParserValue* val = m_valueList->current()) { | 2261 while (CSSParserValue* val = m_valueList->current()) { |
2255 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2262 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
2256 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 2263 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
2257 // url | 2264 // url |
2258 parsedValue = CSSImageValue::create(val->string, completeURL(val->st
ring)); | 2265 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); |
2259 } else if (val->unit == CSSParserValue::Function) { | 2266 } else if (val->unit == CSSParserValue::Function) { |
2260 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 2267 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
2261 CSSParserValueList* args = val->function->args.get(); | 2268 CSSParserValueList* args = val->function->args.get(); |
2262 if (!args) | 2269 if (!args) |
2263 return false; | 2270 return false; |
2264 if (equalIgnoringCase(val->function->name, "attr(")) { | 2271 if (equalIgnoringCase(val->function->name, "attr(")) { |
2265 parsedValue = parseAttr(args); | 2272 parsedValue = parseAttr(args); |
2266 if (!parsedValue) | 2273 if (!parsedValue) |
2267 return false; | 2274 return false; |
2268 } else if (equalIgnoringCase(val->function->name, "counter(")) { | 2275 } else if (equalIgnoringCase(val->function->name, "counter(")) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2352 return parseColor(); | 2359 return parseColor(); |
2353 } | 2360 } |
2354 | 2361 |
2355 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 2362 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) |
2356 { | 2363 { |
2357 if (valueList->current()->id == CSSValueNone) { | 2364 if (valueList->current()->id == CSSValueNone) { |
2358 value = cssValuePool().createIdentifierValue(CSSValueNone); | 2365 value = cssValuePool().createIdentifierValue(CSSValueNone); |
2359 return true; | 2366 return true; |
2360 } | 2367 } |
2361 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { | 2368 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { |
2362 value = CSSImageValue::create(valueList->current()->string, completeURL(
valueList->current()->string)); | 2369 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); |
2363 return true; | 2370 return true; |
2364 } | 2371 } |
2365 | 2372 |
2366 if (isGeneratedImageValue(valueList->current())) | 2373 if (isGeneratedImageValue(valueList->current())) |
2367 return parseGeneratedImage(valueList, value); | 2374 return parseGeneratedImage(valueList, value); |
2368 | 2375 |
2369 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { | 2376 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { |
2370 value = parseImageSet(m_valueList.get()); | 2377 value = parseImageSet(m_valueList.get()); |
2371 if (value) | 2378 if (value) |
2372 return true; | 2379 return true; |
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4711 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); | 4718 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); |
4712 return true; | 4719 return true; |
4713 } | 4720 } |
4714 } | 4721 } |
4715 return false; | 4722 return false; |
4716 } | 4723 } |
4717 | 4724 |
4718 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) | 4725 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) |
4719 { | 4726 { |
4720 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string))); | 4727 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string))); |
| 4728 uriValue->setReferrer(m_context.referrer()); |
4721 | 4729 |
4722 CSSParserValue* value = m_valueList->next(); | 4730 CSSParserValue* value = m_valueList->next(); |
4723 if (!value) { | 4731 if (!value) { |
4724 valueList->append(uriValue.release()); | 4732 valueList->append(uriValue.release()); |
4725 return true; | 4733 return true; |
4726 } | 4734 } |
4727 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { | 4735 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { |
4728 m_valueList->next(); | 4736 m_valueList->next(); |
4729 valueList->append(uriValue.release()); | 4737 valueList->append(uriValue.release()); |
4730 return true; | 4738 return true; |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5806 { | 5814 { |
5807 CSSPropertyParser::ShorthandScope scope(&parser, propId); | 5815 CSSPropertyParser::ShorthandScope scope(&parser, propId); |
5808 while (CSSParserValue* val = parser.m_valueList->current()) { | 5816 while (CSSParserValue* val = parser.m_valueList->current()) { |
5809 context.setCanAdvance(false); | 5817 context.setCanAdvance(false); |
5810 | 5818 |
5811 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 5819 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
5812 context.commitForwardSlashOperator(); | 5820 context.commitForwardSlashOperator(); |
5813 | 5821 |
5814 if (!context.canAdvance() && context.allowImage()) { | 5822 if (!context.canAdvance() && context.allowImage()) { |
5815 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 5823 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
5816 context.commitImage(CSSImageValue::create(val->string, parser.m_
context.completeURL(val->string))); | 5824 context.commitImage(parser.createCSSImageValueWithReferrer(val->
string, parser.m_context.completeURL(val->string))); |
5817 } else if (isGeneratedImageValue(val)) { | 5825 } else if (isGeneratedImageValue(val)) { |
5818 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 5826 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
5819 if (parser.parseGeneratedImage(parser.m_valueList.get(), value)) | 5827 if (parser.parseGeneratedImage(parser.m_valueList.get(), value)) |
5820 context.commitImage(value.release()); | 5828 context.commitImage(value.release()); |
5821 else | 5829 else |
5822 return false; | 5830 return false; |
5823 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas
e(val->function->name, "-webkit-image-set(")) { | 5831 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas
e(val->function->name, "-webkit-image-set(")) { |
5824 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser
.m_valueList.get()); | 5832 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser
.m_valueList.get()); |
5825 if (value) | 5833 if (value) |
5826 context.commitImage(value.release()); | 5834 context.commitImage(value.release()); |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7095 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 7103 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
7096 return nullptr; | 7104 return nullptr; |
7097 | 7105 |
7098 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 7106 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
7099 | 7107 |
7100 CSSParserValue* arg = functionArgs->current(); | 7108 CSSParserValue* arg = functionArgs->current(); |
7101 while (arg) { | 7109 while (arg) { |
7102 if (arg->unit != CSSPrimitiveValue::CSS_URI) | 7110 if (arg->unit != CSSPrimitiveValue::CSS_URI) |
7103 return nullptr; | 7111 return nullptr; |
7104 | 7112 |
7105 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(arg->str
ing, completeURL(arg->string)); | 7113 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, completeURL(arg->string)); |
7106 imageSet->append(image); | 7114 imageSet->append(image); |
7107 | 7115 |
7108 arg = functionArgs->next(); | 7116 arg = functionArgs->next(); |
7109 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) | 7117 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) |
7110 return nullptr; | 7118 return nullptr; |
7111 | 7119 |
7112 double imageScaleFactor = 0; | 7120 double imageScaleFactor = 0; |
7113 const String& string = arg->string; | 7121 const String& string = arg->string; |
7114 unsigned length = string.length(); | 7122 unsigned length = string.length(); |
7115 if (!length) | 7123 if (!length) |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8410 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8418 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
8411 if (!seenStroke) | 8419 if (!seenStroke) |
8412 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); | 8420 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
8413 if (!seenMarkers) | 8421 if (!seenMarkers) |
8414 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); | 8422 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
8415 | 8423 |
8416 return parsedValues.release(); | 8424 return parsedValues.release(); |
8417 } | 8425 } |
8418 | 8426 |
8419 } // namespace WebCore | 8427 } // namespace WebCore |
OLD | NEW |