| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef DOMStringMap_h | 26 #ifndef DOMStringMap_h |
| 27 #define DOMStringMap_h | 27 #define DOMStringMap_h |
| 28 | 28 |
| 29 #include "bindings/v8/ExceptionState.h" | 29 #include "bindings/v8/ExceptionState.h" |
| 30 #include "bindings/v8/ScriptWrappable.h" | 30 #include "bindings/v8/ScriptWrappable.h" |
| 31 #include "bindings/v8/V8Binding.h" |
| 31 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
| 32 #include "wtf/Vector.h" | 33 #include "wtf/Vector.h" |
| 33 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 34 | 35 |
| 35 namespace WebCore { | 36 namespace WebCore { |
| 36 | 37 |
| 37 class Element; | 38 class Element; |
| 38 | 39 |
| 39 class DOMStringMap : public ScriptWrappable { | 40 class DOMStringMap : public ScriptWrappable { |
| 40 WTF_MAKE_NONCOPYABLE(DOMStringMap); WTF_MAKE_FAST_ALLOCATED; | 41 WTF_MAKE_NONCOPYABLE(DOMStringMap); WTF_MAKE_FAST_ALLOCATED; |
| 41 public: | 42 public: |
| 42 virtual ~DOMStringMap(); | 43 virtual ~DOMStringMap(); |
| 43 | 44 |
| 44 virtual void ref() = 0; | 45 virtual void ref() = 0; |
| 45 virtual void deref() = 0; | 46 virtual void deref() = 0; |
| 46 | 47 |
| 47 virtual void getNames(Vector<String>&) = 0; | 48 virtual void getNames(Vector<String>&) = 0; |
| 48 virtual String item(const String& name) = 0; | 49 virtual String item(const String& name) = 0; |
| 49 virtual bool contains(const String& name) = 0; | 50 virtual bool contains(const String& name) = 0; |
| 50 virtual void setItem(const String& name, const String& value, ExceptionState
&) = 0; | 51 virtual void setItem(const String& name, const String& value, ExceptionState
&) = 0; |
| 51 virtual void deleteItem(const String& name, ExceptionState&) = 0; | 52 virtual bool deleteItem(const String& name) = 0; |
| 52 bool anonymousNamedSetter(const String& name, const String& value, Exception
State& exceptionState) | 53 bool anonymousNamedSetter(const String& name, const String& value, Exception
State& exceptionState) |
| 53 { | 54 { |
| 54 setItem(name, value, exceptionState); | 55 setItem(name, value, exceptionState); |
| 55 return true; | 56 return true; |
| 56 } | 57 } |
| 57 bool anonymousNamedDeleter(const AtomicString& name, ExceptionState&) | 58 DeleteResult anonymousNamedDeleter(const AtomicString& name) |
| 58 { | 59 { |
| 59 // FIXME: Remove ExceptionState parameter. | 60 bool knownProperty = deleteItem(name); |
| 60 | 61 return knownProperty ? DeleteSuccess : DeleteUnknownProperty; |
| 61 TrackExceptionState exceptionState; | |
| 62 deleteItem(name, exceptionState); | |
| 63 bool result = !exceptionState.hadException(); | |
| 64 // DOMStringMap deleter should ignore exception. | |
| 65 // Behavior of Firefox and Opera are same. | |
| 66 // delete document.body.dataset["-foo"] // false instead of DOM Exceptio
n 12 | |
| 67 // LayoutTests/fast/dom/HTMLSelectElement/select-selectedIndex-multiple.
html | |
| 68 return result; | |
| 69 } | 62 } |
| 70 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&) | 63 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&) |
| 71 { | 64 { |
| 72 getNames(names); | 65 getNames(names); |
| 73 } | 66 } |
| 74 bool namedPropertyQuery(const AtomicString&, ExceptionState&); | 67 bool namedPropertyQuery(const AtomicString&, ExceptionState&); |
| 75 | 68 |
| 76 String anonymousIndexedGetter(uint32_t index) | 69 String anonymousIndexedGetter(uint32_t index) |
| 77 { | 70 { |
| 78 return item(String::number(index)); | 71 return item(String::number(index)); |
| 79 } | 72 } |
| 80 bool anonymousIndexedSetter(uint32_t index, const String& value, ExceptionSt
ate& exceptionState) | 73 bool anonymousIndexedSetter(uint32_t index, const String& value, ExceptionSt
ate& exceptionState) |
| 81 { | 74 { |
| 82 return anonymousNamedSetter(String::number(index), value, exceptionState
); | 75 return anonymousNamedSetter(String::number(index), value, exceptionState
); |
| 83 } | 76 } |
| 84 bool anonymousIndexedDeleter(uint32_t index, ExceptionState& exceptionState) | 77 DeleteResult anonymousIndexedDeleter(uint32_t index) |
| 85 { | 78 { |
| 86 return anonymousNamedDeleter(AtomicString::number(index), exceptionState
); | 79 return anonymousNamedDeleter(AtomicString::number(index)); |
| 87 } | 80 } |
| 88 | 81 |
| 89 virtual Element* element() = 0; | 82 virtual Element* element() = 0; |
| 90 | 83 |
| 91 protected: | 84 protected: |
| 92 DOMStringMap() | 85 DOMStringMap() |
| 93 { | 86 { |
| 94 ScriptWrappable::init(this); | 87 ScriptWrappable::init(this); |
| 95 } | 88 } |
| 96 }; | 89 }; |
| 97 | 90 |
| 98 } // namespace WebCore | 91 } // namespace WebCore |
| 99 | 92 |
| 100 #endif // DOMStringMap_h | 93 #endif // DOMStringMap_h |
| OLD | NEW |