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 6806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6817 | 6817 |
6818 gradient = result.release(); | 6818 gradient = result.release(); |
6819 return true; | 6819 return true; |
6820 } | 6820 } |
6821 | 6821 |
6822 bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
SSGradientValue* gradient, bool expectComma) | 6822 bool CSSPropertyParser::parseGradientColorStops(CSSParserValueList* valueList, C
SSGradientValue* gradient, bool expectComma) |
6823 { | 6823 { |
6824 CSSParserValue* a = valueList->current(); | 6824 CSSParserValue* a = valueList->current(); |
6825 | 6825 |
6826 // Now look for color stops. | 6826 // Now look for color stops. |
| 6827 // <color-stop-list> = [ <color-stop> , <color-hint>? ]# , <color-stop> |
| 6828 bool supportsColorHints = gradient->gradientType() == CSSLinearGradient |
| 6829 || gradient->gradientType() == CSSRadialGradient; |
| 6830 |
| 6831 // The first color stop cannot be a color hint. |
| 6832 bool previousStopWasColorHint = true; |
6827 while (a) { | 6833 while (a) { |
6828 // Look for the comma before the next stop. | 6834 // Look for the comma before the next stop. |
6829 if (expectComma) { | 6835 if (expectComma) { |
6830 if (!isComma(a)) | 6836 if (!isComma(a)) |
6831 return false; | 6837 return false; |
6832 | 6838 |
6833 a = valueList->next(); | 6839 a = valueList->next(); |
6834 if (!a) | 6840 if (!a) |
6835 return false; | 6841 return false; |
6836 } | 6842 } |
6837 | 6843 |
6838 // <color-stop> = <color> [ <percentage> | <length> ]? | 6844 // <color-stop> = <color> [ <percentage> | <length> ]? |
| 6845 // <color-hint> = <length> | <percentage> |
6839 CSSGradientColorStop stop; | 6846 CSSGradientColorStop stop; |
6840 stop.m_color = parseGradientColorOrKeyword(this, a); | 6847 stop.m_color = parseGradientColorOrKeyword(this, a); |
6841 if (!stop.m_color) | 6848 |
| 6849 // Two hints in a row are not allowed. |
| 6850 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) |
6842 return false; | 6851 return false; |
| 6852 previousStopWasColorHint = !stop.m_color; |
6843 | 6853 |
6844 a = valueList->next(); | 6854 if (stop.m_color) |
| 6855 a = valueList->next(); |
| 6856 |
6845 if (a) { | 6857 if (a) { |
6846 if (validUnit(a, FLength | FPercent)) { | 6858 if (validUnit(a, FLength | FPercent)) { |
6847 stop.m_position = createPrimitiveNumericValue(a); | 6859 stop.m_position = createPrimitiveNumericValue(a); |
6848 a = valueList->next(); | 6860 a = valueList->next(); |
6849 } | 6861 } |
6850 } | 6862 } |
6851 | 6863 |
| 6864 if (!stop.m_color && !stop.m_position) |
| 6865 return false; |
| 6866 |
6852 gradient->addStop(stop); | 6867 gradient->addStop(stop); |
6853 expectComma = true; | 6868 expectComma = true; |
6854 } | 6869 } |
6855 | 6870 |
| 6871 // The last color stop cannot be a color hint. |
| 6872 if (previousStopWasColorHint) |
| 6873 return false; |
| 6874 |
6856 // Must have 2 or more stops to be valid. | 6875 // Must have 2 or more stops to be valid. |
6857 return gradient->stopCount() >= 2; | 6876 return gradient->stopCount() >= 2; |
6858 } | 6877 } |
6859 | 6878 |
6860 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& value) | 6879 bool CSSPropertyParser::parseGeneratedImage(CSSParserValueList* valueList, RefPt
rWillBeRawPtr<CSSValue>& value) |
6861 { | 6880 { |
6862 CSSParserValue* val = valueList->current(); | 6881 CSSParserValue* val = valueList->current(); |
6863 | 6882 |
6864 if (val->unit != CSSParserValue::Function) | 6883 if (val->unit != CSSParserValue::Function) |
6865 return false; | 6884 return false; |
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8377 return nullptr; | 8396 return nullptr; |
8378 a = args->next(); | 8397 a = args->next(); |
8379 | 8398 |
8380 argNumber++; | 8399 argNumber++; |
8381 } | 8400 } |
8382 | 8401 |
8383 return transformValue.release(); | 8402 return transformValue.release(); |
8384 } | 8403 } |
8385 | 8404 |
8386 } // namespace blink | 8405 } // namespace blink |
OLD | NEW |