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 static const int tenthAlphaValues[] = {0, 26, 51, 77, 102, |
sashab
2017/01/02 23:04:15
What are these numbers? Maybe add a comment
ktyliu
2017/01/03 02:14:22
Done.
| |
369 127, 153, 179, 204, 230}; | 369 128, 153, 179, 204, 230}; |
370 value = negative ? 0 : tenthAlphaValues[string[length - 2] - '0']; | 370 value = negative ? 0 : tenthAlphaValues[string[length - 2] - '0']; |
371 string = end; | 371 string = end; |
372 return true; | 372 return true; |
373 } | 373 } |
374 | 374 |
375 double alpha = 0; | 375 double alpha = 0; |
376 if (!parseDouble(string, end, terminator, alpha)) | 376 if (!parseDouble(string, end, terminator, alpha)) |
377 return false; | 377 return false; |
378 value = negative | 378 value = |
379 ? 0 | 379 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; | 380 string = end; |
382 return true; | 381 return true; |
383 } | 382 } |
384 | 383 |
385 template <typename CharacterType> | 384 template <typename CharacterType> |
386 static inline bool mightBeRGBA(const CharacterType* characters, | 385 static inline bool mightBeRGBA(const CharacterType* characters, |
387 unsigned length) { | 386 unsigned length) { |
388 if (length < 5) | 387 if (length < 5) |
389 return false; | 388 return false; |
390 return characters[4] == '(' && | 389 return characters[4] == '(' && |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1203 if (isColorPropertyID(propertyID)) | 1202 if (isColorPropertyID(propertyID)) |
1204 return parseColor(string, parserMode); | 1203 return parseColor(string, parserMode); |
1205 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1204 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
1206 return keyword; | 1205 return keyword; |
1207 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1206 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
1208 return transform; | 1207 return transform; |
1209 return nullptr; | 1208 return nullptr; |
1210 } | 1209 } |
1211 | 1210 |
1212 } // namespace blink | 1211 } // namespace blink |
OLD | NEW |