OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSParserFastPaths.h" | 6 #include "core/css/parser/CSSParserFastPaths.h" |
7 | 7 |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSFunctionValue.h" | 9 #include "core/css/CSSFunctionValue.h" |
10 #include "core/css/CSSValuePool.h" | 10 #include "core/css/CSSValuePool.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 | 447 |
448 RGBA32 color; | 448 RGBA32 color; |
449 bool quirksMode = isQuirksModeBehavior(parserMode); | 449 bool quirksMode = isQuirksModeBehavior(parserMode); |
450 | 450 |
451 // Fast path for hex colors and rgb()/rgba() colors | 451 // Fast path for hex colors and rgb()/rgba() colors |
452 bool parseResult; | 452 bool parseResult; |
453 if (string.is8Bit()) | 453 if (string.is8Bit()) |
454 parseResult = fastParseColorInternal(color, string.characters8(), string
.length(), quirksMode); | 454 parseResult = fastParseColorInternal(color, string.characters8(), string
.length(), quirksMode); |
455 else | 455 else |
456 parseResult = fastParseColorInternal(color, string.characters16(), strin
g.length(), quirksMode); | 456 parseResult = fastParseColorInternal(color, string.characters16(), strin
g.length(), quirksMode); |
457 if (parseResult) | 457 if (!parseResult) |
458 return cssValuePool().createColorValue(color); | |
459 | |
460 Color namedColor; | |
461 if (!namedColor.setNamedColor(string)) | |
462 return nullptr; | 458 return nullptr; |
463 return cssValuePool().createColorValue(namedColor.rgb()); | 459 return cssValuePool().createColorValue(color); |
464 } | 460 } |
465 | 461 |
466 bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId
, CSSValueID valueID) | 462 bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId
, CSSValueID valueID) |
467 { | 463 { |
468 if (valueID == CSSValueInvalid) | 464 if (valueID == CSSValueInvalid) |
469 return false; | 465 return false; |
470 | 466 |
471 switch (propertyId) { | 467 switch (propertyId) { |
472 case CSSPropertyAlignmentBaseline: | 468 case CSSPropertyAlignmentBaseline: |
473 // auto | baseline | before-edge | text-before-edge | middle | | 469 // auto | baseline | before-edge | text-before-edge | middle | |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 if (isColorPropertyID(propertyID)) | 1005 if (isColorPropertyID(propertyID)) |
1010 return parseColor(string, parserMode); | 1006 return parseColor(string, parserMode); |
1011 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str
ing)) | 1007 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str
ing)) |
1012 return keyword.release(); | 1008 return keyword.release(); |
1013 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID
, string)) | 1009 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID
, string)) |
1014 return transform.release(); | 1010 return transform.release(); |
1015 return nullptr; | 1011 return nullptr; |
1016 } | 1012 } |
1017 | 1013 |
1018 } // namespace blink | 1014 } // namespace blink |
OLD | NEW |