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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "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/CSSFunctionValue.h" 8 #include "core/css/CSSFunctionValue.h"
9 #include "core/css/CSSValuePool.h" 9 #include "core/css/CSSValuePool.h"
10 #include "core/css/parser/CSSParserIdioms.h" 10 #include "core/css/parser/CSSParserIdioms.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 // We rely on charactersToDouble for validation as well. The function 81 // We rely on charactersToDouble for validation as well. The function
82 // will set "ok" to "false" if the entire passed-in character range does 82 // will set "ok" to "false" if the entire passed-in character range does
83 // not represent a double. 83 // not represent a double.
84 bool ok; 84 bool ok;
85 number = charactersToDouble(characters, length, &ok); 85 number = charactersToDouble(characters, length, &ok);
86 return ok && CSSPropertyParser::isValidNumericValue(number); 86 return ok && CSSPropertyParser::isValidNumericValue(number);
87 } 87 }
88 88
89 static PassRefPtrWillBeRawPtr<CSSValue> parseSimpleLengthValue(CSSPropertyID pro pertyId, const String& string, CSSParserMode cssParserMode) 89 static RawPtr<CSSValue> parseSimpleLengthValue(CSSPropertyID propertyId, const S tring& string, CSSParserMode cssParserMode)
90 { 90 {
91 ASSERT(!string.isEmpty()); 91 ASSERT(!string.isEmpty());
92 bool acceptsNegativeNumbers = false; 92 bool acceptsNegativeNumbers = false;
93 93
94 // In @viewport, width and height are shorthands, not simple length values. 94 // In @viewport, width and height are shorthands, not simple length values.
95 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers)) 95 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp ertyID(propertyId, acceptsNegativeNumbers))
96 return nullptr; 96 return nullptr;
97 97
98 unsigned length = string.length(); 98 unsigned length = string.length();
99 double number; 99 double number;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 return false; 430 return false;
431 if (current != end) 431 if (current != end)
432 return false; 432 return false;
433 rgb = makeRGB(red, green, blue); 433 rgb = makeRGB(red, green, blue);
434 return true; 434 return true;
435 } 435 }
436 436
437 return false; 437 return false;
438 } 438 }
439 439
440 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::parseColor(const String& st ring, CSSParserMode parserMode) 440 RawPtr<CSSValue> CSSParserFastPaths::parseColor(const String& string, CSSParserM ode parserMode)
441 { 441 {
442 ASSERT(!string.isEmpty()); 442 ASSERT(!string.isEmpty());
443 CSSParserString cssString; 443 CSSParserString cssString;
444 cssString.init(string); 444 cssString.init(string);
445 CSSValueID valueID = cssValueKeywordID(cssString); 445 CSSValueID valueID = cssValueKeywordID(cssString);
446 if (CSSPropertyParser::isColorKeyword(valueID)) { 446 if (CSSPropertyParser::isColorKeyword(valueID)) {
447 if (!isValueAllowedInMode(valueID, parserMode)) 447 if (!isValueAllowedInMode(valueID, parserMode))
448 return nullptr; 448 return nullptr;
449 return cssValuePool().createIdentifierValue(valueID); 449 return cssValuePool().createIdentifierValue(valueID);
450 } 450 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 case CSSPropertyJustifyContent: 823 case CSSPropertyJustifyContent:
824 case CSSPropertyAlignContent: 824 case CSSPropertyAlignContent:
825 case CSSPropertyAlignItems: 825 case CSSPropertyAlignItems:
826 case CSSPropertyAlignSelf: 826 case CSSPropertyAlignSelf:
827 return !RuntimeEnabledFeatures::cssGridLayoutEnabled(); 827 return !RuntimeEnabledFeatures::cssGridLayoutEnabled();
828 default: 828 default:
829 return false; 829 return false;
830 } 830 }
831 } 831 }
832 832
833 static PassRefPtrWillBeRawPtr<CSSValue> parseKeywordValue(CSSPropertyID property Id, const String& string) 833 static RawPtr<CSSValue> parseKeywordValue(CSSPropertyID propertyId, const String & string)
834 { 834 {
835 ASSERT(!string.isEmpty()); 835 ASSERT(!string.isEmpty());
836 836
837 if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) { 837 if (!CSSParserFastPaths::isKeywordPropertyID(propertyId)) {
838 // All properties accept the values of "initial" and "inherit". 838 // All properties accept the values of "initial" and "inherit".
839 String lowerCaseString = string.lower(); 839 String lowerCaseString = string.lower();
840 if (lowerCaseString != "initial" && lowerCaseString != "inherit") 840 if (lowerCaseString != "initial" && lowerCaseString != "inherit")
841 return nullptr; 841 return nullptr;
842 842
843 // Parse initial/inherit shorthands using the CSSPropertyParser. 843 // Parse initial/inherit shorthands using the CSSPropertyParser.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 if (!ok) 895 if (!ok)
896 return false; 896 return false;
897 transformValue->append(cssValuePool().createValue(number, CSSPrimitiveVa lue::UnitType::Number)); 897 transformValue->append(cssValuePool().createValue(number, CSSPrimitiveVa lue::UnitType::Number));
898 pos += argumentLength + 1; 898 pos += argumentLength + 1;
899 --expectedCount; 899 --expectedCount;
900 } 900 }
901 return true; 901 return true;
902 } 902 }
903 903
904 template <typename CharType> 904 template <typename CharType>
905 static PassRefPtrWillBeRawPtr<CSSFunctionValue> parseSimpleTransformValue(CharTy pe*& pos, CharType* end) 905 static RawPtr<CSSFunctionValue> parseSimpleTransformValue(CharType*& pos, CharTy pe* end)
906 { 906 {
907 static const int shortestValidTransformStringLength = 12; 907 static const int shortestValidTransformStringLength = 12;
908 908
909 if (end - pos < shortestValidTransformStringLength) 909 if (end - pos < shortestValidTransformStringLength)
910 return nullptr; 910 return nullptr;
911 911
912 const bool isTranslate = toASCIILower(pos[0]) == 't' 912 const bool isTranslate = toASCIILower(pos[0]) == 't'
913 && toASCIILower(pos[1]) == 'r' 913 && toASCIILower(pos[1]) == 'r'
914 && toASCIILower(pos[2]) == 'a' 914 && toASCIILower(pos[2]) == 'a'
915 && toASCIILower(pos[3]) == 'n' 915 && toASCIILower(pos[3]) == 'n'
(...skipping 19 matching lines...) Expand all
935 expectedArgumentCount = 2; 935 expectedArgumentCount = 2;
936 argumentStart = 10; 936 argumentStart = 10;
937 } else if (c9 == '3' && toASCIILower(pos[10]) == 'd' && pos[11] == '(') { 937 } else if (c9 == '3' && toASCIILower(pos[10]) == 'd' && pos[11] == '(') {
938 transformType = CSSValueTranslate3d; 938 transformType = CSSValueTranslate3d;
939 expectedArgumentCount = 3; 939 expectedArgumentCount = 3;
940 argumentStart = 12; 940 argumentStart = 12;
941 } else { 941 } else {
942 return nullptr; 942 return nullptr;
943 } 943 }
944 pos += argumentStart; 944 pos += argumentStart;
945 RefPtrWillBeRawPtr<CSSFunctionValue> transformValue = CSSFunctionValue:: create(transformType); 945 RawPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(trans formType);
946 if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, t ransformValue.get())) 946 if (!parseTransformTranslateArguments(pos, end, expectedArgumentCount, t ransformValue.get()))
947 return nullptr; 947 return nullptr;
948 return transformValue.release(); 948 return transformValue.release();
949 } 949 }
950 950
951 const bool isMatrix3d = toASCIILower(pos[0]) == 'm' 951 const bool isMatrix3d = toASCIILower(pos[0]) == 'm'
952 && toASCIILower(pos[1]) == 'a' 952 && toASCIILower(pos[1]) == 'a'
953 && toASCIILower(pos[2]) == 't' 953 && toASCIILower(pos[2]) == 't'
954 && toASCIILower(pos[3]) == 'r' 954 && toASCIILower(pos[3]) == 'r'
955 && toASCIILower(pos[4]) == 'i' 955 && toASCIILower(pos[4]) == 'i'
956 && toASCIILower(pos[5]) == 'x' 956 && toASCIILower(pos[5]) == 'x'
957 && pos[6] == '3' 957 && pos[6] == '3'
958 && toASCIILower(pos[7]) == 'd' 958 && toASCIILower(pos[7]) == 'd'
959 && pos[8] == '('; 959 && pos[8] == '(';
960 960
961 if (isMatrix3d) { 961 if (isMatrix3d) {
962 pos += 9; 962 pos += 9;
963 RefPtrWillBeRawPtr<CSSFunctionValue> transformValue = CSSFunctionValue:: create(CSSValueMatrix3d); 963 RawPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(CSSVa lueMatrix3d);
964 if (!parseTransformNumberArguments(pos, end, 16, transformValue.get())) 964 if (!parseTransformNumberArguments(pos, end, 16, transformValue.get()))
965 return nullptr; 965 return nullptr;
966 return transformValue.release(); 966 return transformValue.release();
967 } 967 }
968 968
969 const bool isScale3d = toASCIILower(pos[0]) == 's' 969 const bool isScale3d = toASCIILower(pos[0]) == 's'
970 && toASCIILower(pos[1]) == 'c' 970 && toASCIILower(pos[1]) == 'c'
971 && toASCIILower(pos[2]) == 'a' 971 && toASCIILower(pos[2]) == 'a'
972 && toASCIILower(pos[3]) == 'l' 972 && toASCIILower(pos[3]) == 'l'
973 && toASCIILower(pos[4]) == 'e' 973 && toASCIILower(pos[4]) == 'e'
974 && pos[5] == '3' 974 && pos[5] == '3'
975 && toASCIILower(pos[6]) == 'd' 975 && toASCIILower(pos[6]) == 'd'
976 && pos[7] == '('; 976 && pos[7] == '(';
977 977
978 if (isScale3d) { 978 if (isScale3d) {
979 pos += 8; 979 pos += 8;
980 RefPtrWillBeRawPtr<CSSFunctionValue> transformValue = CSSFunctionValue:: create(CSSValueScale3d); 980 RawPtr<CSSFunctionValue> transformValue = CSSFunctionValue::create(CSSVa lueScale3d);
981 if (!parseTransformNumberArguments(pos, end, 3, transformValue.get())) 981 if (!parseTransformNumberArguments(pos, end, 3, transformValue.get()))
982 return nullptr; 982 return nullptr;
983 return transformValue.release(); 983 return transformValue.release();
984 } 984 }
985 985
986 return nullptr; 986 return nullptr;
987 } 987 }
988 988
989 template <typename CharType> 989 template <typename CharType>
990 static PassRefPtrWillBeRawPtr<CSSValueList> parseSimpleTransformList(CharType*& pos, CharType* end) 990 static RawPtr<CSSValueList> parseSimpleTransformList(CharType*& pos, CharType* e nd)
991 { 991 {
992 RefPtrWillBeRawPtr<CSSValueList> transformList = nullptr; 992 RawPtr<CSSValueList> transformList = nullptr;
993 while (pos < end) { 993 while (pos < end) {
994 while (pos < end && isCSSSpace(*pos)) 994 while (pos < end && isCSSSpace(*pos))
995 ++pos; 995 ++pos;
996 RefPtrWillBeRawPtr<CSSFunctionValue> transformValue = parseSimpleTransfo rmValue(pos, end); 996 RawPtr<CSSFunctionValue> transformValue = parseSimpleTransformValue(pos, end);
997 if (!transformValue) 997 if (!transformValue)
998 return nullptr; 998 return nullptr;
999 if (!transformList) 999 if (!transformList)
1000 transformList = CSSValueList::createSpaceSeparated(); 1000 transformList = CSSValueList::createSpaceSeparated();
1001 transformList->append(transformValue.release()); 1001 transformList->append(transformValue.release());
1002 if (pos < end) { 1002 if (pos < end) {
1003 if (isCSSSpace(*pos)) 1003 if (isCSSSpace(*pos))
1004 return nullptr; 1004 return nullptr;
1005 } 1005 }
1006 } 1006 }
1007 return transformList.release(); 1007 return transformList.release();
1008 } 1008 }
1009 1009
1010 static PassRefPtrWillBeRawPtr<CSSValue> parseSimpleTransform(CSSPropertyID prope rtyID, const String& string) 1010 static RawPtr<CSSValue> parseSimpleTransform(CSSPropertyID propertyID, const Str ing& string)
1011 { 1011 {
1012 ASSERT(!string.isEmpty()); 1012 ASSERT(!string.isEmpty());
1013 1013
1014 if (propertyID != CSSPropertyTransform) 1014 if (propertyID != CSSPropertyTransform)
1015 return nullptr; 1015 return nullptr;
1016 if (string.is8Bit()) { 1016 if (string.is8Bit()) {
1017 const LChar* pos = string.characters8(); 1017 const LChar* pos = string.characters8();
1018 const LChar* end = pos + string.length(); 1018 const LChar* end = pos + string.length();
1019 return parseSimpleTransformList(pos, end); 1019 return parseSimpleTransformList(pos, end);
1020 } 1020 }
1021 const UChar* pos = string.characters16(); 1021 const UChar* pos = string.characters16();
1022 const UChar* end = pos + string.length(); 1022 const UChar* end = pos + string.length();
1023 return parseSimpleTransformList(pos, end); 1023 return parseSimpleTransformList(pos, end);
1024 } 1024 }
1025 1025
1026 PassRefPtrWillBeRawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSProperty ID propertyID, const String& string, CSSParserMode parserMode) 1026 RawPtr<CSSValue> CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, c onst String& string, CSSParserMode parserMode)
1027 { 1027 {
1028 if (RefPtrWillBeRawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, parserMode)) 1028 if (RawPtr<CSSValue> length = parseSimpleLengthValue(propertyID, string, par serMode))
1029 return length.release(); 1029 return length.release();
1030 if (isColorPropertyID(propertyID)) 1030 if (isColorPropertyID(propertyID))
1031 return parseColor(string, parserMode); 1031 return parseColor(string, parserMode);
1032 if (RefPtrWillBeRawPtr<CSSValue> keyword = parseKeywordValue(propertyID, str ing)) 1032 if (RawPtr<CSSValue> keyword = parseKeywordValue(propertyID, string))
1033 return keyword.release(); 1033 return keyword.release();
1034 if (RefPtrWillBeRawPtr<CSSValue> transform = parseSimpleTransform(propertyID , string)) 1034 if (RawPtr<CSSValue> transform = parseSimpleTransform(propertyID, string))
1035 return transform.release(); 1035 return transform.release();
1036 return nullptr; 1036 return nullptr;
1037 } 1037 }
1038 1038
1039 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698