| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); | 344 || (value->unit >= CSSPrimitiveValue::CSS_DPPX && value->unit <= CSSPrim
itiveValue::CSS_DPCM)); |
| 345 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitTypes>(value->unit)); | 345 return cssValuePool().createValue(value->fValue, static_cast<CSSPrimitiveVal
ue::UnitTypes>(value->unit)); |
| 346 } | 346 } |
| 347 | 347 |
| 348 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveStringValue(CSSParserValue* value) | 348 inline PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::createPrimit
iveStringValue(CSSParserValue* value) |
| 349 { | 349 { |
| 350 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); | 350 ASSERT(value->unit == CSSPrimitiveValue::CSS_STRING || value->unit == CSSPri
mitiveValue::CSS_IDENT); |
| 351 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); | 351 return cssValuePool().createValue(value->string, CSSPrimitiveValue::CSS_STRI
NG); |
| 352 } | 352 } |
| 353 | 353 |
| 354 inline PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::createCSSImageValueWi
thReferrer(const String& rawValue, const KURL& url) | |
| 355 { | |
| 356 RefPtrWillBeRawPtr<CSSValue> imageValue = CSSImageValue::create(rawValue, ur
l); | |
| 357 toCSSImageValue(imageValue.get())->setReferrer(m_context.baseURL().strippedF
orUseAsReferrer()); | |
| 358 return imageValue; | |
| 359 } | |
| 360 | |
| 361 static inline bool isComma(CSSParserValue* value) | 354 static inline bool isComma(CSSParserValue* value) |
| 362 { | 355 { |
| 363 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; | 356 return value && value->unit == CSSParserValue::Operator && value->iValue ==
','; |
| 364 } | 357 } |
| 365 | 358 |
| 366 static inline bool isForwardSlashOperator(CSSParserValue* value) | 359 static inline bool isForwardSlashOperator(CSSParserValue* value) |
| 367 { | 360 { |
| 368 ASSERT(value); | 361 ASSERT(value); |
| 369 return value->unit == CSSParserValue::Operator && value->iValue == '/'; | 362 return value->unit == CSSParserValue::Operator && value->iValue == '/'; |
| 370 } | 363 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | | 617 // nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize |
ew-resize | |
| 625 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | | 618 // ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | tex
t | wait | help | |
| 626 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | -webkit-zoom-in | 619 // vertical-text | cell | context-menu | alias | copy | no-drop | not-al
lowed | -webkit-zoom-in |
| 627 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] |
inherit | 620 // -webkit-zoom-out | all-scroll | -webkit-grab | -webkit-grabbing ] ] |
inherit |
| 628 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 621 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
| 629 while (value) { | 622 while (value) { |
| 630 RefPtrWillBeRawPtr<CSSValue> image = nullptr; | 623 RefPtrWillBeRawPtr<CSSValue> image = nullptr; |
| 631 if (value->unit == CSSPrimitiveValue::CSS_URI) { | 624 if (value->unit == CSSPrimitiveValue::CSS_URI) { |
| 632 String uri = value->string; | 625 String uri = value->string; |
| 633 if (!uri.isNull()) | 626 if (!uri.isNull()) |
| 634 image = createCSSImageValueWithReferrer(uri, completeURL(uri
)); | 627 image = CSSImageValue::create(uri, completeURL(uri)); |
| 635 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { | 628 } else if (value->unit == CSSParserValue::Function && equalIgnoringC
ase(value->function->name, "-webkit-image-set(")) { |
| 636 image = parseImageSet(m_valueList.get()); | 629 image = parseImageSet(m_valueList.get()); |
| 637 if (!image) | 630 if (!image) |
| 638 break; | 631 break; |
| 639 } else | 632 } else |
| 640 break; | 633 break; |
| 641 | 634 |
| 642 Vector<int> coords; | 635 Vector<int> coords; |
| 643 value = m_valueList->next(); | 636 value = m_valueList->next(); |
| 644 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { | 637 while (value && value->unit == CSSPrimitiveValue::CSS_NUMBER) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 } | 736 } |
| 744 case CSSPropertyObjectPosition: | 737 case CSSPropertyObjectPosition: |
| 745 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject
Position(important); | 738 return RuntimeEnabledFeatures::objectFitPositionEnabled() && parseObject
Position(important); |
| 746 case CSSPropertyListStyleImage: // <uri> | none | inherit | 739 case CSSPropertyListStyleImage: // <uri> | none | inherit |
| 747 case CSSPropertyBorderImageSource: | 740 case CSSPropertyBorderImageSource: |
| 748 case CSSPropertyWebkitMaskBoxImageSource: | 741 case CSSPropertyWebkitMaskBoxImageSource: |
| 749 if (id == CSSValueNone) { | 742 if (id == CSSValueNone) { |
| 750 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); | 743 parsedValue = cssValuePool().createIdentifierValue(CSSValueNone); |
| 751 m_valueList->next(); | 744 m_valueList->next(); |
| 752 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { | 745 } else if (value->unit == CSSPrimitiveValue::CSS_URI) { |
| 753 parsedValue = createCSSImageValueWithReferrer(value->string, complet
eURL(value->string)); | 746 parsedValue = CSSImageValue::create(value->string, completeURL(value
->string)); |
| 754 m_valueList->next(); | 747 m_valueList->next(); |
| 755 } else if (isGeneratedImageValue(value)) { | 748 } else if (isGeneratedImageValue(value)) { |
| 756 if (parseGeneratedImage(m_valueList.get(), parsedValue)) | 749 if (parseGeneratedImage(m_valueList.get(), parsedValue)) |
| 757 m_valueList->next(); | 750 m_valueList->next(); |
| 758 else | 751 else |
| 759 return false; | 752 return false; |
| 760 } | 753 } |
| 761 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "-webkit-image-set(")) { | 754 else if (value->unit == CSSParserValue::Function && equalIgnoringCase(va
lue->function->name, "-webkit-image-set(")) { |
| 762 parsedValue = parseImageSet(m_valueList.get()); | 755 parsedValue = parseImageSet(m_valueList.get()); |
| 763 if (!parsedValue) | 756 if (!parsedValue) |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 // in CSS 2.1 this got somewhat reduced: | 2291 // in CSS 2.1 this got somewhat reduced: |
| 2299 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit | 2292 // [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-qu
ote ]+ | inherit |
| 2300 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important) | 2293 bool CSSPropertyParser::parseContent(CSSPropertyID propId, bool important) |
| 2301 { | 2294 { |
| 2302 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 2295 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
| 2303 | 2296 |
| 2304 while (CSSParserValue* val = m_valueList->current()) { | 2297 while (CSSParserValue* val = m_valueList->current()) { |
| 2305 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 2298 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
| 2306 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 2299 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
| 2307 // url | 2300 // url |
| 2308 parsedValue = createCSSImageValueWithReferrer(val->string, completeU
RL(val->string)); | 2301 parsedValue = CSSImageValue::create(val->string, completeURL(val->st
ring)); |
| 2309 } else if (val->unit == CSSParserValue::Function) { | 2302 } else if (val->unit == CSSParserValue::Function) { |
| 2310 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) | 2303 // attr(X) | counter(X [,Y]) | counters(X, Y, [,Z]) | -webkit-gradie
nt(...) |
| 2311 CSSParserValueList* args = val->function->args.get(); | 2304 CSSParserValueList* args = val->function->args.get(); |
| 2312 if (!args) | 2305 if (!args) |
| 2313 return false; | 2306 return false; |
| 2314 if (equalIgnoringCase(val->function->name, "attr(")) { | 2307 if (equalIgnoringCase(val->function->name, "attr(")) { |
| 2315 parsedValue = parseAttr(args); | 2308 parsedValue = parseAttr(args); |
| 2316 if (!parsedValue) | 2309 if (!parsedValue) |
| 2317 return false; | 2310 return false; |
| 2318 } else if (equalIgnoringCase(val->function->name, "counter(")) { | 2311 } else if (equalIgnoringCase(val->function->name, "counter(")) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 return parseColor(); | 2395 return parseColor(); |
| 2403 } | 2396 } |
| 2404 | 2397 |
| 2405 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 2398 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) |
| 2406 { | 2399 { |
| 2407 if (valueList->current()->id == CSSValueNone) { | 2400 if (valueList->current()->id == CSSValueNone) { |
| 2408 value = cssValuePool().createIdentifierValue(CSSValueNone); | 2401 value = cssValuePool().createIdentifierValue(CSSValueNone); |
| 2409 return true; | 2402 return true; |
| 2410 } | 2403 } |
| 2411 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { | 2404 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { |
| 2412 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 2405 value = CSSImageValue::create(valueList->current()->string, completeURL(
valueList->current()->string)); |
| 2413 return true; | 2406 return true; |
| 2414 } | 2407 } |
| 2415 | 2408 |
| 2416 if (isGeneratedImageValue(valueList->current())) | 2409 if (isGeneratedImageValue(valueList->current())) |
| 2417 return parseGeneratedImage(valueList, value); | 2410 return parseGeneratedImage(valueList, value); |
| 2418 | 2411 |
| 2419 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { | 2412 if (valueList->current()->unit == CSSParserValue::Function && equalIgnoringC
ase(valueList->current()->function->name, "-webkit-image-set(")) { |
| 2420 value = parseImageSet(m_valueList.get()); | 2413 value = parseImageSet(m_valueList.get()); |
| 2421 if (value) | 2414 if (value) |
| 2422 return true; | 2415 return true; |
| (...skipping 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4784 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); | 4777 addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierVa
lue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important); |
| 4785 return true; | 4778 return true; |
| 4786 } | 4779 } |
| 4787 } | 4780 } |
| 4788 return false; | 4781 return false; |
| 4789 } | 4782 } |
| 4790 | 4783 |
| 4791 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) | 4784 bool CSSPropertyParser::parseFontFaceSrcURI(CSSValueList* valueList) |
| 4792 { | 4785 { |
| 4793 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string))); | 4786 RefPtrWillBeRawPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create
(completeURL(m_valueList->current()->string))); |
| 4794 uriValue->setReferrer(m_context.baseURL().strippedForUseAsReferrer()); | |
| 4795 | 4787 |
| 4796 CSSParserValue* value = m_valueList->next(); | 4788 CSSParserValue* value = m_valueList->next(); |
| 4797 if (!value) { | 4789 if (!value) { |
| 4798 valueList->append(uriValue.release()); | 4790 valueList->append(uriValue.release()); |
| 4799 return true; | 4791 return true; |
| 4800 } | 4792 } |
| 4801 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { | 4793 if (value->unit == CSSParserValue::Operator && value->iValue == ',') { |
| 4802 m_valueList->next(); | 4794 m_valueList->next(); |
| 4803 valueList->append(uriValue.release()); | 4795 valueList->append(uriValue.release()); |
| 4804 return true; | 4796 return true; |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5882 { | 5874 { |
| 5883 CSSPropertyParser::ShorthandScope scope(&parser, propId); | 5875 CSSPropertyParser::ShorthandScope scope(&parser, propId); |
| 5884 while (CSSParserValue* val = parser.m_valueList->current()) { | 5876 while (CSSParserValue* val = parser.m_valueList->current()) { |
| 5885 context.setCanAdvance(false); | 5877 context.setCanAdvance(false); |
| 5886 | 5878 |
| 5887 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) | 5879 if (!context.canAdvance() && context.allowForwardSlashOperator() && isFo
rwardSlashOperator(val)) |
| 5888 context.commitForwardSlashOperator(); | 5880 context.commitForwardSlashOperator(); |
| 5889 | 5881 |
| 5890 if (!context.canAdvance() && context.allowImage()) { | 5882 if (!context.canAdvance() && context.allowImage()) { |
| 5891 if (val->unit == CSSPrimitiveValue::CSS_URI) { | 5883 if (val->unit == CSSPrimitiveValue::CSS_URI) { |
| 5892 context.commitImage(parser.createCSSImageValueWithReferrer(val->
string, parser.m_context.completeURL(val->string))); | 5884 context.commitImage(CSSImageValue::create(val->string, parser.m_
context.completeURL(val->string))); |
| 5893 } else if (isGeneratedImageValue(val)) { | 5885 } else if (isGeneratedImageValue(val)) { |
| 5894 RefPtrWillBeRawPtr<CSSValue> value = nullptr; | 5886 RefPtrWillBeRawPtr<CSSValue> value = nullptr; |
| 5895 if (parser.parseGeneratedImage(parser.m_valueList.get(), value)) | 5887 if (parser.parseGeneratedImage(parser.m_valueList.get(), value)) |
| 5896 context.commitImage(value.release()); | 5888 context.commitImage(value.release()); |
| 5897 else | 5889 else |
| 5898 return false; | 5890 return false; |
| 5899 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas
e(val->function->name, "-webkit-image-set(")) { | 5891 } else if (val->unit == CSSParserValue::Function && equalIgnoringCas
e(val->function->name, "-webkit-image-set(")) { |
| 5900 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser
.m_valueList.get()); | 5892 RefPtrWillBeRawPtr<CSSValue> value = parser.parseImageSet(parser
.m_valueList.get()); |
| 5901 if (value) | 5893 if (value) |
| 5902 context.commitImage(value.release()); | 5894 context.commitImage(value.release()); |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7170 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) | 7162 if (!functionArgs || !functionArgs->size() || !functionArgs->current()) |
| 7171 return nullptr; | 7163 return nullptr; |
| 7172 | 7164 |
| 7173 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); | 7165 RefPtrWillBeRawPtr<CSSImageSetValue> imageSet = CSSImageSetValue::create(); |
| 7174 | 7166 |
| 7175 CSSParserValue* arg = functionArgs->current(); | 7167 CSSParserValue* arg = functionArgs->current(); |
| 7176 while (arg) { | 7168 while (arg) { |
| 7177 if (arg->unit != CSSPrimitiveValue::CSS_URI) | 7169 if (arg->unit != CSSPrimitiveValue::CSS_URI) |
| 7178 return nullptr; | 7170 return nullptr; |
| 7179 | 7171 |
| 7180 RefPtrWillBeRawPtr<CSSValue> image = createCSSImageValueWithReferrer(arg
->string, completeURL(arg->string)); | 7172 RefPtrWillBeRawPtr<CSSImageValue> image = CSSImageValue::create(arg->str
ing, completeURL(arg->string)); |
| 7181 imageSet->append(image); | 7173 imageSet->append(image); |
| 7182 | 7174 |
| 7183 arg = functionArgs->next(); | 7175 arg = functionArgs->next(); |
| 7184 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) | 7176 if (!arg || arg->unit != CSSPrimitiveValue::CSS_DIMENSION) |
| 7185 return nullptr; | 7177 return nullptr; |
| 7186 | 7178 |
| 7187 double imageScaleFactor = 0; | 7179 double imageScaleFactor = 0; |
| 7188 const String& string = arg->string; | 7180 const String& string = arg->string; |
| 7189 unsigned length = string.length(); | 7181 unsigned length = string.length(); |
| 7190 if (!length) | 7182 if (!length) |
| (...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8485 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); | 8477 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); |
| 8486 if (!seenStroke) | 8478 if (!seenStroke) |
| 8487 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); | 8479 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke)
); |
| 8488 if (!seenMarkers) | 8480 if (!seenMarkers) |
| 8489 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); | 8481 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers
)); |
| 8490 | 8482 |
| 8491 return parsedValues.release(); | 8483 return parsedValues.release(); |
| 8492 } | 8484 } |
| 8493 | 8485 |
| 8494 } // namespace WebCore | 8486 } // namespace WebCore |
| OLD | NEW |