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 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 break; | 1341 break; |
1342 | 1342 |
1343 // End Apple-specific properties | 1343 // End Apple-specific properties |
1344 | 1344 |
1345 case CSSPropertyWebkitAppRegion: | 1345 case CSSPropertyWebkitAppRegion: |
1346 if (id >= CSSValueDrag && id <= CSSValueNoDrag) | 1346 if (id >= CSSValueDrag && id <= CSSValueNoDrag) |
1347 validPrimitive = true; | 1347 validPrimitive = true; |
1348 break; | 1348 break; |
1349 | 1349 |
1350 case CSSPropertyWebkitTapHighlightColor: | 1350 case CSSPropertyWebkitTapHighlightColor: |
1351 parsedValue = parseTapHighlightColor(m_valueList->current()); | 1351 parsedValue = parseColor(m_valueList->current()); |
1352 if (parsedValue) | 1352 if (parsedValue) |
1353 m_valueList->next(); | 1353 m_valueList->next(); |
1354 break; | 1354 break; |
1355 | 1355 |
1356 /* shorthand properties */ | 1356 /* shorthand properties */ |
1357 case CSSPropertyBackground: { | 1357 case CSSPropertyBackground: { |
1358 // Position must come before color in this array because a plain old "0"
is a legal color | 1358 // Position must come before color in this array because a plain old "0"
is a legal color |
1359 // in quirks mode but it's usually the X coordinate of a position. | 1359 // in quirks mode but it's usually the X coordinate of a position. |
1360 const CSSPropertyID properties[] = { CSSPropertyBackgroundImage, CSSProp
ertyBackgroundRepeat, | 1360 const CSSPropertyID properties[] = { CSSPropertyBackgroundImage, CSSProp
ertyBackgroundRepeat, |
1361 CSSPropertyBackgroundAttachment, CSSPropertyB
ackgroundPosition, CSSPropertyBackgroundOrigin, | 1361 CSSPropertyBackgroundAttachment, CSSPropertyB
ackgroundPosition, CSSPropertyBackgroundOrigin, |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 if (!isValueAllowedInMode(id, m_context.mode())) | 2319 if (!isValueAllowedInMode(id, m_context.mode())) |
2320 return nullptr; | 2320 return nullptr; |
2321 return cssValuePool().createIdentifierValue(id); | 2321 return cssValuePool().createIdentifierValue(id); |
2322 } | 2322 } |
2323 RGBA32 c = Color::transparent; | 2323 RGBA32 c = Color::transparent; |
2324 if (!parseColorFromValue(value, c, acceptQuirkyColors)) | 2324 if (!parseColorFromValue(value, c, acceptQuirkyColors)) |
2325 return nullptr; | 2325 return nullptr; |
2326 return cssValuePool().createColorValue(c); | 2326 return cssValuePool().createColorValue(c); |
2327 } | 2327 } |
2328 | 2328 |
2329 // Used to parse background-color when part of a shorthand. | |
2330 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseBackgroundColo
r(const CSSParserValue* value) | |
2331 { | |
2332 CSSValueID id = value->id; | |
2333 // Allow -webkit-text regardless of quirks. | |
2334 if (id == CSSValueWebkitText) | |
2335 return cssValuePool().createIdentifierValue(id); | |
2336 return parseColor(value); | |
2337 } | |
2338 | |
2339 // Used to parse the '-webkit-tap-highlight-color' property. | |
2340 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseTapHighlightCo
lor(const CSSParserValue* value) | |
2341 { | |
2342 CSSValueID id = value->id; | |
2343 // Disallow -webkit-text regardless of quirks. | |
2344 if (id == CSSValueWebkitText) | |
2345 return nullptr; | |
2346 return parseColor(value); | |
2347 } | |
2348 | |
2349 // Used to parse <color> for CSS gradients. | |
2350 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseGradientStopCo
lor(const CSSParserValue* value) | |
2351 { | |
2352 CSSValueID id = value->id; | |
2353 // Allow -webkit-text regardless of quirks. | |
2354 if (id == CSSValueWebkitText) | |
2355 return cssValuePool().createIdentifierValue(id); | |
2356 return parseColor(value); | |
2357 } | |
2358 | |
2359 // Used to parse colors for -webkit-gradient(...). | |
2360 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGrad
ientStopColor(const CSSParserValue* value) | |
2361 { | |
2362 // Disallow currentcolor. | |
2363 if (value->id == CSSValueCurrentcolor) | |
2364 return nullptr; | |
2365 return parseGradientStopColor(value); | |
2366 } | |
2367 | |
2368 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) | 2329 bool CSSPropertyParser::parseFillImage(CSSParserValueList* valueList, RefPtrWill
BeRawPtr<CSSValue>& value) |
2369 { | 2330 { |
2370 if (valueList->current()->id == CSSValueNone) { | 2331 if (valueList->current()->id == CSSValueNone) { |
2371 value = cssValuePool().createIdentifierValue(CSSValueNone); | 2332 value = cssValuePool().createIdentifierValue(CSSValueNone); |
2372 return true; | 2333 return true; |
2373 } | 2334 } |
2374 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { | 2335 if (valueList->current()->unit == CSSPrimitiveValue::CSS_URI) { |
2375 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); | 2336 value = createCSSImageValueWithReferrer(valueList->current()->string, co
mpleteURL(valueList->current()->string)); |
2376 return true; | 2337 return true; |
2377 } | 2338 } |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2846 while (true) { | 2807 while (true) { |
2847 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; | 2808 RefPtrWillBeRawPtr<CSSValue> currValue = nullptr; |
2848 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; | 2809 RefPtrWillBeRawPtr<CSSValue> currValue2 = nullptr; |
2849 | 2810 |
2850 Units unitless = FUnknown; | 2811 Units unitless = FUnknown; |
2851 CSSParserValue* val = m_valueList->current(); | 2812 CSSParserValue* val = m_valueList->current(); |
2852 ASSERT(val); | 2813 ASSERT(val); |
2853 | 2814 |
2854 switch (propId) { | 2815 switch (propId) { |
2855 case CSSPropertyBackgroundColor: | 2816 case CSSPropertyBackgroundColor: |
2856 currValue = parseBackgroundColor(val); | 2817 currValue = parseColor(val); |
2857 if (currValue) | 2818 if (currValue) |
2858 m_valueList->next(); | 2819 m_valueList->next(); |
2859 break; | 2820 break; |
2860 case CSSPropertyBackgroundAttachment: | 2821 case CSSPropertyBackgroundAttachment: |
2861 if (val->id == CSSValueScroll || val->id == CSSValueFixed || val->id
== CSSValueLocal) { | 2822 if (val->id == CSSValueScroll || val->id == CSSValueFixed || val->id
== CSSValueLocal) { |
2862 currValue = cssValuePool().createIdentifierValue(val->id); | 2823 currValue = cssValuePool().createIdentifierValue(val->id); |
2863 m_valueList->next(); | 2824 m_valueList->next(); |
2864 } | 2825 } |
2865 break; | 2826 break; |
2866 case CSSPropertyBackgroundImage: | 2827 case CSSPropertyBackgroundImage: |
(...skipping 3183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6050 || (a->id == CSSValueBottom && !horizontal)) | 6011 || (a->id == CSSValueBottom && !horizontal)) |
6051 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER
CENTAGE); | 6012 result = cssValuePool().createValue(100., CSSPrimitiveValue::CSS_PER
CENTAGE); |
6052 else if (a->id == CSSValueCenter) | 6013 else if (a->id == CSSValueCenter) |
6053 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC
ENTAGE); | 6014 result = cssValuePool().createValue(50., CSSPrimitiveValue::CSS_PERC
ENTAGE); |
6054 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti
veValue::CSS_PERCENTAGE) { | 6015 } else if (a->unit == CSSPrimitiveValue::CSS_NUMBER || a->unit == CSSPrimiti
veValue::CSS_PERCENTAGE) { |
6055 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV
alue::UnitType>(a->unit)); | 6016 result = cssValuePool().createValue(a->fValue, static_cast<CSSPrimitiveV
alue::UnitType>(a->unit)); |
6056 } | 6017 } |
6057 return result; | 6018 return result; |
6058 } | 6019 } |
6059 | 6020 |
| 6021 // Used to parse colors for -webkit-gradient(...). |
| 6022 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseDeprecatedGrad
ientStopColor(const CSSParserValue* value) |
| 6023 { |
| 6024 // Disallow currentcolor. |
| 6025 if (value->id == CSSValueCurrentcolor) |
| 6026 return nullptr; |
| 6027 return parseColor(value); |
| 6028 } |
| 6029 |
6060 bool CSSPropertyParser::parseDeprecatedGradientColorStop(CSSParserValue* a, CSSG
radientColorStop& stop) | 6030 bool CSSPropertyParser::parseDeprecatedGradientColorStop(CSSParserValue* a, CSSG
radientColorStop& stop) |
6061 { | 6031 { |
6062 if (a->unit != CSSParserValue::Function) | 6032 if (a->unit != CSSParserValue::Function) |
6063 return false; | 6033 return false; |
6064 | 6034 |
6065 if (a->function->id != CSSValueFrom | 6035 if (a->function->id != CSSValueFrom |
6066 && a->function->id != CSSValueTo | 6036 && a->function->id != CSSValueTo |
6067 && a->function->id != CSSValueColorStop) | 6037 && a->function->id != CSSValueColorStop) |
6068 return false; | 6038 return false; |
6069 | 6039 |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6661 return false; | 6631 return false; |
6662 | 6632 |
6663 a = valueList->next(); | 6633 a = valueList->next(); |
6664 if (!a) | 6634 if (!a) |
6665 return false; | 6635 return false; |
6666 } | 6636 } |
6667 | 6637 |
6668 // <color-stop> = <color> [ <percentage> | <length> ]? | 6638 // <color-stop> = <color> [ <percentage> | <length> ]? |
6669 // <color-hint> = <length> | <percentage> | 6639 // <color-hint> = <length> | <percentage> |
6670 CSSGradientColorStop stop; | 6640 CSSGradientColorStop stop; |
6671 stop.m_color = parseGradientStopColor(a); | 6641 stop.m_color = parseColor(a); |
6672 | 6642 |
6673 // Two hints in a row are not allowed. | 6643 // Two hints in a row are not allowed. |
6674 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) | 6644 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) |
6675 return false; | 6645 return false; |
6676 previousStopWasColorHint = !stop.m_color; | 6646 previousStopWasColorHint = !stop.m_color; |
6677 | 6647 |
6678 if (stop.m_color) | 6648 if (stop.m_color) |
6679 a = valueList->next(); | 6649 a = valueList->next(); |
6680 | 6650 |
6681 if (a) { | 6651 if (a) { |
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8262 } | 8232 } |
8263 } | 8233 } |
8264 | 8234 |
8265 if (!list->length()) | 8235 if (!list->length()) |
8266 return nullptr; | 8236 return nullptr; |
8267 | 8237 |
8268 return list.release(); | 8238 return list.release(); |
8269 } | 8239 } |
8270 | 8240 |
8271 } // namespace blink | 8241 } // namespace blink |
OLD | NEW |