| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "core/css/CSSTimingFunctionValue.h" | 51 #include "core/css/CSSTimingFunctionValue.h" |
| 52 #include "core/css/CSSUnicodeRangeValue.h" | 52 #include "core/css/CSSUnicodeRangeValue.h" |
| 53 #include "core/css/CSSValuePool.h" | 53 #include "core/css/CSSValuePool.h" |
| 54 #include "core/css/Counter.h" | 54 #include "core/css/Counter.h" |
| 55 #include "core/css/HashTools.h" | 55 #include "core/css/HashTools.h" |
| 56 #include "core/css/Pair.h" | 56 #include "core/css/Pair.h" |
| 57 #include "core/css/Rect.h" | 57 #include "core/css/Rect.h" |
| 58 #include "core/css/parser/CSSParserFastPaths.h" | 58 #include "core/css/parser/CSSParserFastPaths.h" |
| 59 #include "core/css/parser/CSSParserValues.h" | 59 #include "core/css/parser/CSSParserValues.h" |
| 60 #include "core/frame/UseCounter.h" | 60 #include "core/frame/UseCounter.h" |
| 61 #include "core/html/parser/HTMLParserIdioms.h" | |
| 62 #include "core/layout/LayoutTheme.h" | 61 #include "core/layout/LayoutTheme.h" |
| 63 #include "core/style/GridCoordinate.h" | 62 #include "core/style/GridCoordinate.h" |
| 64 #include "core/svg/SVGPathUtilities.h" | 63 #include "core/svg/SVGPathUtilities.h" |
| 65 #include "platform/RuntimeEnabledFeatures.h" | 64 #include "platform/RuntimeEnabledFeatures.h" |
| 66 | 65 |
| 67 namespace blink { | 66 namespace blink { |
| 68 | 67 |
| 69 static const double MAX_SCALE = 1000000; | |
| 70 | |
| 71 template <unsigned N> | 68 template <unsigned N> |
| 72 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) | 69 static bool equalIgnoringCase(const CSSParserString& a, const char (&b)[N]) |
| 73 { | 70 { |
| 74 unsigned length = N - 1; // Ignore the trailing null character | 71 unsigned length = N - 1; // Ignore the trailing null character |
| 75 if (a.length() != length) | 72 if (a.length() != length) |
| 76 return false; | 73 return false; |
| 77 | 74 |
| 78 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); | 75 return a.is8Bit() ? WTF::equalIgnoringCase(b, a.characters8(), length) : WTF
::equalIgnoringCase(b, a.characters16(), length); |
| 79 } | 76 } |
| 80 | 77 |
| (...skipping 4753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4834 UChar32 end = current->m_unicodeRange.end; | 4831 UChar32 end = current->m_unicodeRange.end; |
| 4835 if (start > end) | 4832 if (start > end) |
| 4836 return nullptr; | 4833 return nullptr; |
| 4837 values->append(CSSUnicodeRangeValue::create(start, end)); | 4834 values->append(CSSUnicodeRangeValue::create(start, end)); |
| 4838 m_valueList->next(); | 4835 m_valueList->next(); |
| 4839 } while (consumeComma(m_valueList)); | 4836 } while (consumeComma(m_valueList)); |
| 4840 | 4837 |
| 4841 return values.release(); | 4838 return values.release(); |
| 4842 } | 4839 } |
| 4843 | 4840 |
| 4844 // Returns the number of characters which form a valid double | |
| 4845 // and are terminated by the given terminator character | |
| 4846 template <typename CharacterType> | |
| 4847 static int checkForValidDouble(const CharacterType* string, const CharacterType*
end, const char terminator) | |
| 4848 { | |
| 4849 int length = end - string; | |
| 4850 if (length < 1) | |
| 4851 return 0; | |
| 4852 | |
| 4853 bool decimalMarkSeen = false; | |
| 4854 int processedLength = 0; | |
| 4855 | |
| 4856 for (int i = 0; i < length; ++i) { | |
| 4857 if (string[i] == terminator) { | |
| 4858 processedLength = i; | |
| 4859 break; | |
| 4860 } | |
| 4861 if (!isASCIIDigit(string[i])) { | |
| 4862 if (!decimalMarkSeen && string[i] == '.') | |
| 4863 decimalMarkSeen = true; | |
| 4864 else | |
| 4865 return 0; | |
| 4866 } | |
| 4867 } | |
| 4868 | |
| 4869 if (decimalMarkSeen && processedLength == 1) | |
| 4870 return 0; | |
| 4871 | |
| 4872 return processedLength; | |
| 4873 } | |
| 4874 | |
| 4875 // Returns the number of characters consumed for parsing a valid double | |
| 4876 // terminated by the given terminator character | |
| 4877 template <typename CharacterType> | |
| 4878 static int parseDouble(const CharacterType* string, const CharacterType* end, co
nst char terminator, double& value) | |
| 4879 { | |
| 4880 int length = checkForValidDouble(string, end, terminator); | |
| 4881 if (!length) | |
| 4882 return 0; | |
| 4883 | |
| 4884 int position = 0; | |
| 4885 double localValue = 0; | |
| 4886 | |
| 4887 // The consumed characters here are guaranteed to be | |
| 4888 // ASCII digits with or without a decimal mark | |
| 4889 for (; position < length; ++position) { | |
| 4890 if (string[position] == '.') | |
| 4891 break; | |
| 4892 localValue = localValue * 10 + string[position] - '0'; | |
| 4893 } | |
| 4894 | |
| 4895 if (++position == length) { | |
| 4896 value = localValue; | |
| 4897 return length; | |
| 4898 } | |
| 4899 | |
| 4900 double fraction = 0; | |
| 4901 double scale = 1; | |
| 4902 | |
| 4903 while (position < length && scale < MAX_SCALE) { | |
| 4904 fraction = fraction * 10 + string[position++] - '0'; | |
| 4905 scale *= 10; | |
| 4906 } | |
| 4907 | |
| 4908 value = localValue + fraction / scale; | |
| 4909 return length; | |
| 4910 } | |
| 4911 | |
| 4912 template <typename CharacterType> | |
| 4913 static bool parseColorIntOrPercentage(const CharacterType*& string, const Charac
terType* end, const char terminator, CSSPrimitiveValue::UnitType& expect, int& v
alue) | |
| 4914 { | |
| 4915 const CharacterType* current = string; | |
| 4916 double localValue = 0; | |
| 4917 bool negative = false; | |
| 4918 while (current != end && isHTMLSpace<CharacterType>(*current)) | |
| 4919 current++; | |
| 4920 if (current != end && *current == '-') { | |
| 4921 negative = true; | |
| 4922 current++; | |
| 4923 } | |
| 4924 if (current == end || !isASCIIDigit(*current)) | |
| 4925 return false; | |
| 4926 while (current != end && isASCIIDigit(*current)) { | |
| 4927 double newValue = localValue * 10 + *current++ - '0'; | |
| 4928 if (newValue >= 255) { | |
| 4929 // Clamp values at 255. | |
| 4930 localValue = 255; | |
| 4931 while (current != end && isASCIIDigit(*current)) | |
| 4932 ++current; | |
| 4933 break; | |
| 4934 } | |
| 4935 localValue = newValue; | |
| 4936 } | |
| 4937 | |
| 4938 if (current == end) | |
| 4939 return false; | |
| 4940 | |
| 4941 if (expect == CSSPrimitiveValue::CSS_NUMBER && (*current == '.' || *current
== '%')) | |
| 4942 return false; | |
| 4943 | |
| 4944 if (*current == '.') { | |
| 4945 // We already parsed the integral part, try to parse | |
| 4946 // the fraction part of the percentage value. | |
| 4947 double percentage = 0; | |
| 4948 int numCharactersParsed = parseDouble(current, end, '%', percentage); | |
| 4949 if (!numCharactersParsed) | |
| 4950 return false; | |
| 4951 current += numCharactersParsed; | |
| 4952 if (*current != '%') | |
| 4953 return false; | |
| 4954 localValue += percentage; | |
| 4955 } | |
| 4956 | |
| 4957 if (expect == CSSPrimitiveValue::CSS_PERCENTAGE && *current != '%') | |
| 4958 return false; | |
| 4959 | |
| 4960 if (*current == '%') { | |
| 4961 expect = CSSPrimitiveValue::CSS_PERCENTAGE; | |
| 4962 localValue = localValue / 100.0 * 256.0; | |
| 4963 // Clamp values at 255 for percentages over 100% | |
| 4964 if (localValue > 255) | |
| 4965 localValue = 255; | |
| 4966 current++; | |
| 4967 } else | |
| 4968 expect = CSSPrimitiveValue::CSS_NUMBER; | |
| 4969 | |
| 4970 while (current != end && isHTMLSpace<CharacterType>(*current)) | |
| 4971 current++; | |
| 4972 if (current == end || *current++ != terminator) | |
| 4973 return false; | |
| 4974 // Clamp negative values at zero. | |
| 4975 value = negative ? 0 : static_cast<int>(localValue); | |
| 4976 string = current; | |
| 4977 return true; | |
| 4978 } | |
| 4979 | |
| 4980 template <typename CharacterType> | |
| 4981 static inline bool isTenthAlpha(const CharacterType* string, const int length) | |
| 4982 { | |
| 4983 // "0.X" | |
| 4984 if (length == 3 && string[0] == '0' && string[1] == '.' && isASCIIDigit(stri
ng[2])) | |
| 4985 return true; | |
| 4986 | |
| 4987 // ".X" | |
| 4988 if (length == 2 && string[0] == '.' && isASCIIDigit(string[1])) | |
| 4989 return true; | |
| 4990 | |
| 4991 return false; | |
| 4992 } | |
| 4993 | |
| 4994 template <typename CharacterType> | |
| 4995 static inline bool parseAlphaValue(const CharacterType*& string, const Character
Type* end, const char terminator, int& value) | |
| 4996 { | |
| 4997 while (string != end && isHTMLSpace<CharacterType>(*string)) | |
| 4998 string++; | |
| 4999 | |
| 5000 bool negative = false; | |
| 5001 | |
| 5002 if (string != end && *string == '-') { | |
| 5003 negative = true; | |
| 5004 string++; | |
| 5005 } | |
| 5006 | |
| 5007 value = 0; | |
| 5008 | |
| 5009 int length = end - string; | |
| 5010 if (length < 2) | |
| 5011 return false; | |
| 5012 | |
| 5013 if (string[length - 1] != terminator || !isASCIIDigit(string[length - 2])) | |
| 5014 return false; | |
| 5015 | |
| 5016 if (string[0] != '0' && string[0] != '1' && string[0] != '.') { | |
| 5017 if (checkForValidDouble(string, end, terminator)) { | |
| 5018 value = negative ? 0 : 255; | |
| 5019 string = end; | |
| 5020 return true; | |
| 5021 } | |
| 5022 return false; | |
| 5023 } | |
| 5024 | |
| 5025 if (length == 2 && string[0] != '.') { | |
| 5026 value = !negative && string[0] == '1' ? 255 : 0; | |
| 5027 string = end; | |
| 5028 return true; | |
| 5029 } | |
| 5030 | |
| 5031 if (isTenthAlpha(string, length - 1)) { | |
| 5032 static const int tenthAlphaValues[] = { 0, 25, 51, 76, 102, 127, 153, 17
9, 204, 230 }; | |
| 5033 value = negative ? 0 : tenthAlphaValues[string[length - 2] - '0']; | |
| 5034 string = end; | |
| 5035 return true; | |
| 5036 } | |
| 5037 | |
| 5038 double alpha = 0; | |
| 5039 if (!parseDouble(string, end, terminator, alpha)) | |
| 5040 return false; | |
| 5041 value = negative ? 0 : static_cast<int>(alpha * nextafter(256.0, 0.0)); | |
| 5042 string = end; | |
| 5043 return true; | |
| 5044 } | |
| 5045 | |
| 5046 template <typename CharacterType> | |
| 5047 static inline bool mightBeRGBA(const CharacterType* characters, unsigned length) | |
| 5048 { | |
| 5049 if (length < 5) | |
| 5050 return false; | |
| 5051 return characters[4] == '(' | |
| 5052 && isASCIIAlphaCaselessEqual(characters[0], 'r') | |
| 5053 && isASCIIAlphaCaselessEqual(characters[1], 'g') | |
| 5054 && isASCIIAlphaCaselessEqual(characters[2], 'b') | |
| 5055 && isASCIIAlphaCaselessEqual(characters[3], 'a'); | |
| 5056 } | |
| 5057 | |
| 5058 template <typename CharacterType> | |
| 5059 static inline bool mightBeRGB(const CharacterType* characters, unsigned length) | |
| 5060 { | |
| 5061 if (length < 4) | |
| 5062 return false; | |
| 5063 return characters[3] == '(' | |
| 5064 && isASCIIAlphaCaselessEqual(characters[0], 'r') | |
| 5065 && isASCIIAlphaCaselessEqual(characters[1], 'g') | |
| 5066 && isASCIIAlphaCaselessEqual(characters[2], 'b'); | |
| 5067 } | |
| 5068 | |
| 5069 template <typename CharacterType> | |
| 5070 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char
acters, unsigned length, bool strict) | |
| 5071 { | |
| 5072 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::CSS_UNKNOWN; | |
| 5073 | |
| 5074 if (length >= 4 && characters[0] == '#') | |
| 5075 return Color::parseHexColor(characters + 1, length - 1, rgb); | |
| 5076 | |
| 5077 if (!strict && length >= 3) { | |
| 5078 if (Color::parseHexColor(characters, length, rgb)) | |
| 5079 return true; | |
| 5080 } | |
| 5081 | |
| 5082 // Try rgba() syntax. | |
| 5083 if (mightBeRGBA(characters, length)) { | |
| 5084 const CharacterType* current = characters + 5; | |
| 5085 const CharacterType* end = characters + length; | |
| 5086 int red; | |
| 5087 int green; | |
| 5088 int blue; | |
| 5089 int alpha; | |
| 5090 | |
| 5091 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) | |
| 5092 return false; | |
| 5093 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) | |
| 5094 return false; | |
| 5095 if (!parseColorIntOrPercentage(current, end, ',', expect, blue)) | |
| 5096 return false; | |
| 5097 if (!parseAlphaValue(current, end, ')', alpha)) | |
| 5098 return false; | |
| 5099 if (current != end) | |
| 5100 return false; | |
| 5101 rgb = makeRGBA(red, green, blue, alpha); | |
| 5102 return true; | |
| 5103 } | |
| 5104 | |
| 5105 // Try rgb() syntax. | |
| 5106 if (mightBeRGB(characters, length)) { | |
| 5107 const CharacterType* current = characters + 4; | |
| 5108 const CharacterType* end = characters + length; | |
| 5109 int red; | |
| 5110 int green; | |
| 5111 int blue; | |
| 5112 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) | |
| 5113 return false; | |
| 5114 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) | |
| 5115 return false; | |
| 5116 if (!parseColorIntOrPercentage(current, end, ')', expect, blue)) | |
| 5117 return false; | |
| 5118 if (current != end) | |
| 5119 return false; | |
| 5120 rgb = makeRGB(red, green, blue); | |
| 5121 return true; | |
| 5122 } | |
| 5123 | |
| 5124 return false; | |
| 5125 } | |
| 5126 | |
| 5127 template<typename StringType> | |
| 5128 bool CSSPropertyParser::fastParseColor(RGBA32& rgb, const StringType& name, bool
strict) | |
| 5129 { | |
| 5130 unsigned length = name.length(); | |
| 5131 bool parseResult; | |
| 5132 | |
| 5133 if (!length) | |
| 5134 return false; | |
| 5135 | |
| 5136 if (name.is8Bit()) | |
| 5137 parseResult = fastParseColorInternal(rgb, name.characters8(), length, st
rict); | |
| 5138 else | |
| 5139 parseResult = fastParseColorInternal(rgb, name.characters16(), length, s
trict); | |
| 5140 | |
| 5141 if (parseResult) | |
| 5142 return true; | |
| 5143 | |
| 5144 // Try named colors. | |
| 5145 Color tc; | |
| 5146 if (!tc.setNamedColor(name)) | |
| 5147 return false; | |
| 5148 rgb = tc.rgb(); | |
| 5149 return true; | |
| 5150 } | |
| 5151 | |
| 5152 template bool CSSPropertyParser::fastParseColor(RGBA32&, const String&, bool str
ict); | |
| 5153 | 4841 |
| 5154 bool CSSPropertyParser::isCalculation(CSSParserValue* value) | 4842 bool CSSPropertyParser::isCalculation(CSSParserValue* value) |
| 5155 { | 4843 { |
| 5156 return (value->unit == CSSParserValue::Function) | 4844 return (value->unit == CSSParserValue::Function) |
| 5157 && (value->function->id == CSSValueCalc | 4845 && (value->function->id == CSSValueCalc |
| 5158 || value->function->id == CSSValueWebkitCalc); | 4846 || value->function->id == CSSValueWebkitCalc); |
| 5159 } | 4847 } |
| 5160 | 4848 |
| 5161 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) | 4849 inline int CSSPropertyParser::colorIntFromValue(CSSParserValue* v) |
| 5162 { | 4850 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5261 } | 4949 } |
| 5262 | 4950 |
| 5263 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value, bool acceptQuirkyColors) | 4951 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> CSSPropertyParser::parseColor(CSSParse
rValue* value, bool acceptQuirkyColors) |
| 5264 { | 4952 { |
| 5265 RGBA32 c = Color::transparent; | 4953 RGBA32 c = Color::transparent; |
| 5266 if (!parseColorFromValue(value ? value : m_valueList->current(), c, acceptQu
irkyColors)) | 4954 if (!parseColorFromValue(value ? value : m_valueList->current(), c, acceptQu
irkyColors)) |
| 5267 return nullptr; | 4955 return nullptr; |
| 5268 return cssValuePool().createColorValue(c); | 4956 return cssValuePool().createColorValue(c); |
| 5269 } | 4957 } |
| 5270 | 4958 |
| 5271 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& c, bo
ol acceptQuirkyColors) | 4959 bool CSSPropertyParser::parseColorFromValue(CSSParserValue* value, RGBA32& resul
t, bool acceptQuirkyColors) |
| 5272 { | 4960 { |
| 5273 if (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_NUMBER | 4961 if (acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_NUMBER |
| 5274 && value->fValue >= 0. && value->fValue < 1000000.) { | 4962 && value->fValue >= 0. && value->fValue < 1000000. && value->isInt) { |
| 5275 if (!value->isInt) | 4963 String str = String::format("%06d", static_cast<int>(value->fValue)); |
| 5276 return false; | 4964 return Color::parseHexColor(str, result); |
| 5277 String str = String::format("%06d", static_cast<int>((value->fValue+.5))
); | |
| 5278 if (!fastParseColor(c, str, !acceptQuirkyColors)) | |
| 5279 return false; | |
| 5280 } else if (acceptQuirkyColors && value->unit == CSSParserValue::DimensionLis
t) { | 4965 } else if (acceptQuirkyColors && value->unit == CSSParserValue::DimensionLis
t) { |
| 5281 CSSParserValue* numberToken = value->valueList->valueAt(0); | 4966 CSSParserValue* numberToken = value->valueList->valueAt(0); |
| 5282 CSSParserValue* unitToken = value->valueList->valueAt(1); | 4967 CSSParserValue* unitToken = value->valueList->valueAt(1); |
| 5283 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER); | 4968 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER); |
| 5284 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT); | 4969 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT); |
| 5285 if (!numberToken->isInt || numberToken->fValue < 0) | 4970 if (!numberToken->isInt || numberToken->fValue < 0) |
| 5286 return false; | 4971 return false; |
| 5287 String color = String::number(numberToken->fValue) + String(unitToken->s
tring); | 4972 String color = String::number(numberToken->fValue) + String(unitToken->s
tring); |
| 5288 if (color.length() > 6) | 4973 if (color.length() > 6) |
| 5289 return false; | 4974 return false; |
| 5290 while (color.length() < 6) | 4975 while (color.length() < 6) |
| 5291 color = "0" + color; | 4976 color = "0" + color; |
| 5292 return fastParseColor(c, color, false); | 4977 return Color::parseHexColor(color, result); |
| 5293 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) { | 4978 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) { |
| 5294 if (!fastParseColor(c, value->string, !acceptQuirkyColors)) | 4979 Color color; |
| 5295 return false; | 4980 if (!color.setNamedColor(value->string)) |
| 4981 return acceptQuirkyColors && Color::parseHexColor(value->string, res
ult); |
| 4982 result = color.rgb(); |
| 4983 return true; |
| 5296 } else if (value->unit == CSSParserValue::HexColor) { | 4984 } else if (value->unit == CSSParserValue::HexColor) { |
| 5297 if (value->string.is8Bit()) | 4985 if (value->string.is8Bit()) |
| 5298 return Color::parseHexColor(value->string.characters8(), value->stri
ng.length(), c); | 4986 return Color::parseHexColor(value->string.characters8(), value->stri
ng.length(), result); |
| 5299 return Color::parseHexColor(value->string.characters16(), value->string.
length(), c); | 4987 return Color::parseHexColor(value->string.characters16(), value->string.
length(), result); |
| 5300 } else if (value->unit == CSSParserValue::Function && | 4988 } else if (value->unit == CSSParserValue::Function && |
| 5301 value->function->args != 0 && | 4989 value->function->args != 0 && |
| 5302 value->function->args->size() == 5 /* rgb + two commas */ && | 4990 value->function->args->size() == 5 /* rgb + two commas */ && |
| 5303 value->function->id == CSSValueRgb) { | 4991 value->function->id == CSSValueRgb) { |
| 5304 int colorValues[3]; | 4992 int colorValues[3]; |
| 5305 if (!parseColorParameters(value, colorValues, false)) | 4993 if (!parseColorParameters(value, colorValues, false)) |
| 5306 return false; | 4994 return false; |
| 5307 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); | 4995 result = makeRGB(colorValues[0], colorValues[1], colorValues[2]); |
| 5308 } else { | 4996 } else { |
| 5309 if (value->unit == CSSParserValue::Function && | 4997 if (value->unit == CSSParserValue::Function && |
| 5310 value->function->args != 0 && | 4998 value->function->args != 0 && |
| 5311 value->function->args->size() == 7 /* rgba + three commas */ && | 4999 value->function->args->size() == 7 /* rgba + three commas */ && |
| 5312 value->function->id == CSSValueRgba) { | 5000 value->function->id == CSSValueRgba) { |
| 5313 int colorValues[4]; | 5001 int colorValues[4]; |
| 5314 if (!parseColorParameters(value, colorValues, true)) | 5002 if (!parseColorParameters(value, colorValues, true)) |
| 5315 return false; | 5003 return false; |
| 5316 c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorVa
lues[3]); | 5004 result = makeRGBA(colorValues[0], colorValues[1], colorValues[2], co
lorValues[3]); |
| 5317 } else if (value->unit == CSSParserValue::Function && | 5005 } else if (value->unit == CSSParserValue::Function && |
| 5318 value->function->args != 0 && | 5006 value->function->args != 0 && |
| 5319 value->function->args->size() == 5 /* hsl + two commas */ && | 5007 value->function->args->size() == 5 /* hsl + two commas */ && |
| 5320 value->function->id == CSSValueHsl) { | 5008 value->function->id == CSSValueHsl) { |
| 5321 double colorValues[3]; | 5009 double colorValues[3]; |
| 5322 if (!parseHSLParameters(value, colorValues, false)) | 5010 if (!parseHSLParameters(value, colorValues, false)) |
| 5323 return false; | 5011 return false; |
| 5324 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2],
1.0); | 5012 result = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValue
s[2], 1.0); |
| 5325 } else if (value->unit == CSSParserValue::Function && | 5013 } else if (value->unit == CSSParserValue::Function && |
| 5326 value->function->args != 0 && | 5014 value->function->args != 0 && |
| 5327 value->function->args->size() == 7 /* hsla + three commas */
&& | 5015 value->function->args->size() == 7 /* hsla + three commas */
&& |
| 5328 value->function->id == CSSValueHsla) { | 5016 value->function->id == CSSValueHsla) { |
| 5329 double colorValues[4]; | 5017 double colorValues[4]; |
| 5330 if (!parseHSLParameters(value, colorValues, true)) | 5018 if (!parseHSLParameters(value, colorValues, true)) |
| 5331 return false; | 5019 return false; |
| 5332 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2],
colorValues[3]); | 5020 result = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValue
s[2], colorValues[3]); |
| 5333 } else | 5021 } else |
| 5334 return false; | 5022 return false; |
| 5335 } | 5023 } |
| 5336 | 5024 |
| 5337 return true; | 5025 return true; |
| 5338 } | 5026 } |
| 5339 | 5027 |
| 5340 // This class tracks parsing state for shadow values. If it goes out of scope (
e.g., due to an early return) | 5028 // This class tracks parsing state for shadow values. If it goes out of scope (
e.g., due to an early return) |
| 5341 // without the allowBreak bit being set, then it will clean up all of the object
s and destroy them. | 5029 // without the allowBreak bit being set, then it will clean up all of the object
s and destroy them. |
| 5342 class ShadowParseContext { | 5030 class ShadowParseContext { |
| (...skipping 3134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8477 } | 8165 } |
| 8478 } | 8166 } |
| 8479 | 8167 |
| 8480 if (!list->length()) | 8168 if (!list->length()) |
| 8481 return nullptr; | 8169 return nullptr; |
| 8482 | 8170 |
| 8483 return list.release(); | 8171 return list.release(); |
| 8484 } | 8172 } |
| 8485 | 8173 |
| 8486 } // namespace blink | 8174 } // namespace blink |
| OLD | NEW |