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

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

Issue 1451053002: Move paint-order property into CSSPropertyParser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 5 years, 1 month 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 c71f77870d641e5d76a304c320cf887717bacad8..05d164421a65ccafbb6d5036b67afaaba731bdd6 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -1775,6 +1775,56 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumePaint(CSSParserTokenRange& range,
return consumeColor(range, context);
}
+static PassRefPtrWillBeRawPtr<CSSValue> consumePaintOrder(CSSParserTokenRange& range)
+{
+ if (range.peek().id() == CSSValueNormal)
+ return consumeIdent(range);
+
+ Vector<CSSValueID, 3> paintTypeList;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> stroke = nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> markers = nullptr;
+ do {
+ CSSValueID id = range.peek().id();
+ if (id == CSSValueFill && !fill)
+ fill = consumeIdent(range);
+ else if (id == CSSValueStroke && !stroke)
+ stroke = consumeIdent(range);
+ else if (id == CSSValueMarkers && !markers)
+ markers = consumeIdent(range);
+ else
+ return nullptr;
+ paintTypeList.append(id);
+ } while (!range.atEnd());
+
+ // After parsing we serialize the paint-order list. Since it is not possible to
+ // pop a last list items from CSSValueList without bigger cost, we create the
+ // list after parsing.
+ CSSValueID firstPaintOrderType = paintTypeList.at(0);
+ RefPtrWillBeRawPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceSeparated();
+ switch (firstPaintOrderType) {
+ case CSSValueFill:
+ case CSSValueStroke:
+ paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.release() : stroke.release());
+ if (paintTypeList.size() > 1) {
+ if (paintTypeList.at(1) == CSSValueMarkers)
+ paintOrderList->append(markers.release());
+ }
+ break;
+ case CSSValueMarkers:
+ paintOrderList->append(markers.release());
+ if (paintTypeList.size() > 1) {
+ if (paintTypeList.at(1) == CSSValueStroke)
+ paintOrderList->append(stroke.release());
+ }
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return paintOrderList.release();
+}
+
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty)
{
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
@@ -1929,6 +1979,8 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
case CSSPropertyFill:
case CSSPropertyStroke:
return consumePaint(m_range, m_context);
+ case CSSPropertyPaintOrder:
+ return consumePaintOrder(m_range);
default:
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698