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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 stop.m_color = consumeColor(range, cssParserMode); | 960 stop.m_color = consumeColor(range, cssParserMode); |
961 // Two hints in a row are not allowed. | 961 // Two hints in a row are not allowed. |
962 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) | 962 if (!stop.m_color && (!supportsColorHints || previousStopWasColorHint)) |
963 return false; | 963 return false; |
964 previousStopWasColorHint = !stop.m_color; | 964 previousStopWasColorHint = !stop.m_color; |
965 stop.m_offset = consumePositionFunc(range, cssParserMode, ValueRangeAll, | 965 stop.m_offset = consumePositionFunc(range, cssParserMode, ValueRangeAll, |
966 UnitlessQuirk::Forbid); | 966 UnitlessQuirk::Forbid); |
967 if (!stop.m_color && !stop.m_offset) | 967 if (!stop.m_color && !stop.m_offset) |
968 return false; | 968 return false; |
969 gradient->addStop(stop); | 969 gradient->addStop(stop); |
| 970 |
| 971 if (RuntimeEnabledFeatures::multipleColorStopPositionsEnabled()) { |
| 972 if (!stop.m_color || !stop.m_offset) |
| 973 continue; |
| 974 |
| 975 // Optional second position. |
| 976 stop.m_offset = consumePositionFunc(range, cssParserMode, ValueRangeAll, |
| 977 UnitlessQuirk::Forbid); |
| 978 if (stop.m_offset) |
| 979 gradient->addStop(stop); |
| 980 } |
970 } while (consumeCommaIncludingWhitespace(range)); | 981 } while (consumeCommaIncludingWhitespace(range)); |
971 | 982 |
972 // The last color stop cannot be a color hint. | 983 // The last color stop cannot be a color hint. |
973 if (previousStopWasColorHint) | 984 if (previousStopWasColorHint) |
974 return false; | 985 return false; |
975 | 986 |
976 // Must have 2 or more stops to be valid. | 987 // Must have 2 or more stops to be valid. |
977 return gradient->stopCount() >= 2; | 988 return gradient->stopCount() >= 2; |
978 } | 989 } |
979 | 990 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 | 1418 |
1408 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box | 1419 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box |
1409 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { | 1420 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { |
1410 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, | 1421 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, |
1411 CSSValueMarginBox>(range); | 1422 CSSValueMarginBox>(range); |
1412 } | 1423 } |
1413 | 1424 |
1414 } // namespace CSSPropertyParserHelpers | 1425 } // namespace CSSPropertyParserHelpers |
1415 | 1426 |
1416 } // namespace blink | 1427 } // namespace blink |
OLD | NEW |