Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp |
| diff --git a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp |
| index 5f4bcc3cd22f339823ee21d6b6b19639906215c4..cc6cfe380b15f646abce95aa120bc044a784a607 100644 |
| --- a/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp |
| +++ b/third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp |
| @@ -7,21 +7,27 @@ |
| #include "bindings/core/v8/ExceptionState.h" |
| #include "core/css/cssom/SimpleLength.h" |
| #include "core/css/cssom/StyleValue.h" |
| +#include "core/css/cssom/StyleValueFactory.h" |
| namespace blink { |
| StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& exceptionState) |
| { |
| CSSPropertyID propertyID = cssPropertyID(propertyName); |
| - if (propertyID != CSSPropertyInvalid) |
| - return get(propertyID); |
| + if (propertyID == CSSPropertyInvalid) { |
| + // TODO(meade): Handle custom properties here. |
| + exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| + return nullptr; |
| + } |
| - // TODO(meade): Handle custom properties here. |
| - exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| - return nullptr; |
| + StyleValueVector styleVector = getAll(propertyID); |
| + if (styleVector.isEmpty()) |
| + return nullptr; |
| + |
| + return styleVector.at(0); |
| } |
| -HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyName, ExceptionState& exceptionState) |
| +StylePropertyMap::StyleValueVector StylePropertyMap::getAll(const String& propertyName, ExceptionState& exceptionState) |
| { |
| CSSPropertyID propertyID = cssPropertyID(propertyName); |
| if (propertyID != CSSPropertyInvalid) |
| @@ -76,4 +82,25 @@ void StylePropertyMap::remove(const String& propertyName, ExceptionState& except |
| exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| } |
| +StylePropertyMap::StyleValueVector StylePropertyMap::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& cssValue) |
|
Timothy Loh
2016/04/15 04:16:08
The part of the CL which just moves code around sh
|
| +{ |
| + StyleValueVector styleValueVector; |
| + |
| + if (!cssValue.isValueList()) { |
| + StyleValue* styleValue = StyleValueFactory::create(propertyID, cssValue); |
| + if (styleValue) |
| + styleValueVector.append(styleValue); |
| + return styleValueVector; |
| + } |
| + |
| + for (const Member<CSSValue> value : *toCSSValueList(&cssValue)) { |
|
Timothy Loh
2016/04/15 04:16:08
Wasn't this CSSValue* previously?
|
| + StyleValue* styleValue = StyleValueFactory::create(propertyID, *value); |
| + if (!styleValue) |
| + return StyleValueVector(); |
| + styleValueVector.append(styleValue); |
| + } |
| + |
| + return styleValueVector; |
| +} |
| + |
| } // namespace blink |