| 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/CSSIdentifierValue.h" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 return false; | 362 return false; |
| 363 } | 363 } |
| 364 | 364 |
| 365 if (length == 2 && string[0] != '.') { | 365 if (length == 2 && string[0] != '.') { |
| 366 value = !negative && string[0] == '1' ? 255 : 0; | 366 value = !negative && string[0] == '1' ? 255 : 0; |
| 367 string = end; | 367 string = end; |
| 368 return true; | 368 return true; |
| 369 } | 369 } |
| 370 | 370 |
| 371 if (isTenthAlpha(string, length - 1)) { | 371 if (isTenthAlpha(string, length - 1)) { |
| 372 // Fast conversions for 0.1 steps of alpha values between 0.0 and 0.9, | 372 static const int tenthAlphaValues[] = {0, 25, 51, 76, 102, |
| 373 // where 0.1 alpha is value 26 (25.5 rounded) and so on. | 373 127, 153, 179, 204, 230}; |
| 374 static const int tenthAlphaValues[] = {0, 26, 51, 77, 102, | |
| 375 128, 153, 179, 204, 230}; | |
| 376 value = negative ? 0 : tenthAlphaValues[string[length - 2] - '0']; | 374 value = negative ? 0 : tenthAlphaValues[string[length - 2] - '0']; |
| 377 string = end; | 375 string = end; |
| 378 return true; | 376 return true; |
| 379 } | 377 } |
| 380 | 378 |
| 381 double alpha = 0; | 379 double alpha = 0; |
| 382 if (!parseDouble(string, end, terminator, alpha)) | 380 if (!parseDouble(string, end, terminator, alpha)) |
| 383 return false; | 381 return false; |
| 384 value = | 382 value = negative |
| 385 negative ? 0 : static_cast<int>(roundf(std::min(alpha, 1.0) * 255.0f)); | 383 ? 0 |
| 384 : static_cast<int>(std::min(alpha, 1.0) * nextafter(256.0, 0.0)); |
| 386 string = end; | 385 string = end; |
| 387 return true; | 386 return true; |
| 388 } | 387 } |
| 389 | 388 |
| 390 template <typename CharacterType> | 389 template <typename CharacterType> |
| 391 static inline bool mightBeRGBA(const CharacterType* characters, | 390 static inline bool mightBeRGBA(const CharacterType* characters, |
| 392 unsigned length) { | 391 unsigned length) { |
| 393 if (length < 5) | 392 if (length < 5) |
| 394 return false; | 393 return false; |
| 395 return characters[4] == '(' && | 394 return characters[4] == '(' && |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 if (isColorPropertyID(propertyID)) | 1207 if (isColorPropertyID(propertyID)) |
| 1209 return parseColor(string, parserMode); | 1208 return parseColor(string, parserMode); |
| 1210 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1209 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
| 1211 return keyword; | 1210 return keyword; |
| 1212 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1211 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
| 1213 return transform; | 1212 return transform; |
| 1214 return nullptr; | 1213 return nullptr; |
| 1215 } | 1214 } |
| 1216 | 1215 |
| 1217 } // namespace blink | 1216 } // namespace blink |
| OLD | NEW |