Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/CSSPropertyParserHelpers.h" | 5 #include "core/css/parser/CSSPropertyParserHelpers.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCalculationValue.h" | 7 #include "core/css/CSSCalculationValue.h" |
| 8 #include "core/css/CSSStringValue.h" | 8 #include "core/css/CSSStringValue.h" |
| 9 #include "core/css/CSSValuePair.h" | 9 #include "core/css/CSSValuePair.h" |
| 10 // TODO(timloh): Remove this dependency | 10 // TODO(timloh): Remove this dependency |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 } | 398 } |
| 399 result = makeRGBAFromHSLA(colorArray[0], colorArray[1], colorArray[2], alpha ); | 399 result = makeRGBAFromHSLA(colorArray[0], colorArray[1], colorArray[2], alpha ); |
| 400 return args.atEnd(); | 400 return args.atEnd(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 static bool parseHexColor(CSSParserTokenRange& range, RGBA32& result, bool accep tQuirkyColors) | 403 static bool parseHexColor(CSSParserTokenRange& range, RGBA32& result, bool accep tQuirkyColors) |
| 404 { | 404 { |
| 405 const CSSParserToken& token = range.peek(); | 405 const CSSParserToken& token = range.peek(); |
| 406 String color; | 406 String color; |
| 407 if (acceptQuirkyColors) { | 407 if (acceptQuirkyColors) { |
| 408 if (token.type() == NumberToken && token.numericValueType() == IntegerVa lueType | 408 if (token.type() == NumberToken) { // e.g. 112233 |
| 409 && token.numericValue() >= 0. && token.numericValue() < 1000000.) { // e.g. 112233 | 409 if (token.numericValueType() != IntegerValueType |
| 410 || token.numericValue() < 0. || token.numericValue() >= 1000000. ) | |
| 411 return false; | |
| 410 color = String::format("%06d", static_cast<int>(token.numericValue() )); | 412 color = String::format("%06d", static_cast<int>(token.numericValue() )); |
| 411 } else if (token.type() == DimensionToken) { // e.g. 0001FF | 413 } else if (token.type() == DimensionToken) { // e.g. 0001FF |
| 412 // TODO(timloh): This should check the numericValueType flag | 414 if (token.numericValueType() != IntegerValueType || token.numericVal ue() < 0.) |
| 415 return false; | |
| 413 color = String::number(static_cast<int>(token.numericValue())) + Str ing(token.value()); | 416 color = String::number(static_cast<int>(token.numericValue())) + Str ing(token.value()); |
|
rune
2016/05/10 21:27:32
What happens with the static_cast when numericValu
rwlbuis
2016/05/10 21:34:31
Good point! Will have a look.
| |
| 414 if (color.length() > 6) | |
| 415 return false; | |
| 416 while (color.length() < 6) | 417 while (color.length() < 6) |
| 417 color = "0" + color; | 418 color = "0" + color; |
| 418 } else if (token.type() == IdentToken) { // e.g. FF0000 | 419 } else if (token.type() == IdentToken) { // e.g. FF0000 |
| 419 color = token.value(); | 420 color = token.value(); |
| 420 } | 421 } |
| 421 } | 422 } |
| 422 if (token.type() == HashToken) | 423 if (token.type() == HashToken) |
| 423 color = token.value(); | 424 color = token.value(); |
| 424 if (!Color::parseHexColor(color, result)) | 425 if (!Color::parseHexColor(color, result)) |
| 425 return false; | 426 return false; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 if (!value2) { | 591 if (!value2) { |
| 591 positionFromOneValue(value1, resultX, resultY); | 592 positionFromOneValue(value1, resultX, resultY); |
| 592 return true; | 593 return true; |
| 593 } | 594 } |
| 594 return positionFromTwoValues(value1, value2, resultX, resultY); | 595 return positionFromTwoValues(value1, value2, resultX, resultY); |
| 595 } | 596 } |
| 596 | 597 |
| 597 } // namespace CSSPropertyParserHelpers | 598 } // namespace CSSPropertyParserHelpers |
| 598 | 599 |
| 599 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |