| 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/CSSColorValue.h" | 8 #include "core/css/CSSColorValue.h" |
| 9 #include "core/css/CSSCrossfadeValue.h" | 9 #include "core/css/CSSCrossfadeValue.h" |
| 10 #include "core/css/CSSGradientValue.h" | 10 #include "core/css/CSSGradientValue.h" |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return false; | 479 return false; |
| 480 if (!Color::parseHexColor(color, result)) | 480 if (!Color::parseHexColor(color, result)) |
| 481 return false; | 481 return false; |
| 482 } else { | 482 } else { |
| 483 return false; | 483 return false; |
| 484 } | 484 } |
| 485 range.consumeIncludingWhitespace(); | 485 range.consumeIncludingWhitespace(); |
| 486 return true; | 486 return true; |
| 487 } | 487 } |
| 488 | 488 |
| 489 static bool isRGBFunctionId(CSSValueID functionId) { |
| 490 return functionId == CSSValueRgb || functionId == CSSValueRgba; |
| 491 } |
| 492 |
| 493 static bool isHSLFunctionId(CSSValueID functionId) { |
| 494 return functionId == CSSValueHsl || functionId == CSSValueHsla; |
| 495 } |
| 496 |
| 489 static bool parseColorFunction(CSSParserTokenRange& range, RGBA32& result) { | 497 static bool parseColorFunction(CSSParserTokenRange& range, RGBA32& result) { |
| 490 CSSValueID functionId = range.peek().functionId(); | 498 CSSValueID functionId = range.peek().functionId(); |
| 491 if (functionId < CSSValueRgb || functionId > CSSValueHsla) | 499 if (!isRGBFunctionId(functionId) && !isHSLFunctionId(functionId)) |
| 492 return false; | 500 return false; |
| 493 CSSParserTokenRange colorRange = range; | 501 CSSParserTokenRange colorRange = range; |
| 494 if ((functionId <= CSSValueRgba && | 502 if ((isRGBFunctionId(functionId) && |
| 495 !parseRGBParameters(colorRange, result, functionId == CSSValueRgba)) || | 503 !parseRGBParameters(colorRange, result, functionId == CSSValueRgba)) || |
| 496 (functionId >= CSSValueHsl && | 504 (isHSLFunctionId(functionId) && |
| 497 !parseHSLParameters(colorRange, result, functionId == CSSValueHsla))) | 505 !parseHSLParameters(colorRange, result, functionId == CSSValueHsla))) |
| 498 return false; | 506 return false; |
| 499 range = colorRange; | 507 range = colorRange; |
| 500 return true; | 508 return true; |
| 501 } | 509 } |
| 502 | 510 |
| 503 CSSValue* consumeColor(CSSParserTokenRange& range, | 511 CSSValue* consumeColor(CSSParserTokenRange& range, |
| 504 CSSParserMode cssParserMode, | 512 CSSParserMode cssParserMode, |
| 505 bool acceptQuirkyColors) { | 513 bool acceptQuirkyColors) { |
| 506 CSSValueID id = range.peek().id(); | 514 CSSValueID id = range.peek().id(); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 | 1238 |
| 1231 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box | 1239 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box |
| 1232 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { | 1240 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { |
| 1233 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, | 1241 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, |
| 1234 CSSValueMarginBox>(range); | 1242 CSSValueMarginBox>(range); |
| 1235 } | 1243 } |
| 1236 | 1244 |
| 1237 } // namespace CSSPropertyParserHelpers | 1245 } // namespace CSSPropertyParserHelpers |
| 1238 | 1246 |
| 1239 } // namespace blink | 1247 } // namespace blink |
| OLD | NEW |