WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
proposed patch
bug-76035-20120111001043.patch (text/plain), 8.75 KB, created by
Pablo Flouret
on 2012-01-11 00:10:44 PST
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Pablo Flouret
Created:
2012-01-11 00:10:44 PST
Size:
8.75 KB
patch
obsolete
>Subversion Revision: 104467 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 537751e33946f76d7710c46d9e481d1e8300630e..c8ee9ac0eb5d6ef48fcaf747e6a334a05d63bd69 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2012-01-11 Pablo Flouret <pablof@motorola.com> >+ >+ Add state attribute to history's dom interface. >+ https://bugs.webkit.org/show_bug.cgi?id=76035 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: fast/loader/stateobjects/pushstate-state-attribute-object-types.html >+ >+ * bindings/js/JSHistoryCustom.cpp: >+ (WebCore::JSHistory::state): >+ * bindings/v8/custom/V8HistoryCustom.cpp: >+ (WebCore::V8History::stateAccessorGetter): >+ * page/History.cpp: >+ (WebCore::History::stateObject): >+ * page/History.h: >+ * page/History.idl: >+ > 2012-01-10 Pablo Flouret <pablof@motorola.com> > > Fix inconsistent text selection behavior with option-shift-left/right/up/down. >diff --git a/Source/WebCore/bindings/js/JSHistoryCustom.cpp b/Source/WebCore/bindings/js/JSHistoryCustom.cpp >index 72ea5424c7c12f3a672bc7d739e11dedfb4818c7..7700cada6c0a3d74ae15b6a5b6c05a774d99c2dc 100644 >--- a/Source/WebCore/bindings/js/JSHistoryCustom.cpp >+++ b/Source/WebCore/bindings/js/JSHistoryCustom.cpp >@@ -164,6 +164,12 @@ void JSHistory::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyN > Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); > } > >+JSValue JSHistory::state(ExecState* exec) const >+{ >+ History* history = static_cast<History*>(impl()); >+ return history->stateObject()->deserialize(exec, globalObject(), 0); >+} >+ > JSValue JSHistory::pushState(ExecState* exec) > { > RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(exec, exec->argument(0), 0); >diff --git a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >index 89561090ca149dbd1ef7036a91cd3a9a7efba68b..efdca437aebf87507403a96de5fbdd6c905d43d0 100644 >--- a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >+++ b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >@@ -41,6 +41,12 @@ > > namespace WebCore { > >+v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) >+{ >+ History* history = V8History::toNative(info.Holder()); >+ return history->stateObject()->deserialize(); >+} >+ > v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) > { > bool didThrow = false; >diff --git a/Source/WebCore/page/History.cpp b/Source/WebCore/page/History.cpp >index 1f5a39f287584f7c2748b33e1099e664d192ae68..1a07c13cfa0180a87483564854f634239d82aaf9 100644 >--- a/Source/WebCore/page/History.cpp >+++ b/Source/WebCore/page/History.cpp >@@ -32,6 +32,7 @@ > #include "Frame.h" > #include "FrameLoader.h" > #include "FrameLoaderClient.h" >+#include "HistoryController.h" > #include "HistoryItem.h" > #include "Page.h" > #include "SecurityOrigin.h" >@@ -107,6 +108,17 @@ KURL History::urlForState(const String& urlString) > return KURL(baseURL, urlString); > } > >+SerializedScriptValue* History::stateObject() const >+{ >+ if (m_frame) { >+ HistoryItem* historyItem = m_frame->loader()->history()->currentItem(); >+ if (historyItem && historyItem->stateObject()) >+ return historyItem->stateObject(); >+ } >+ >+ return SerializedScriptValue::nullValue(); >+} >+ > void History::stateObjectAdded(PassRefPtr<SerializedScriptValue> data, const String& title, const String& urlString, StateObjectType stateObjectType, ExceptionCode& ec) > { > if (!m_frame || !m_frame->page()) >diff --git a/Source/WebCore/page/History.h b/Source/WebCore/page/History.h >index bd50fccd2b861d9e6418e974f42dfb2b2b5f91ce..3579ef3743ba3a062428289970449fae66a6320d 100644 >--- a/Source/WebCore/page/History.h >+++ b/Source/WebCore/page/History.h >@@ -56,6 +56,8 @@ public: > StateObjectPush, > StateObjectReplace > }; >+ >+ SerializedScriptValue* stateObject() const; > void stateObjectAdded(PassRefPtr<SerializedScriptValue>, const String& title, const String& url, StateObjectType, ExceptionCode&); > > private: >diff --git a/Source/WebCore/page/History.idl b/Source/WebCore/page/History.idl >index ff3701ed276d4f5698da6a0530e066380a33b1c1..41e81258a0c40d5c7bb44a3dd3d9d2ceb0eb5419 100644 >--- a/Source/WebCore/page/History.idl >+++ b/Source/WebCore/page/History.idl >@@ -37,6 +37,7 @@ module window { > OmitConstructor > ] History { > readonly attribute unsigned long length; >+ readonly attribute [CustomGetter] DOMObject state; > > [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void back(); > [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void forward(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index c98fa5987f1a20acee8c0120f28a8e099d5f06dc..223dcf1a4075c68ede76437139653050ddb019c3 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2012-01-11 Pablo Flouret <pablof@motorola.com> >+ >+ Add state attribute to history's dom interface. >+ https://bugs.webkit.org/show_bug.cgi?id=76035 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/loader/stateobjects/pushstate-state-attribute-object-types-expected.txt: Added. >+ * fast/loader/stateobjects/pushstate-state-attribute-object-types.html: Added. >+ > 2012-01-10 Pablo Flouret <pablof@motorola.com> > > Fix inconsistent text selection behavior with option-shift-left/right/up/down. >diff --git a/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types-expected.txt b/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..c1a87a78fbc6893f0c6e1f99584cedb53eb86611 >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types-expected.txt >@@ -0,0 +1,15 @@ >+This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the state attribute returns the expected objects. >+ >+State is initially null (type object) >+State pushed - undefined (type undefined) >+State pushed - null (type object) >+State pushed - false (type boolean) >+State pushed - true (type boolean) >+State pushed - 42 (type number) >+State pushed - String (type string) >+State pushed - 0 (type object) >+State pushed - /foo/gi (type object) >+State pushed - (type object) >+State pushed - [object Object] (type object) >+State pushed - [object ImageData] (type object) >+ >diff --git a/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types.html b/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f35a3d79336178bc2bc4a02f2e289903f4f9b074 >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/pushstate-state-attribute-object-types.html >@@ -0,0 +1,57 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script> >+ >+if (window.layoutTestController) { >+ layoutTestController.clearBackForwardList(); >+ layoutTestController.dumpAsText(); >+} >+ >+function log(txt) >+{ >+ document.getElementById("logger").appendChild(document.createTextNode(txt + "\n")); >+} >+ >+function runTest() >+{ >+ log("State is initially " + history.state + " (type " + typeof history.state + ")"); >+ pushAndTestState(undefined, "undefined entry"); >+ pushAndTestState(null, "null entry"); >+ pushAndTestState(false, "false entry"); >+ pushAndTestState(true, "true entry"); >+ pushAndTestState(42, "Number entry"); >+ pushAndTestState("String", "String entry"); >+ pushAndTestState(new Date(0), "Date entry"); >+ pushAndTestState(new RegExp("foo", "gi"), "RegExp entry"); >+ pushAndTestState(new Array, "Array entry"); >+ pushAndTestState(new Object, "Object entry"); >+ pushAndTestState(document.createElement("canvas").getContext("2d").createImageData(10,10), "ImageData entry"); >+ >+/* The following are not yet well enough supported in WebKit to meaningfully test here: >+ history.pushAndState([Blob], "Blob entry"); >+ history.pushAndState([File], "File entry"); >+ history.pushAndState([FileList], "FileList entry"); >+*/ >+} >+ >+function pushAndTestState(data, title) >+{ >+ history.pushState(data, title); >+ var state = history.state; >+ >+ if (state instanceof Date) >+ log("State pushed - " + state.getTime() + " (type " + typeof state + ")"); >+ else >+ log("State pushed - " + state + " (type " + typeof state + ")"); >+} >+ >+</script> >+<body onload="runTest()"> >+<p> >+This test calls pushState with state objects of all the different object types supported by the >+HTML5 "internal structured cloning algorithm" and makes sure the state attribute returns the expected objects. >+</p> >+<pre id="logger"></pre> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 76035
:
121987
|
122471
|
122518
|
122586
|
122857
|
122860
|
123150
|
124811
|
124856
|
125274
|
126022