Commit d02b7dca authored by weinig@apple.com's avatar weinig@apple.com

2008-04-25 Sam Weinig <sam@webkit.org>

        Reviewed by Mark Rowe.

        The EventListeners need to operate and store JSDOMWindows, not JSDOMWrapperWindows.

        * bindings/js/JSDOMWindowBase.cpp:
        (WebCore::JSDOMWindowBase::~JSDOMWindowBase):
        (WebCore::JSDOMWindowBase::findOrCreateJSEventListener):
        (WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener):
        * bindings/js/JSSVGLazyEventListener.cpp:
        (WebCore::JSSVGLazyEventListener::JSSVGLazyEventListener):
        * bindings/js/JSSVGLazyEventListener.h:
        * bindings/js/kjs_events.cpp:
        (WebCore::JSAbstractEventListener::handleEvent):
        (WebCore::JSUnprotectedEventListener::JSUnprotectedEventListener):
        (WebCore::JSUnprotectedEventListener::~JSUnprotectedEventListener):
        (WebCore::JSUnprotectedEventListener::window):
        (WebCore::JSUnprotectedEventListener::clearWindow):
        (WebCore::JSEventListener::JSEventListener):
        (WebCore::JSEventListener::~JSEventListener):
        (WebCore::JSEventListener::window):
        (WebCore::JSEventListener::clearWindow):
        (WebCore::JSLazyEventListener::JSLazyEventListener):
        (WebCore::JSLazyEventListener::parseCode):
        * bindings/js/kjs_events.h:
        * bindings/js/kjs_proxy.cpp:
        (WebCore::KJSProxy::createHTMLEventHandler):
        (WebCore::KJSProxy::createSVGEventHandler):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 443213ad
2008-04-25 Sam Weinig <sam@webkit.org>
Reviewed by Mark Rowe.
The EventListeners need to operate and store JSDOMWindows, not JSDOMWrapperWindows.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::~JSDOMWindowBase):
(WebCore::JSDOMWindowBase::findOrCreateJSEventListener):
(WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener):
* bindings/js/JSSVGLazyEventListener.cpp:
(WebCore::JSSVGLazyEventListener::JSSVGLazyEventListener):
* bindings/js/JSSVGLazyEventListener.h:
* bindings/js/kjs_events.cpp:
(WebCore::JSAbstractEventListener::handleEvent):
(WebCore::JSUnprotectedEventListener::JSUnprotectedEventListener):
(WebCore::JSUnprotectedEventListener::~JSUnprotectedEventListener):
(WebCore::JSUnprotectedEventListener::window):
(WebCore::JSUnprotectedEventListener::clearWindow):
(WebCore::JSEventListener::JSEventListener):
(WebCore::JSEventListener::~JSEventListener):
(WebCore::JSEventListener::window):
(WebCore::JSEventListener::clearWindow):
(WebCore::JSLazyEventListener::JSLazyEventListener):
(WebCore::JSLazyEventListener::parseCode):
* bindings/js/kjs_events.h:
* bindings/js/kjs_proxy.cpp:
(WebCore::KJSProxy::createHTMLEventHandler):
(WebCore::KJSProxy::createSVGEventHandler):
2008-04-25 Mark Rowe <mrowe@apple.com>
Rubber-stamped by Sam Weinig.
......@@ -40,6 +40,7 @@
#include "HTMLDocument.h"
#include "JSAudioConstructor.h"
#include "JSDOMWindow.h"
#include "JSDOMWindow.h"
#include "JSEvent.h"
#include "JSHTMLCollection.h"
#include "JSHTMLOptionElementConstructor.h"
......@@ -215,20 +216,20 @@ JSDOMWindowBase::~JSDOMWindowBase()
ListenersMap::iterator i2 = d->jsEventListeners.begin();
ListenersMap::iterator e2 = d->jsEventListeners.end();
for (; i2 != e2; ++i2)
i2->second->clearWindowWrapper();
i2->second->clearWindow();
i2 = d->jsHTMLEventListeners.begin();
e2 = d->jsHTMLEventListeners.end();
for (; i2 != e2; ++i2)
i2->second->clearWindowWrapper();
i2->second->clearWindow();
UnprotectedListenersMap::iterator i1 = d->jsUnprotectedEventListeners.begin();
UnprotectedListenersMap::iterator e1 = d->jsUnprotectedEventListeners.end();
for (; i1 != e1; ++i1)
i1->second->clearWindowWrapper();
i1->second->clearWindow();
i1 = d->jsUnprotectedHTMLEventListeners.begin();
e1 = d->jsUnprotectedHTMLEventListeners.end();
for (; i1 != e1; ++i1)
i1->second->clearWindowWrapper();
i1->second->clearWindow();
}
static bool allowPopUp(ExecState* exec)
......@@ -916,7 +917,7 @@ JSEventListener* JSDOMWindowBase::findOrCreateJSEventListener(JSValue* val, bool
JSObject* object = static_cast<JSObject*>(val);
// Note that the JSEventListener constructor adds it to our jsEventListeners list
return new JSEventListener(object, wrapper(), html);
return new JSEventListener(object, static_cast<JSDOMWindow*>(this), html);
}
JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(JSValue* val, bool html)
......@@ -938,7 +939,7 @@ JSUnprotectedEventListener* JSDOMWindowBase::findOrCreateJSUnprotectedEventListe
JSObject* object = static_cast<JSObject*>(val);
// The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map.
return new JSUnprotectedEventListener(object, wrapper(), html);
return new JSUnprotectedEventListener(object, static_cast<JSDOMWindow*>(this), html);
}
void JSDOMWindowBase::clearHelperObjectProperties()
......
......@@ -28,8 +28,8 @@ using namespace KJS;
namespace WebCore {
JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber)
: JSLazyEventListener(functionName, code, windowWrapper, node, lineNumber)
JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
: JSLazyEventListener(functionName, code, window, node, lineNumber)
{
}
......
......@@ -29,7 +29,7 @@ namespace WebCore {
class JSSVGLazyEventListener : public JSLazyEventListener {
public:
JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper*, Node*, int lineNumber = 0);
JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber = 0);
private:
virtual KJS::JSValue* eventParameterName() const;
......
......@@ -53,12 +53,12 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
if (!listener)
return;
JSDOMWindowWrapper* windowWrapper = this->windowWrapper();
// Null check as clearWindowWrapper() can clear this and we still get called back by
JSDOMWindow* window = this->window();
// Null check as clearWindow() can clear this and we still get called back by
// xmlhttprequest objects. See http://bugs.webkit.org/show_bug.cgi?id=13275
if (!windowWrapper)
if (!window)
return;
Frame* frame = windowWrapper->window()->impl()->frame();
Frame* frame = window->impl()->frame();
if (!frame)
return;
KJSProxy* scriptProxy = frame->scriptProxy();
......@@ -67,7 +67,7 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
JSLock lock;
ExecState* exec = windowWrapper->window()->globalExec();
ExecState* exec = window->globalExec();
JSValue* handleEventFuncValue = listener->get(exec, "handleEvent");
JSObject* handleEventFunc = 0;
......@@ -83,25 +83,25 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
List args;
args.append(toJS(exec, event));
Event* savedEvent = windowWrapper->window()->currentEvent();
windowWrapper->window()->setCurrentEvent(event);
Event* savedEvent = window->currentEvent();
window->setCurrentEvent(event);
JSValue* retval;
if (handleEventFunc) {
windowWrapper->window()->startTimeoutCheck();
window->startTimeoutCheck();
retval = handleEventFunc->call(exec, listener, args);
} else {
JSObject* thisObj;
if (isWindowEvent)
thisObj = windowWrapper;
thisObj = window->wrapper();
else
thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget()));
windowWrapper->window()->startTimeoutCheck();
window->startTimeoutCheck();
retval = listener->call(exec, thisObj, args);
}
windowWrapper->window()->stopTimeoutCheck();
window->stopTimeoutCheck();
windowWrapper->window()->setCurrentEvent(savedEvent);
window->setCurrentEvent(savedEvent);
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
......@@ -134,23 +134,23 @@ bool JSAbstractEventListener::isHTMLEventListener() const
// -------------------------------------------------------------------------
JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html)
JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* window, bool html)
: JSAbstractEventListener(html)
, m_listener(listener)
, m_windowWrapper(windowWrapper)
, m_window(window)
{
if (m_listener) {
JSDOMWindow::UnprotectedListenersMap& listeners = html
? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners();
? window->jsUnprotectedHTMLEventListeners() : window->jsUnprotectedEventListeners();
listeners.set(m_listener, this);
}
}
JSUnprotectedEventListener::~JSUnprotectedEventListener()
{
if (m_listener && m_windowWrapper) {
if (m_listener && m_window) {
JSDOMWindow::UnprotectedListenersMap& listeners = isHTMLEventListener()
? m_windowWrapper->window()->jsUnprotectedHTMLEventListeners() : m_windowWrapper->window()->jsUnprotectedEventListeners();
? m_window->jsUnprotectedHTMLEventListeners() : m_window->jsUnprotectedEventListeners();
listeners.remove(m_listener);
}
}
......@@ -160,14 +160,14 @@ JSObject* JSUnprotectedEventListener::listenerObj() const
return m_listener;
}
JSDOMWindowWrapper* JSUnprotectedEventListener::windowWrapper() const
JSDOMWindow* JSUnprotectedEventListener::window() const
{
return m_windowWrapper;
return m_window;
}
void JSUnprotectedEventListener::clearWindowWrapper()
void JSUnprotectedEventListener::clearWindow()
{
m_windowWrapper = 0;
m_window = 0;
}
void JSUnprotectedEventListener::mark()
......@@ -196,14 +196,14 @@ static EventListenerCounter eventListenerCounter;
// -------------------------------------------------------------------------
JSEventListener::JSEventListener(JSObject* listener, JSDOMWindowWrapper* windowWrapper, bool html)
JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool html)
: JSAbstractEventListener(html)
, m_listener(listener)
, m_windowWrapper(windowWrapper)
, m_window(window)
{
if (m_listener) {
JSDOMWindow::ListenersMap& listeners = html
? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners();
? m_window->jsHTMLEventListeners() : m_window->jsEventListeners();
listeners.set(m_listener, this);
}
#ifndef NDEBUG
......@@ -213,9 +213,9 @@ JSEventListener::JSEventListener(JSObject* listener, JSDOMWindowWrapper* windowW
JSEventListener::~JSEventListener()
{
if (m_listener && m_windowWrapper) {
if (m_listener && m_window) {
JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
? m_windowWrapper->window()->jsHTMLEventListeners() : m_windowWrapper->window()->jsEventListeners();
? m_window->jsHTMLEventListeners() : m_window->jsEventListeners();
listeners.remove(m_listener);
}
#ifndef NDEBUG
......@@ -228,20 +228,20 @@ JSObject* JSEventListener::listenerObj() const
return m_listener;
}
JSDOMWindowWrapper* JSEventListener::windowWrapper() const
JSDOMWindow* JSEventListener::window() const
{
return m_windowWrapper;
return m_window;
}
void JSEventListener::clearWindowWrapper()
void JSEventListener::clearWindow()
{
m_windowWrapper = 0;
m_window = 0;
}
// -------------------------------------------------------------------------
JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper* windowWrapper, Node* node, int lineNumber)
: JSEventListener(0, windowWrapper, true)
JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
: JSEventListener(0, window, true)
, m_functionName(functionName)
, m_code(code)
, m_parsed(false)
......@@ -273,12 +273,12 @@ void JSLazyEventListener::parseCode() const
return;
m_parsed = true;
Frame* frame = windowWrapper()->window()->impl()->frame();
Frame* frame = window()->impl()->frame();
if (frame && frame->scriptProxy()->isEnabled()) {
ExecState* exec = windowWrapper()->window()->globalExec();
ExecState* exec = window()->globalExec();
JSLock lock;
JSObject* constr = windowWrapper()->window()->functionConstructor();
JSObject* constr = window()->functionConstructor();
List args;
UString sourceURL(frame->loader()->url().string());
......@@ -312,7 +312,7 @@ void JSLazyEventListener::parseCode() const
if (m_listener) {
JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
? windowWrapper()->window()->jsHTMLEventListeners() : windowWrapper()->window()->jsEventListeners();
? window()->jsHTMLEventListeners() : window()->jsEventListeners();
listeners.set(m_listener, const_cast<JSLazyEventListener*>(this));
}
}
......
......@@ -27,7 +27,7 @@
namespace WebCore {
class Event;
class JSDOMWindowWrapper;
class JSDOMWindow;
class Node;
class JSAbstractEventListener : public EventListener {
......@@ -37,7 +37,7 @@ namespace WebCore {
virtual void handleEvent(Event*, bool isWindowEvent);
virtual bool isHTMLEventListener() const;
virtual KJS::JSObject* listenerObj() const = 0;
virtual JSDOMWindowWrapper* windowWrapper() const = 0;
virtual JSDOMWindow* window() const = 0;
private:
bool m_html;
......@@ -45,38 +45,38 @@ namespace WebCore {
class JSUnprotectedEventListener : public JSAbstractEventListener {
public:
JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false);
JSUnprotectedEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false);
virtual ~JSUnprotectedEventListener();
virtual KJS::JSObject* listenerObj() const;
virtual JSDOMWindowWrapper* windowWrapper() const;
void clearWindowWrapper();
virtual JSDOMWindow* window() const;
void clearWindow();
void mark();
private:
KJS::JSObject* m_listener;
JSDOMWindowWrapper* m_windowWrapper;
JSDOMWindow* m_window;
};
class JSEventListener : public JSAbstractEventListener {
public:
JSEventListener(KJS::JSObject* listener, JSDOMWindowWrapper*, bool html = false);
JSEventListener(KJS::JSObject* listener, JSDOMWindow*, bool html = false);
virtual ~JSEventListener();
virtual KJS::JSObject* listenerObj() const;
virtual JSDOMWindowWrapper* windowWrapper() const;
void clearWindowWrapper();
virtual JSDOMWindow* window() const;
void clearWindow();
protected:
mutable KJS::ProtectedPtr<KJS::JSObject> m_listener;
private:
KJS::ProtectedPtr<JSDOMWindowWrapper> m_windowWrapper;
KJS::ProtectedPtr<JSDOMWindow> m_window;
};
class JSLazyEventListener : public JSEventListener {
public:
JSLazyEventListener(const String& functionName, const String& code, JSDOMWindowWrapper*, Node*, int lineNumber = 0);
JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber = 0);
virtual KJS::JSObject* listenerObj() const;
private:
......
......@@ -117,7 +117,7 @@ EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, cons
{
initScriptIfNeeded();
JSLock lock;
return new JSLazyEventListener(functionName, code, m_windowWrapper, node, m_handlerLineno);
return new JSLazyEventListener(functionName, code, m_windowWrapper->window(), node, m_handlerLineno);
}
#if ENABLE(SVG)
......@@ -125,7 +125,7 @@ EventListener* KJSProxy::createSVGEventHandler(const String& functionName, const
{
initScriptIfNeeded();
JSLock lock;
return new JSSVGLazyEventListener(functionName, code, m_windowWrapper, node, m_handlerLineno);
return new JSSVGLazyEventListener(functionName, code, m_windowWrapper->window(), node, m_handlerLineno);
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment