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 "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/CSSColorValue.h" | 8 #include "core/css/CSSColorValue.h" |
9 #include "core/css/CSSFunctionValue.h" | 9 #include "core/css/CSSFunctionValue.h" |
| 10 #include "core/css/CSSIdentifierValue.h" |
10 #include "core/css/CSSInheritedValue.h" | 11 #include "core/css/CSSInheritedValue.h" |
11 #include "core/css/CSSInitialValue.h" | 12 #include "core/css/CSSInitialValue.h" |
12 #include "core/css/CSSPrimitiveValue.h" | 13 #include "core/css/CSSPrimitiveValue.h" |
13 #include "core/css/StyleColor.h" | 14 #include "core/css/StyleColor.h" |
14 #include "core/css/parser/CSSParserIdioms.h" | 15 #include "core/css/parser/CSSParserIdioms.h" |
15 #include "core/css/parser/CSSPropertyParser.h" | 16 #include "core/css/parser/CSSPropertyParser.h" |
16 #include "core/html/parser/HTMLParserIdioms.h" | 17 #include "core/html/parser/HTMLParserIdioms.h" |
17 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
18 #include "wtf/text/StringToNumber.h" | 19 #include "wtf/text/StringToNumber.h" |
19 | 20 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 return false; | 445 return false; |
445 } | 446 } |
446 | 447 |
447 CSSValue* CSSParserFastPaths::parseColor(const String& string, CSSParserMode par
serMode) | 448 CSSValue* CSSParserFastPaths::parseColor(const String& string, CSSParserMode par
serMode) |
448 { | 449 { |
449 ASSERT(!string.isEmpty()); | 450 ASSERT(!string.isEmpty()); |
450 CSSValueID valueID = cssValueKeywordID(string); | 451 CSSValueID valueID = cssValueKeywordID(string); |
451 if (StyleColor::isColorKeyword(valueID)) { | 452 if (StyleColor::isColorKeyword(valueID)) { |
452 if (!isValueAllowedInMode(valueID, parserMode)) | 453 if (!isValueAllowedInMode(valueID, parserMode)) |
453 return nullptr; | 454 return nullptr; |
454 return CSSPrimitiveValue::createIdentifier(valueID); | 455 return CSSIdentifierValue::create(valueID); |
455 } | 456 } |
456 | 457 |
457 RGBA32 color; | 458 RGBA32 color; |
458 bool quirksMode = isQuirksModeBehavior(parserMode); | 459 bool quirksMode = isQuirksModeBehavior(parserMode); |
459 | 460 |
460 // Fast path for hex colors and rgb()/rgba() colors | 461 // Fast path for hex colors and rgb()/rgba() colors |
461 bool parseResult; | 462 bool parseResult; |
462 if (string.is8Bit()) | 463 if (string.is8Bit()) |
463 parseResult = fastParseColorInternal(color, string.characters8(), string
.length(), quirksMode); | 464 parseResult = fastParseColorInternal(color, string.characters8(), string
.length(), quirksMode); |
464 else | 465 else |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 CSSValueID valueID = cssValueKeywordID(string); | 862 CSSValueID valueID = cssValueKeywordID(string); |
862 | 863 |
863 if (!valueID) | 864 if (!valueID) |
864 return nullptr; | 865 return nullptr; |
865 | 866 |
866 if (valueID == CSSValueInherit) | 867 if (valueID == CSSValueInherit) |
867 return CSSInheritedValue::create(); | 868 return CSSInheritedValue::create(); |
868 if (valueID == CSSValueInitial) | 869 if (valueID == CSSValueInitial) |
869 return CSSInitialValue::create(); | 870 return CSSInitialValue::create(); |
870 if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID,
parserMode)) | 871 if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID,
parserMode)) |
871 return CSSPrimitiveValue::createIdentifier(valueID); | 872 return CSSIdentifierValue::create(valueID); |
872 return nullptr; | 873 return nullptr; |
873 } | 874 } |
874 | 875 |
875 template <typename CharType> | 876 template <typename CharType> |
876 static bool parseTransformTranslateArguments(CharType*& pos, CharType* end, unsi
gned expectedCount, CSSFunctionValue* transformValue) | 877 static bool parseTransformTranslateArguments(CharType*& pos, CharType* end, unsi
gned expectedCount, CSSFunctionValue* transformValue) |
877 { | 878 { |
878 while (expectedCount) { | 879 while (expectedCount) { |
879 size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' :
','); | 880 size_t delimiter = WTF::find(pos, end - pos, expectedCount == 1 ? ')' :
','); |
880 if (delimiter == kNotFound) | 881 if (delimiter == kNotFound) |
881 return false; | 882 return false; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 if (isColorPropertyID(propertyID)) | 1086 if (isColorPropertyID(propertyID)) |
1086 return parseColor(string, parserMode); | 1087 return parseColor(string, parserMode); |
1087 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1088 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
1088 return keyword; | 1089 return keyword; |
1089 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1090 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
1090 return transform; | 1091 return transform; |
1091 return nullptr; | 1092 return nullptr; |
1092 } | 1093 } |
1093 | 1094 |
1094 } // namespace blink | 1095 } // namespace blink |
OLD | NEW |