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