OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/css/cssom/FilteredComputedStylePropertyMap.h" | |
6 | |
7 #include "core/css/parser/CSSVariableParser.h" | |
8 | |
9 namespace blink { | |
10 | |
11 FilteredComputedStylePropertyMap::FilteredComputedStylePropertyMap(CSSComputedSt yleDeclaration* computedStyleDeclaration, const Vector<CSSPropertyID>& nativePro perties, const Vector<AtomicString>& customProperties) | |
12 : ComputedStylePropertyMap(computedStyleDeclaration) | |
13 { | |
14 for (const auto& nativeProperty : nativeProperties) { | |
15 m_nativeProperties.add(nativeProperty); | |
ikilpatrick
2016/06/09 02:28:47
These two HashSets could also just be vectors. At
| |
16 } | |
17 | |
18 for (const auto& customProperty: customProperties) { | |
19 m_customProperties.add(customProperty); | |
20 } | |
21 } | |
22 | |
23 | |
24 CSSStyleValue* FilteredComputedStylePropertyMap::get(const String& propertyName, ExceptionState& exceptionState) | |
25 { | |
ikilpatrick
2016/06/09 02:28:47
get, has, getAll are basically the same as StylePr
shans
2016/06/09 03:49:05
This seems fine to me. The check is there so we do
| |
26 CSSPropertyID propertyID = cssPropertyID(propertyName); | |
27 if (propertyID != CSSPropertyInvalid && m_nativeProperties.contains(property ID)) { | |
28 CSSStyleValueVector styleVector = getAllInternal(propertyID); | |
29 if (styleVector.isEmpty()) | |
30 return nullptr; | |
31 | |
32 return styleVector[0]; | |
33 } | |
34 | |
35 if (propertyID == CSSPropertyInvalid && CSSVariableParser::isValidVariableNa me(propertyName) && m_customProperties.contains(AtomicString(propertyName))) { | |
36 CSSStyleValueVector styleVector = getAllInternal(AtomicString(propertyNa me)); | |
37 if (styleVector.isEmpty()) | |
38 return nullptr; | |
39 | |
40 return styleVector[0]; | |
41 } | |
42 | |
43 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
44 return nullptr; | |
45 } | |
46 | |
47 CSSStyleValueVector FilteredComputedStylePropertyMap::getAll(const String& prope rtyName, ExceptionState& exceptionState) | |
48 { | |
49 CSSPropertyID propertyID = cssPropertyID(propertyName); | |
50 if (propertyID != CSSPropertyInvalid && m_nativeProperties.contains(property ID)) | |
51 return getAllInternal(propertyID); | |
52 | |
53 if (propertyID == CSSPropertyInvalid && CSSVariableParser::isValidVariableNa me(propertyName) && m_customProperties.contains(AtomicString(propertyName))) | |
54 return getAllInternal(AtomicString(propertyName)); | |
55 | |
56 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
57 return CSSStyleValueVector(); | |
58 } | |
59 | |
60 bool FilteredComputedStylePropertyMap::has(const String& propertyName, Exception State& exceptionState) | |
61 { | |
62 CSSPropertyID propertyID = cssPropertyID(propertyName); | |
63 if (propertyID != CSSPropertyInvalid && m_nativeProperties.contains(property ID)) | |
64 return !getAllInternal(propertyID).isEmpty(); | |
65 | |
66 if (propertyID == CSSPropertyInvalid && CSSVariableParser::isValidVariableNa me(propertyName) && m_customProperties.contains(AtomicString(propertyName))) | |
67 return !getAllInternal(AtomicString(propertyName)).isEmpty(); | |
68 | |
69 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
70 return false; | |
71 } | |
72 | |
73 Vector<String> FilteredComputedStylePropertyMap::getProperties() | |
74 { | |
75 Vector<String> result; | |
76 for (const auto& nativeProperty : m_nativeProperties) { | |
77 result.append(getPropertyNameString(nativeProperty)); | |
78 } | |
79 | |
80 for (const auto& customProperty : m_customProperties) { | |
81 result.append(customProperty); | |
82 } | |
83 | |
84 return result; | |
85 } | |
86 | |
87 } // namespace blink | |
OLD | NEW |