From 7a4828e0f4ca9279eecb8698a755340068a23888 Mon Sep 17 00:00:00 2001 From: darin Date: Fri, 30 Jun 2006 02:56:14 +0000 Subject: [PATCH] Reviewed by Anders. - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9622 showModalDialog returnValue ignored, function result is always "undefined" * manual-tests/modal-dialog.html: Added. * manual-tests/show-modal-dialog-test.html: Added. * page/Frame.cpp: (WebCore::Frame::clear): Call KJSProxy::clear with the clearWindowProperties parameter instead of not calling it at all when clearWindowProperties is false. * bindings/js/kjs_proxy.h: Add boolean clearWindowProperties parameter. * bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::clear): Pass clearWindowProperties variable through to Window::clear instead of not calling it at all. * bindings/js/kjs_window.h: Add boolean clearWindowProperties parameter. * bindings/js/kjs_window.cpp: (KJS::Window::clear): If clearWindowProperties is false, do only the returnValue work, not the rest of the work. * manual-tests/modal-dialog.html: Added. * manual-tests/show-modal-dialog-test.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15097 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebCore/ChangeLog | 25 ++++++++++++++++++ WebCore/bindings/js/kjs_proxy.cpp | 18 ++++++------- WebCore/bindings/js/kjs_proxy.h | 2 +- WebCore/bindings/js/kjs_window.cpp | 26 ++++++++++--------- WebCore/bindings/js/kjs_window.h | 2 +- WebCore/manual-tests/modal-dialog.html | 12 +++++++++ .../manual-tests/show-modal-dialog-test.html | 15 +++++++++++ WebCore/page/Frame.cpp | 4 +-- 8 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 WebCore/manual-tests/modal-dialog.html create mode 100644 WebCore/manual-tests/show-modal-dialog-test.html diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 78bc9b65e87..f9f70af8ba1 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2006-06-29 Darin Adler + + Reviewed by Anders. + + - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9622 + showModalDialog returnValue ignored, function result is always "undefined" + + * manual-tests/modal-dialog.html: Added. + * manual-tests/show-modal-dialog-test.html: Added. + + * page/Frame.cpp: (WebCore::Frame::clear): Call KJSProxy::clear with the + clearWindowProperties parameter instead of not calling it at all when + clearWindowProperties is false. + + * bindings/js/kjs_proxy.h: Add boolean clearWindowProperties parameter. + * bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::clear): Pass clearWindowProperties + variable through to Window::clear instead of not calling it at all. + + * bindings/js/kjs_window.h: Add boolean clearWindowProperties parameter. + * bindings/js/kjs_window.cpp: (KJS::Window::clear): If clearWindowProperties + is false, do only the returnValue work, not the rest of the work. + + * manual-tests/modal-dialog.html: Added. + * manual-tests/show-modal-dialog-test.html: Added. + 2006-06-29 Beth Dakin Reviewed by Hyatt. diff --git a/WebCore/bindings/js/kjs_proxy.cpp b/WebCore/bindings/js/kjs_proxy.cpp index e13a152db0c..264cd80a41f 100644 --- a/WebCore/bindings/js/kjs_proxy.cpp +++ b/WebCore/bindings/js/kjs_proxy.cpp @@ -83,15 +83,15 @@ JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String& return 0; } -void KJSProxy::clear() { - // clear resources allocated by the interpreter, and make it ready to be used by another page - // We have to keep it, so that the Window object for the frame remains the same. - // (we used to delete and re-create it, previously) - if (m_script) { - Window *win = Window::retrieveWindow(m_frame); - if (win) - win->clear(); - } +void KJSProxy::clear(bool clearWindowProperties) +{ + // Clear resources allocated by the interpreter, and make it ready to be used by another page. + // Earlier versions of this function deleted and re-created the window object, but we have to + // keep it because JavaScript can keep a reference to the window object and it must be the same. + if (m_script) { + if (Window* window = Window::retrieveWindow(m_frame)) + window->clear(clearWindowProperties); + } } EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node) diff --git a/WebCore/bindings/js/kjs_proxy.h b/WebCore/bindings/js/kjs_proxy.h index 15f79f1d99e..8befef489ad 100644 --- a/WebCore/bindings/js/kjs_proxy.h +++ b/WebCore/bindings/js/kjs_proxy.h @@ -41,7 +41,7 @@ public: KJSProxy(Frame*); ~KJSProxy(); KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code, Node*); - void clear(); + void clear(bool clearWindowProperties); EventListener* createHTMLEventHandler(const String& functionName, const String& code, Node*); #if SVG_SUPPORT EventListener* createSVGEventHandler(const String& functionName, const String& code, Node*); diff --git a/WebCore/bindings/js/kjs_window.cpp b/WebCore/bindings/js/kjs_window.cpp index d59f87fe279..b2335ea3c81 100644 --- a/WebCore/bindings/js/kjs_window.cpp +++ b/WebCore/bindings/js/kjs_window.cpp @@ -1323,23 +1323,25 @@ JSUnprotectedEventListener *Window::getJSUnprotectedEventListener(JSValue *val, return new JSUnprotectedEventListener(object, this, html); } -void Window::clear() +void Window::clear(bool clearWindowProperties) { - JSLock lock; + JSLock lock; - if (m_returnValueSlot) - if (JSValue* returnValue = getDirect("returnValue")) - *m_returnValueSlot = returnValue; + if (m_returnValueSlot) + if (JSValue* returnValue = getDirect("returnValue")) + *m_returnValueSlot = returnValue; - clearAllTimeouts(); - clearProperties(); - setPrototype(JSDOMWindowProto::self()); // clear the prototype + if (clearWindowProperties) { + clearAllTimeouts(); + clearProperties(); + setPrototype(JSDOMWindowProto::self()); // clear the prototype - // there's likely to be lots of garbage now - Collector::collect(); + // there's likely to be lots of garbage now + Collector::collect(); - // Now recreate a working global object for the next URL that will use us - interpreter()->initGlobalObject(); + // Now recreate a working global object for the next URL that will use us + interpreter()->initGlobalObject(); + } } void Window::setCurrentEvent(Event *evt) diff --git a/WebCore/bindings/js/kjs_window.h b/WebCore/bindings/js/kjs_window.h index 3619ed805a9..270dad0cf9f 100644 --- a/WebCore/bindings/js/kjs_window.h +++ b/WebCore/bindings/js/kjs_window.h @@ -138,7 +138,7 @@ namespace KJS { BarInfo *toolbar(ExecState*) const; JSEventListener *getJSEventListener(JSValue*, bool html = false); JSUnprotectedEventListener *getJSUnprotectedEventListener(JSValue*, bool html = false); - void clear(); + void clear(bool clearWindowProperties); virtual UString toString(ExecState *) const; // Set the current "event" object diff --git a/WebCore/manual-tests/modal-dialog.html b/WebCore/manual-tests/modal-dialog.html new file mode 100644 index 00000000000..7e608356b8a --- /dev/null +++ b/WebCore/manual-tests/modal-dialog.html @@ -0,0 +1,12 @@ +
+

Here is the text from the main window:

+

Type text here to be sent back to the main window:

+

Then, push this button:

+
+ diff --git a/WebCore/manual-tests/show-modal-dialog-test.html b/WebCore/manual-tests/show-modal-dialog-test.html new file mode 100644 index 00000000000..f34e4104f44 --- /dev/null +++ b/WebCore/manual-tests/show-modal-dialog-test.html @@ -0,0 +1,15 @@ + +
+

Type text here to be sent to the modal window and press the button: + +

+ +

Text will appear her from the modal window: +

diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp index 3ba6206a04e..2150edce53d 100644 --- a/WebCore/page/Frame.cpp +++ b/WebCore/page/Frame.cpp @@ -436,8 +436,8 @@ void Frame::clear(bool clearWindowProperties) } // Moving past doc so that onUnload works. - if (clearWindowProperties && d->m_jscript) - d->m_jscript->clear(); + if (d->m_jscript) + d->m_jscript->clear(clearWindowProperties); if (d->m_view) d->m_view->clear(); -- GitLab