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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 return false; | 421 return false; |
422 if (current != end) | 422 if (current != end) |
423 return false; | 423 return false; |
424 rgb = makeRGB(red, green, blue); | 424 rgb = makeRGB(red, green, blue); |
425 return true; | 425 return true; |
426 } | 426 } |
427 | 427 |
428 return false; | 428 return false; |
429 } | 429 } |
430 | 430 |
431 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::parseColor(const String& st ring, bool quirksMode) | 431 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::parseColor(const String& st ring, CSSParserMode parserMode) |
432 { | 432 { |
433 ASSERT(!string.isEmpty()); | 433 ASSERT(!string.isEmpty()); |
434 CSSParserString cssString; | 434 CSSParserString cssString; |
435 cssString.init(string); | 435 cssString.init(string); |
436 CSSValueID valueID = cssValueKeywordID(cssString); | 436 CSSValueID valueID = cssValueKeywordID(cssString); |
437 if (valueID == CSSValueCurrentcolor || valueID == CSSValueGrey | 437 if (CSSPropertyParser::isColorKeyword(valueID)) { |
438 || (valueID >= CSSValueAqua && valueID <= CSSValueWindowtext) || valueID == CSSValueMenu | 438 if (!isValueAllowedInMode(valueID, parserMode)) |
fs
2015/07/13 13:59:28
Could also just have picked HTMLStandardMode/HTMLQ
| |
439 || (quirksMode && valueID >= CSSValueWebkitFocusRingColor && valueID <= CSSValueWebkitText)) | 439 return nullptr; |
440 return cssValuePool().createIdentifierValue(valueID); | 440 return cssValuePool().createIdentifierValue(valueID); |
441 } | |
441 | 442 |
442 RGBA32 color; | 443 RGBA32 color; |
444 bool quirksMode = isQuirksModeBehavior(parserMode); | |
443 | 445 |
444 // Fast path for hex colors and rgb()/rgba() colors | 446 // Fast path for hex colors and rgb()/rgba() colors |
445 bool parseResult; | 447 bool parseResult; |
446 if (string.is8Bit()) | 448 if (string.is8Bit()) |
447 parseResult = fastParseColorInternal(color, string.characters8(), string .length(), quirksMode); | 449 parseResult = fastParseColorInternal(color, string.characters8(), string .length(), quirksMode); |
448 else | 450 else |
449 parseResult = fastParseColorInternal(color, string.characters16(), strin g.length(), quirksMode); | 451 parseResult = fastParseColorInternal(color, string.characters16(), strin g.length(), quirksMode); |
450 if (parseResult) | 452 if (parseResult) |
451 return cssValuePool().createColorValue(color); | 453 return cssValuePool().createColorValue(color); |
452 | 454 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 const UChar* pos = string.characters16(); | 942 const UChar* pos = string.characters16(); |
941 const UChar* end = pos + string.length(); | 943 const UChar* end = pos + string.length(); |
942 return parseSimpleTransformList(pos, end); | 944 return parseSimpleTransformList(pos, end); |
943 } | 945 } |
944 | 946 |
945 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSProperty ID propertyID, const String& string, CSSParserMode parserMode) | 947 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSProperty ID propertyID, const String& string, CSSParserMode parserMode) |
946 { | 948 { |
947 if (RefPtrWillBeRawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, parserMode)) | 949 if (RefPtrWillBeRawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, parserMode)) |
948 return length.release(); | 950 return length.release(); |
949 if (isColorPropertyID(propertyID)) | 951 if (isColorPropertyID(propertyID)) |
950 return parseColor(string, isQuirksModeBehavior(parserMode)); | 952 return parseColor(string, parserMode); |
951 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str ing)) | 953 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str ing)) |
952 return keyword.release(); | 954 return keyword.release(); |
953 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID , string)) | 955 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID , string)) |
954 return transform.release(); | 956 return transform.release(); |
955 return nullptr; | 957 return nullptr; |
956 } | 958 } |
957 | 959 |
958 } // namespace blink | 960 } // namespace blink |
OLD | NEW |