Index: third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp |
diff --git a/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp b/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp |
index 399b9d48a87c2729201d193dcb47178c37c32341..7c43738804692fe4ae343b1c6564bcc01b8f9ed3 100644 |
--- a/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp |
+++ b/third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.cpp |
@@ -4,6 +4,7 @@ |
#include "core/css/cssom/InlineStylePropertyMap.h" |
+#include "bindings/core/v8/Iterable.h" |
#include "core/CSSPropertyNames.h" |
#include "core/css/CSSPrimitiveValue.h" |
#include "core/css/CSSPropertyMetadata.h" |
@@ -15,7 +16,41 @@ |
namespace blink { |
-StyleValueVector InlineStylePropertyMap::getAll(CSSPropertyID propertyID) |
+namespace { |
+ |
+class InlineStylePropertyMapIterationSource final : public PairIterable<String, StyleValueOrStyleValueSequence>::IterationSource { |
+public: |
+ explicit InlineStylePropertyMapIterationSource(HeapVector<std::pair<String, StyleValueOrStyleValueSequence>> values) |
Timothy Loh
2016/04/15 05:27:53
let's just make a using declaration for the pair s
meade_UTC10
2016/04/27 05:39:01
Done.
|
+ : m_index(0) |
+ , m_values(values) |
+ { |
+ } |
+ |
+ bool next(ScriptState*, String& key, StyleValueOrStyleValueSequence& value, ExceptionState&) override |
+ { |
+ if (m_index >= m_values.size()) |
+ return false; |
+ |
+ std::pair<String, StyleValueOrStyleValueSequence> pair = m_values.at(m_index++); |
+ key = pair.first; |
+ value = pair.second; |
+ return true; |
+ } |
+ |
+ DEFINE_INLINE_VIRTUAL_TRACE() |
+ { |
+ visitor->trace(m_values); |
+ PairIterable<String, StyleValueOrStyleValueSequence>::IterationSource::trace(visitor); |
+ } |
+ |
+private: |
+ size_t m_index; |
+ const HeapVector<std::pair<String, StyleValueOrStyleValueSequence>> m_values; |
+}; |
+ |
+} // namespace |
+ |
+StylePropertyMap::StyleValueVector InlineStylePropertyMap::getAll(CSSPropertyID propertyID) |
{ |
CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyCSSValue(propertyID); |
if (!cssValue) |
@@ -128,5 +163,23 @@ void InlineStylePropertyMap::remove(CSSPropertyID propertyID, ExceptionState& ex |
m_ownerElement->removeInlineStyleProperty(propertyID); |
} |
+InlineStylePropertyMap::IterationSource* InlineStylePropertyMap::startIteration(ScriptState* scriptState, ExceptionState& exceptionState) |
Timothy Loh
2016/04/15 05:27:53
can we make something that works for all the maps?
meade_UTC10
2016/04/27 05:39:01
Done.
|
+{ |
+ HeapVector<std::pair<String, StyleValueOrStyleValueSequence>> result; |
+ StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle(); |
+ for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { |
+ StylePropertySet::PropertyReference propertyReference = inlineStyleSet.propertyAt(i); |
+ CSSPropertyID propertyID = propertyReference.id(); |
+ StyleValueVector styleValueVector = cssValueToStyleValueVector(propertyID, *propertyReference.value()); |
+ StyleValueOrStyleValueSequence value; |
+ if (styleValueVector.size() == 1) |
+ value.setStyleValue(styleValueVector[0]); |
+ else |
+ value.setStyleValueSequence(styleValueVector); |
+ result.append(std::make_pair(getPropertyNameString(propertyID), value)); |
+ } |
+ return new InlineStylePropertyMapIterationSource(result); |
+} |
+ |
} // namespace blink |