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

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: Update LayoutTests Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CSSValueList.h" 8 #include "core/css/CSSValueList.h"
9 #include "core/css/cssom/CSSSimpleLength.h" 9 #include "core/css/cssom/CSSSimpleLength.h"
10 #include "core/css/cssom/StyleValue.h" 10 #include "core/css/cssom/StyleValue.h"
11 #include "core/css/cssom/StyleValueFactory.h" 11 #include "core/css/cssom/StyleValueFactory.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 namespace {
16
17 class StylePropertyMapIterationSource final : public PairIterable<String, StyleV alueOrStyleValueSequence>::IterationSource {
18 public:
19 explicit StylePropertyMapIterationSource(HeapVector<StylePropertyMap::StyleP ropertyMapEntry> values)
20 : m_index(0)
21 , m_values(values)
22 {
23 }
24
25 bool next(ScriptState*, String& key, StyleValueOrStyleValueSequence& value, ExceptionState&) override
26 {
27 if (m_index >= m_values.size())
28 return false;
29
30 const StylePropertyMap::StylePropertyMapEntry& pair = m_values.at(m_inde x++);
31 key = pair.first;
32 value = pair.second;
33 return true;
34 }
35
36 DEFINE_INLINE_VIRTUAL_TRACE()
37 {
38 visitor->trace(m_values);
39 PairIterable<String, StyleValueOrStyleValueSequence>::IterationSource::t race(visitor);
40 }
41
42 private:
43 size_t m_index;
44 const HeapVector<StylePropertyMap::StylePropertyMapEntry> m_values;
45 };
46
47 } // namespace
48
15 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState) 49 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState)
16 { 50 {
17 CSSPropertyID propertyID = cssPropertyID(propertyName); 51 CSSPropertyID propertyID = cssPropertyID(propertyName);
18 if (propertyID == CSSPropertyInvalid) { 52 if (propertyID == CSSPropertyInvalid) {
19 // TODO(meade): Handle custom properties here. 53 // TODO(meade): Handle custom properties here.
20 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 54 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
21 return nullptr; 55 return nullptr;
22 } 56 }
23 57
24 StyleValueVector styleVector = getAll(propertyID); 58 StyleValueVector styleVector = getAll(propertyID);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 130
97 for (CSSValue* value : *toCSSValueList(&cssValue)) { 131 for (CSSValue* value : *toCSSValueList(&cssValue)) {
98 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value); 132 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value);
99 if (!styleValue) 133 if (!styleValue)
100 return StyleValueVector(); 134 return StyleValueVector();
101 styleValueVector.append(styleValue); 135 styleValueVector.append(styleValue);
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
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/StylePropertyMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698