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/CSSInheritedValue.h" | 10 #include "core/css/CSSInheritedValue.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } else if (length > 1 && characters[length - 1] == '%') { | 80 } else if (length > 1 && characters[length - 1] == '%') { |
81 length -= 1; | 81 length -= 1; |
82 unit = CSSPrimitiveValue::UnitType::Percentage; | 82 unit = CSSPrimitiveValue::UnitType::Percentage; |
83 } | 83 } |
84 | 84 |
85 // We rely on charactersToDouble for validation as well. The function | 85 // We rely on charactersToDouble for validation as well. The function |
86 // will set "ok" to "false" if the entire passed-in character range does | 86 // will set "ok" to "false" if the entire passed-in character range does |
87 // not represent a double. | 87 // not represent a double. |
88 bool ok; | 88 bool ok; |
89 number = charactersToDouble(characters, length, &ok); | 89 number = charactersToDouble(characters, length, &ok); |
90 return ok && CSSParserToken::isValidNumericValue(number); | 90 if (!ok) |
| 91 return false; |
| 92 number = clampTo<double>(number, -std::numeric_limits<float>::max(), std::nu
meric_limits<float>::max()); |
| 93 return true; |
91 } | 94 } |
92 | 95 |
93 static CSSValue* parseSimpleLengthValue(CSSPropertyID propertyId, const String&
string, CSSParserMode cssParserMode) | 96 static CSSValue* parseSimpleLengthValue(CSSPropertyID propertyId, const String&
string, CSSParserMode cssParserMode) |
94 { | 97 { |
95 ASSERT(!string.isEmpty()); | 98 ASSERT(!string.isEmpty()); |
96 bool acceptsNegativeNumbers = false; | 99 bool acceptsNegativeNumbers = false; |
97 | 100 |
98 // In @viewport, width and height are shorthands, not simple length values. | 101 // In @viewport, width and height are shorthands, not simple length values. |
99 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp
ertyID(propertyId, acceptsNegativeNumbers)) | 102 if (isCSSViewportParsingEnabledForMode(cssParserMode) || !isSimpleLengthProp
ertyID(propertyId, acceptsNegativeNumbers)) |
100 return nullptr; | 103 return nullptr; |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 if (isColorPropertyID(propertyID)) | 1081 if (isColorPropertyID(propertyID)) |
1079 return parseColor(string, parserMode); | 1082 return parseColor(string, parserMode); |
1080 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1083 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
1081 return keyword; | 1084 return keyword; |
1082 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1085 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
1083 return transform; | 1086 return transform; |
1084 return nullptr; | 1087 return nullptr; |
1085 } | 1088 } |
1086 | 1089 |
1087 } // namespace blink | 1090 } // namespace blink |
OLD | NEW |