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

Side by Side 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, 8 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 11
11 namespace blink { 12 namespace blink {
12 13
13 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState) 14 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex ceptionState)
14 { 15 {
15 CSSPropertyID propertyID = cssPropertyID(propertyName); 16 CSSPropertyID propertyID = cssPropertyID(propertyName);
16 if (propertyID != CSSPropertyInvalid) 17 if (propertyID == CSSPropertyInvalid) {
17 return get(propertyID); 18 // TODO(meade): Handle custom properties here.
19 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
20 return nullptr;
21 }
18 22
19 // TODO(meade): Handle custom properties here. 23 StyleValueVector styleVector = getAll(propertyID);
20 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 24 if (styleVector.isEmpty())
21 return nullptr; 25 return nullptr;
26
27 return styleVector.at(0);
22 } 28 }
23 29
24 HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyNa me, ExceptionState& exceptionState) 30 StylePropertyMap::StyleValueVector StylePropertyMap::getAll(const String& proper tyName, ExceptionState& exceptionState)
25 { 31 {
26 CSSPropertyID propertyID = cssPropertyID(propertyName); 32 CSSPropertyID propertyID = cssPropertyID(propertyName);
27 if (propertyID != CSSPropertyInvalid) 33 if (propertyID != CSSPropertyInvalid)
28 return getAll(propertyID); 34 return getAll(propertyID);
29 35
30 // TODO(meade): Handle custom properties here. 36 // TODO(meade): Handle custom properties here.
31 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 37 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
32 return HeapVector<Member<StyleValue>>(); 38 return HeapVector<Member<StyleValue>>();
33 } 39 }
34 40
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 { 75 {
70 CSSPropertyID propertyID = cssPropertyID(propertyName); 76 CSSPropertyID propertyID = cssPropertyID(propertyName);
71 if (propertyID != CSSPropertyInvalid) { 77 if (propertyID != CSSPropertyInvalid) {
72 remove(propertyID, exceptionState); 78 remove(propertyID, exceptionState);
73 return; 79 return;
74 } 80 }
75 // TODO(meade): Handle custom properties here. 81 // TODO(meade): Handle custom properties here.
76 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); 82 exceptionState.throwTypeError("Invalid propertyName: " + propertyName);
77 } 83 }
78 84
85 StylePropertyMap::StyleValueVector StylePropertyMap::cssValueToStyleValueVector( CSSPropertyID propertyID, const CSSValue& cssValue)
86 {
87 StyleValueVector styleValueVector;
88
89 if (!cssValue.isValueList()) {
90 StyleValue* styleValue = StyleValueFactory::create(propertyID, cssValue) ;
91 if (styleValue)
92 styleValueVector.append(styleValue);
93 return styleValueVector;
94 }
95
96 for (const Member<CSSValue> value : *toCSSValueList(&cssValue)) {
97 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value);
98 if (styleValue)
99 styleValueVector.append(styleValue);
100 }
101
102 return styleValueVector;
103 }
104
79 } // namespace blink 105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698