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

Side by Side Diff: third_party/WebKit/Source/core/css/cssom/InlineStylePropertyMap.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/InlineStylePropertyMap.h" 5 #include "core/css/cssom/InlineStylePropertyMap.h"
6 6
7 #include "core/CSSPropertyNames.h" 7 #include "core/CSSPropertyNames.h"
8 #include "core/css/CSSPrimitiveValue.h" 8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/CSSPropertyMetadata.h" 9 #include "core/css/CSSPropertyMetadata.h"
10 #include "core/css/CSSValueList.h" 10 #include "core/css/CSSValueList.h"
11 #include "core/css/StylePropertySet.h" 11 #include "core/css/StylePropertySet.h"
12 #include "core/css/cssom/CSSOMTypes.h" 12 #include "core/css/cssom/CSSOMTypes.h"
13 #include "core/css/cssom/SimpleLength.h" 13 #include "core/css/cssom/SimpleLength.h"
14 #include "core/css/cssom/StyleValueFactory.h" 14 #include "core/css/cssom/StyleValueFactory.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 StyleValue* InlineStylePropertyMap::get(CSSPropertyID propertyID)
19 {
20 ASSERT(propertyID != CSSPropertyInvalid);
21
22 StyleValueVector styleVector = getAll(propertyID);
23 if (styleVector.isEmpty())
24 return nullptr;
25
26 return styleVector.at(0);
27 }
28
29 StyleValueVector InlineStylePropertyMap::getAll(CSSPropertyID propertyID) 18 StyleValueVector InlineStylePropertyMap::getAll(CSSPropertyID propertyID)
30 { 19 {
31 ASSERT(propertyID != CSSPropertyInvalid); 20 ASSERT(propertyID != CSSPropertyInvalid);
32 21
33 RefPtrWillBeRawPtr<CSSValue> cssValue = m_ownerElement->ensureMutableInlineS tyle().getPropertyCSSValue(propertyID); 22 RefPtrWillBeRawPtr<CSSValue> cssValue = m_ownerElement->ensureMutableInlineS tyle().getPropertyCSSValue(propertyID);
34 if (!cssValue) 23 if (!cssValue)
35 return StyleValueVector(); 24 return StyleValueVector();
36 25
37 StyleValueVector styleValueVector; 26 return cssValueToStyleValueVector(propertyID, *cssValue);
38
39 if (!cssValue->isValueList()) {
40 StyleValue* styleValue = StyleValueFactory::create(propertyID, *cssValue );
41 if (styleValue)
42 styleValueVector.append(styleValue);
43 return styleValueVector;
44 }
45
46 for (auto& value : *toCSSValueList(cssValue.get())) {
47 StyleValue* styleValue = StyleValueFactory::create(propertyID, *value);
48 if (styleValue)
49 styleValueVector.append(styleValue);
50 }
51
52 return styleValueVector;
53 } 27 }
54 28
55 bool InlineStylePropertyMap::has(CSSPropertyID propertyID) 29 bool InlineStylePropertyMap::has(CSSPropertyID propertyID)
56 { 30 {
57 ASSERT(propertyID != CSSPropertyInvalid); 31 ASSERT(propertyID != CSSPropertyInvalid);
58 return !getAll(propertyID).isEmpty(); 32
33 RefPtrWillBeRawPtr<CSSValue> cssValue = m_ownerElement->ensureMutableInlineS tyle().getPropertyCSSValue(propertyID);
34 if (!cssValue)
35 return false;
36
37 return (!cssValue->isValueList() || toCSSValueList(cssValue)->length() > 0);
Timothy Loh 2016/03/31 06:59:25 CSSValueLists are never empty (if you're setting e
meade_UTC10 2016/04/04 03:32:41 Acknowledged. Seems best to look at that case thou
Timothy Loh 2016/04/15 04:16:07 Why would this function care about whether the val
59 } 38 }
60 39
61 Vector<String> InlineStylePropertyMap::getProperties() 40 Vector<String> InlineStylePropertyMap::getProperties()
62 { 41 {
63 Vector<String> result; 42 Vector<String> result;
64 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( ); 43 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle( );
65 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { 44 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) {
66 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id(); 45 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id();
67 result.append(getPropertyNameString(propertyID)); 46 result.append(getPropertyNameString(propertyID));
68 } 47 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 133 }
155 134
156 void InlineStylePropertyMap::remove(CSSPropertyID propertyID, ExceptionState& ex ceptionState) 135 void InlineStylePropertyMap::remove(CSSPropertyID propertyID, ExceptionState& ex ceptionState)
157 { 136 {
158 ASSERT(propertyID != CSSPropertyInvalid); 137 ASSERT(propertyID != CSSPropertyInvalid);
159 m_ownerElement->removeInlineStyleProperty(propertyID); 138 m_ownerElement->removeInlineStyleProperty(propertyID);
160 } 139 }
161 140
162 } // namespace blink 141 } // namespace blink
163 142
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698