Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 1715513002: Move background related shorthands into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase test Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 abe82415875d441110e5c8cdb72824cf39ddc35e..e79d4b84edbd8bafdee8f0e800d342289e7569ac 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -4499,6 +4499,58 @@ bool CSSPropertyParser::consumeLegacyBreakProperty(CSSPropertyID property, bool
return true;
}
+static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParserContext& context, UnitlessQuirk unitless, RefPtrWillBeRawPtr<CSSValue>& resultX, RefPtrWillBeRawPtr<CSSValue>& resultY)
+{
+ do {
+ RefPtrWillBeRawPtr<CSSValue> positionX = nullptr;
+ RefPtrWillBeRawPtr<CSSValue> positionY = nullptr;
+ if (!consumePosition(range, context.mode(), unitless, positionX, positionY))
+ return false;
+ addBackgroundValue(resultX, positionX);
+ addBackgroundValue(resultY, positionY);
+ } while (consumeCommaIncludingWhitespace(range));
+ return true;
+}
+
+static bool consumeRepeatStyleComponent(CSSParserTokenRange& range, RefPtrWillBeRawPtr<CSSValue>& value1, RefPtrWillBeRawPtr<CSSValue>& value2, bool& implicit)
+{
+ if (consumeIdent<CSSValueRepeatX>(range)) {
+ value1 = cssValuePool().createIdentifierValue(CSSValueRepeat);
+ value2 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
+ implicit = true;
+ return true;
+ }
+ if (consumeIdent<CSSValueRepeatY>(range)) {
+ value1 = cssValuePool().createIdentifierValue(CSSValueNoRepeat);
+ value2 = cssValuePool().createIdentifierValue(CSSValueRepeat);
+ implicit = true;
+ return true;
+ }
+ value1 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSValueSpace>(range);
+ if (!value1)
+ return false;
+
+ value2 = consumeIdent<CSSValueRepeat, CSSValueNoRepeat, CSSValueRound, CSSValueSpace>(range);
+ if (!value2) {
+ value2 = value1;
+ implicit = true;
+ }
+ return true;
+}
+
+static bool consumeRepeatStyle(CSSParserTokenRange& range, RefPtrWillBeRawPtr<CSSValue>& resultX, RefPtrWillBeRawPtr<CSSValue>& resultY, bool& implicit)
+{
+ do {
+ RefPtrWillBeRawPtr<CSSValue> repeatX = nullptr;
+ RefPtrWillBeRawPtr<CSSValue> repeatY = nullptr;
+ if (!consumeRepeatStyleComponent(range, repeatX, repeatY, implicit))
+ return false;
+ addBackgroundValue(resultX, repeatX);
+ addBackgroundValue(resultY, repeatY);
+ } while (consumeCommaIncludingWhitespace(range));
+ return true;
+}
+
bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool important)
{
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
@@ -4640,6 +4692,27 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im
case CSSPropertyWebkitColumnBreakBefore:
case CSSPropertyWebkitColumnBreakInside:
return consumeLegacyBreakProperty(property, important);
+ case CSSPropertyWebkitMaskPosition:
+ case CSSPropertyBackgroundPosition: {
+ RefPtrWillBeRawPtr<CSSValue> resultX = nullptr;
+ RefPtrWillBeRawPtr<CSSValue> resultY = nullptr;
+ if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow, resultX, resultY) || !m_range.atEnd())
+ return false;
+ addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionX : CSSPropertyWebkitMaskPositionX, resultX.release(), important);
+ addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackgroundPositionY : CSSPropertyWebkitMaskPositionY, resultY.release(), important);
+ return true;
+ }
+ case CSSPropertyBackgroundRepeat:
+ case CSSPropertyWebkitMaskRepeat: {
+ RefPtrWillBeRawPtr<CSSValue> resultX = nullptr;
+ RefPtrWillBeRawPtr<CSSValue> resultY = nullptr;
+ bool implicit = false;
+ if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range.atEnd())
+ return false;
+ addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatX : CSSPropertyWebkitMaskRepeatX, resultX.release(), important, implicit);
+ addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgroundRepeatY : CSSPropertyWebkitMaskRepeatY, resultY.release(), important, implicit);
+ return true;
+ }
default:
m_currentShorthand = oldShorthand;
CSSParserValueList valueList(m_range);

Powered by Google App Engine
This is Rietveld 408576698