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..04f70df7b4a1b1214fe0d6af0868dbc193240ca6 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,24 @@ void StylePropertyMap::remove(const String& propertyName, ExceptionState& except |
exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
} |
+StylePropertyMap::StyleValueVector StylePropertyMap::cssValueToStyleValueVector(CSSPropertyID propertyID, const CSSValue& cssValue) |
+{ |
+ 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)) { |
+ StyleValue* styleValue = StyleValueFactory::create(propertyID, *value); |
+ if (styleValue) |
+ styleValueVector.append(styleValue); |
+ } |
+ |
+ return styleValueVector; |
+} |
+ |
} // namespace blink |