diff options
Diffstat (limited to 'WebCore/bindings/v8/ScriptController.cpp')
-rw-r--r-- | WebCore/bindings/v8/ScriptController.cpp | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index 6f17373..889642f 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -34,7 +34,7 @@ #include "PlatformBridge.h" #include "Document.h" -#include "DocumentParser.h" +#include "ScriptableDocumentParser.h" #include "DOMWindow.h" #include "Event.h" #include "EventListener.h" @@ -53,6 +53,7 @@ #include "V8BindingState.h" #include "V8DOMWindow.h" #include "V8Event.h" +#include "V8HiddenPropertyName.h" #include "V8HTMLEmbedElement.h" #include "V8IsolatedContext.h" #include "V8NPObject.h" @@ -160,16 +161,13 @@ void ScriptController::updatePlatformScriptObjects() bool ScriptController::processingUserGesture(DOMWrapperWorld*) const { - Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext(); // No script is running, so it is user-initiated unless the gesture stack // explicitly says it is not. - if (!activeFrame) + if (!m_proxy->executingScript()) return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; - V8Proxy* activeProxy = activeFrame->script()->proxy(); - v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame); + v8::Handle<v8::Context> v8Context = m_proxy->mainWorldContext(); // FIXME: find all cases context can be empty: // 1) JS is disabled; // 2) page is NULL; @@ -179,33 +177,24 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const v8::Context::Scope scope(v8Context); v8::Handle<v8::Object> global = v8Context->Global(); - v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event")); + v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(); + v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol); Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0; - // Based on code from kjs_bindings.cpp. + // Based on code from JSC's ScriptController::processingUserGesture. // Note: This is more liberal than Firefox's implementation. if (event) { - if (!UserGestureIndicator::processingUserGesture()) - return false; - - const AtomicString& type = event->type(); - bool eventOk = - // mouse events - type == eventNames().clickEvent || type == eventNames().mousedownEvent || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent - // keyboard events - || type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent - // other accepted events - || type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent; - - if (eventOk) - return true; - } else if (m_sourceURL && m_sourceURL->isNull() && !activeProxy->timerCallback()) { + // Event::fromUserGesture will return false when UserGestureIndicator::processingUserGesture() returns false. + return event->fromUserGesture(); + } + if (m_sourceURL && m_sourceURL->isNull() && !m_proxy->timerCallback()) { // This is the <a href="javascript:window.open('...')> case -> we let it through. return true; } // This is the <script>window.open(...)</script> case or a timer callback -> block it. - return false; + // Based on JSC version, use returned value of UserGestureIndicator::processingUserGesture for all other situations. + return UserGestureIndicator::processingUserGesture(); } bool ScriptController::anyPageIsProcessingUserGesture() const @@ -261,14 +250,16 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode, Shoul int ScriptController::eventHandlerLineNumber() const { - if (DocumentParser* parser = m_frame->document()->parser()) + ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); + if (parser) return parser->lineNumber(); return 0; } int ScriptController::eventHandlerColumnNumber() const { - if (DocumentParser* parser = m_frame->document()->parser()) + ScriptableDocumentParser* parser = m_frame->document()->scriptableDocumentParser(); + if (parser) return parser->columnNumber(); return 0; } |