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

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

Issue 1252933003: Shrink SVG paint-order to take less bits (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Align with review comments Created 5 years, 5 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: Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/Source/core/css/parser/CSSPropertyParser.cpp b/Source/core/css/parser/CSSPropertyParser.cpp
index 98e638f9ab8ea36b52381bdd2c08714ac522a16f..3359feff92d6d7317b7a982de0d2c38c99f1b4c3 100644
--- a/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/Source/core/css/parser/CSSPropertyParser.cpp
@@ -7871,50 +7871,49 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePaintOrder() const
CSSParserValue* value = m_valueList->current();
ASSERT(value);
- RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated();
-
- // The default paint-order is: Fill, Stroke, Markers.
- bool seenFill = false, seenStroke = false, seenMarkers = false;
-
- for (; value; value = m_valueList->next()) {
- switch (value->id) {
- case CSSValueNormal:
- // normal inside [fill || stroke || markers] not valid
+ Vector<CSSValueID, 3> paintTypeList;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> stroke = nullptr;
+ RefPtrWillBeRawPtr<CSSPrimitiveValue> markers = nullptr;
+ while (value) {
+ if (value->id == CSSValueFill && !fill)
+ fill = CSSPrimitiveValue::createIdentifier(value->id);
+ else if (value->id == CSSValueStroke && !stroke)
+ stroke = CSSPrimitiveValue::createIdentifier(value->id);
+ else if (value->id == CSSValueMarkers && !markers)
+ markers = CSSPrimitiveValue::createIdentifier(value->id);
+ else
return nullptr;
- case CSSValueFill:
- if (seenFill)
- return nullptr;
-
- seenFill = true;
- break;
- case CSSValueStroke:
- if (seenStroke)
- return nullptr;
-
- seenStroke = true;
- break;
- case CSSValueMarkers:
- if (seenMarkers)
- return nullptr;
+ paintTypeList.append(value->id);
+ value = m_valueList->next();
+ }
- seenMarkers = true;
- break;
- default:
- return nullptr;
+ // 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());
}
-
- parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
+ 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();
}
- // fill out the rest of the paint order
- if (!seenFill)
- parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueFill));
- if (!seenStroke)
- parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueStroke));
- if (!seenMarkers)
- parsedValues->append(CSSPrimitiveValue::createIdentifier(CSSValueMarkers));
-
- return parsedValues.release();
+ return paintOrderList.release();
}
class TransformOperationInfo {
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/resolver/StyleBuilderConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698