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

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

Issue 1874623002: Implement iterable<DOMString, (StyleValue or sequence<StyleValue>)> for InlineStylePropertyMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@computed-stylepropertymap-2
Patch Set: Address review comments Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 the chromium authors. All rights reserved. 1 // Copyright 2016 the chromium authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/cssom/StylePropertyMap.h" 5 #include "core/css/cssom/StylePropertyMap.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/cssom/SimpleLength.h" 8 #include "core/css/cssom/SimpleLength.h"
9 #include "core/css/cssom/StyleValue.h" 9 #include "core/css/cssom/StyleValue.h"
10 #include "core/css/cssom/StyleValueFactory.h" 10 #include "core/css/cssom/StyleValueFactory.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 namespace {
15
16 class StylePropertyMapIterationSource final : public PairIterable<String, StyleV alueOrStyleValueSequence>::IterationSource {
17 public:
18 explicit StylePropertyMapIterationSource(HeapVector<StylePropertyMap::StyleP ropertyMapEntry> values)
19 : m_index(0)
20 , m_values(values)
21 {
22 }
23
24 bool next(ScriptState*, String& key, StyleValueOrStyleValueSequence& value, ExceptionState&) override
25 {
26 if (m_index >= m_values.size())
27 return false;
28
29 StylePropertyMap::StylePropertyMapEntry pair = m_values.at(m_index++);
Timothy Loh 2016/05/13 04:57:45 const Foo&
meade_UTC10 2016/05/13 05:46:34 Done.
30 key = pair.first;
31 value = pair.second;
32 return true;
33 }
34
35 DEFINE_INLINE_VIRTUAL_TRACE()
36 {
37 visitor->trace(m_values);
38 PairIterable<String, StyleValueOrStyleValueSequence>::IterationSource::t race(visitor);
39 }
40
41 private:
42 size_t m_index;
43 const HeapVector<StylePropertyMap::StylePropertyMapEntry> m_values;
44 };
45
46 } // namespace
47
14 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState) 48 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState)
15 { 49 {
16 CSSPropertyID propertyID = cssPropertyID(propertyName); 50 CSSPropertyID propertyID = cssPropertyID(propertyName);
17 if (propertyID == CSSPropertyInvalid) { 51 if (propertyID == CSSPropertyInvalid) {
18 // TODO(meade): Handle custom properties here. 52 // TODO(meade): Handle custom properties here.
19 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 53 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
20 return nullptr; 54 return nullptr;
21 } 55 }
22 56
23 StyleValueVector styleVector = getAll(propertyID); 57 StyleValueVector styleVector = getAll(propertyID);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 for (const Member<CSSValue> value : *toCSSValueList(&cssValue)) { 130 for (const Member<CSSValue> value : *toCSSValueList(&cssValue)) {
97 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value); 131 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value);
98 if (!styleValue) 132 if (!styleValue)
99 return StyleValueVector(); 133 return StyleValueVector();
100 styleValueVector.append(styleValue); 134 styleValueVector.append(styleValue);
101 } 135 }
102 136
103 return styleValueVector; 137 return styleValueVector;
104 } 138 }
105 139
140 StylePropertyMap::IterationSource* StylePropertyMap::startIteration(ScriptState* , ExceptionState&)
141 {
142 return new StylePropertyMapIterationSource(getIterationEntries());
143 }
144
106 } // namespace blink 145 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698