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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CSSPropertyParserHelpers.h" 5 #include "core/css/parser/CSSPropertyParserHelpers.h"
6 6
7 #include "core/css/CSSCalculationValue.h" 7 #include "core/css/CSSCalculationValue.h"
8 #include "core/css/CSSStringValue.h" 8 #include "core/css/CSSStringValue.h"
9 #include "core/css/CSSValuePair.h" 9 #include "core/css/CSSValuePair.h"
10 // TODO(timloh): Remove this dependency 10 // TODO(timloh): Remove this dependency
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 && token.numericValue() >= 0. && token.numericValue() < 1000000.) { // e.g. 112233 409 && token.numericValue() >= 0. && token.numericValue() < 1000000.) { // e.g. 112233
410 color = String::format("%06d", static_cast<int>(token.numericValue() )); 410 color = String::format("%06d", static_cast<int>(token.numericValue() ));
411 } else if (token.type() == DimensionToken) { // e.g. 0001FF 411 } else if (token.type() == DimensionToken) { // e.g. 0001FF
412 // TODO(timloh): This should check the numericValueType flag 412 // TODO(timloh): This should check the numericValueType flag
413 color = String::number(static_cast<int>(token.numericValue())) + Str ing(token.value()); 413 color = String::number(static_cast<int>(token.numericValue())) + Str ing(token.value());
414 if (color.length() > 6) 414 if (color.length() > 6)
415 return false; 415 return false;
416 while (color.length() < 6) 416 while (color.length() < 6)
417 color = "0" + color; 417 color = "0" + color;
418 } else if (token.type() == IdentToken) { // e.g. FF0000 418 } else if (token.type() == IdentToken) { // e.g. FF0000
419 unsigned length = token.value().length();
420 if (length != 3 && length != 6)
421 return false;
419 color = token.value(); 422 color = token.value();
420 } 423 }
421 } 424 }
422 if (token.type() == HashToken) 425 if (token.type() == HashToken)
423 color = token.value(); 426 color = token.value();
424 if (!Color::parseHexColor(color, result)) 427 if (!Color::parseHexColor(color, result))
425 return false; 428 return false;
426 range.consumeIncludingWhitespace(); 429 range.consumeIncludingWhitespace();
427 return true; 430 return true;
428 } 431 }
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 if (!value2) { 593 if (!value2) {
591 positionFromOneValue(value1, resultX, resultY); 594 positionFromOneValue(value1, resultX, resultY);
592 return true; 595 return true;
593 } 596 }
594 return positionFromTwoValues(value1, value2, resultX, resultY); 597 return positionFromTwoValues(value1, value2, resultX, resultY);
595 } 598 }
596 599
597 } // namespace CSSPropertyParserHelpers 600 } // namespace CSSPropertyParserHelpers
598 601
599 } // namespace blink 602 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp ('k') | third_party/WebKit/Source/core/html/HTMLElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698