Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: third_party/WebKit/Source/core/css/cssom/StylePropertyMap.cpp

Issue 1849653003: Implement ComputedStylePropertyMap for Typed OM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maps-inline
Patch Set: Update global-interface-listing Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698