| 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..acd32707855ea5efe193d94dcd02c03ab1d2ed70 100644
|
| --- a/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
|
| +++ b/third_party/WebKit/Source/core/css/cssom/StyleValueFactory.cpp
|
| @@ -4,40 +4,77 @@
|
|
|
| #include "core/css/cssom/StyleValueFactory.h"
|
|
|
| +#include "core/css/CSSImageValue.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"
|
| +#include "core/css/cssom/CSSURLImageValue.h"
|
| #include "core/css/cssom/CSSUnsupportedStyleValue.h"
|
|
|
| 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 styleValueVector;
|
| - default:
|
| - // TODO(meade): Implement the rest.
|
| - break;
|
| + if (value.isImageValue()) {
|
| + const CSSImageValue& imageValue = toCSSImageValue(value);
|
| + return CSSURLImageValue::create(imageValue.valueWithURLMadeAbsolute());
|
| }
|
|
|
| + 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;
|
| + }
|
| +
|
| + 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 CSSValue* innerValue : cssValueList) {
|
| + styleValue = styleValueForProperty(propertyID, *innerValue);
|
| + if (!styleValue) {
|
| + return unsupportedCSSValue(value);
|
| + }
|
| + styleValueVector.append(styleValue);
|
| + }
|
| + return styleValueVector;
|
| +}
|
| +
|
| } // namespace blink
|
|
|