Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp |
| index e710d8f8a8a0b94a98fc72d57939bc72020111fd..edb693bbf13173ad65fe6b18cdf76c147446f3e2 100644 |
| --- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp |
| +++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp |
| @@ -5,6 +5,7 @@ |
| #include "core/css/cssom/StyleValueFactory.h" |
| #include "core/css/CSSValue.h" |
| +#include "core/css/cssom/CSSNumberValue.h" |
| #include "core/css/cssom/CSSSimpleLength.h" |
| #include "core/css/cssom/CSSStyleValue.h" |
| #include "core/css/cssom/CSSTransformValue.h" |
| @@ -12,31 +13,60 @@ |
| namespace blink { |
| -CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value) |
| +namespace { |
| + |
| +CSSStyleValue* styleValueForProperty(CSSPropertyID propertyID, const CSSValue& value) |
| { |
| - CSSStyleValueVector styleValueVector; |
| + switch (propertyID) { |
| + case CSSPropertyTransform: |
| + return CSSTransformValue::fromCSSValue(value); |
| + default: |
| + // TODO(meade): Implement other complex properties. |
| + break; |
| + } |
| if (value.isPrimitiveValue()) { |
| const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| - if (primitiveValue.isLength() && !primitiveValue.isCalculated()) { |
| - styleValueVector.append(CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved())); |
| - return styleValueVector; |
| - } |
| + if (primitiveValue.isLength() && !primitiveValue.isCalculated()) |
| + return CSSSimpleLength::create(primitiveValue.getDoubleValue(), primitiveValue.typeWithCalcResolved()); |
| + if (primitiveValue.isNumber()) |
| + return CSSNumberValue::create(primitiveValue.getDoubleValue()); |
| } |
| - CSSStyleValue* styleValue = nullptr; |
| - switch (propertyID) { |
| - case CSSPropertyTransform: |
| - styleValue = CSSTransformValue::fromCSSValue(value); |
| - if (styleValue) |
| - styleValueVector.append(styleValue); |
| + return nullptr; |
| +} |
| + |
| +CSSStyleValueVector unsupportedCSSValue(const CSSValue& value) |
| +{ |
| + CSSStyleValueVector styleValueVector; |
| + styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); |
| + return styleValueVector; |
| +} |
| + |
| +} // namespace |
| + |
| +CSSStyleValueVector StyleValueFactory::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& value) |
| +{ |
| + CSSStyleValueVector styleValueVector; |
| + CSSStyleValue* styleValue = styleValueForProperty(propertyID, value); |
| + if (styleValue) { |
| + styleValueVector.append(styleValue); |
| return styleValueVector; |
| - default: |
| - // TODO(meade): Implement the rest. |
| - break; |
| } |
| - styleValueVector.append(CSSUnsupportedStyleValue::create(value.cssText())); |
| + if (!value.isValueList()) { |
| + return unsupportedCSSValue(value); |
| + } |
| + |
| + // If it's a list, we can try it as a list valued property. |
| + const CSSValueList& cssValueList = toCSSValueList(value); |
| + for (const Member<const CSSValue> innerValue : cssValueList) { |
|
Timothy Loh
2016/07/05 05:50:03
for (const CSSValue* innerValue :
It's weird to h
meade_UTC10
2016/07/05 07:05:22
Agreed, done.
|
| + styleValue = styleValueForProperty(propertyID, *innerValue); |
| + if (!styleValue) { |
| + return unsupportedCSSValue(value); |
| + } |
| + styleValueVector.append(styleValue); |
| + } |
| return styleValueVector; |
| } |