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

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

Issue 2036893003: [CSS Typed OM] Rename StyleValue -> CSSStyleValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update more union types 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
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/CSSStyleValue.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 { 15 namespace {
16 16
17 class StylePropertyMapIterationSource final : public PairIterable<String, StyleV alueOrStyleValueSequence>::IterationSource { 17 class StylePropertyMapIterationSource final : public PairIterable<String, CSSSty leValueOrCSSStyleValueSequence>::IterationSource {
18 public: 18 public:
19 explicit StylePropertyMapIterationSource(HeapVector<StylePropertyMap::StyleP ropertyMapEntry> values) 19 explicit StylePropertyMapIterationSource(HeapVector<StylePropertyMap::StyleP ropertyMapEntry> values)
20 : m_index(0) 20 : m_index(0)
21 , m_values(values) 21 , m_values(values)
22 { 22 {
23 } 23 }
24 24
25 bool next(ScriptState*, String& key, StyleValueOrStyleValueSequence& value, ExceptionState&) override 25 bool next(ScriptState*, String& key, CSSStyleValueOrCSSStyleValueSequence& v alue, ExceptionState&) override
26 { 26 {
27 if (m_index >= m_values.size()) 27 if (m_index >= m_values.size())
28 return false; 28 return false;
29 29
30 const StylePropertyMap::StylePropertyMapEntry& pair = m_values.at(m_inde x++); 30 const StylePropertyMap::StylePropertyMapEntry& pair = m_values.at(m_inde x++);
31 key = pair.first; 31 key = pair.first;
32 value = pair.second; 32 value = pair.second;
33 return true; 33 return true;
34 } 34 }
35 35
36 DEFINE_INLINE_VIRTUAL_TRACE() 36 DEFINE_INLINE_VIRTUAL_TRACE()
37 { 37 {
38 visitor->trace(m_values); 38 visitor->trace(m_values);
39 PairIterable<String, StyleValueOrStyleValueSequence>::IterationSource::t race(visitor); 39 PairIterable<String, CSSStyleValueOrCSSStyleValueSequence>::IterationSou rce::trace(visitor);
40 } 40 }
41 41
42 private: 42 private:
43 size_t m_index; 43 size_t m_index;
44 const HeapVector<StylePropertyMap::StylePropertyMapEntry> m_values; 44 const HeapVector<StylePropertyMap::StylePropertyMapEntry> m_values;
45 }; 45 };
46 46
47 } // namespace 47 } // namespace
48 48
49 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState) 49 CSSStyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& exceptionState)
50 { 50 {
51 CSSPropertyID propertyID = cssPropertyID(propertyName); 51 CSSPropertyID propertyID = cssPropertyID(propertyName);
52 if (propertyID == CSSPropertyInvalid) { 52 if (propertyID == CSSPropertyInvalid) {
53 // TODO(meade): Handle custom properties here. 53 // TODO(meade): Handle custom properties here.
54 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 54 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
55 return nullptr; 55 return nullptr;
56 } 56 }
57 57
58 StyleValueVector styleVector = getAll(propertyID); 58 StyleValueVector styleVector = getAll(propertyID);
59 if (styleVector.isEmpty()) 59 if (styleVector.isEmpty())
(...skipping 17 matching lines...) Expand all
77 { 77 {
78 CSSPropertyID propertyID = cssPropertyID(propertyName); 78 CSSPropertyID propertyID = cssPropertyID(propertyName);
79 if (propertyID != CSSPropertyInvalid) 79 if (propertyID != CSSPropertyInvalid)
80 return !getAll(propertyID).isEmpty(); 80 return !getAll(propertyID).isEmpty();
81 81
82 // TODO(meade): Handle custom properties here. 82 // TODO(meade): Handle custom properties here.
83 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 83 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
84 return false; 84 return false;
85 } 85 }
86 86
87 void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSeq uenceOrString& item, ExceptionState& exceptionState) 87 void StylePropertyMap::set(const String& propertyName, CSSStyleValueOrCSSStyleVa lueSequenceOrString& item, ExceptionState& exceptionState)
88 { 88 {
89 CSSPropertyID propertyID = cssPropertyID(propertyName); 89 CSSPropertyID propertyID = cssPropertyID(propertyName);
90 if (propertyID != CSSPropertyInvalid) { 90 if (propertyID != CSSPropertyInvalid) {
91 set(propertyID, item, exceptionState); 91 set(propertyID, item, exceptionState);
92 return; 92 return;
93 } 93 }
94 // TODO(meade): Handle custom properties here. 94 // TODO(meade): Handle custom properties here.
95 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 95 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
96 } 96 }
97 97
98 void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValue SequenceOrString& item, ExceptionState& exceptionState) 98 void StylePropertyMap::append(const String& propertyName, CSSStyleValueOrCSSStyl eValueSequenceOrString& item, ExceptionState& exceptionState)
99 { 99 {
100 CSSPropertyID propertyID = cssPropertyID(propertyName); 100 CSSPropertyID propertyID = cssPropertyID(propertyName);
101 if (propertyID != CSSPropertyInvalid) { 101 if (propertyID != CSSPropertyInvalid) {
102 append(propertyID, item, exceptionState); 102 append(propertyID, item, exceptionState);
103 return; 103 return;
104 } 104 }
105 // TODO(meade): Handle custom properties here. 105 // TODO(meade): Handle custom properties here.
106 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 106 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
107 } 107 }
108 108
109 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except ionState) 109 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except ionState)
110 { 110 {
111 CSSPropertyID propertyID = cssPropertyID(propertyName); 111 CSSPropertyID propertyID = cssPropertyID(propertyName);
112 if (propertyID != CSSPropertyInvalid) { 112 if (propertyID != CSSPropertyInvalid) {
113 remove(propertyID, exceptionState); 113 remove(propertyID, exceptionState);
114 return; 114 return;
115 } 115 }
116 // TODO(meade): Handle custom properties here. 116 // TODO(meade): Handle custom properties here.
117 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 117 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
118 } 118 }
119 119
120 StylePropertyMap::StyleValueVector StylePropertyMap::cssValueToStyleValueVector( CSSPropertyID propertyID, const CSSValue& cssValue) 120 StylePropertyMap::StyleValueVector StylePropertyMap::cssValueToStyleValueVector( CSSPropertyID propertyID, const CSSValue& cssValue)
121 { 121 {
122 StyleValueVector styleValueVector; 122 StyleValueVector styleValueVector;
123 123
124 if (!cssValue.isValueList()) { 124 if (!cssValue.isValueList()) {
125 StyleValue* styleValue = StyleValueFactory::create(propertyID, cssValue) ; 125 CSSStyleValue* styleValue = StyleValueFactory::create(propertyID, cssVal ue);
126 if (styleValue) 126 if (styleValue)
127 styleValueVector.append(styleValue); 127 styleValueVector.append(styleValue);
128 return styleValueVector; 128 return styleValueVector;
129 } 129 }
130 130
131 for (CSSValue* value : *toCSSValueList(&cssValue)) { 131 for (CSSValue* value : *toCSSValueList(&cssValue)) {
132 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value); 132 CSSStyleValue* styleValue = StyleValueFactory::create(propertyID, *value );
133 if (!styleValue) 133 if (!styleValue)
134 return StyleValueVector(); 134 return StyleValueVector();
135 styleValueVector.append(styleValue); 135 styleValueVector.append(styleValue);
136 } 136 }
137 return styleValueVector; 137 return styleValueVector;
138 } 138 }
139 139
140 StylePropertyMap::IterationSource* StylePropertyMap::startIteration(ScriptState* , ExceptionState&) 140 StylePropertyMap::IterationSource* StylePropertyMap::startIteration(ScriptState* , ExceptionState&)
141 { 141 {
142 return new StylePropertyMapIterationSource(getIterationEntries()); 142 return new StylePropertyMapIterationSource(getIterationEntries());
143 } 143 }
144 144
145 } // namespace blink 145 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698