Chromium Code Reviews| 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) |
| 14 { | 14 { |
| 15 return get(cssPropertyID(propertyName)); | 15 return get(cssPropertyID(propertyName)); |
| 16 } | 16 } |
| 17 | 17 |
| 18 HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyNa me) | 18 HeapVector<Member<StyleValue>> StylePropertyMap::getAll(const String& propertyNa me) |
| 19 { | 19 { |
| 20 return getAll(cssPropertyID(propertyName)); | 20 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 21 if (propertyID != CSSPropertyInvalid) { | |
| 22 return getAll(propertyID); | |
| 23 } | |
| 24 // TODO(meade): Handle custom properties here. | |
| 25 return HeapVector<Member<StyleValue>>(); | |
| 21 } | 26 } |
| 22 | 27 |
| 23 bool StylePropertyMap::has(const String& propertyName) | 28 bool StylePropertyMap::has(const String& propertyName) |
| 24 { | 29 { |
| 25 return has(cssPropertyID(propertyName)); | 30 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 31 if (propertyID != CSSPropertyInvalid) { | |
| 32 return has(cssPropertyID(propertyName)); | |
|
Timothy Loh
2016/02/09 07:29:32
You probably meant to use propertyID here and all
meade_UTC10
2016/02/10 05:55:39
Done.
| |
| 33 } | |
| 34 // TODO(meade): Handle custom properties here. | |
| 35 return false; | |
| 26 } | 36 } |
| 27 | 37 |
| 28 void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSeq uenceOrString& item, ExceptionState& exceptionState) | 38 void StylePropertyMap::set(const String& propertyName, StyleValueOrStyleValueSeq uenceOrString& item, ExceptionState& exceptionState) |
| 29 { | 39 { |
| 30 set(cssPropertyID(propertyName), item, exceptionState); | 40 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 41 if (propertyID != CSSPropertyInvalid) { | |
| 42 set(cssPropertyID(propertyName), item, exceptionState); | |
| 43 return; | |
| 44 } | |
| 45 // TODO(meade): Handle custom properties here. | |
| 46 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
| 31 } | 47 } |
| 32 | 48 |
| 33 void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValue SequenceOrString& item, ExceptionState& exceptionState) | 49 void StylePropertyMap::append(const String& propertyName, StyleValueOrStyleValue SequenceOrString& item, ExceptionState& exceptionState) |
| 34 { | 50 { |
| 35 append(cssPropertyID(propertyName), item, exceptionState); | 51 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 52 if (propertyID != CSSPropertyInvalid) { | |
| 53 append(cssPropertyID(propertyName), item, exceptionState); | |
| 54 return; | |
| 55 } | |
| 56 // TODO(meade): Handle custom properties here. | |
| 57 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
| 36 } | 58 } |
| 37 | 59 |
| 38 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except ionState) | 60 void StylePropertyMap::remove(const String& propertyName, ExceptionState& except ionState) |
| 39 { | 61 { |
| 40 remove(cssPropertyID(propertyName), exceptionState); | 62 CSSPropertyID propertyID = cssPropertyID(propertyName); |
| 63 if (propertyID != CSSPropertyInvalid) { | |
| 64 remove(cssPropertyID(propertyName), exceptionState); | |
| 65 return; | |
| 66 } | |
| 67 // TODO(meade): Handle custom properties here. | |
| 68 exceptionState.throwTypeError("Invalid propertyName: " + propertyName); | |
| 41 } | 69 } |
| 42 | 70 |
| 43 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |