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

Side by Side Diff: Source/core/css/parser/CSSParserFastPaths.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: (Hopefully) Builds with oilpan now Created 5 years, 6 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 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 // We rely on charactersToDouble for validation as well. The function 79 // We rely on charactersToDouble for validation as well. The function
80 // will set "ok" to "false" if the entire passed-in character range does 80 // will set "ok" to "false" if the entire passed-in character range does
81 // not represent a double. 81 // not represent a double.
82 bool ok; 82 bool ok;
83 number = charactersToDouble(characters, length, &ok); 83 number = charactersToDouble(characters, length, &ok);
84 return ok; 84 return ok;
85 } 85 }
86 86
87 static PassRefPtrWillBeRawPtr<CSSValue> parseSimpleLengthValue(CSSPropertyID pro pertyId, const String& string, CSSParserMode cssParserMode) 87 static NullableCSSValue parseSimpleLengthValue(CSSPropertyID propertyId, const S tring& string, CSSParserMode cssParserMode)
88 { 88 {
89 ASSERT(!string.isEmpty()); 89 ASSERT(!string.isEmpty());
90 bool acceptsNegativeNumbers = false; 90 bool acceptsNegativeNumbers = false;
91 91
92 // In @viewport, width and height are shorthands, not simple length values. 92 // In @viewport, width and height are shorthands, not simple length values.
93 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers)) 93 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers))
94 return nullptr; 94 return nullptr;
95 95
96 unsigned length = string.length(); 96 unsigned length = string.length();
97 double number; 97 double number;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 case CSSPropertyWebkitTextEmphasisColor: 135 case CSSPropertyWebkitTextEmphasisColor:
136 case CSSPropertyWebkitTextFillColor: 136 case CSSPropertyWebkitTextFillColor:
137 case CSSPropertyWebkitTextStrokeColor: 137 case CSSPropertyWebkitTextStrokeColor:
138 case CSSPropertyTextDecorationColor: 138 case CSSPropertyTextDecorationColor:
139 return true; 139 return true;
140 default: 140 default:
141 return false; 141 return false;
142 } 142 }
143 } 143 }
144 144
145 static PassRefPtrWillBeRawPtr<CSSValue> parseColorValue(CSSPropertyID propertyId , const String& string, CSSParserMode cssParserMode) 145 static NullableCSSValue parseColorValue(CSSPropertyID propertyId, const String& string, CSSParserMode cssParserMode)
146 { 146 {
147 ASSERT(!string.isEmpty()); 147 ASSERT(!string.isEmpty());
148 bool quirksMode = isQuirksModeBehavior(cssParserMode); 148 bool quirksMode = isQuirksModeBehavior(cssParserMode);
149 if (!isColorPropertyID(propertyId)) 149 if (!isColorPropertyID(propertyId))
150 return nullptr; 150 return nullptr;
151 CSSParserString cssString; 151 CSSParserString cssString;
152 cssString.init(string); 152 cssString.init(string);
153 CSSValueID valueID = cssValueKeywordID(cssString); 153 CSSValueID valueID = cssValueKeywordID(cssString);
154 bool validPrimitive = false; 154 bool validPrimitive = false;
155 if (valueID == CSSValueWebkitText) { 155 if (valueID == CSSValueWebkitText) {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 case CSSPropertyScrollSnapType: 456 case CSSPropertyScrollSnapType:
457 return true; 457 return true;
458 case CSSPropertyAlignItems: 458 case CSSPropertyAlignItems:
459 case CSSPropertyAlignSelf: 459 case CSSPropertyAlignSelf:
460 return !RuntimeEnabledFeatures::cssGridLayoutEnabled(); 460 return !RuntimeEnabledFeatures::cssGridLayoutEnabled();
461 default: 461 default:
462 return false; 462 return false;
463 } 463 }
464 } 464 }
465 465
466 static PassRefPtrWillBeRawPtr<CSSValue> parseKeywordValue(CSSPropertyID property Id, const String& string) 466 static NullableCSSValue parseKeywordValue(CSSPropertyID propertyId, const String & string)
467 { 467 {
468 ASSERT(!string.isEmpty()); 468 ASSERT(!string.isEmpty());
469 469
470 if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) { 470 if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) {
471 // All properties accept the values of "initial" and "inherit". 471 // All properties accept the values of "initial" and "inherit".
472 String lowerCaseString = string.lower(); 472 String lowerCaseString = string.lower();
473 if (lowerCaseString != "initial" && lowerCaseString != "inherit") 473 if (lowerCaseString != "initial" && lowerCaseString != "inherit")
474 return nullptr; 474 return nullptr;
475 475
476 // Parse initial/inherit shorthands using the CSSPropertyParser. 476 // Parse initial/inherit shorthands using the CSSPropertyParser.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 transformList = CSSValueList::createSpaceSeparated(); 633 transformList = CSSValueList::createSpaceSeparated();
634 transformList->append(transformValue.release()); 634 transformList->append(transformValue.release());
635 if (pos < end) { 635 if (pos < end) {
636 if (isCSSSpace(*pos)) 636 if (isCSSSpace(*pos))
637 return nullptr; 637 return nullptr;
638 } 638 }
639 } 639 }
640 return transformList.release(); 640 return transformList.release();
641 } 641 }
642 642
643 static PassRefPtrWillBeRawPtr<CSSValue> parseSimpleTransform(CSSPropertyID prope rtyID, const String& string) 643 static NullableCSSValue parseSimpleTransform(CSSPropertyID propertyID, const Str ing& string)
644 { 644 {
645 ASSERT(!string.isEmpty()); 645 ASSERT(!string.isEmpty());
646 646
647 if (propertyID != CSSPropertyTransform) 647 if (propertyID != CSSPropertyTransform)
648 return nullptr; 648 return nullptr;
649 if (string.is8Bit()) { 649 if (string.is8Bit()) {
650 const LChar* pos = string.characters8(); 650 const LChar* pos = string.characters8();
651 const LChar* end = pos + string.length(); 651 const LChar* end = pos + string.length();
652 return parseSimpleTransformList(pos, end); 652 return parseSimpleTransformList(pos, end);
653 } 653 }
654 const UChar* pos = string.characters16(); 654 const UChar* pos = string.characters16();
655 const UChar* end = pos + string.length(); 655 const UChar* end = pos + string.length();
656 return parseSimpleTransformList(pos, end); 656 return parseSimpleTransformList(pos, end);
657 } 657 }
658 658
659 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSProperty ID propertyID, const String& string, CSSParserMode parserMode) 659 NullableCSSValue CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, c onst String& string, CSSParserMode parserMode)
660 { 660 {
661 if (RefPtrWillBeRawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, parserMode)) 661 if (NullableCSSValue length = parseSimpleLengthValue(propertyID, string, par serMode))
662 return length.release(); 662 return *length;
663 if (RefPtrWillBeRawPtr<CSSValue> color = parseColorValue(propertyID, string, parserMode)) 663 if (NullableCSSValue color = parseColorValue(propertyID, string, parserMode) )
664 return color.release(); 664 return *color;
665 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str ing)) 665 if (NullableCSSValue keyword = parseKeywordValue(propertyID, string))
666 return keyword.release(); 666 return *keyword;
667 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID , string)) 667 if (NullableCSSValue transform = parseSimpleTransform(propertyID, string))
668 return transform.release(); 668 return *transform;
669 return nullptr; 669 return nullptr;
670 } 670 }
671 671
672 } // namespace blink 672 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698