Commit e19e177e authored by Bugs Nash's avatar Bugs Nash Committed by Commit Bot

Refactored out need to pass CSSPropertyID in background list parsing.

Rewritten from https://codereview.chromium.org/2897833004, this version
does not use the memory optimisation which has since been removed from
the code.

This patch
- Split property specific parsing logic for background components
  into the case statements in CSSPropertyParser::ParseSingleValue,
  using the general ConsumeCommaSeparatedList template instead of
  ConsumeCommaSeparatedBackgroundComponent so that CSSPropertyID
  no longer needs to be passed.
- Delted ConsumeCommaSeparatedBackgroundComponent (now unused).

NB
- ConsumeBackgroundComponent is still currently used in
  ConsumeBackgroundShorthand and so cannot be deleted.
- Some bool literals are passed in this patch, violating the style
  guide. These arguments were not introduced in this patch and so
  will not be fixed in this patch. They will be converted to enums
  when the APIs are implemented.

Bug: 668012
Change-Id: Ie364b810e10f0df3b3053e337d47fd60118cc985
Reviewed-on: https://chromium-review.googlesource.com/575253Reviewed-by: default avatarRenée Wright <rjwright@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Bugs Nash <bugsnash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488613}
parent 3f3b0167
...@@ -682,21 +682,6 @@ static CSSValue* ConsumeBackgroundComponent(CSSPropertyID unresolved_property, ...@@ -682,21 +682,6 @@ static CSSValue* ConsumeBackgroundComponent(CSSPropertyID unresolved_property,
return nullptr; return nullptr;
} }
static CSSValueList* ConsumeCommaSeparatedBackgroundComponent(
CSSPropertyID unresolved_property,
CSSParserTokenRange& range,
const CSSParserContext* context) {
CSSValueList* result = CSSValueList::CreateCommaSeparated();
do {
CSSValue* value =
ConsumeBackgroundComponent(unresolved_property, range, context);
if (!value)
return nullptr;
result->Append(*value);
} while (ConsumeCommaIncludingWhitespace(range));
return result;
}
static CSSValue* ConsumeFitContent(CSSParserTokenRange& range, static CSSValue* ConsumeFitContent(CSSParserTokenRange& range,
CSSParserMode css_parser_mode) { CSSParserMode css_parser_mode) {
CSSParserTokenRange range_copy = range; CSSParserTokenRange range_copy = range;
...@@ -1217,25 +1202,44 @@ const CSSValue* CSSPropertyParser::ParseSingleValue( ...@@ -1217,25 +1202,44 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
case CSSPropertyWebkitMaskBoxImageWidth: case CSSPropertyWebkitMaskBoxImageWidth:
return CSSPropertyBorderImageUtils::ConsumeBorderImageWidth(range_); return CSSPropertyBorderImageUtils::ConsumeBorderImageWidth(range_);
case CSSPropertyBackgroundAttachment: case CSSPropertyBackgroundAttachment:
return ConsumeCommaSeparatedList(ConsumeBackgroundAttachment, range_);
case CSSPropertyBackgroundBlendMode: case CSSPropertyBackgroundBlendMode:
return ConsumeCommaSeparatedList(ConsumeBackgroundBlendMode, range_);
case CSSPropertyBackgroundClip: case CSSPropertyBackgroundClip:
case CSSPropertyBackgroundImage:
case CSSPropertyBackgroundOrigin: case CSSPropertyBackgroundOrigin:
return ConsumeCommaSeparatedList(ConsumeBackgroundBox, range_);
case CSSPropertyBackgroundImage:
case CSSPropertyWebkitMaskImage:
return ConsumeCommaSeparatedList(ConsumeImageOrNone, range_, context_);
case CSSPropertyBackgroundPositionX: case CSSPropertyBackgroundPositionX:
case CSSPropertyWebkitMaskPositionX:
return ConsumeCommaSeparatedList(
CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueLeft,
CSSValueRight>,
range_, context_->Mode());
case CSSPropertyBackgroundPositionY: case CSSPropertyBackgroundPositionY:
case CSSPropertyWebkitMaskPositionY:
return ConsumeCommaSeparatedList(
CSSPropertyPositionUtils::ConsumePositionLonghand<CSSValueTop,
CSSValueBottom>,
range_, context_->Mode());
case CSSPropertyBackgroundSize: case CSSPropertyBackgroundSize:
case CSSPropertyWebkitMaskSize:
return ConsumeCommaSeparatedList(ConsumeBackgroundSize, range_,
context_->Mode(),
isPropertyAlias(unresolved_property));
case CSSPropertyMaskSourceType: case CSSPropertyMaskSourceType:
return ConsumeCommaSeparatedList(ConsumeMaskSourceType, range_);
case CSSPropertyWebkitBackgroundClip: case CSSPropertyWebkitBackgroundClip:
case CSSPropertyWebkitBackgroundOrigin:
case CSSPropertyWebkitMaskClip: case CSSPropertyWebkitMaskClip:
case CSSPropertyWebkitMaskComposite: return ConsumeCommaSeparatedList(ConsumePrefixedBackgroundBox, range_,
case CSSPropertyWebkitMaskImage: context_, true /* allow_text_value */);
case CSSPropertyWebkitBackgroundOrigin:
case CSSPropertyWebkitMaskOrigin: case CSSPropertyWebkitMaskOrigin:
case CSSPropertyWebkitMaskPositionX: return ConsumeCommaSeparatedList(ConsumePrefixedBackgroundBox, range_,
case CSSPropertyWebkitMaskPositionY: context_, false /* allow_text_value */);
case CSSPropertyWebkitMaskSize: case CSSPropertyWebkitMaskComposite:
return ConsumeCommaSeparatedBackgroundComponent(unresolved_property, return ConsumeCommaSeparatedList(ConsumeBackgroundComposite, range_);
range_, context_);
case CSSPropertyWebkitMaskRepeatX: case CSSPropertyWebkitMaskRepeatX:
case CSSPropertyWebkitMaskRepeatY: case CSSPropertyWebkitMaskRepeatY:
return nullptr; return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment