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 5064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5075 { | 5075 { |
5076 if (length < 4) | 5076 if (length < 4) |
5077 return false; | 5077 return false; |
5078 return characters[3] == '(' | 5078 return characters[3] == '(' |
5079 && isASCIIAlphaCaselessEqual(characters[0], 'r') | 5079 && isASCIIAlphaCaselessEqual(characters[0], 'r') |
5080 && isASCIIAlphaCaselessEqual(characters[1], 'g') | 5080 && isASCIIAlphaCaselessEqual(characters[1], 'g') |
5081 && isASCIIAlphaCaselessEqual(characters[2], 'b'); | 5081 && isASCIIAlphaCaselessEqual(characters[2], 'b'); |
5082 } | 5082 } |
5083 | 5083 |
5084 template <typename CharacterType> | 5084 template <typename CharacterType> |
5085 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length , bool strict) | 5085 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length, bool strict) |
5086 { | 5086 { |
5087 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::CSS_UNKNOWN; | 5087 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::CSS_UNKNOWN; |
5088 | 5088 |
5089 if (length >= 4 && characters[0] == '#') | 5089 if (length >= 4 && characters[0] == '#') |
5090 return Color::parseHexColor(characters + 1, length - 1, rgb); | 5090 return Color::parseHexColor(characters + 1, length - 1, rgb); |
5091 | 5091 |
5092 if (!strict && length >= 3) { | 5092 if (!strict && length >= 3) { |
5093 if (Color::parseHexColor(characters, length, rgb)) | 5093 if (Color::parseHexColor(characters, length, rgb)) |
5094 return true; | 5094 return true; |
5095 } | 5095 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5298 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER); | 5298 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER); |
5299 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT); | 5299 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT); |
5300 if (!numberToken->isInt || numberToken->fValue < 0) | 5300 if (!numberToken->isInt || numberToken->fValue < 0) |
5301 return false; | 5301 return false; |
5302 String color = String::number(numberToken->fValue) + String(unitToken->s tring); | 5302 String color = String::number(numberToken->fValue) + String(unitToken->s tring); |
5303 if (color.length() > 6) | 5303 if (color.length() > 6) |
5304 return false; | 5304 return false; |
5305 while (color.length() < 6) | 5305 while (color.length() < 6) |
5306 color = "0" + color; | 5306 color = "0" + color; |
5307 return fastParseColor(c, color, false); | 5307 return fastParseColor(c, color, false); |
5308 } else if (value->unit == CSSParserValue::HexColor || value->unit == CSSPrim itiveValue::CSS_IDENT) { | 5308 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) { |
5309 if (!fastParseColor(c, value->string, !acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_IDENT)) | 5309 if (!fastParseColor(c, value->string, !acceptQuirkyColors)) |
5310 return false; | 5310 return false; |
5311 } else if (value->unit == CSSParserValue::HexColor) { | |
5312 ASSERT(value->string[0] != '#'); | |
Timothy Loh
2015/05/22 01:05:10
I don't think this assertion is right (you can wri
| |
5313 if (value->string.is8Bit()) | |
5314 return Color::parseHexColor(value->string.characters8(), value->stri ng.length(), c); | |
5315 return Color::parseHexColor(value->string.characters16(), value->string. length(), c); | |
5311 } else if (value->unit == CSSParserValue::Function && | 5316 } else if (value->unit == CSSParserValue::Function && |
5312 value->function->args != 0 && | 5317 value->function->args != 0 && |
5313 value->function->args->size() == 5 /* rgb + two commas */ && | 5318 value->function->args->size() == 5 /* rgb + two commas */ && |
5314 value->function->id == CSSValueRgb) { | 5319 value->function->id == CSSValueRgb) { |
5315 int colorValues[3]; | 5320 int colorValues[3]; |
5316 if (!parseColorParameters(value, colorValues, false)) | 5321 if (!parseColorParameters(value, colorValues, false)) |
5317 return false; | 5322 return false; |
5318 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); | 5323 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); |
5319 } else { | 5324 } else { |
5320 if (value->unit == CSSParserValue::Function && | 5325 if (value->unit == CSSParserValue::Function && |
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8466 } | 8471 } |
8467 } | 8472 } |
8468 | 8473 |
8469 if (!list->length()) | 8474 if (!list->length()) |
8470 return nullptr; | 8475 return nullptr; |
8471 | 8476 |
8472 return list.release(); | 8477 return list.release(); |
8473 } | 8478 } |
8474 | 8479 |
8475 } // namespace blink | 8480 } // namespace blink |
OLD | NEW |