| 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/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/CSSStyleValue.h" | 10 #include "core/css/cssom/CSSStyleValue.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 CSSStyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState&
exceptionState) | 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 || propertyID == CSSPropertyVariable) { |
| 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 CSSStyleValueVector styleVector = getAllInternal(propertyID); | 58 CSSStyleValueVector styleVector = getAllInternal(propertyID); |
| 59 if (styleVector.isEmpty()) | 59 if (styleVector.isEmpty()) |
| 60 return nullptr; | 60 return nullptr; |
| 61 | 61 |
| 62 return styleVector[0]; | 62 return styleVector[0]; |
| 63 } | 63 } |
| 64 | 64 |
| 65 CSSStyleValueVector StylePropertyMap::getAll(const String& propertyName, Excepti
onState& exceptionState) | 65 CSSStyleValueVector StylePropertyMap::getAll(const String& propertyName, Excepti
onState& exceptionState) |
| 66 { | 66 { |
| 67 CSSPropertyID propertyID = cssPropertyID(propertyName); | 67 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 68 if (propertyID != CSSPropertyInvalid) | 68 if (propertyID != CSSPropertyInvalid && propertyID != CSSPropertyVariable) |
| 69 return getAllInternal(propertyID); | 69 return getAllInternal(propertyID); |
| 70 | 70 |
| 71 // TODO(meade): Handle custom properties here. | 71 // TODO(meade): Handle custom properties here. |
| 72 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | 72 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 73 return CSSStyleValueVector(); | 73 return CSSStyleValueVector(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool StylePropertyMap::has(const String& propertyName, ExceptionState& exception
State) | 76 bool StylePropertyMap::has(const String& propertyName, ExceptionState& exception
State) |
| 77 { | 77 { |
| 78 CSSPropertyID propertyID = cssPropertyID(propertyName); | 78 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 79 if (propertyID != CSSPropertyInvalid) | 79 if (propertyID != CSSPropertyInvalid && propertyID != CSSPropertyVariable) |
| 80 return !getAllInternal(propertyID).isEmpty(); | 80 return !getAllInternal(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, CSSStyleValueOrCSSStyleVa
lueSequenceOrString& 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 && propertyID != CSSPropertyVariable) { |
| 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, CSSStyleValueOrCSSStyl
eValueSequenceOrString& 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 && propertyID != CSSPropertyVariable) { |
| 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 && propertyID != CSSPropertyVariable) { |
| 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::IterationSource* StylePropertyMap::startIteration(ScriptState*
, ExceptionState&) | 120 StylePropertyMap::IterationSource* StylePropertyMap::startIteration(ScriptState*
, ExceptionState&) |
| 121 { | 121 { |
| 122 return new StylePropertyMapIterationSource(getIterationEntries()); | 122 return new StylePropertyMapIterationSource(getIterationEntries()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |