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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 static const int tenthAlphaValues[] = {0, 25, 51, 76, 102, | 368 static const int tenthAlphaValues[] = {0, 25, 51, 76, 102, |
369 127, 153, 179, 204, 230}; | 369 127, 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 ? 0 : static_cast<int>(alpha * nextafter(256.0, 0.0)); | 378 value = negative |
379 ? 0 | |
380 : static_cast<int>(std::min(alpha, 1.0) * nextafter(256.0, 0.0)); | |
alancutter (OOO until 2018)
2016/12/20 23:31:24
Instead of static_cast can we use clampTo<int>?
fs
2016/12/21 08:53:00
We can, but it would be a waste of perfectly good
| |
379 string = end; | 381 string = end; |
380 return true; | 382 return true; |
381 } | 383 } |
382 | 384 |
383 template <typename CharacterType> | 385 template <typename CharacterType> |
384 static inline bool mightBeRGBA(const CharacterType* characters, | 386 static inline bool mightBeRGBA(const CharacterType* characters, |
385 unsigned length) { | 387 unsigned length) { |
386 if (length < 5) | 388 if (length < 5) |
387 return false; | 389 return false; |
388 return characters[4] == '(' && | 390 return characters[4] == '(' && |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 if (isColorPropertyID(propertyID)) | 1203 if (isColorPropertyID(propertyID)) |
1202 return parseColor(string, parserMode); | 1204 return parseColor(string, parserMode); |
1203 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) | 1205 if (CSSValue* keyword = parseKeywordValue(propertyID, string, parserMode)) |
1204 return keyword; | 1206 return keyword; |
1205 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) | 1207 if (CSSValue* transform = parseSimpleTransform(propertyID, string)) |
1206 return transform; | 1208 return transform; |
1207 return nullptr; | 1209 return nullptr; |
1208 } | 1210 } |
1209 | 1211 |
1210 } // namespace blink | 1212 } // namespace blink |
OLD | NEW |