Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: Source/core/css/parser/CSSPropertyParser.cpp

Issue 1151593003: Remove hexDigit check in CSSParserValueList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove ASSERT and add subtest Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/parser/CSSParserValues.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5012 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 { 5023 {
5024 if (length < 4) 5024 if (length < 4)
5025 return false; 5025 return false;
5026 return characters[3] == '(' 5026 return characters[3] == '('
5027 && isASCIIAlphaCaselessEqual(characters[0], 'r') 5027 && isASCIIAlphaCaselessEqual(characters[0], 'r')
5028 && isASCIIAlphaCaselessEqual(characters[1], 'g') 5028 && isASCIIAlphaCaselessEqual(characters[1], 'g')
5029 && isASCIIAlphaCaselessEqual(characters[2], 'b'); 5029 && isASCIIAlphaCaselessEqual(characters[2], 'b');
5030 } 5030 }
5031 5031
5032 template <typename CharacterType> 5032 template <typename CharacterType>
5033 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length , bool strict) 5033 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length, bool strict)
5034 { 5034 {
5035 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::CSS_UNKNOWN; 5035 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::CSS_UNKNOWN;
5036 5036
5037 if (length >= 4 && characters[0] == '#') 5037 if (length >= 4 && characters[0] == '#')
5038 return Color::parseHexColor(characters + 1, length - 1, rgb); 5038 return Color::parseHexColor(characters + 1, length - 1, rgb);
5039 5039
5040 if (!strict && length >= 3) { 5040 if (!strict && length >= 3) {
5041 if (Color::parseHexColor(characters, length, rgb)) 5041 if (Color::parseHexColor(characters, length, rgb))
5042 return true; 5042 return true;
5043 } 5043 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5246 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER); 5246 ASSERT(numberToken->unit == CSSPrimitiveValue::CSS_NUMBER);
5247 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT); 5247 ASSERT(unitToken->unit == CSSPrimitiveValue::CSS_IDENT);
5248 if (!numberToken->isInt || numberToken->fValue < 0) 5248 if (!numberToken->isInt || numberToken->fValue < 0)
5249 return false; 5249 return false;
5250 String color = String::number(numberToken->fValue) + String(unitToken->s tring); 5250 String color = String::number(numberToken->fValue) + String(unitToken->s tring);
5251 if (color.length() > 6) 5251 if (color.length() > 6)
5252 return false; 5252 return false;
5253 while (color.length() < 6) 5253 while (color.length() < 6)
5254 color = "0" + color; 5254 color = "0" + color;
5255 return fastParseColor(c, color, false); 5255 return fastParseColor(c, color, false);
5256 } else if (value->unit == CSSParserValue::HexColor || value->unit == CSSPrim itiveValue::CSS_IDENT) { 5256 } else if (value->unit == CSSPrimitiveValue::CSS_IDENT) {
5257 if (!fastParseColor(c, value->string, !acceptQuirkyColors && value->unit == CSSPrimitiveValue::CSS_IDENT)) 5257 if (!fastParseColor(c, value->string, !acceptQuirkyColors))
5258 return false; 5258 return false;
5259 } else if (value->unit == CSSParserValue::HexColor) {
5260 if (value->string.is8Bit())
5261 return Color::parseHexColor(value->string.characters8(), value->stri ng.length(), c);
5262 return Color::parseHexColor(value->string.characters16(), value->string. length(), c);
5259 } else if (value->unit == CSSParserValue::Function && 5263 } else if (value->unit == CSSParserValue::Function &&
5260 value->function->args != 0 && 5264 value->function->args != 0 &&
5261 value->function->args->size() == 5 /* rgb + two commas */ && 5265 value->function->args->size() == 5 /* rgb + two commas */ &&
5262 value->function->id == CSSValueRgb) { 5266 value->function->id == CSSValueRgb) {
5263 int colorValues[3]; 5267 int colorValues[3];
5264 if (!parseColorParameters(value, colorValues, false)) 5268 if (!parseColorParameters(value, colorValues, false))
5265 return false; 5269 return false;
5266 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]); 5270 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]);
5267 } else { 5271 } else {
5268 if (value->unit == CSSParserValue::Function && 5272 if (value->unit == CSSParserValue::Function &&
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after
8414 } 8418 }
8415 } 8419 }
8416 8420
8417 if (!list->length()) 8421 if (!list->length())
8418 return nullptr; 8422 return nullptr;
8419 8423
8420 return list.release(); 8424 return list.release();
8421 } 8425 }
8422 8426
8423 } // namespace blink 8427 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserValues.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698