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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp

Issue 1936913002: [CSS] Accept 8 (#RRGGBBAA) and 4 (#RGBA) value hex colors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add quirks mode fastParseColorInternal() test cases. Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSParserFastPaths.h" 5 #include "core/css/parser/CSSParserFastPaths.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSFunctionValue.h" 8 #include "core/css/CSSFunctionValue.h"
9 #include "core/css/CSSValuePool.h" 9 #include "core/css/CSSValuePool.h"
10 #include "core/css/parser/CSSParserIdioms.h" 10 #include "core/css/parser/CSSParserIdioms.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 381
382 template <typename CharacterType> 382 template <typename CharacterType>
383 static bool fastParseColorInternal(RGBA32& rgb, const CharacterType* characters, unsigned length, bool quirksMode) 383 static bool fastParseColorInternal(RGBA32& rgb, const CharacterType* characters, unsigned length, bool quirksMode)
384 { 384 {
385 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::UnitType::Unknown; 385 CSSPrimitiveValue::UnitType expect = CSSPrimitiveValue::UnitType::Unknown;
386 386
387 if (length >= 4 && characters[0] == '#') 387 if (length >= 4 && characters[0] == '#')
388 return Color::parseHexColor(characters + 1, length - 1, rgb); 388 return Color::parseHexColor(characters + 1, length - 1, rgb);
389 389
390 if (quirksMode && length >= 3) { 390 if (quirksMode && (length == 3 || length == 6)) {
391 if (Color::parseHexColor(characters, length, rgb)) 391 if (Color::parseHexColor(characters, length, rgb))
392 return true; 392 return true;
393 } 393 }
394 394
395 // Try rgba() syntax. 395 // Try rgba() syntax.
396 if (mightBeRGBA(characters, length)) { 396 if (mightBeRGBA(characters, length)) {
397 const CharacterType* current = characters + 5; 397 const CharacterType* current = characters + 5;
398 const CharacterType* end = characters + length; 398 const CharacterType* end = characters + length;
399 int red; 399 int red;
400 int green; 400 int green;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 if (isColorPropertyID(propertyID)) 1030 if (isColorPropertyID(propertyID))
1031 return parseColor(string, parserMode); 1031 return parseColor(string, parserMode);
1032 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) 1032 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode))
1033 return keyword; 1033 return keyword;
1034 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) 1034 if (CSSValue* transform = parseSimpleTransform(propertyID, string))
1035 return transform; 1035 return transform;
1036 return nullptr; 1036 return nullptr;
1037 } 1037 }
1038 1038
1039 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698