Title: [96073] trunk
Revision
96073
Author
commit-qu...@webkit.org
Date
2011-09-26 23:27:02 -0700 (Mon, 26 Sep 2011)

Log Message

Implement PopStateEvent.state with SerializedScriptValue and ScriptValue
https://bugs.webkit.org/show_bug.cgi?id=68345

Patch by Kentaro Hara <hara...@chromium.org> on 2011-09-26
Reviewed by Adam Barth.

Source/WebCore:

Previously, the following test cases fail or crash:

- shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1") -> FAIL
- new PopStateEvent('eventType', { state: document }).state -> CRASH in DRT

This is because PopStateEvent.state is implemented not as ScriptValue but as SerializedScriptValue.
However, we cannot simply change the type of PopStateEvent.state to ScriptValue,
since PopStateEvent can be constructed in the context that does not know ScriptValue.
For example, Document.cpp calls PopStateEvent::create() with SerializedScriptValue
popped from HistoryItem, but we cannot deserialize the SerializedScriptValue into
the corresponding ScriptValue here because the deserialization requires ExecState.
In other words, although we want to store PopStateEvent.state by ScriptValue internally,
PopStateEvent still needs to provide an API to construct it with SerializedScriptValue.
With these observations, this patch makes the following changes:

- If PopStateEvent is constructed with ScriptValue, it is stored as ScriptValue internally.
When PopStateEvent.state is called, the ScriptValue is returned.
- If PopStateEvent is constructed with SerializedScriptValue, it is stored as
SerializedScriptValue internally (since we cannot deserialize it into ScriptValue
at this point). When PopStateEvent.state is called, the SerializedScriptValue is
deserialized into the corresponding ScriptValue, and the ScriptValue is returned.

Tests: fast/events/constructors/pop-state-event-constructor.html
       fast/events/fire-popstate-event.html

* GNUmakefile.list.am: Added JSPopStateEventCustom.cpp.
* UseJSC.cmake: Ditto.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* bindings/js/JSBindingsAllInOne.cpp: Ditto.
* bindings/js/JSPopStateEventCustom.cpp:
(WebCore::JSPopStateEvent::state): Custom getter for PopStateEvent.state.
* bindings/v8/custom/V8PopStateEventCustom.cpp:
(WebCore::V8PopStateEvent::stateAccessorGetter): Custom getter for PopStateEvent.state.
* dom/PopStateEvent.cpp:
(WebCore::PopStateEventInit::PopStateEventInit): Added initialization code for PopStateEvent.m_state.
(WebCore::PopStateEvent::PopStateEvent): Ditto.
(WebCore::PopStateEvent::create): Ditto.
(WebCore::PopStateEvent::initPopStateEvent): Ditto.
* dom/PopStateEvent.h:
(WebCore::PopStateEvent::serializedState): Getter.
(WebCore::PopStateEvent::state): Getter.
* dom/PopStateEvent.idl: Change the type of 'stateArg' and 'state' to DOMObject. Added [CustomGetter] to 'state'.

LayoutTests:

* fast/events/constructors/pop-state-event-constructor-expected.txt:
* fast/events/constructors/pop-state-event-constructor.html: Removed failures and crashes. Added one test case.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96072 => 96073)


--- trunk/LayoutTests/ChangeLog	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/LayoutTests/ChangeLog	2011-09-27 06:27:02 UTC (rev 96073)
@@ -1,3 +1,13 @@
+2011-09-26  Kentaro Hara  <hara...@chromium.org>
+
+        Implement PopStateEvent.state with SerializedScriptValue and ScriptValue
+        https://bugs.webkit.org/show_bug.cgi?id=68345
+
+        Reviewed by Adam Barth.
+
+        * fast/events/constructors/pop-state-event-constructor-expected.txt:
+        * fast/events/constructors/pop-state-event-constructor.html: Removed failures and crashes. Added one test case.
+
 2011-09-09  Simon Fraser  <simon.fra...@apple.com>
 
         Translucent scrollbars on composited layers render incorrectly

Modified: trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt (96072 => 96073)


--- trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt	2011-09-27 06:27:02 UTC (rev 96073)
@@ -10,21 +10,23 @@
 PASS new PopStateEvent('eventType', { bubbles: true }).bubbles is true
 PASS new PopStateEvent('eventType', { cancelable: false }).cancelable is false
 PASS new PopStateEvent('eventType', { cancelable: true }).cancelable is true
-FAIL new PopStateEvent('eventType', { state: object1 }).state should be [object Object]. Was [object Object].
+PASS new PopStateEvent('eventType', { state: object1 }).state is object1
+PASS new PopStateEvent('eventType', { state: document }).state is document
 PASS new PopStateEvent('eventType', { state: undefined }).state is undefined
 PASS new PopStateEvent('eventType', { state: null }).state is null
 PASS new PopStateEvent('eventType', { state: false }).state is false
 PASS new PopStateEvent('eventType', { state: true }).state is true
-FAIL new PopStateEvent('eventType', { state: '' }).state should be undefined (of type undefined). Was  (of type string).
+PASS new PopStateEvent('eventType', { state: '' }).state is ""
+PASS new PopStateEvent('eventType', { state: 'doremi' }).state is "doremi"
 PASS new PopStateEvent('eventType', { state: 12345 }).state is 12345
 PASS new PopStateEvent('eventType', { state: 18446744073709551615 }).state is 18446744073709552000
 PASS new PopStateEvent('eventType', { state: NaN }).state is NaN
-FAIL new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state should be [object Object]. Was [object Object].
+PASS new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state == object2 is false
 PASS new PopStateEvent('eventType', { get state() { return 123; } }).state is 123
 PASS new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } }) threw exception PopState Error.
 PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).bubbles is true
 PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).cancelable is true
-FAIL new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state should be [object Object]. Was [object Object].
+PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state is object3
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html (96072 => 96073)


--- trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html	2011-09-27 06:27:02 UTC (rev 96073)
@@ -27,18 +27,19 @@
 // state is passed.
 var object1 = {nyannyan: 123};
 shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1");
-// FIXME(haraken): When we pass a DOM object, it crashes.
-// shouldBe("new PopStateEvent('eventType', { state: document }).state", "document");
+shouldBe("new PopStateEvent('eventType', { state: document }).state", "document");
 shouldBe("new PopStateEvent('eventType', { state: undefined }).state", "undefined");
 shouldBe("new PopStateEvent('eventType', { state: null }).state", "null");
 shouldBe("new PopStateEvent('eventType', { state: false }).state", "false");
 shouldBe("new PopStateEvent('eventType', { state: true }).state", "true");
-shouldBe("new PopStateEvent('eventType', { state: '' }).state", "");
+shouldBeEqualToString("new PopStateEvent('eventType', { state: '' }).state", "");
+shouldBeEqualToString("new PopStateEvent('eventType', { state: 'doremi' }).state", "doremi");
 shouldBe("new PopStateEvent('eventType', { state: 12345 }).state", "12345");
 shouldBe("new PopStateEvent('eventType', { state: 18446744073709551615 }).state", "18446744073709552000");
 shouldBe("new PopStateEvent('eventType', { state: NaN }).state", "NaN");
 var object2 = {nyannyan: 456};
-shouldBe("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state", "object2");
+// Note that valueOf() is not called when the left hand side is evaluated.
+shouldBeFalse("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state == object2");
 shouldBe("new PopStateEvent('eventType', { get state() { return 123; } }).state", "123");
 shouldThrow("new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } })");
 

Modified: trunk/Source/WebCore/ChangeLog (96072 => 96073)


--- trunk/Source/WebCore/ChangeLog	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/ChangeLog	2011-09-27 06:27:02 UTC (rev 96073)
@@ -1,3 +1,55 @@
+2011-09-26  Kentaro Hara  <hara...@chromium.org>
+
+        Implement PopStateEvent.state with SerializedScriptValue and ScriptValue
+        https://bugs.webkit.org/show_bug.cgi?id=68345
+
+        Reviewed by Adam Barth.
+
+        Previously, the following test cases fail or crash:
+
+        - shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1") -> FAIL
+        - new PopStateEvent('eventType', { state: document }).state -> CRASH in DRT
+
+        This is because PopStateEvent.state is implemented not as ScriptValue but as SerializedScriptValue.
+        However, we cannot simply change the type of PopStateEvent.state to ScriptValue,
+        since PopStateEvent can be constructed in the context that does not know ScriptValue.
+        For example, Document.cpp calls PopStateEvent::create() with SerializedScriptValue
+        popped from HistoryItem, but we cannot deserialize the SerializedScriptValue into
+        the corresponding ScriptValue here because the deserialization requires ExecState.
+        In other words, although we want to store PopStateEvent.state by ScriptValue internally,
+        PopStateEvent still needs to provide an API to construct it with SerializedScriptValue.
+        With these observations, this patch makes the following changes:
+
+        - If PopStateEvent is constructed with ScriptValue, it is stored as ScriptValue internally.
+        When PopStateEvent.state is called, the ScriptValue is returned.
+        - If PopStateEvent is constructed with SerializedScriptValue, it is stored as
+        SerializedScriptValue internally (since we cannot deserialize it into ScriptValue
+        at this point). When PopStateEvent.state is called, the SerializedScriptValue is
+        deserialized into the corresponding ScriptValue, and the ScriptValue is returned.
+
+        Tests: fast/events/constructors/pop-state-event-constructor.html
+               fast/events/fire-popstate-event.html
+
+        * GNUmakefile.list.am: Added JSPopStateEventCustom.cpp.
+        * UseJSC.cmake: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.pro: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * bindings/js/JSBindingsAllInOne.cpp: Ditto.
+        * bindings/js/JSPopStateEventCustom.cpp:
+        (WebCore::JSPopStateEvent::state): Custom getter for PopStateEvent.state.
+        * bindings/v8/custom/V8PopStateEventCustom.cpp:
+        (WebCore::V8PopStateEvent::stateAccessorGetter): Custom getter for PopStateEvent.state.
+        * dom/PopStateEvent.cpp:
+        (WebCore::PopStateEventInit::PopStateEventInit): Added initialization code for PopStateEvent.m_state.
+        (WebCore::PopStateEvent::PopStateEvent): Ditto.
+        (WebCore::PopStateEvent::create): Ditto.
+        (WebCore::PopStateEvent::initPopStateEvent): Ditto.
+        * dom/PopStateEvent.h:
+        (WebCore::PopStateEvent::serializedState): Getter.
+        (WebCore::PopStateEvent::state): Getter.
+        * dom/PopStateEvent.idl: Change the type of 'stateArg' and 'state' to DOMObject. Added [CustomGetter] to 'state'.
+
 2011-09-09  Simon Fraser  <simon.fra...@apple.com>
 
         Pixel result shows that compositing/iframes/repaint-after-losing-scrollbars.html is failing

Modified: trunk/Source/WebCore/GNUmakefile.list.am (96072 => 96073)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-09-27 06:27:02 UTC (rev 96073)
@@ -793,6 +793,7 @@
 	Source/WebCore/bindings/js/JSPeerConnectionCustom.cpp \
 	Source/WebCore/bindings/js/JSPluginElementFunctions.cpp \
 	Source/WebCore/bindings/js/JSPluginElementFunctions.h \
+	Source/WebCore/bindings/js/JSPopStateEventCustom.cpp \
 	Source/WebCore/bindings/js/JSProcessingInstructionCustom.cpp \
 	Source/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp \
 	Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp \

Modified: trunk/Source/WebCore/UseJSC.cmake (96072 => 96073)


--- trunk/Source/WebCore/UseJSC.cmake	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/UseJSC.cmake	2011-09-27 06:27:02 UTC (rev 96073)
@@ -105,6 +105,7 @@
     bindings/js/JSOptionConstructor.cpp
     bindings/js/JSPeerConnectionCustom.cpp
     bindings/js/JSPluginElementFunctions.cpp
+    bindings/js/JSPopStateEventCustom.cpp
     bindings/js/JSProcessingInstructionCustom.cpp
     bindings/js/JSScriptProfileNodeCustom.cpp
     bindings/js/JSStyleSheetCustom.cpp

Modified: trunk/Source/WebCore/WebCore.gypi (96072 => 96073)


--- trunk/Source/WebCore/WebCore.gypi	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/WebCore.gypi	2011-09-27 06:27:02 UTC (rev 96073)
@@ -1897,6 +1897,7 @@
             'bindings/js/JSOptionConstructor.h',
             'bindings/js/JSPeerConnectionCustom.cpp',
             'bindings/js/JSPluginElementFunctions.cpp',
+            'bindings/js/JSPopStateEventCustom.cpp',
             'bindings/js/JSProcessingInstructionCustom.cpp',
             'bindings/js/JSSQLResultSetRowListCustom.cpp',
             'bindings/js/JSSQLTransactionCustom.cpp',

Modified: trunk/Source/WebCore/WebCore.pro (96072 => 96073)


--- trunk/Source/WebCore/WebCore.pro	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/WebCore.pro	2011-09-27 06:27:02 UTC (rev 96073)
@@ -323,6 +323,7 @@
         bindings/js/JSNodeListCustom.cpp \
         bindings/js/JSOptionConstructor.cpp \
         bindings/js/JSPluginElementFunctions.cpp \
+        bindings/js/JSPopStateEventCustom.cpp \
         bindings/js/JSProcessingInstructionCustom.cpp \
         bindings/js/JSScriptProfileNodeCustom.cpp \
         bindings/js/JSStyleSheetCustom.cpp \

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (96072 => 96073)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-09-27 06:27:02 UTC (rev 96073)
@@ -3730,6 +3730,7 @@
 		A84EBD830CB8C97700079609 /* JSStyleSheetList.h in Headers */ = {isa = PBXBuildFile; fileRef = A84EBD810CB8C97700079609 /* JSStyleSheetList.h */; };
 		A84EBD840CB8C97700079609 /* JSStyleSheetList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A84EBD820CB8C97700079609 /* JSStyleSheetList.cpp */; };
 		A853123D11D0471B00D4D077 /* FragmentScriptingPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A85F22091430377D007CC884 /* JSPopStateEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */; };
 		A863E2011343412000274926 /* UnicodeBidi.h in Headers */ = {isa = PBXBuildFile; fileRef = A863E2001343412000274926 /* UnicodeBidi.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A86629CF09DA2B47009633A5 /* JSUIEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A86629C909DA2B47009633A5 /* JSUIEvent.h */; };
 		A86629D009DA2B48009633A5 /* JSUIEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A86629CA09DA2B47009633A5 /* JSUIEvent.cpp */; };
@@ -10252,6 +10253,7 @@
 		A84EBD820CB8C97700079609 /* JSStyleSheetList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSStyleSheetList.cpp; sourceTree = "<group>"; };
 		A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FragmentScriptingPermission.h; sourceTree = "<group>"; };
 		A85D7A2F0879EBA9006A9172 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
+		A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPopStateEventCustom.cpp; sourceTree = "<group>"; };
 		A863E2001343412000274926 /* UnicodeBidi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeBidi.h; sourceTree = "<group>"; };
 		A86629C909DA2B47009633A5 /* JSUIEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSUIEvent.h; sourceTree = "<group>"; };
 		A86629CA09DA2B47009633A5 /* JSUIEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSUIEvent.cpp; sourceTree = "<group>"; };
@@ -18717,6 +18719,7 @@
 		BC4EDEF70C08F414007EDD49 /* Custom */ = {
 			isa = PBXGroup;
 			children = (
+				A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
 				BC275CB211C5E85C00C9206C /* JSArrayBufferCustom.cpp */,
 				86243D0011BC31F700CC006A /* JSArrayBufferViewHelper.h */,
 				BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
@@ -26352,6 +26355,7 @@
 				9752D38D1413104B003305BD /* JSHTMLSpanElement.cpp in Sources */,
 				0FE71405142170B800DB33BA /* ScrollbarThemeMock.cpp in Sources */,
 				5D8C4DBF1428222C0026CE72 /* DisplaySleepDisabler.cpp in Sources */,
+				A85F22091430377D007CC884 /* JSPopStateEventCustom.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (96072 => 96073)


--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2011-09-27 06:27:02 UTC (rev 96073)
@@ -126,6 +126,7 @@
 #include "JSOptionConstructor.cpp"
 #include "JSPeerConnectionCustom.cpp"
 #include "JSPluginElementFunctions.cpp"
+#include "JSPopStateEventCustom.cpp"
 #include "JSProcessingInstructionCustom.cpp"
 #include "JSRequestAnimationFrameCallbackCustom.cpp"
 #include "JSSQLResultSetRowListCustom.cpp"

Copied: trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp (from rev 96071, trunk/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp) (0 => 96073)


--- trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSPopStateEventCustom.cpp	2011-09-27 06:27:02 UTC (rev 96073)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "JSPopStateEvent.h"
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSPopStateEvent::state(ExecState* exec) const
+{
+    PopStateEvent* event = static_cast<PopStateEvent*>(impl());
+    SerializedScriptValue* serializedState = event->serializedState();
+    if (serializedState)
+        return serializedState->deserialize(exec, globalObject());
+    if (!event->state().hasNoValue())
+        return event->state().jsValue();
+    return jsNull();
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp (96072 => 96073)


--- trunk/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp	2011-09-27 06:27:02 UTC (rev 96073)
@@ -42,11 +42,12 @@
     INC_STATS("DOM.PopStateEvent.state");
 
     PopStateEvent* event = V8PopStateEvent::toNative(info.Holder());
-    SerializedScriptValue* state = event->state();
-    if (!state)
-        return v8::Null();
-
-    return state->deserialize();
+    SerializedScriptValue* serializedState = event->serializedState();
+    if (serializedState)
+        return serializedState->deserialize();
+    if (!event->state().hasNoValue())
+        return event->state().v8Value();
+    return v8::Null();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/PopStateEvent.cpp (96072 => 96073)


--- trunk/Source/WebCore/dom/PopStateEvent.cpp	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/dom/PopStateEvent.cpp	2011-09-27 06:27:02 UTC (rev 96073)
@@ -33,26 +33,34 @@
 
 PopStateEventInit::PopStateEventInit()
 {
-    state = SerializedScriptValue::create();
 }
 
 PopStateEvent::PopStateEvent()
     : Event(eventNames().popstateEvent, false, true)
+    , m_serializedState(0)
 {
 }
 
 PopStateEvent::PopStateEvent(const AtomicString& type, const PopStateEventInit& initializer)
     : Event(type, initializer)
-    , m_stateObject(initializer.state)
+    , m_state(initializer.state)
+    , m_serializedState(0)
 {
 }
 
-PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> stateObject)
+PopStateEvent::PopStateEvent(ScriptValue state)
     : Event(eventNames().popstateEvent, false, true)
-    , m_stateObject(stateObject)
+    , m_state(state)
+    , m_serializedState(0)
 {
 }
 
+PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> serializedState)
+    : Event(eventNames().popstateEvent, false, true)
+    , m_serializedState(serializedState)
+{
+}
+
 PopStateEvent::~PopStateEvent()
 {
 }
@@ -62,24 +70,29 @@
     return adoptRef(new PopStateEvent);
 }
 
-PassRefPtr<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> stateObject)
+PassRefPtr<PopStateEvent> PopStateEvent::create(ScriptValue state)
 {
-    return adoptRef(new PopStateEvent(stateObject));
+    return adoptRef(new PopStateEvent(state));
 }
 
+PassRefPtr<PopStateEvent> PopStateEvent::create(PassRefPtr<SerializedScriptValue> serializedState)
+{
+    return adoptRef(new PopStateEvent(serializedState));
+}
+
 PassRefPtr<PopStateEvent> PopStateEvent::create(const AtomicString& type, const PopStateEventInit& initializer)
 {
     return adoptRef(new PopStateEvent(type, initializer));
 }
 
-void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> stateObject)
+void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue state)
 {
     if (dispatched())
         return;
-    
+
     initEvent(type, canBubble, cancelable);
 
-    m_stateObject = stateObject;
+    m_state = state;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/PopStateEvent.h (96072 => 96073)


--- trunk/Source/WebCore/dom/PopStateEvent.h	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/dom/PopStateEvent.h	2011-09-27 06:27:02 UTC (rev 96073)
@@ -28,35 +28,38 @@
 #define PopStateEvent_h
 
 #include "Event.h"
+#include "ScriptValue.h"
 #include "SerializedScriptValue.h"
 
 namespace WebCore {
 
-class SerializedScriptValue;
-
 struct PopStateEventInit : public EventInit {
     PopStateEventInit();
 
-    RefPtr<SerializedScriptValue> state;
+    ScriptValue state;
 };
 
 class PopStateEvent : public Event {
 public:
     virtual ~PopStateEvent();
     static PassRefPtr<PopStateEvent> create();
+    static PassRefPtr<PopStateEvent> create(ScriptValue);
     static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue>);
     static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
-    void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>);
+    void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue);
     bool isPopStateEvent() const { return true; }
 
-    SerializedScriptValue* state() const { return m_stateObject.get(); }    
+    SerializedScriptValue* serializedState() const { return m_serializedState.get(); }
+    ScriptValue state() const { return m_state; }
 
 private:
     PopStateEvent();
     PopStateEvent(const AtomicString&, const PopStateEventInit&);
+    explicit PopStateEvent(ScriptValue);
     explicit PopStateEvent(PassRefPtr<SerializedScriptValue>);
 
-    RefPtr<SerializedScriptValue> m_stateObject;
+    ScriptValue m_state;
+    RefPtr<SerializedScriptValue> m_serializedState;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/PopStateEvent.idl (96072 => 96073)


--- trunk/Source/WebCore/dom/PopStateEvent.idl	2011-09-27 06:26:14 UTC (rev 96072)
+++ trunk/Source/WebCore/dom/PopStateEvent.idl	2011-09-27 06:27:02 UTC (rev 96073)
@@ -34,9 +34,9 @@
         void initPopStateEvent(in [Optional=CallWithDefaultValue] DOMString typeArg, 
                                in [Optional=CallWithDefaultValue] boolean canBubbleArg, 
                                in [Optional=CallWithDefaultValue] boolean cancelableArg, 
-                               in [Optional=CallWithDefaultValue] SerializedScriptValue stateArg);
+                               in [Optional=CallWithDefaultValue] DOMObject stateArg);
 
-        readonly attribute [V8CustomGetter] any state;
+        readonly attribute [CustomGetter] DOMObject state;
     };
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to