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 004a9552fdf5f151421fa59ce754a44a0daeb6a2..c35a2c59477b1f00a9c604cac18de34a1754e462 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp |
@@ -42,6 +42,7 @@ |
#include "core/css/parser/CSSVariableParser.h" |
#include "core/css/parser/FontVariantLigaturesParser.h" |
#include "core/css/properties/CSSPropertyAlignmentUtils.h" |
+#include "core/css/properties/CSSPropertyBackgroundComponentUtils.h" |
#include "core/css/properties/CSSPropertyColumnUtils.h" |
#include "core/css/properties/CSSPropertyDescriptor.h" |
#include "core/css/properties/CSSPropertyLengthUtils.h" |
@@ -1635,136 +1636,6 @@ static CSSValue* consumeImageOrientation(CSSParserTokenRange& range) { |
return nullptr; |
} |
-static CSSValue* consumeBackgroundBlendMode(CSSParserTokenRange& range) { |
- CSSValueID id = range.peek().id(); |
- if (id == CSSValueNormal || id == CSSValueOverlay || |
- (id >= CSSValueMultiply && id <= CSSValueLuminosity)) |
- return consumeIdent(range); |
- return nullptr; |
-} |
- |
-static CSSValue* consumeBackgroundAttachment(CSSParserTokenRange& range) { |
- return consumeIdent<CSSValueScroll, CSSValueFixed, CSSValueLocal>(range); |
-} |
- |
-static CSSValue* consumeBackgroundBox(CSSParserTokenRange& range) { |
- return consumeIdent<CSSValueBorderBox, CSSValuePaddingBox, |
- CSSValueContentBox>(range); |
-} |
- |
-static CSSValue* consumeBackgroundComposite(CSSParserTokenRange& range) { |
- return consumeIdentRange(range, CSSValueClear, CSSValuePlusLighter); |
-} |
- |
-static CSSValue* consumeMaskSourceType(CSSParserTokenRange& range) { |
- ASSERT(RuntimeEnabledFeatures::cssMaskSourceTypeEnabled()); |
- return consumeIdent<CSSValueAuto, CSSValueAlpha, CSSValueLuminance>(range); |
-} |
- |
-static CSSValue* consumePrefixedBackgroundBox(CSSPropertyID property, |
- CSSParserTokenRange& range, |
- const CSSParserContext* context) { |
- // The values 'border', 'padding' and 'content' are deprecated and do not |
- // apply to the version of the property that has the -webkit- prefix removed. |
- if (CSSValue* value = |
- consumeIdentRange(range, CSSValueBorder, CSSValuePaddingBox)) |
- return value; |
- if ((property == CSSPropertyWebkitBackgroundClip || |
- property == CSSPropertyWebkitMaskClip) && |
- range.peek().id() == CSSValueText) |
- return consumeIdent(range); |
- return nullptr; |
-} |
- |
-static CSSValue* consumeBackgroundSize(CSSPropertyID unresolvedProperty, |
- CSSParserTokenRange& range, |
- CSSParserMode cssParserMode) { |
- if (identMatches<CSSValueContain, CSSValueCover>(range.peek().id())) |
- return consumeIdent(range); |
- |
- CSSValue* horizontal = consumeIdent<CSSValueAuto>(range); |
- if (!horizontal) |
- horizontal = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, |
- UnitlessQuirk::Forbid); |
- |
- CSSValue* vertical = nullptr; |
- if (!range.atEnd()) { |
- if (range.peek().id() == CSSValueAuto) // `auto' is the default |
- range.consumeIncludingWhitespace(); |
- else |
- vertical = consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, |
- UnitlessQuirk::Forbid); |
- } else if (unresolvedProperty == CSSPropertyAliasWebkitBackgroundSize) { |
- // Legacy syntax: "-webkit-background-size: 10px" is equivalent to |
- // "background-size: 10px 10px". |
- vertical = horizontal; |
- } |
- if (!vertical) |
- return horizontal; |
- return CSSValuePair::create(horizontal, vertical, |
- CSSValuePair::KeepIdenticalValues); |
-} |
- |
-static CSSValue* consumeBackgroundComponent(CSSPropertyID unresolvedProperty, |
- CSSParserTokenRange& range, |
- const CSSParserContext* context) { |
- switch (unresolvedProperty) { |
- case CSSPropertyBackgroundClip: |
- return consumeBackgroundBox(range); |
- case CSSPropertyBackgroundBlendMode: |
- return consumeBackgroundBlendMode(range); |
- case CSSPropertyBackgroundAttachment: |
- return consumeBackgroundAttachment(range); |
- case CSSPropertyBackgroundOrigin: |
- return consumeBackgroundBox(range); |
- case CSSPropertyWebkitMaskComposite: |
- return consumeBackgroundComposite(range); |
- case CSSPropertyMaskSourceType: |
- return consumeMaskSourceType(range); |
- case CSSPropertyWebkitBackgroundClip: |
- case CSSPropertyWebkitBackgroundOrigin: |
- case CSSPropertyWebkitMaskClip: |
- case CSSPropertyWebkitMaskOrigin: |
- return consumePrefixedBackgroundBox(unresolvedProperty, range, context); |
- case CSSPropertyBackgroundImage: |
- case CSSPropertyWebkitMaskImage: |
- return consumeImageOrNone(range, context); |
- case CSSPropertyBackgroundPositionX: |
- case CSSPropertyWebkitMaskPositionX: |
- return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueLeft, |
- CSSValueRight>( |
- range, context->mode()); |
- case CSSPropertyBackgroundPositionY: |
- case CSSPropertyWebkitMaskPositionY: |
- return CSSPropertyPositionUtils::consumePositionLonghand<CSSValueTop, |
- CSSValueBottom>( |
- range, context->mode()); |
- case CSSPropertyBackgroundSize: |
- case CSSPropertyAliasWebkitBackgroundSize: |
- case CSSPropertyWebkitMaskSize: |
- return consumeBackgroundSize(unresolvedProperty, range, context->mode()); |
- case CSSPropertyBackgroundColor: |
- return consumeColor(range, context->mode()); |
- default: |
- break; |
- }; |
- return nullptr; |
-} |
- |
-static void addBackgroundValue(CSSValue*& list, CSSValue* value) { |
- if (list) { |
- if (!list->isBaseValueList()) { |
- CSSValue* firstValue = list; |
- list = CSSValueList::createCommaSeparated(); |
- toCSSValueList(list)->append(*firstValue); |
- } |
- 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 unresolvedProperty, |
CSSParserTokenRange& range, |
@@ -1772,10 +1643,11 @@ static CSSValue* consumeCommaSeparatedBackgroundComponent( |
CSSValue* result = nullptr; |
do { |
CSSValue* value = |
- consumeBackgroundComponent(unresolvedProperty, range, context); |
+ CSSPropertyBackgroundComponentUtils::consumeBackgroundComponent( |
+ unresolvedProperty, range, context); |
if (!value) |
return nullptr; |
- addBackgroundValue(result, value); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(result, value); |
} while (consumeCommaIncludingWhitespace(range)); |
return result; |
} |
@@ -3385,8 +3257,8 @@ static bool consumeBackgroundPosition(CSSParserTokenRange& range, |
if (!consumePosition(range, context->mode(), unitless, positionX, |
positionY)) |
return false; |
- addBackgroundValue(resultX, positionX); |
- addBackgroundValue(resultY, positionY); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(resultX, positionX); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(resultY, positionY); |
} while (consumeCommaIncludingWhitespace(range)); |
return true; |
} |
@@ -3430,8 +3302,8 @@ static bool consumeRepeatStyle(CSSParserTokenRange& range, |
CSSValue* repeatY = nullptr; |
if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit)) |
return false; |
- addBackgroundValue(resultX, repeatX); |
- addBackgroundValue(resultY, repeatY); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(resultX, repeatX); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(resultY, repeatY); |
} while (consumeCommaIncludingWhitespace(range)); |
return true; |
} |
@@ -3470,7 +3342,8 @@ bool CSSPropertyParser::consumeBackgroundShorthand( |
property == CSSPropertyWebkitMaskSize) { |
if (!consumeSlashIncludingWhitespace(m_range)) |
continue; |
- value = consumeBackgroundSize(property, m_range, m_context->mode()); |
+ value = CSSPropertyBackgroundComponentUtils::consumeBackgroundSize( |
+ property, m_range, m_context->mode()); |
if (!value || !parsedLonghand[i - 1]) // Position must have been |
// parsed in the current layer. |
return false; |
@@ -3480,7 +3353,9 @@ bool CSSPropertyParser::consumeBackgroundShorthand( |
property == CSSPropertyWebkitMaskRepeatY) { |
continue; |
} else { |
- value = consumeBackgroundComponent(property, m_range, m_context); |
+ value = |
+ CSSPropertyBackgroundComponentUtils::consumeBackgroundComponent( |
+ property, m_range, m_context); |
} |
if (value) { |
if (property == CSSPropertyBackgroundOrigin || |
@@ -3488,10 +3363,12 @@ bool CSSPropertyParser::consumeBackgroundShorthand( |
originValue = value; |
parsedLonghand[i] = true; |
foundProperty = true; |
- addBackgroundValue(longhands[i], value); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(longhands[i], |
+ value); |
if (valueY) { |
parsedLonghand[i + 1] = true; |
- addBackgroundValue(longhands[i + 1], valueY); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue( |
+ longhands[i + 1], valueY); |
} |
} |
} |
@@ -3510,11 +3387,14 @@ bool CSSPropertyParser::consumeBackgroundShorthand( |
if ((property == CSSPropertyBackgroundClip || |
property == CSSPropertyWebkitMaskClip) && |
!parsedLonghand[i] && originValue) { |
- addBackgroundValue(longhands[i], originValue); |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue(longhands[i], |
+ originValue); |
continue; |
} |
- if (!parsedLonghand[i]) |
- addBackgroundValue(longhands[i], CSSInitialValue::create()); |
+ if (!parsedLonghand[i]) { |
+ CSSPropertyBackgroundComponentUtils::addBackgroundValue( |
+ longhands[i], CSSInitialValue::create()); |
+ } |
} |
} while (consumeCommaIncludingWhitespace(m_range)); |
if (!m_range.atEnd()) |