| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 return false; | 462 return false; |
| 462 } | 463 } |
| 463 | 464 |
| 464 CSSValue* CSSParserFastPaths::parseColor(const String& string, | 465 CSSValue* CSSParserFastPaths::parseColor(const String& string, |
| 465 CSSParserMode parserMode) { | 466 CSSParserMode parserMode) { |
| 466 ASSERT(!string.isEmpty()); | 467 ASSERT(!string.isEmpty()); |
| 467 CSSValueID valueID = cssValueKeywordID(string); | 468 CSSValueID valueID = cssValueKeywordID(string); |
| 468 if (StyleColor::isColorKeyword(valueID)) { | 469 if (StyleColor::isColorKeyword(valueID)) { |
| 469 if (!isValueAllowedInMode(valueID, parserMode)) | 470 if (!isValueAllowedInMode(valueID, parserMode)) |
| 470 return nullptr; | 471 return nullptr; |
| 471 return CSSPrimitiveValue::createIdentifier(valueID); | 472 return CSSIdentifierValue::create(valueID); |
| 472 } | 473 } |
| 473 | 474 |
| 474 RGBA32 color; | 475 RGBA32 color; |
| 475 bool quirksMode = isQuirksModeBehavior(parserMode); | 476 bool quirksMode = isQuirksModeBehavior(parserMode); |
| 476 | 477 |
| 477 // Fast path for hex colors and rgb()/rgba() colors | 478 // Fast path for hex colors and rgb()/rgba() colors |
| 478 bool parseResult; | 479 bool parseResult; |
| 479 if (string.is8Bit()) | 480 if (string.is8Bit()) |
| 480 parseResult = fastParseColorInternal(color, string.characters8(), | 481 parseResult = fastParseColorInternal(color, string.characters8(), |
| 481 string.length(), quirksMode); | 482 string.length(), quirksMode); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 | 981 |
| 981 if (!valueID) | 982 if (!valueID) |
| 982 return nullptr; | 983 return nullptr; |
| 983 | 984 |
| 984 if (valueID == CSSValueInherit) | 985 if (valueID == CSSValueInherit) |
| 985 return CSSInheritedValue::create(); | 986 return CSSInheritedValue::create(); |
| 986 if (valueID == CSSValueInitial) | 987 if (valueID == CSSValueInitial) |
| 987 return CSSInitialValue::create(); | 988 return CSSInitialValue::create(); |
| 988 if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID, | 989 if (CSSParserFastPaths::isValidKeywordPropertyAndValue(propertyId, valueID, |
| 989 parserMode)) | 990 parserMode)) |
| 990 return CSSPrimitiveValue::createIdentifier(valueID); | 991 return CSSIdentifierValue::create(valueID); |
| 991 return nullptr; | 992 return nullptr; |
| 992 } | 993 } |
| 993 | 994 |
| 994 template <typename CharType> | 995 template <typename CharType> |
| 995 static bool parseTransformTranslateArguments(CharType*& pos, | 996 static bool parseTransformTranslateArguments(CharType*& pos, |
| 996 CharType* end, | 997 CharType* end, |
| 997 unsigned expectedCount, | 998 unsigned expectedCount, |
| 998 CSSFunctionValue* transformValue) { | 999 CSSFunctionValue* transformValue) { |
| 999 while (expectedCount) { | 1000 while (expectedCount) { |
| 1000 size_t delimiter = | 1001 size_t delimiter = |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 if (isColorPropertyID(propertyID)) | 1208 if (isColorPropertyID(propertyID)) |
| 1208 return parseColor(string, parserMode); | 1209 return parseColor(string, parserMode); |
| 1209 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1210 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
| 1210 return keyword; | 1211 return keyword; |
| 1211 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1212 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
| 1212 return transform; | 1213 return transform; |
| 1213 return nullptr; | 1214 return nullptr; |
| 1214 } | 1215 } |
| 1215 | 1216 |
| 1216 } // namespace blink | 1217 } // namespace blink |
| OLD | NEW |