Chromium Code Reviews| Index: Source/core/css/SVGCSSParser.cpp |
| diff --git a/Source/core/css/SVGCSSParser.cpp b/Source/core/css/SVGCSSParser.cpp |
| index 6085823fa5aa5b8311a6b18050b9fe55aafd1577..40ff73ccdbd136f51cc819bd23313021c2260fc3 100644 |
| --- a/Source/core/css/SVGCSSParser.cpp |
| +++ b/Source/core/css/SVGCSSParser.cpp |
| @@ -24,6 +24,7 @@ |
| #include "CSSPropertyNames.h" |
| #include "CSSValueKeywords.h" |
| +#include "RuntimeEnabledFeatures.h" |
| #include "core/css/CSSParser.h" |
| #include "core/css/CSSValueList.h" |
| #include "core/rendering/RenderTheme.h" |
| @@ -225,6 +226,16 @@ bool CSSParser::parseSVGValue(CSSPropertyID propId, bool important) |
| break; |
| + case CSSPropertyPaintOrder: |
| + if (!RuntimeEnabledFeatures::svg2Enabled()) |
| + return false; |
| + |
| + if (m_valueList->size() == 1 && id == CSSValueNormal) |
| + valid_primitive = true; |
| + else if ((parsedValue = parsePaintOrder())) |
| + m_valueList->next(); |
| + break; |
| + |
| case CSSPropertyVectorEffect: // none | non-scaling-stroke | inherit |
| if (id == CSSValueNone || id == CSSValueNonScalingStroke) |
| valid_primitive = true; |
| @@ -368,4 +379,56 @@ PassRefPtr<CSSValue> CSSParser::parseSVGColor() |
| return SVGColor::createFromColor(Color(c)); |
| } |
| +// normal | [ fill || stroke || markers ] |
| +PassRefPtr<CSSValue> CSSParser::parsePaintOrder() const |
| +{ |
| + if (m_valueList->size() > 3) |
| + return 0; |
| + |
| + CSSParserValue* value = m_valueList->current(); |
| + if (!value) |
| + return 0; |
| + |
| + RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated(); |
| + |
| + int defaultPaintOrder[] = { CSSValueFill, CSSValueStroke, CSSValueMarkers }; |
| + bool seen[] = { false, false, false }; |
|
pdr.
2013/06/25 15:30:45
Style nit (fix at your discretion)
I think this f
|
| + bool valid = true; |
| + |
| + do { |
| + switch (value->id) { |
| + case CSSValueNormal: |
| + // normal inside [fill || stroke || markers] not valid |
| + return 0; |
| + case CSSValueFill: |
| + if (seen[0]) |
| + return 0; |
| + |
| + seen[0] = true; |
| + break; |
| + case CSSValueStroke: |
| + if (seen[1]) |
| + return 0; |
| + |
| + seen[1] = true; |
| + break; |
| + case CSSValueMarkers: |
| + if (seen[2]) |
| + return 0; |
| + |
| + seen[2] = true; |
| + break; |
| + } |
| + |
| + parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id)); |
| + } while (value = m_valueList->next()); |
| + |
| + // fill out the rest of the paint order |
| + for (int i = 0; i < 3; i++) |
|
pdr.
2013/06/25 15:30:45
Nit: if you choose to keep this, because the body
|
| + if (!seen[i]) |
| + parsedValues->append(CSSPrimitiveValue::createIdentifier(defaultPaintOrder[i])); |
| + |
| + return parsedValues; |
| +} |
| + |
| } |