| 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/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 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 StyleValue* StylePropertyMap::get(const String& propertyName) | 13 StyleValue* StylePropertyMap::get(const String& propertyName, ExceptionState& ex
ceptionState) |
| 14 { | 14 { |
| 15 return get(cssPropertyID(propertyName)); | 15 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 16 if (propertyID != CSSPropertyInvalid) |
| 17 return get(propertyID); |
| 18 |
| 19 // TODO(meade): Handle custom properties here. |
| 20 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 21 return nullptr; |
| 16 } | 22 } |
| 17 | 23 |
| 18 HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyNa
me) | 24 HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyNa
me, ExceptionState& exceptionState) |
| 19 { | 25 { |
| 20 return getAll(cssPropertyID(propertyName)); | 26 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 27 if (propertyID != CSSPropertyInvalid) |
| 28 return getAll(propertyID); |
| 29 |
| 30 // TODO(meade): Handle custom properties here. |
| 31 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 32 return HeapVector<Member<StyleValue>>(); |
| 21 } | 33 } |
| 22 | 34 |
| 23 bool StylePropertyMap::has(const String& propertyName) | 35 bool StylePropertyMap::has(const String& propertyName, ExceptionState& exception
State) |
| 24 { | 36 { |
| 25 return has(cssPropertyID(propertyName)); | 37 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 38 if (propertyID != CSSPropertyInvalid) |
| 39 return has(propertyID); |
| 40 |
| 41 // TODO(meade): Handle custom properties here. |
| 42 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 43 return false; |
| 26 } | 44 } |
| 27 | 45 |
| 28 void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSeq
uenceOrString& item, ExceptionState& exceptionState) | 46 void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSeq
uenceOrString& item, ExceptionState& exceptionState) |
| 29 { | 47 { |
| 30 set(cssPropertyID(propertyName), item, exceptionState); | 48 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 49 if (propertyID != CSSPropertyInvalid) { |
| 50 set(propertyID, item, exceptionState); |
| 51 return; |
| 52 } |
| 53 // TODO(meade): Handle custom properties here. |
| 54 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 31 } | 55 } |
| 32 | 56 |
| 33 void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValue
SequenceOrString& item, ExceptionState& exceptionState) | 57 void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValue
SequenceOrString& item, ExceptionState& exceptionState) |
| 34 { | 58 { |
| 35 append(cssPropertyID(propertyName), item, exceptionState); | 59 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 60 if (propertyID != CSSPropertyInvalid) { |
| 61 append(propertyID, item, exceptionState); |
| 62 return; |
| 63 } |
| 64 // TODO(meade): Handle custom properties here. |
| 65 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 36 } | 66 } |
| 37 | 67 |
| 38 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except
ionState) | 68 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except
ionState) |
| 39 { | 69 { |
| 40 remove(cssPropertyID(propertyName), exceptionState); | 70 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 71 if (propertyID != CSSPropertyInvalid) { |
| 72 remove(propertyID, exceptionState); |
| 73 return; |
| 74 } |
| 75 // TODO(meade): Handle custom properties here. |
| 76 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); |
| 41 } | 77 } |
| 42 | 78 |
| 43 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |