Title: [101591] trunk
Revision
101591
Author
[email protected]
Date
2011-11-30 19:23:05 -0800 (Wed, 30 Nov 2011)

Log Message

Implement the StorageEvent constructor
https://bugs.webkit.org/show_bug.cgi?id=71685

Reviewed by Adam Barth.

Source/WebCore:

This patch makes StorageEvent constractable.
The spec: http://www.whatwg.org/specs/web-apps/current-work/#storageevent

Test: fast/events/constructors/storage-event-constructor.html

* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::tryGetProperty):
(WebCore::JSDictionary::convertValue): Returns a Storage object corresponding to a given key.
* bindings/js/JSDictionary.h:
(WebCore::JSDictionary::tryGetProperty):
* bindings/v8/OptionsObject.cpp:
(WebCore::OptionsObject::get): Ditto.
* bindings/v8/OptionsObject.h:
* storage/StorageEvent.cpp: Added an implementation of the StorageEvent constructor.
(WebCore::StorageEventInit::StorageEventInit):
(WebCore::StorageEvent::create):
(WebCore::StorageEvent::StorageEvent):
* storage/StorageEvent.h: Added a definition of StorageEventInit.
(WebCore::StorageEvent::key):
(WebCore::StorageEvent::oldValue):
(WebCore::StorageEvent::newValue):
(WebCore::StorageEvent::url):
(WebCore::StorageEvent::storageArea):
* storage/StorageEvent.idl: Added [ConstructorTemplate=Event] IDL.

LayoutTests:

storage-event-constructor.html checks the behavior of the StorageEvent constructor.

* fast/dom/constructed-objects-prototypes-expected.txt: Added window.StorageEvent.
* fast/events/constructors/storage-event-constructor-expected.txt: Added.
* fast/events/constructors/storage-event-constructor.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101590 => 101591)


--- trunk/LayoutTests/ChangeLog	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/LayoutTests/ChangeLog	2011-12-01 03:23:05 UTC (rev 101591)
@@ -1,3 +1,16 @@
+2011-11-30  Kentaro Hara  <[email protected]>
+
+        Implement the StorageEvent constructor
+        https://bugs.webkit.org/show_bug.cgi?id=71685
+
+        Reviewed by Adam Barth.
+
+        storage-event-constructor.html checks the behavior of the StorageEvent constructor.
+
+        * fast/dom/constructed-objects-prototypes-expected.txt: Added window.StorageEvent.
+        * fast/events/constructors/storage-event-constructor-expected.txt: Added.
+        * fast/events/constructors/storage-event-constructor.html: Added.
+
 2011-11-30  Hayato Ito  <[email protected]>
 
         Unreviewed. Update test expectations for flaky svg test.

Modified: trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt (101590 => 101591)


--- trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt	2011-12-01 03:23:05 UTC (rev 101591)
@@ -39,6 +39,8 @@
 PASS (new inner.PopStateEvent()).constructor.isInner is true
 PASS (new inner.ProgressEvent()).isInner is true
 PASS (new inner.ProgressEvent()).constructor.isInner is true
+PASS (new inner.StorageEvent()).isInner is true
+PASS (new inner.StorageEvent()).constructor.isInner is true
 PASS (new inner.WebGLContextEvent()).isInner is true
 PASS (new inner.WebGLContextEvent()).constructor.isInner is true
 PASS (new inner.WebKitAnimationEvent()).isInner is true

Added: trunk/LayoutTests/fast/events/constructors/storage-event-constructor-expected.txt (0 => 101591)


--- trunk/LayoutTests/fast/events/constructors/storage-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/storage-event-constructor-expected.txt	2011-12-01 03:23:05 UTC (rev 101591)
@@ -0,0 +1,93 @@
+This tests the constructor for the StorageEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new StorageEvent('eventType').bubbles is false
+PASS new StorageEvent('eventType').cancelable is false
+PASS new StorageEvent('eventType').key is ""
+PASS new StorageEvent('eventType').oldValue is null
+PASS new StorageEvent('eventType').newValue is null
+PASS new StorageEvent('eventType').url is ""
+PASS new StorageEvent('eventType').storageArea is null
+PASS new StorageEvent('eventType', { bubbles: false }).bubbles is false
+PASS new StorageEvent('eventType', { bubbles: true }).bubbles is true
+PASS new StorageEvent('eventType', { cancelable: false }).cancelable is false
+PASS new StorageEvent('eventType', { cancelable: true }).cancelable is true
+PASS new StorageEvent('eventType', { key: 'abcde' }).key is "abcde"
+PASS new StorageEvent('eventType', { key: '' }).key is ""
+PASS new StorageEvent('eventType', { key: undefined }).key is "undefined"
+PASS new StorageEvent('eventType', { key: null }).key is "null"
+PASS new StorageEvent('eventType', { key: false }).key is "false"
+PASS new StorageEvent('eventType', { key: true }).key is "true"
+PASS new StorageEvent('eventType', { key: 12345 }).key is "12345"
+PASS new StorageEvent('eventType', { key: 18446744073709551615 }).key is "18446744073709552000"
+PASS new StorageEvent('eventType', { key: NaN }).key is "NaN"
+PASS new StorageEvent('eventType', { key: [] }).key is ""
+PASS new StorageEvent('eventType', { key: [1, 2, 3] }).key is "1,2,3"
+PASS new StorageEvent('eventType', { key: {abcde: 12345} }).key is "[object Object]"
+PASS new StorageEvent('eventType', { key: {valueOf: function () { return 'abcde'; } } }).key is "[object Object]"
+PASS new StorageEvent('eventType', { oldValue: 'abcde' }).oldValue is "abcde"
+PASS new StorageEvent('eventType', { oldValue: '' }).oldValue is ""
+PASS new StorageEvent('eventType', { oldValue: undefined }).oldValue is "undefined"
+PASS new StorageEvent('eventType', { oldValue: null }).oldValue is "null"
+PASS new StorageEvent('eventType', { oldValue: false }).oldValue is "false"
+PASS new StorageEvent('eventType', { oldValue: true }).oldValue is "true"
+PASS new StorageEvent('eventType', { oldValue: 12345 }).oldValue is "12345"
+PASS new StorageEvent('eventType', { oldValue: 18446744073709551615 }).oldValue is "18446744073709552000"
+PASS new StorageEvent('eventType', { oldValue: NaN }).oldValue is "NaN"
+PASS new StorageEvent('eventType', { oldValue: [] }).oldValue is ""
+PASS new StorageEvent('eventType', { oldValue: [1, 2, 3] }).oldValue is "1,2,3"
+PASS new StorageEvent('eventType', { oldValue: {abcde: 12345} }).oldValue is "[object Object]"
+PASS new StorageEvent('eventType', { oldValue: {valueOf: function () { return 'abcde'; } } }).oldValue is "[object Object]"
+PASS new StorageEvent('eventType', { newValue: 'abcde' }).newValue is "abcde"
+PASS new StorageEvent('eventType', { newValue: '' }).newValue is ""
+PASS new StorageEvent('eventType', { newValue: undefined }).newValue is "undefined"
+PASS new StorageEvent('eventType', { newValue: null }).newValue is "null"
+PASS new StorageEvent('eventType', { newValue: false }).newValue is "false"
+PASS new StorageEvent('eventType', { newValue: true }).newValue is "true"
+PASS new StorageEvent('eventType', { newValue: 12345 }).newValue is "12345"
+PASS new StorageEvent('eventType', { newValue: 18446744073709551615 }).newValue is "18446744073709552000"
+PASS new StorageEvent('eventType', { newValue: NaN }).newValue is "NaN"
+PASS new StorageEvent('eventType', { newValue: [] }).newValue is ""
+PASS new StorageEvent('eventType', { newValue: [1, 2, 3] }).newValue is "1,2,3"
+PASS new StorageEvent('eventType', { newValue: {abcde: 12345} }).newValue is "[object Object]"
+PASS new StorageEvent('eventType', { newValue: {valueOf: function () { return 'abcde'; } } }).newValue is "[object Object]"
+PASS new StorageEvent('eventType', { url: 'abcde' }).url is "abcde"
+PASS new StorageEvent('eventType', { url: '' }).url is ""
+PASS new StorageEvent('eventType', { url: undefined }).url is "undefined"
+PASS new StorageEvent('eventType', { url: null }).url is "null"
+PASS new StorageEvent('eventType', { url: false }).url is "false"
+PASS new StorageEvent('eventType', { url: true }).url is "true"
+PASS new StorageEvent('eventType', { url: 12345 }).url is "12345"
+PASS new StorageEvent('eventType', { url: 18446744073709551615 }).url is "18446744073709552000"
+PASS new StorageEvent('eventType', { url: NaN }).url is "NaN"
+PASS new StorageEvent('eventType', { url: [] }).url is ""
+PASS new StorageEvent('eventType', { url: [1, 2, 3] }).url is "1,2,3"
+PASS new StorageEvent('eventType', { url: {abcde: 12345} }).url is "[object Object]"
+PASS new StorageEvent('eventType', { url: {valueOf: function () { return 'abcde'; } } }).url is "[object Object]"
+PASS new StorageEvent('eventType', { storageArea: localStorage }).storageArea is localStorage
+PASS new StorageEvent('eventType', { storageArea: sessionStorage }).storageArea is sessionStorage
+PASS new StorageEvent('eventType', { storageArea: test_object }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: window }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: document }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: undefined }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: null }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: false }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: true }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: '' }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: 'chocolate' }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: 12345 }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: 18446744073709551615 }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: NaN }).storageArea is null
+PASS new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } }).storageArea == window is false
+PASS new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea is null
+PASS new StorageEvent('eventType', { get storageArea() { throw 'StorageEvent Error'; } }) threw exception StorageEvent Error.
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: false, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).bubbles is true
+PASS new StorageEvent('eventType', { bubbles: false, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).cancelable is true
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).key is "abc"
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).oldValue is "def"
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).newValue is "ghi"
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).url is "jkl"
+PASS new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).storageArea is localStorage
+

Added: trunk/LayoutTests/fast/events/constructors/storage-event-constructor.html (0 => 101591)


--- trunk/LayoutTests/fast/events/constructors/storage-event-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/storage-event-constructor.html	2011-12-01 03:23:05 UTC (rev 101591)
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the StorageEvent DOM class.");
+
+// No initializer is passed.
+shouldBe("new StorageEvent('eventType').bubbles", "false");
+shouldBe("new StorageEvent('eventType').cancelable", "false");
+shouldBeEqualToString("new StorageEvent('eventType').key", "");
+// Note: oldValue is nullable.
+shouldBe("new StorageEvent('eventType').oldValue", "null");
+// Note: newValue is nullable.
+shouldBe("new StorageEvent('eventType').newValue", "null");
+shouldBeEqualToString("new StorageEvent('eventType').url", "");
+shouldBe("new StorageEvent('eventType').storageArea", "null");
+
+// bubbles is passed.
+shouldBe("new StorageEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new StorageEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new StorageEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new StorageEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// key, oldValue, newValue and url is passed.
+["key", "oldValue", "newValue", "url"].forEach(function(attr) {
+    // Strings.
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": 'abcde' })." + attr, "abcde");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": '' })." + attr, "");
+
+    // Non-strings.
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": undefined })." + attr, "undefined");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": null })." + attr, "null");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": false })." + attr, "false");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": true })." + attr, "true");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": 12345 })." + attr, "12345");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": 18446744073709551615 })." + attr, "18446744073709552000");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": NaN })." + attr, "NaN");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": [] })." + attr, "");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": [1, 2, 3] })." + attr, "1,2,3");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": {abcde: 12345} })." + attr, "[object Object]");
+    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": {valueOf: function () { return 'abcde'; } } })." + attr, "[object Object]");
+});
+
+// storageArea is passed.
+// Storage objects.
+shouldBe("new StorageEvent('eventType', { storageArea: localStorage }).storageArea", "localStorage");
+shouldBe("new StorageEvent('eventType', { storageArea: sessionStorage }).storageArea", "sessionStorage");
+
+// Non-Storage objects.
+var test_object = {abc: 123};
+shouldBe("new StorageEvent('eventType', { storageArea: test_object }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: window }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: document }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: undefined }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: null }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: false }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: true }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: '' }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: 'chocolate' }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: 12345 }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: 18446744073709551615 }).storageArea", "null");
+shouldBe("new StorageEvent('eventType', { storageArea: NaN }).storageArea", "null");
+// Note that valueOf() is not called, when the left hand side is evaluated.
+shouldBeFalse("new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } }).storageArea == window");
+shouldBe("new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea", "null");
+shouldThrow("new StorageEvent('eventType', { get storageArea() { throw 'StorageEvent Error'; } })");
+
+// All initializers are passed.
+shouldBe("new StorageEvent('eventType', { bubbles: true, cancelable: false, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).bubbles", "true");
+shouldBe("new StorageEvent('eventType', { bubbles: false, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).cancelable", "true");
+shouldBeEqualToString("new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).key", "abc");
+shouldBeEqualToString("new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).oldValue", "def");
+shouldBeEqualToString("new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).newValue", "ghi");
+shouldBeEqualToString("new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).url", "jkl");
+shouldBe("new StorageEvent('eventType', { bubbles: true, cancelable: true, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).storageArea", "localStorage");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (101590 => 101591)


--- trunk/Source/WebCore/ChangeLog	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/ChangeLog	2011-12-01 03:23:05 UTC (rev 101591)
@@ -1,3 +1,35 @@
+2011-11-30  Kentaro Hara  <[email protected]>
+
+        Implement the StorageEvent constructor
+        https://bugs.webkit.org/show_bug.cgi?id=71685
+
+        Reviewed by Adam Barth.
+
+        This patch makes StorageEvent constractable.
+        The spec: http://www.whatwg.org/specs/web-apps/current-work/#storageevent
+
+        Test: fast/events/constructors/storage-event-constructor.html
+
+        * bindings/js/JSDictionary.cpp:
+        (WebCore::JSDictionary::tryGetProperty):
+        (WebCore::JSDictionary::convertValue): Returns a Storage object corresponding to a given key.
+        * bindings/js/JSDictionary.h:
+        (WebCore::JSDictionary::tryGetProperty):
+        * bindings/v8/OptionsObject.cpp:
+        (WebCore::OptionsObject::get): Ditto.
+        * bindings/v8/OptionsObject.h:
+        * storage/StorageEvent.cpp: Added an implementation of the StorageEvent constructor.
+        (WebCore::StorageEventInit::StorageEventInit):
+        (WebCore::StorageEvent::create):
+        (WebCore::StorageEvent::StorageEvent):
+        * storage/StorageEvent.h: Added a definition of StorageEventInit.
+        (WebCore::StorageEvent::key):
+        (WebCore::StorageEvent::oldValue):
+        (WebCore::StorageEvent::newValue):
+        (WebCore::StorageEvent::url):
+        (WebCore::StorageEvent::storageArea):
+        * storage/StorageEvent.idl: Added [ConstructorTemplate=Event] IDL.
+
 2011-11-30  Naveen Bobbili  <[email protected]>
 
         window.getMatchedCSSRules() not supporting pseudo element

Modified: trunk/Source/WebCore/bindings/js/JSDictionary.cpp (101590 => 101591)


--- trunk/Source/WebCore/bindings/js/JSDictionary.cpp	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.cpp	2011-12-01 03:23:05 UTC (rev 101591)
@@ -30,6 +30,7 @@
 #include "JSEventTarget.h"
 #include "JSMessagePortCustom.h"
 #include "JSNode.h"
+#include "JSStorage.h"
 #include "JSTrackCustom.h"
 #include "SerializedScriptValue.h"
 #include "ScriptValue.h"
@@ -43,7 +44,7 @@
 {
     Identifier identifier(m_exec, propertyName);
     PropertySlot slot(m_initializerObject);
-    
+
     if (!m_initializerObject->getPropertySlot(m_exec, identifier, slot))
         return NoPropertyFound;
 
@@ -118,6 +119,11 @@
     result = toNode(value);
 }
 
+void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Storage>& result)
+{
+    result = toStorage(value);
+}
+
 void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result)
 {
     fillMessagePortArray(exec, value, result);

Modified: trunk/Source/WebCore/bindings/js/JSDictionary.h (101590 => 101591)


--- trunk/Source/WebCore/bindings/js/JSDictionary.h	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/bindings/js/JSDictionary.h	2011-12-01 03:23:05 UTC (rev 101591)
@@ -37,6 +37,7 @@
 class Node;
 class ScriptValue;
 class SerializedScriptValue;
+class Storage;
 class TrackBase;
 
 class JSDictionary {
@@ -81,6 +82,7 @@
     static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<DOMWindow>& result);
     static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
     static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
+    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Storage>& result);
     static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
 #if ENABLE(VIDEO_TRACK)
     static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<TrackBase>& result);
@@ -104,7 +106,7 @@
 
         if (m_exec->hadException())
             return false;
-    
+
         setter(context, result);
         break;
     }

Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.cpp (101590 => 101591)


--- trunk/Source/WebCore/bindings/v8/OptionsObject.cpp	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.cpp	2011-12-01 03:23:05 UTC (rev 101591)
@@ -29,6 +29,7 @@
 #include "DOMStringList.h"
 #include "V8Binding.h"
 #include "V8DOMWindow.h"
+#include "V8Storage.h"
 #include "V8Utilities.h"
 #include <wtf/MathExtras.h>
 
@@ -206,6 +207,23 @@
     return true;
 }
 
+bool OptionsObject::get(const String& key, RefPtr<Storage>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    Storage* source = 0;
+    if (v8Value->IsObject()) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        v8::Handle<v8::Object> storage = V8DOMWrapper::lookupDOMWrapper(V8Storage::GetTemplate(), wrapper);
+        if (!storage.IsEmpty())
+            source = V8Storage::toNative(storage);
+    }
+    value = source;
+    return true;
+}
+
 bool OptionsObject::get(const String& key, MessagePortArray& value) const
 {
     v8::Local<v8::Value> v8Value;

Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.h (101590 => 101591)


--- trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-12-01 03:23:05 UTC (rev 101591)
@@ -38,6 +38,7 @@
 class DOMStringList;
 class DOMWindow;
 class IDBKeyRange;
+class Storage;
 class TrackBase;
 
 class OptionsObject {
@@ -59,6 +60,7 @@
     bool get(const String&, unsigned&) const;
     bool get(const String&, unsigned long long&) const;
     bool get(const String&, RefPtr<DOMWindow>&) const;
+    bool get(const String&, RefPtr<Storage>&) const;
     bool get(const String&, MessagePortArray&) const;
 #if ENABLE(VIDEO_TRACK)
     bool get(const String&, RefPtr<TrackBase>&) const;

Modified: trunk/Source/WebCore/storage/StorageEvent.cpp (101590 => 101591)


--- trunk/Source/WebCore/storage/StorageEvent.cpp	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/storage/StorageEvent.cpp	2011-12-01 03:23:05 UTC (rev 101591)
@@ -31,6 +31,10 @@
 
 namespace WebCore {
 
+StorageEventInit::StorageEventInit()
+{
+}
+
 PassRefPtr<StorageEvent> StorageEvent::create()
 {
     return adoptRef(new StorageEvent);
@@ -49,6 +53,11 @@
     return adoptRef(new StorageEvent(type, key, oldValue, newValue, url, storageArea));
 }
 
+PassRefPtr<StorageEvent> StorageEvent::create(const AtomicString& type, const StorageEventInit& initializer)
+{
+    return adoptRef(new StorageEvent(type, initializer));
+}
+
 StorageEvent::StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea)
     : Event(type, false, false)
     , m_key(key)
@@ -59,6 +68,16 @@
 {
 }
 
+StorageEvent::StorageEvent(const AtomicString& type, const StorageEventInit& initializer)
+    : Event(type, initializer)
+    , m_key(initializer.key)
+    , m_oldValue(initializer.oldValue)
+    , m_newValue(initializer.newValue)
+    , m_url(initializer.url)
+    , m_storageArea(initializer.storageArea)
+{
+}
+
 void StorageEvent::initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea)
 {
     if (dispatched())

Modified: trunk/Source/WebCore/storage/StorageEvent.h (101590 => 101591)


--- trunk/Source/WebCore/storage/StorageEvent.h	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/storage/StorageEvent.h	2011-12-01 03:23:05 UTC (rev 101591)
@@ -31,38 +31,50 @@
 
 namespace WebCore {
 
-    class Storage;
+class Storage;
 
-    class StorageEvent : public Event {
-    public:
-        static PassRefPtr<StorageEvent> create();
-        static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
-        virtual ~StorageEvent();
+struct StorageEventInit : public EventInit {
+    StorageEventInit();
 
-        const String& key() const { return m_key; }
-        const String& oldValue() const { return m_oldValue; }
-        const String& newValue() const { return m_newValue; }
-        const String& url() const { return m_url; }
-        Storage* storageArea() const { return m_storageArea.get(); }
+    String key;
+    String oldValue;
+    String newValue;
+    String url;
+    RefPtr<Storage> storageArea;
+};
 
-        void initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
+class StorageEvent : public Event {
+public:
+    static PassRefPtr<StorageEvent> create();
+    static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
+    static PassRefPtr<StorageEvent> create(const AtomicString&, const StorageEventInit&);
+    virtual ~StorageEvent();
 
-        // Needed once we support init<blank>EventNS
-        // void initStorageEventNS(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, Storage storageAreaArg);
+    const String& key() const { return m_key; }
+    const String& oldValue() const { return m_oldValue; }
+    const String& newValue() const { return m_newValue; }
+    const String& url() const { return m_url; }
+    Storage* storageArea() const { return m_storageArea.get(); }
 
-        virtual const AtomicString& interfaceName() const;
+    void initStorageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
 
-    private:
-        StorageEvent();
-        StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
+    // Needed once we support init<blank>EventNS
+    // void initStorageEventNS(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, Storage storageAreaArg);
 
-        String m_key;
-        String m_oldValue;
-        String m_newValue;
-        String m_url;
-        RefPtr<Storage> m_storageArea;
-    };
+    virtual const AtomicString& interfaceName() const;
 
+private:
+    StorageEvent();
+    StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
+    StorageEvent(const AtomicString&, const StorageEventInit&);
+
+    String m_key;
+    String m_oldValue;
+    String m_newValue;
+    String m_url;
+    RefPtr<Storage> m_storageArea;
+};
+
 } // namespace WebCore
 
 #endif // StorageEvent_h

Modified: trunk/Source/WebCore/storage/StorageEvent.idl (101590 => 101591)


--- trunk/Source/WebCore/storage/StorageEvent.idl	2011-12-01 03:13:20 UTC (rev 101590)
+++ trunk/Source/WebCore/storage/StorageEvent.idl	2011-12-01 03:23:05 UTC (rev 101591)
@@ -25,12 +25,15 @@
 
 module storage {
 
-    interface StorageEvent : Event {
-        readonly attribute DOMString key;
-        readonly attribute [ConvertNullStringTo=Null] DOMString oldValue;
-        readonly attribute [ConvertNullStringTo=Null] DOMString newValue;
-        readonly attribute DOMString url;
-        readonly attribute Storage storageArea;
+    interface [
+        ConstructorTemplate=Event
+    ] StorageEvent : Event {
+        readonly attribute [InitializedByConstructor] DOMString key;
+        readonly attribute [InitializedByConstructor, ConvertNullStringTo=Null] DOMString oldValue;
+        readonly attribute [InitializedByConstructor, ConvertNullStringTo=Null] DOMString newValue;
+        readonly attribute [InitializedByConstructor] DOMString url;
+        readonly attribute [InitializedByConstructor] Storage storageArea;
+
         void initStorageEvent(in [Optional=CallWithDefaultValue] DOMString typeArg, 
                               in [Optional=CallWithDefaultValue] boolean canBubbleArg, 
                               in [Optional=CallWithDefaultValue] boolean cancelableArg, 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to