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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 && token.numericValue() >= 0. && token.numericValue() < 1000000.) {
// e.g. 112233 | 409 && token.numericValue() >= 0. && token.numericValue() < 1000000.) {
// e.g. 112233 |
410 color = String::format("%06d", static_cast<int>(token.numericValue()
)); | 410 color = String::format("%06d", static_cast<int>(token.numericValue()
)); |
411 } else if (token.type() == DimensionToken) { // e.g. 0001FF | 411 } else if (token.type() == DimensionToken) { // e.g. 0001FF |
412 // TODO(timloh): This should check the numericValueType flag | 412 // TODO(timloh): This should check the numericValueType flag |
413 color = String::number(static_cast<int>(token.numericValue())) + Str
ing(token.value()); | 413 color = String::number(static_cast<int>(token.numericValue())) + Str
ing(token.value()); |
414 if (color.length() > 6) | 414 if (color.length() > 6) |
415 return false; | 415 return false; |
416 while (color.length() < 6) | 416 while (color.length() < 6) |
417 color = "0" + color; | 417 color = "0" + color; |
418 } else if (token.type() == IdentToken) { // e.g. FF0000 | 418 } else if (token.type() == IdentToken) { // e.g. FF0000 |
| 419 unsigned length = token.value().length(); |
| 420 if (length != 3 && length != 6) |
| 421 return false; |
419 color = token.value(); | 422 color = token.value(); |
420 } | 423 } |
421 } | 424 } |
422 if (token.type() == HashToken) | 425 if (token.type() == HashToken) |
423 color = token.value(); | 426 color = token.value(); |
424 if (!Color::parseHexColor(color, result)) | 427 if (!Color::parseHexColor(color, result)) |
425 return false; | 428 return false; |
426 range.consumeIncludingWhitespace(); | 429 range.consumeIncludingWhitespace(); |
427 return true; | 430 return true; |
428 } | 431 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 if (!value2) { | 593 if (!value2) { |
591 positionFromOneValue(value1, resultX, resultY); | 594 positionFromOneValue(value1, resultX, resultY); |
592 return true; | 595 return true; |
593 } | 596 } |
594 return positionFromTwoValues(value1, value2, resultX, resultY); | 597 return positionFromTwoValues(value1, value2, resultX, resultY); |
595 } | 598 } |
596 | 599 |
597 } // namespace CSSPropertyParserHelpers | 600 } // namespace CSSPropertyParserHelpers |
598 | 601 |
599 } // namespace blink | 602 } // namespace blink |
OLD | NEW |