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

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

Issue 246833005: Allow hex-style colors to be parsed by fastParseColor in strict mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 5167 matching lines...) Expand 10 before | Expand all | Expand 10 after
5178 && isASCIIAlphaCaselessEqual(characters[0], 'r') 5178 && isASCIIAlphaCaselessEqual(characters[0], 'r')
5179 && isASCIIAlphaCaselessEqual(characters[1], 'g') 5179 && isASCIIAlphaCaselessEqual(characters[1], 'g')
5180 && isASCIIAlphaCaselessEqual(characters[2], 'b'); 5180 && isASCIIAlphaCaselessEqual(characters[2], 'b');
5181 } 5181 }
5182 5182
5183 template <typename CharacterType> 5183 template <typename CharacterType>
5184 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length , bool strict) 5184 static inline bool fastParseColorInternal(RGBA32& rgb, const CharacterType* char acters, unsigned length , bool strict)
5185 { 5185 {
5186 CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::CSS_UNKNOWN; 5186 CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::CSS_UNKNOWN;
5187 5187
5188 if (length >= 4 && characters[0] == '#')
5189 return Color::parseHexColor(characters + 1, length - 1, rgb);
5190
5188 if (!strict && length >= 3) { 5191 if (!strict && length >= 3) {
5189 if (characters[0] == '#') { 5192 if (Color::parseHexColor(characters, length, rgb))
5190 if (Color::parseHexColor(characters + 1, length - 1, rgb)) 5193 return true;
5191 return true;
5192 } else {
5193 if (Color::parseHexColor(characters, length, rgb))
5194 return true;
5195 }
5196 } 5194 }
5197 5195
5198 // Try rgba() syntax. 5196 // Try rgba() syntax.
5199 if (mightBeRGBA(characters, length)) { 5197 if (mightBeRGBA(characters, length)) {
5200 const CharacterType* current = characters + 5; 5198 const CharacterType* current = characters + 5;
5201 const CharacterType* end = characters + length; 5199 const CharacterType* end = characters + length;
5202 int red; 5200 int red;
5203 int green; 5201 int green;
5204 int blue; 5202 int blue;
5205 int alpha; 5203 int alpha;
(...skipping 3271 matching lines...) Expand 10 before | Expand all | Expand 10 after
8477 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill)); 8475 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
8478 if (!seenStroke) 8476 if (!seenStroke)
8479 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) ); 8477 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke) );
8480 if (!seenMarkers) 8478 if (!seenMarkers)
8481 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers )); 8479 parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers ));
8482 8480
8483 return parsedValues.release(); 8481 return parsedValues.release();
8484 } 8482 }
8485 8483
8486 } // namespace WebCore 8484 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698