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