OLD | NEW |
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 "bindings/core/v8/Iterable.h" | 7 #include "bindings/core/v8/Iterable.h" |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/CSSPropertyMetadata.h" | 10 #include "core/css/CSSPropertyMetadata.h" |
11 #include "core/css/CSSValueList.h" | 11 #include "core/css/CSSValueList.h" |
12 #include "core/css/StylePropertySet.h" | 12 #include "core/css/StylePropertySet.h" |
13 #include "core/css/cssom/CSSOMTypes.h" | 13 #include "core/css/cssom/CSSOMTypes.h" |
14 #include "core/css/cssom/CSSSimpleLength.h" | 14 #include "core/css/cssom/CSSSimpleLength.h" |
15 #include "core/css/cssom/StyleValueFactory.h" | 15 #include "core/css/cssom/StyleValueFactory.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 CSSValue* styleValueToCSSValue(CSSPropertyID propertyID, const CSSStyleValue& st
yleValue) | 21 CSSValue* styleValueToCSSValue(CSSPropertyID propertyID, const CSSStyleValue& st
yleValue) |
22 { | 22 { |
23 if (!CSSOMTypes::propertyCanTake(propertyID, styleValue)) | 23 if (!CSSOMTypes::propertyCanTake(propertyID, styleValue)) |
24 return nullptr; | 24 return nullptr; |
25 return styleValue.toCSSValueWithProperty(propertyID); | 25 return styleValue.toCSSValueWithProperty(propertyID); |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 CSSStyleValueVector InlineStylePropertyMap::getAll(CSSPropertyID propertyID) | 30 CSSStyleValueVector InlineStylePropertyMap::getAllInternal(CSSPropertyID propert
yID) |
31 { | 31 { |
32 CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyC
SSValue(propertyID); | 32 CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyC
SSValue(propertyID); |
33 if (!cssValue) | 33 if (!cssValue) |
34 return CSSStyleValueVector(); | 34 return CSSStyleValueVector(); |
35 | 35 |
36 return StyleValueFactory::cssValueToStyleValueVector(propertyID, *cssValue); | 36 return StyleValueFactory::cssValueToStyleValueVector(propertyID, *cssValue); |
37 } | 37 } |
38 | 38 |
| 39 CSSStyleValueVector InlineStylePropertyMap::getAllInternal(AtomicString customPr
opertyName) |
| 40 { |
| 41 CSSValue* cssValue = m_ownerElement->ensureMutableInlineStyle().getPropertyC
SSValue(customPropertyName); |
| 42 if (!cssValue) |
| 43 return CSSStyleValueVector(); |
| 44 |
| 45 return StyleValueFactory::cssValueToStyleValueVector(CSSPropertyInvalid, *cs
sValue); |
| 46 } |
| 47 |
39 Vector<String> InlineStylePropertyMap::getProperties() | 48 Vector<String> InlineStylePropertyMap::getProperties() |
40 { | 49 { |
41 Vector<String> result; | 50 Vector<String> result; |
42 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle(
); | 51 StylePropertySet& inlineStyleSet = m_ownerElement->ensureMutableInlineStyle(
); |
43 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { | 52 for (unsigned i = 0; i < inlineStyleSet.propertyCount(); i++) { |
44 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id(); | 53 CSSPropertyID propertyID = inlineStyleSet.propertyAt(i).id(); |
45 result.append(getPropertyNameString(propertyID)); | 54 result.append(getPropertyNameString(propertyID)); |
46 } | 55 } |
47 return result; | 56 return result; |
48 } | 57 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 value.setCSSStyleValue(styleValueVector[0]); | 154 value.setCSSStyleValue(styleValueVector[0]); |
146 else | 155 else |
147 value.setCSSStyleValueSequence(styleValueVector); | 156 value.setCSSStyleValueSequence(styleValueVector); |
148 result.append(std::make_pair(getPropertyNameString(propertyID), value)); | 157 result.append(std::make_pair(getPropertyNameString(propertyID), value)); |
149 } | 158 } |
150 return result; | 159 return result; |
151 } | 160 } |
152 | 161 |
153 } // namespace blink | 162 } // namespace blink |
154 | 163 |
OLD | NEW |