diff options
author | Ben Murdoch <benm@google.com> | 2009-08-11 17:01:47 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-08-11 18:21:02 +0100 |
commit | 0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5 (patch) | |
tree | 2943df35f62d885c89d01063cc528dd73b480fea /WebCore/bindings/js/JSEventListener.cpp | |
parent | 7e7a70bfa49a1122b2597a1e6367d89eb4035eca (diff) | |
download | external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.zip external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.gz external_webkit-0bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5.tar.bz2 |
Merge in WebKit r47029.
Diffstat (limited to 'WebCore/bindings/js/JSEventListener.cpp')
-rw-r--r-- | WebCore/bindings/js/JSEventListener.cpp | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/WebCore/bindings/js/JSEventListener.cpp b/WebCore/bindings/js/JSEventListener.cpp index b9ed685..42e0281 100644 --- a/WebCore/bindings/js/JSEventListener.cpp +++ b/WebCore/bindings/js/JSEventListener.cpp @@ -51,17 +51,17 @@ JSObject* JSEventListener::jsFunction() const return m_jsFunction; } -void JSEventListener::markJSFunction() +void JSEventListener::markJSFunction(MarkStack& markStack) { - if (m_jsFunction && !m_jsFunction->marked()) - m_jsFunction->mark(); - if (m_globalObject && !m_globalObject->marked()) - m_globalObject->mark(); + if (m_jsFunction) + markStack.append(m_jsFunction); + if (m_globalObject) + markStack.append(m_globalObject); } void JSEventListener::handleEvent(Event* event, bool isWindowEvent) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSObject* jsFunction = this->jsFunction(); if (!jsFunction) @@ -71,6 +71,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) // Null check as clearGlobalObject() can clear this and we still get called back by // xmlhttprequest objects. See http://bugs.webkit.org/show_bug.cgi?id=13275 // FIXME: Is this check still necessary? Requests are supposed to be stopped before clearGlobalObject() is called. + ASSERT(globalObject); if (!globalObject) return; @@ -107,7 +108,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) ref(); MarkedArgumentBuffer args; - args.append(toJS(exec, event)); + args.append(toJS(exec, globalObject, event)); Event* savedEvent = globalObject->currentEvent(); globalObject->setCurrentEvent(event); @@ -127,7 +128,7 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) if (isWindowEvent) thisValue = globalObject->toThisObject(exec); else - thisValue = toJS(exec, event->currentTarget()); + thisValue = toJS(exec, globalObject, event->currentTarget()); globalObject->globalData()->timeoutChecker.start(); retval = call(exec, jsFunction, callType, callData, thisValue, args); } @@ -153,6 +154,53 @@ void JSEventListener::handleEvent(Event* event, bool isWindowEvent) } } +bool JSEventListener::reportError(const String& message, const String& url, int lineNumber) +{ + JSLock lock(SilenceAssertionsOnly); + + JSObject* jsFunction = this->jsFunction(); + if (!jsFunction) + return false; + + JSDOMGlobalObject* globalObject = m_globalObject; + if (!globalObject) + return false; + + ExecState* exec = globalObject->globalExec(); + + CallData callData; + CallType callType = jsFunction->getCallData(callData); + + if (callType == CallTypeNone) + return false; + + MarkedArgumentBuffer args; + args.append(jsString(exec, message)); + args.append(jsString(exec, url)); + args.append(jsNumber(exec, lineNumber)); + + // If this event handler is the first JavaScript to execute, then the + // dynamic global object should be set to the global object of the + // window in which the event occurred. + JSGlobalData* globalData = globalObject->globalData(); + DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject); + + JSValue thisValue = globalObject->toThisObject(exec); + + globalObject->globalData()->timeoutChecker.start(); + JSValue returnValue = call(exec, jsFunction, callType, callData, thisValue, args); + globalObject->globalData()->timeoutChecker.stop(); + + // If an error occurs while handling the script error, it should be bubbled up. + if (exec->hadException()) { + exec->clearException(); + return false; + } + + bool bubbleEvent; + return returnValue.getBoolean(bubbleEvent) && !bubbleEvent; +} + bool JSEventListener::virtualisAttribute() const { return m_isAttribute; |