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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 if (token.GetType() == kPercentageToken) | 316 if (token.GetType() == kPercentageToken) |
317 return ConsumePercent(range, value_range); | 317 return ConsumePercent(range, value_range); |
318 CalcParser calc_parser(range, value_range); | 318 CalcParser calc_parser(range, value_range); |
319 if (const CSSCalcValue* calculation = calc_parser.Value()) { | 319 if (const CSSCalcValue* calculation = calc_parser.Value()) { |
320 if (CanConsumeCalcValue(calculation->Category(), css_parser_mode)) | 320 if (CanConsumeCalcValue(calculation->Category(), css_parser_mode)) |
321 return calc_parser.ConsumeValue(); | 321 return calc_parser.ConsumeValue(); |
322 } | 322 } |
323 return nullptr; | 323 return nullptr; |
324 } | 324 } |
325 | 325 |
326 CSSPrimitiveValue* ConsumeAngle(CSSParserTokenRange& range) { | 326 CSSPrimitiveValue* ConsumeGradientLengthOrPercent( |
alancutter (OOO until 2018)
2017/05/25 01:53:16
I don't understand the purpose of this function, c
Eric Willigers
2017/05/25 02:56:41
ConsumeLengthOrPercent accepts a CSSParserMode.
Fo
alancutter (OOO until 2018)
2017/05/25 03:11:52
Ack. You should make this reason clear in the desc
Eric Willigers
2017/05/25 03:58:14
Done.
| |
327 CSSParserTokenRange& range, | |
328 const CSSParserContext& context, | |
329 ValueRange value_range, | |
330 UnitlessQuirk unitless) { | |
331 return ConsumeLengthOrPercent(range, context.Mode(), value_range, unitless); | |
332 } | |
333 | |
334 CSSPrimitiveValue* ConsumeAngle( | |
335 CSSParserTokenRange& range, | |
336 const CSSParserContext& context, | |
337 UnitlessQuirk angleQuirk, | |
338 WTF::Optional<UseCounter::Feature> literalZeroFeature) { | |
alancutter (OOO until 2018)
2017/05/25 01:53:16
DCHECK that the quirk is disallowed iff the featur
Eric Willigers
2017/05/25 02:56:41
Retiring the quirk argument, it was added in an ea
| |
327 const CSSParserToken& token = range.Peek(); | 339 const CSSParserToken& token = range.Peek(); |
328 if (token.GetType() == kDimensionToken) { | 340 if (token.GetType() == kDimensionToken) { |
329 switch (token.GetUnitType()) { | 341 switch (token.GetUnitType()) { |
330 case CSSPrimitiveValue::UnitType::kDegrees: | 342 case CSSPrimitiveValue::UnitType::kDegrees: |
331 case CSSPrimitiveValue::UnitType::kRadians: | 343 case CSSPrimitiveValue::UnitType::kRadians: |
332 case CSSPrimitiveValue::UnitType::kGradians: | 344 case CSSPrimitiveValue::UnitType::kGradians: |
333 case CSSPrimitiveValue::UnitType::kTurns: | 345 case CSSPrimitiveValue::UnitType::kTurns: |
334 return CSSPrimitiveValue::Create( | 346 return CSSPrimitiveValue::Create( |
335 range.ConsumeIncludingWhitespace().NumericValue(), | 347 range.ConsumeIncludingWhitespace().NumericValue(), |
336 token.GetUnitType()); | 348 token.GetUnitType()); |
337 default: | 349 default: |
338 return nullptr; | 350 return nullptr; |
339 } | 351 } |
340 } | 352 } |
341 if (token.GetType() == kNumberToken && token.NumericValue() == 0) { | 353 if (token.GetType() == kNumberToken && token.NumericValue() == 0 && |
354 literalZeroFeature) { | |
alancutter (OOO until 2018)
2017/05/25 01:53:16
Use the quirk parameter instead. It's completely u
| |
342 range.ConsumeIncludingWhitespace(); | 355 range.ConsumeIncludingWhitespace(); |
356 context.Count(*literalZeroFeature); | |
343 return CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kDegrees); | 357 return CSSPrimitiveValue::Create(0, CSSPrimitiveValue::UnitType::kDegrees); |
344 } | 358 } |
345 CalcParser calc_parser(range, kValueRangeAll); | 359 CalcParser calc_parser(range, kValueRangeAll); |
346 if (const CSSCalcValue* calculation = calc_parser.Value()) { | 360 if (const CSSCalcValue* calculation = calc_parser.Value()) { |
347 if (calculation->Category() == kCalcAngle) | 361 if (calculation->Category() == kCalcAngle) |
348 return calc_parser.ConsumeValue(); | 362 return calc_parser.ConsumeValue(); |
349 } | 363 } |
350 return nullptr; | 364 return nullptr; |
351 } | 365 } |
352 | 366 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 CSSGradientColorStop stop; | 965 CSSGradientColorStop stop; |
952 while (ConsumeCommaIncludingWhitespace(args)) { | 966 while (ConsumeCommaIncludingWhitespace(args)) { |
953 if (!ConsumeDeprecatedGradientColorStop(args, stop, css_parser_mode)) | 967 if (!ConsumeDeprecatedGradientColorStop(args, stop, css_parser_mode)) |
954 return nullptr; | 968 return nullptr; |
955 result->AddStop(stop); | 969 result->AddStop(stop); |
956 } | 970 } |
957 | 971 |
958 return result; | 972 return result; |
959 } | 973 } |
960 | 974 |
961 static CSSPrimitiveValue* ConsumeAngleOrPercent(CSSParserTokenRange& range, | 975 static CSSPrimitiveValue* ConsumeGradientAngleOrPercent( |
962 CSSParserMode, | 976 CSSParserTokenRange& range, |
963 ValueRange value_range, | 977 const CSSParserContext& context, |
964 UnitlessQuirk) { | 978 ValueRange value_range, |
979 UnitlessQuirk) { | |
965 const CSSParserToken& token = range.Peek(); | 980 const CSSParserToken& token = range.Peek(); |
966 if (token.GetType() == kDimensionToken || token.GetType() == kNumberToken) | 981 if (token.GetType() == kDimensionToken || token.GetType() == kNumberToken) { |
967 return ConsumeAngle(range); | 982 return ConsumeAngle(range, context, UnitlessQuirk::kAllow, |
983 UseCounter::kZeroAngleGradient); | |
984 } | |
968 if (token.GetType() == kPercentageToken) | 985 if (token.GetType() == kPercentageToken) |
969 return ConsumePercent(range, value_range); | 986 return ConsumePercent(range, value_range); |
970 CalcParser calc_parser(range, value_range); | 987 CalcParser calc_parser(range, value_range); |
971 if (const CSSCalcValue* calculation = calc_parser.Value()) { | 988 if (const CSSCalcValue* calculation = calc_parser.Value()) { |
972 CalculationCategory category = calculation->Category(); | 989 CalculationCategory category = calculation->Category(); |
973 // TODO(fs): Add and support kCalcPercentAngle? | 990 // TODO(fs): Add and support kCalcPercentAngle? |
974 if (category == kCalcAngle || category == kCalcPercent) | 991 if (category == kCalcAngle || category == kCalcPercent) |
975 return calc_parser.ConsumeValue(); | 992 return calc_parser.ConsumeValue(); |
976 } | 993 } |
977 return nullptr; | 994 return nullptr; |
978 } | 995 } |
979 | 996 |
980 using PositionFunctor = CSSPrimitiveValue* (*)(CSSParserTokenRange&, | 997 using PositionFunctor = CSSPrimitiveValue* (*)(CSSParserTokenRange&, |
981 CSSParserMode, | 998 const CSSParserContext&, |
982 ValueRange, | 999 ValueRange, |
983 UnitlessQuirk); | 1000 UnitlessQuirk); |
984 | 1001 |
985 static bool ConsumeGradientColorStops(CSSParserTokenRange& range, | 1002 static bool ConsumeGradientColorStops(CSSParserTokenRange& range, |
986 CSSParserMode css_parser_mode, | 1003 const CSSParserContext& context, |
987 CSSGradientValue* gradient, | 1004 CSSGradientValue* gradient, |
988 PositionFunctor consume_position_func) { | 1005 PositionFunctor consume_position_func) { |
989 bool supports_color_hints = gradient->GradientType() == kCSSLinearGradient || | 1006 bool supports_color_hints = gradient->GradientType() == kCSSLinearGradient || |
990 gradient->GradientType() == kCSSRadialGradient || | 1007 gradient->GradientType() == kCSSRadialGradient || |
991 gradient->GradientType() == kCSSConicGradient; | 1008 gradient->GradientType() == kCSSConicGradient; |
992 | 1009 |
993 // The first color stop cannot be a color hint. | 1010 // The first color stop cannot be a color hint. |
994 bool previous_stop_was_color_hint = true; | 1011 bool previous_stop_was_color_hint = true; |
995 do { | 1012 do { |
996 CSSGradientColorStop stop; | 1013 CSSGradientColorStop stop; |
997 stop.color_ = ConsumeColor(range, css_parser_mode); | 1014 stop.color_ = ConsumeColor(range, context.Mode()); |
998 // Two hints in a row are not allowed. | 1015 // Two hints in a row are not allowed. |
999 if (!stop.color_ && (!supports_color_hints || previous_stop_was_color_hint)) | 1016 if (!stop.color_ && (!supports_color_hints || previous_stop_was_color_hint)) |
1000 return false; | 1017 return false; |
1001 previous_stop_was_color_hint = !stop.color_; | 1018 previous_stop_was_color_hint = !stop.color_; |
1002 stop.offset_ = consume_position_func(range, css_parser_mode, kValueRangeAll, | 1019 stop.offset_ = consume_position_func(range, context, kValueRangeAll, |
1003 UnitlessQuirk::kForbid); | 1020 UnitlessQuirk::kForbid); |
1004 if (!stop.color_ && !stop.offset_) | 1021 if (!stop.color_ && !stop.offset_) |
1005 return false; | 1022 return false; |
1006 gradient->AddStop(stop); | 1023 gradient->AddStop(stop); |
1007 | 1024 |
1008 if (RuntimeEnabledFeatures::multipleColorStopPositionsEnabled()) { | 1025 if (RuntimeEnabledFeatures::multipleColorStopPositionsEnabled()) { |
1009 if (!stop.color_ || !stop.offset_) | 1026 if (!stop.color_ || !stop.offset_) |
1010 continue; | 1027 continue; |
1011 | 1028 |
1012 // Optional second position. | 1029 // Optional second position. |
1013 stop.offset_ = consume_position_func( | 1030 stop.offset_ = consume_position_func(range, context, kValueRangeAll, |
1014 range, css_parser_mode, kValueRangeAll, UnitlessQuirk::kForbid); | 1031 UnitlessQuirk::kForbid); |
1015 if (stop.offset_) | 1032 if (stop.offset_) |
1016 gradient->AddStop(stop); | 1033 gradient->AddStop(stop); |
1017 } | 1034 } |
1018 } while (ConsumeCommaIncludingWhitespace(range)); | 1035 } while (ConsumeCommaIncludingWhitespace(range)); |
1019 | 1036 |
1020 // The last color stop cannot be a color hint. | 1037 // The last color stop cannot be a color hint. |
1021 if (previous_stop_was_color_hint) | 1038 if (previous_stop_was_color_hint) |
1022 return false; | 1039 return false; |
1023 | 1040 |
1024 // Must have 2 or more stops to be valid. | 1041 // Must have 2 or more stops to be valid. |
1025 return gradient->StopCount() >= 2; | 1042 return gradient->StopCount() >= 2; |
1026 } | 1043 } |
1027 | 1044 |
1028 static CSSValue* ConsumeDeprecatedRadialGradient(CSSParserTokenRange& args, | 1045 static CSSValue* ConsumeDeprecatedRadialGradient( |
1029 CSSParserMode css_parser_mode, | 1046 CSSParserTokenRange& args, |
1030 CSSGradientRepeat repeating) { | 1047 const CSSParserContext& context, |
1048 CSSGradientRepeat repeating) { | |
1031 CSSValue* center_x = nullptr; | 1049 CSSValue* center_x = nullptr; |
1032 CSSValue* center_y = nullptr; | 1050 CSSValue* center_y = nullptr; |
1033 ConsumeOneOrTwoValuedPosition(args, css_parser_mode, UnitlessQuirk::kForbid, | 1051 ConsumeOneOrTwoValuedPosition(args, context.Mode(), UnitlessQuirk::kForbid, |
1034 center_x, center_y); | 1052 center_x, center_y); |
1035 if ((center_x || center_y) && !ConsumeCommaIncludingWhitespace(args)) | 1053 if ((center_x || center_y) && !ConsumeCommaIncludingWhitespace(args)) |
1036 return nullptr; | 1054 return nullptr; |
1037 | 1055 |
1038 const CSSIdentifierValue* shape = | 1056 const CSSIdentifierValue* shape = |
1039 ConsumeIdent<CSSValueCircle, CSSValueEllipse>(args); | 1057 ConsumeIdent<CSSValueCircle, CSSValueEllipse>(args); |
1040 const CSSIdentifierValue* size_keyword = | 1058 const CSSIdentifierValue* size_keyword = |
1041 ConsumeIdent<CSSValueClosestSide, CSSValueClosestCorner, | 1059 ConsumeIdent<CSSValueClosestSide, CSSValueClosestCorner, |
1042 CSSValueFarthestSide, CSSValueFarthestCorner, | 1060 CSSValueFarthestSide, CSSValueFarthestCorner, |
1043 CSSValueContain, CSSValueCover>(args); | 1061 CSSValueContain, CSSValueCover>(args); |
1044 if (!shape) | 1062 if (!shape) |
1045 shape = ConsumeIdent<CSSValueCircle, CSSValueEllipse>(args); | 1063 shape = ConsumeIdent<CSSValueCircle, CSSValueEllipse>(args); |
1046 | 1064 |
1047 // Or, two lengths or percentages | 1065 // Or, two lengths or percentages |
1048 const CSSPrimitiveValue* horizontal_size = nullptr; | 1066 const CSSPrimitiveValue* horizontal_size = nullptr; |
1049 const CSSPrimitiveValue* vertical_size = nullptr; | 1067 const CSSPrimitiveValue* vertical_size = nullptr; |
1050 if (!shape && !size_keyword) { | 1068 if (!shape && !size_keyword) { |
1051 horizontal_size = | 1069 horizontal_size = |
1052 ConsumeLengthOrPercent(args, css_parser_mode, kValueRangeAll); | 1070 ConsumeLengthOrPercent(args, context.Mode(), kValueRangeAll); |
1053 if (horizontal_size) { | 1071 if (horizontal_size) { |
1054 vertical_size = | 1072 vertical_size = |
1055 ConsumeLengthOrPercent(args, css_parser_mode, kValueRangeAll); | 1073 ConsumeLengthOrPercent(args, context.Mode(), kValueRangeAll); |
1056 if (!vertical_size) | 1074 if (!vertical_size) |
1057 return nullptr; | 1075 return nullptr; |
1058 ConsumeCommaIncludingWhitespace(args); | 1076 ConsumeCommaIncludingWhitespace(args); |
1059 } | 1077 } |
1060 } else { | 1078 } else { |
1061 ConsumeCommaIncludingWhitespace(args); | 1079 ConsumeCommaIncludingWhitespace(args); |
1062 } | 1080 } |
1063 | 1081 |
1064 CSSGradientValue* result = CSSRadialGradientValue::Create( | 1082 CSSGradientValue* result = CSSRadialGradientValue::Create( |
1065 center_x, center_y, shape, size_keyword, horizontal_size, vertical_size, | 1083 center_x, center_y, shape, size_keyword, horizontal_size, vertical_size, |
1066 repeating, kCSSPrefixedRadialGradient); | 1084 repeating, kCSSPrefixedRadialGradient); |
1067 return ConsumeGradientColorStops(args, css_parser_mode, result, | 1085 return ConsumeGradientColorStops(args, context, result, |
1068 ConsumeLengthOrPercent) | 1086 ConsumeGradientLengthOrPercent) |
1069 ? result | 1087 ? result |
1070 : nullptr; | 1088 : nullptr; |
1071 } | 1089 } |
1072 | 1090 |
1073 static CSSValue* ConsumeRadialGradient(CSSParserTokenRange& args, | 1091 static CSSValue* ConsumeRadialGradient(CSSParserTokenRange& args, |
1074 const CSSParserContext& context, | 1092 const CSSParserContext& context, |
1075 CSSGradientRepeat repeating) { | 1093 CSSGradientRepeat repeating) { |
1076 const CSSIdentifierValue* shape = nullptr; | 1094 const CSSIdentifierValue* shape = nullptr; |
1077 const CSSIdentifierValue* size_keyword = nullptr; | 1095 const CSSIdentifierValue* size_keyword = nullptr; |
1078 const CSSPrimitiveValue* horizontal_size = nullptr; | 1096 const CSSPrimitiveValue* horizontal_size = nullptr; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1146 } | 1164 } |
1147 | 1165 |
1148 if ((shape || size_keyword || horizontal_size || center_x || center_y) && | 1166 if ((shape || size_keyword || horizontal_size || center_x || center_y) && |
1149 !ConsumeCommaIncludingWhitespace(args)) { | 1167 !ConsumeCommaIncludingWhitespace(args)) { |
1150 return nullptr; | 1168 return nullptr; |
1151 } | 1169 } |
1152 | 1170 |
1153 CSSGradientValue* result = CSSRadialGradientValue::Create( | 1171 CSSGradientValue* result = CSSRadialGradientValue::Create( |
1154 center_x, center_y, shape, size_keyword, horizontal_size, vertical_size, | 1172 center_x, center_y, shape, size_keyword, horizontal_size, vertical_size, |
1155 repeating, kCSSRadialGradient); | 1173 repeating, kCSSRadialGradient); |
1156 return ConsumeGradientColorStops(args, context.Mode(), result, | 1174 return ConsumeGradientColorStops(args, context, result, |
1157 ConsumeLengthOrPercent) | 1175 ConsumeGradientLengthOrPercent) |
1158 ? result | 1176 ? result |
1159 : nullptr; | 1177 : nullptr; |
1160 } | 1178 } |
1161 | 1179 |
1162 static CSSValue* ConsumeLinearGradient(CSSParserTokenRange& args, | 1180 static CSSValue* ConsumeLinearGradient(CSSParserTokenRange& args, |
1163 CSSParserMode css_parser_mode, | 1181 const CSSParserContext& context, |
1164 CSSGradientRepeat repeating, | 1182 CSSGradientRepeat repeating, |
1165 CSSGradientType gradient_type) { | 1183 CSSGradientType gradient_type) { |
1166 bool expect_comma = true; | 1184 bool expect_comma = true; |
1167 const CSSPrimitiveValue* angle = ConsumeAngle(args); | 1185 const CSSPrimitiveValue* angle = ConsumeAngle( |
1186 args, context, UnitlessQuirk::kAllow, UseCounter::kZeroAngleGradient); | |
1168 const CSSIdentifierValue* end_x = nullptr; | 1187 const CSSIdentifierValue* end_x = nullptr; |
1169 const CSSIdentifierValue* end_y = nullptr; | 1188 const CSSIdentifierValue* end_y = nullptr; |
1170 if (!angle) { | 1189 if (!angle) { |
1171 if (gradient_type == kCSSPrefixedLinearGradient || | 1190 if (gradient_type == kCSSPrefixedLinearGradient || |
1172 ConsumeIdent<CSSValueTo>(args)) { | 1191 ConsumeIdent<CSSValueTo>(args)) { |
1173 end_x = ConsumeIdent<CSSValueLeft, CSSValueRight>(args); | 1192 end_x = ConsumeIdent<CSSValueLeft, CSSValueRight>(args); |
1174 end_y = ConsumeIdent<CSSValueBottom, CSSValueTop>(args); | 1193 end_y = ConsumeIdent<CSSValueBottom, CSSValueTop>(args); |
1175 if (!end_x && !end_y) { | 1194 if (!end_x && !end_y) { |
1176 if (gradient_type == kCSSLinearGradient) | 1195 if (gradient_type == kCSSLinearGradient) |
1177 return nullptr; | 1196 return nullptr; |
1178 end_y = CSSIdentifierValue::Create(CSSValueTop); | 1197 end_y = CSSIdentifierValue::Create(CSSValueTop); |
1179 expect_comma = false; | 1198 expect_comma = false; |
1180 } else if (!end_x) { | 1199 } else if (!end_x) { |
1181 end_x = ConsumeIdent<CSSValueLeft, CSSValueRight>(args); | 1200 end_x = ConsumeIdent<CSSValueLeft, CSSValueRight>(args); |
1182 } | 1201 } |
1183 } else { | 1202 } else { |
1184 expect_comma = false; | 1203 expect_comma = false; |
1185 } | 1204 } |
1186 } | 1205 } |
1187 | 1206 |
1188 if (expect_comma && !ConsumeCommaIncludingWhitespace(args)) | 1207 if (expect_comma && !ConsumeCommaIncludingWhitespace(args)) |
1189 return nullptr; | 1208 return nullptr; |
1190 | 1209 |
1191 CSSGradientValue* result = CSSLinearGradientValue::Create( | 1210 CSSGradientValue* result = CSSLinearGradientValue::Create( |
1192 end_x, end_y, nullptr, nullptr, angle, repeating, gradient_type); | 1211 end_x, end_y, nullptr, nullptr, angle, repeating, gradient_type); |
1193 return ConsumeGradientColorStops(args, css_parser_mode, result, | 1212 return ConsumeGradientColorStops(args, context, result, |
1194 ConsumeLengthOrPercent) | 1213 ConsumeGradientLengthOrPercent) |
1195 ? result | 1214 ? result |
1196 : nullptr; | 1215 : nullptr; |
1197 } | 1216 } |
1198 | 1217 |
1199 static CSSValue* ConsumeConicGradient(CSSParserTokenRange& args, | 1218 static CSSValue* ConsumeConicGradient(CSSParserTokenRange& args, |
1200 const CSSParserContext& context, | 1219 const CSSParserContext& context, |
1201 CSSGradientRepeat repeating) { | 1220 CSSGradientRepeat repeating) { |
1202 if (!RuntimeEnabledFeatures::conicGradientEnabled()) | 1221 if (!RuntimeEnabledFeatures::conicGradientEnabled()) |
1203 return nullptr; | 1222 return nullptr; |
1204 | 1223 |
1205 const CSSPrimitiveValue* from_angle = nullptr; | 1224 const CSSPrimitiveValue* from_angle = nullptr; |
1206 if (ConsumeIdent<CSSValueFrom>(args)) { | 1225 if (ConsumeIdent<CSSValueFrom>(args)) { |
1207 if (!(from_angle = ConsumeAngle(args))) | 1226 if (!(from_angle = ConsumeAngle(args, context, UnitlessQuirk::kAllow, |
1227 UseCounter::kZeroAngleGradient))) | |
1208 return nullptr; | 1228 return nullptr; |
1209 } | 1229 } |
1210 | 1230 |
1211 CSSValue* center_x = nullptr; | 1231 CSSValue* center_x = nullptr; |
1212 CSSValue* center_y = nullptr; | 1232 CSSValue* center_y = nullptr; |
1213 if (ConsumeIdent<CSSValueAt>(args)) { | 1233 if (ConsumeIdent<CSSValueAt>(args)) { |
1214 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, | 1234 if (!ConsumePosition(args, context, UnitlessQuirk::kForbid, |
1215 UseCounter::kThreeValuedPositionGradient, center_x, | 1235 UseCounter::kThreeValuedPositionGradient, center_x, |
1216 center_y)) | 1236 center_y)) |
1217 return nullptr; | 1237 return nullptr; |
1218 } | 1238 } |
1219 | 1239 |
1220 // Comma separator required when fromAngle or position is present. | 1240 // Comma separator required when fromAngle or position is present. |
1221 if ((from_angle || center_x || center_y) && | 1241 if ((from_angle || center_x || center_y) && |
1222 !ConsumeCommaIncludingWhitespace(args)) { | 1242 !ConsumeCommaIncludingWhitespace(args)) { |
1223 return nullptr; | 1243 return nullptr; |
1224 } | 1244 } |
1225 | 1245 |
1226 CSSGradientValue* result = | 1246 CSSGradientValue* result = |
1227 CSSConicGradientValue::Create(center_x, center_y, from_angle, repeating); | 1247 CSSConicGradientValue::Create(center_x, center_y, from_angle, repeating); |
1228 return ConsumeGradientColorStops(args, context.Mode(), result, | 1248 return ConsumeGradientColorStops(args, context, result, |
1229 ConsumeAngleOrPercent) | 1249 ConsumeGradientAngleOrPercent) |
1230 ? result | 1250 ? result |
1231 : nullptr; | 1251 : nullptr; |
1232 } | 1252 } |
1233 | 1253 |
1234 CSSValue* ConsumeImageOrNone(CSSParserTokenRange& range, | 1254 CSSValue* ConsumeImageOrNone(CSSParserTokenRange& range, |
1235 const CSSParserContext* context) { | 1255 const CSSParserContext* context) { |
1236 if (range.Peek().Id() == CSSValueNone) | 1256 if (range.Peek().Id() == CSSValueNone) |
1237 return ConsumeIdent(range); | 1257 return ConsumeIdent(range); |
1238 return ConsumeImage(range, context); | 1258 return ConsumeImage(range, context); |
1239 } | 1259 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1312 CSSValueID id = range.Peek().FunctionId(); | 1332 CSSValueID id = range.Peek().FunctionId(); |
1313 CSSParserTokenRange range_copy = range; | 1333 CSSParserTokenRange range_copy = range; |
1314 CSSParserTokenRange args = ConsumeFunction(range_copy); | 1334 CSSParserTokenRange args = ConsumeFunction(range_copy); |
1315 CSSValue* result = nullptr; | 1335 CSSValue* result = nullptr; |
1316 if (id == CSSValueRadialGradient) { | 1336 if (id == CSSValueRadialGradient) { |
1317 result = ConsumeRadialGradient(args, *context, kNonRepeating); | 1337 result = ConsumeRadialGradient(args, *context, kNonRepeating); |
1318 } else if (id == CSSValueRepeatingRadialGradient) { | 1338 } else if (id == CSSValueRepeatingRadialGradient) { |
1319 result = ConsumeRadialGradient(args, *context, kRepeating); | 1339 result = ConsumeRadialGradient(args, *context, kRepeating); |
1320 } else if (id == CSSValueWebkitLinearGradient) { | 1340 } else if (id == CSSValueWebkitLinearGradient) { |
1321 context->Count(UseCounter::kDeprecatedWebKitLinearGradient); | 1341 context->Count(UseCounter::kDeprecatedWebKitLinearGradient); |
1322 result = ConsumeLinearGradient(args, context->Mode(), kNonRepeating, | 1342 result = ConsumeLinearGradient(args, *context, kNonRepeating, |
1323 kCSSPrefixedLinearGradient); | 1343 kCSSPrefixedLinearGradient); |
1324 } else if (id == CSSValueWebkitRepeatingLinearGradient) { | 1344 } else if (id == CSSValueWebkitRepeatingLinearGradient) { |
1325 context->Count(UseCounter::kDeprecatedWebKitRepeatingLinearGradient); | 1345 context->Count(UseCounter::kDeprecatedWebKitRepeatingLinearGradient); |
1326 result = ConsumeLinearGradient(args, context->Mode(), kRepeating, | 1346 result = ConsumeLinearGradient(args, *context, kRepeating, |
1327 kCSSPrefixedLinearGradient); | 1347 kCSSPrefixedLinearGradient); |
1328 } else if (id == CSSValueRepeatingLinearGradient) { | 1348 } else if (id == CSSValueRepeatingLinearGradient) { |
1329 result = ConsumeLinearGradient(args, context->Mode(), kRepeating, | 1349 result = |
1330 kCSSLinearGradient); | 1350 ConsumeLinearGradient(args, *context, kRepeating, kCSSLinearGradient); |
1331 } else if (id == CSSValueLinearGradient) { | 1351 } else if (id == CSSValueLinearGradient) { |
1332 result = ConsumeLinearGradient(args, context->Mode(), kNonRepeating, | 1352 result = ConsumeLinearGradient(args, *context, kNonRepeating, |
1333 kCSSLinearGradient); | 1353 kCSSLinearGradient); |
1334 } else if (id == CSSValueWebkitGradient) { | 1354 } else if (id == CSSValueWebkitGradient) { |
1335 context->Count(UseCounter::kDeprecatedWebKitGradient); | 1355 context->Count(UseCounter::kDeprecatedWebKitGradient); |
1336 result = ConsumeDeprecatedGradient(args, context->Mode()); | 1356 result = ConsumeDeprecatedGradient(args, context->Mode()); |
1337 } else if (id == CSSValueWebkitRadialGradient) { | 1357 } else if (id == CSSValueWebkitRadialGradient) { |
1338 context->Count(UseCounter::kDeprecatedWebKitRadialGradient); | 1358 context->Count(UseCounter::kDeprecatedWebKitRadialGradient); |
1339 result = | 1359 result = ConsumeDeprecatedRadialGradient(args, *context, kNonRepeating); |
1340 ConsumeDeprecatedRadialGradient(args, context->Mode(), kNonRepeating); | |
1341 } else if (id == CSSValueWebkitRepeatingRadialGradient) { | 1360 } else if (id == CSSValueWebkitRepeatingRadialGradient) { |
1342 context->Count(UseCounter::kDeprecatedWebKitRepeatingRadialGradient); | 1361 context->Count(UseCounter::kDeprecatedWebKitRepeatingRadialGradient); |
1343 result = ConsumeDeprecatedRadialGradient(args, context->Mode(), kRepeating); | 1362 result = ConsumeDeprecatedRadialGradient(args, *context, kRepeating); |
1344 } else if (id == CSSValueConicGradient) { | 1363 } else if (id == CSSValueConicGradient) { |
1345 result = ConsumeConicGradient(args, *context, kNonRepeating); | 1364 result = ConsumeConicGradient(args, *context, kNonRepeating); |
1346 } else if (id == CSSValueRepeatingConicGradient) { | 1365 } else if (id == CSSValueRepeatingConicGradient) { |
1347 result = ConsumeConicGradient(args, *context, kRepeating); | 1366 result = ConsumeConicGradient(args, *context, kRepeating); |
1348 } else if (id == CSSValueWebkitCrossFade) { | 1367 } else if (id == CSSValueWebkitCrossFade) { |
1349 result = ConsumeCrossFade(args, context); | 1368 result = ConsumeCrossFade(args, context); |
1350 } else if (id == CSSValuePaint) { | 1369 } else if (id == CSSValuePaint) { |
1351 result = RuntimeEnabledFeatures::cssPaintAPIEnabled() | 1370 result = RuntimeEnabledFeatures::cssPaintAPIEnabled() |
1352 ? ConsumePaint(args, context) | 1371 ? ConsumePaint(args, context) |
1353 : nullptr; | 1372 : nullptr; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1437 | 1456 |
1438 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box | 1457 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box |
1439 CSSIdentifierValue* ConsumeShapeBox(CSSParserTokenRange& range) { | 1458 CSSIdentifierValue* ConsumeShapeBox(CSSParserTokenRange& range) { |
1440 return ConsumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, | 1459 return ConsumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, |
1441 CSSValueMarginBox>(range); | 1460 CSSValueMarginBox>(range); |
1442 } | 1461 } |
1443 | 1462 |
1444 } // namespace CSSPropertyParserHelpers | 1463 } // namespace CSSPropertyParserHelpers |
1445 | 1464 |
1446 } // namespace blink | 1465 } // namespace blink |
OLD | NEW |