Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
index 5270cc2c2a50d856c43cacdf37550e50cda6fed6..48a2d406edb138601a66ec44f4f10ee435d4cc4b 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -1079,35 +1079,6 @@ static CSSValue* ConsumeBackgroundComponent(CSSPropertyID unresolved_property, |
return nullptr; |
} |
-static void AddBackgroundValue(CSSValue*& list, CSSValue* value) { |
- if (list) { |
- if (!list->IsBaseValueList()) { |
- CSSValue* first_value = list; |
- list = CSSValueList::CreateCommaSeparated(); |
- ToCSSValueList(list)->Append(*first_value); |
- } |
- ToCSSValueList(list)->Append(*value); |
- } else { |
- // To conserve memory we don't actually wrap a single value in a list. |
- list = value; |
- } |
-} |
- |
-static CSSValue* ConsumeCommaSeparatedBackgroundComponent( |
- CSSPropertyID unresolved_property, |
- CSSParserTokenRange& range, |
- const CSSParserContext* context) { |
- CSSValue* result = nullptr; |
- do { |
- CSSValue* value = |
- ConsumeBackgroundComponent(unresolved_property, range, context); |
- if (!value) |
- return nullptr; |
- AddBackgroundValue(result, value); |
- } while (ConsumeCommaIncludingWhitespace(range)); |
- return result; |
-} |
- |
static CSSValue* ConsumeFitContent(CSSParserTokenRange& range, |
CSSParserMode css_parser_mode) { |
CSSParserTokenRange range_copy = range; |
@@ -1655,36 +1626,42 @@ const CSSValue* CSSPropertyParser::ParseSingleValue( |
return ConsumeLocale(range_); |
case CSSPropertyAnimationDelay: |
case CSSPropertyTransitionDelay: |
- return ConsumeCommaSeparatedList(ConsumeTime, range_, kValueRangeAll); |
+ return ConsumeCommaSeparatedList(Optimise::kNo, ConsumeTime, range_, |
+ kValueRangeAll); |
case CSSPropertyAnimationDirection: |
return ConsumeCommaSeparatedList( |
+ Optimise::kNo, |
ConsumeIdent<CSSValueNormal, CSSValueAlternate, CSSValueReverse, |
CSSValueAlternateReverse>, |
range_); |
case CSSPropertyAnimationDuration: |
case CSSPropertyTransitionDuration: |
- return ConsumeCommaSeparatedList(ConsumeTime, range_, |
+ return ConsumeCommaSeparatedList(Optimise::kNo, ConsumeTime, range_, |
kValueRangeNonNegative); |
case CSSPropertyAnimationFillMode: |
return ConsumeCommaSeparatedList( |
+ Optimise::kNo, |
ConsumeIdent<CSSValueNone, CSSValueForwards, CSSValueBackwards, |
CSSValueBoth>, |
range_); |
case CSSPropertyAnimationIterationCount: |
- return ConsumeCommaSeparatedList(ConsumeAnimationIterationCount, range_); |
+ return ConsumeCommaSeparatedList(Optimise::kNo, |
+ ConsumeAnimationIterationCount, range_); |
case CSSPropertyAnimationPlayState: |
return ConsumeCommaSeparatedList( |
- ConsumeIdent<CSSValueRunning, CSSValuePaused>, range_); |
+ Optimise::kNo, ConsumeIdent<CSSValueRunning, CSSValuePaused>, range_); |
case CSSPropertyTransitionProperty: { |
- CSSValueList* list = |
- ConsumeCommaSeparatedList(ConsumeTransitionProperty, range_); |
- if (!list || !IsValidAnimationPropertyList(*list)) |
+ CSSValue* list = ConsumeCommaSeparatedList( |
+ Optimise::kNo, ConsumeTransitionProperty, range_); |
+ DCHECK(!list || list->IsBaseValueList()); |
+ if (!list || !IsValidAnimationPropertyList(*ToCSSValueList(list))) |
return nullptr; |
return list; |
} |
case CSSPropertyAnimationTimingFunction: |
case CSSPropertyTransitionTimingFunction: |
- return ConsumeCommaSeparatedList(ConsumeAnimationTimingFunction, range_); |
+ return ConsumeCommaSeparatedList(Optimise::kNo, |
+ ConsumeAnimationTimingFunction, range_); |
case CSSPropertyGridColumnGap: |
case CSSPropertyGridRowGap: |
return ConsumeLengthOrPercent(range_, context_->Mode(), |
@@ -1783,25 +1760,54 @@ const CSSValue* CSSPropertyParser::ParseSingleValue( |
case CSSPropertyWebkitBoxReflect: |
return ConsumeReflect(range_, context_); |
case CSSPropertyBackgroundAttachment: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, |
+ ConsumeBackgroundAttachment, range_); |
case CSSPropertyBackgroundBlendMode: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, |
+ ConsumeBackgroundBlendMode, range_); |
case CSSPropertyBackgroundClip: |
- case CSSPropertyBackgroundImage: |
case CSSPropertyBackgroundOrigin: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, ConsumeBackgroundBox, |
+ range_); |
+ case CSSPropertyBackgroundImage: |
+ case CSSPropertyWebkitMaskImage: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, ConsumeImageOrNone, |
+ range_, context_); |
case CSSPropertyBackgroundPositionX: |
+ case CSSPropertyWebkitMaskPositionX: |
+ return ConsumeCommaSeparatedList( |
+ Optimise::kYes, |
+ CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueLeft, |
+ CSSValueRight>, |
+ range_, context_->Mode()); |
case CSSPropertyBackgroundPositionY: |
+ case CSSPropertyWebkitMaskPositionY: |
+ return ConsumeCommaSeparatedList( |
+ Optimise::kYes, |
+ CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueTop, |
+ CSSValueBottom>, |
+ range_, context_->Mode()); |
case CSSPropertyBackgroundSize: |
+ case CSSPropertyWebkitMaskSize: |
+ return ConsumeCommaSeparatedList( |
+ Optimise::kYes, ConsumeBackgroundSize, range_, context_->Mode(), |
+ unresolved_property == CSSPropertyAliasWebkitBackgroundSize); |
case CSSPropertyMaskSourceType: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, ConsumeMaskSourceType, |
+ range_); |
case CSSPropertyWebkitBackgroundClip: |
- case CSSPropertyWebkitBackgroundOrigin: |
case CSSPropertyWebkitMaskClip: |
- case CSSPropertyWebkitMaskComposite: |
- case CSSPropertyWebkitMaskImage: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, |
+ ConsumePrefixedBackgroundBox, range_, |
+ context_, true /* allow_text_value */); |
+ case CSSPropertyWebkitBackgroundOrigin: |
case CSSPropertyWebkitMaskOrigin: |
- case CSSPropertyWebkitMaskPositionX: |
- case CSSPropertyWebkitMaskPositionY: |
- case CSSPropertyWebkitMaskSize: |
- return ConsumeCommaSeparatedBackgroundComponent(unresolved_property, |
- range_, context_); |
+ return ConsumeCommaSeparatedList(Optimise::kYes, |
+ ConsumePrefixedBackgroundBox, range_, |
+ context_, false /* allow_text_value */); |
+ case CSSPropertyWebkitMaskComposite: |
+ return ConsumeCommaSeparatedList(Optimise::kYes, |
+ ConsumeBackgroundComposite, range_); |
case CSSPropertyWebkitMaskRepeatX: |
case CSSPropertyWebkitMaskRepeatY: |
return nullptr; |
@@ -2610,8 +2616,8 @@ static bool ConsumeBackgroundPosition(CSSParserTokenRange& range, |
UseCounter::kThreeValuedPositionBackground, position_x, |
position_y)) |
return false; |
- AddBackgroundValue(result_x, position_x); |
- AddBackgroundValue(result_y, position_y); |
+ AddListValueOptimized(result_x, position_x); |
+ AddListValueOptimized(result_y, position_y); |
} while (ConsumeCommaIncludingWhitespace(range)); |
return true; |
} |
@@ -2655,8 +2661,8 @@ static bool ConsumeRepeatStyle(CSSParserTokenRange& range, |
CSSValue* repeat_y = nullptr; |
if (!ConsumeRepeatStyleComponent(range, repeat_x, repeat_y, implicit)) |
return false; |
- AddBackgroundValue(result_x, repeat_x); |
- AddBackgroundValue(result_y, repeat_y); |
+ AddListValueOptimized(result_x, repeat_x); |
+ AddListValueOptimized(result_y, repeat_y); |
} while (ConsumeCommaIncludingWhitespace(range)); |
return true; |
} |
@@ -2716,10 +2722,10 @@ bool CSSPropertyParser::ConsumeBackgroundShorthand( |
origin_value = value; |
parsed_longhand[i] = true; |
found_property = true; |
- AddBackgroundValue(longhands[i], value); |
+ AddListValueOptimized(longhands[i], value); |
if (value_y) { |
parsed_longhand[i + 1] = true; |
- AddBackgroundValue(longhands[i + 1], value_y); |
+ AddListValueOptimized(longhands[i + 1], value_y); |
} |
} |
} |
@@ -2738,11 +2744,11 @@ bool CSSPropertyParser::ConsumeBackgroundShorthand( |
if ((property == CSSPropertyBackgroundClip || |
property == CSSPropertyWebkitMaskClip) && |
!parsed_longhand[i] && origin_value) { |
- AddBackgroundValue(longhands[i], origin_value); |
+ AddListValueOptimized(longhands[i], origin_value); |
continue; |
} |
if (!parsed_longhand[i]) |
- AddBackgroundValue(longhands[i], CSSInitialValue::Create()); |
+ AddListValueOptimized(longhands[i], CSSInitialValue::Create()); |
} |
} while (ConsumeCommaIncludingWhitespace(range_)); |
if (!range_.AtEnd()) |