Title: [219743] trunk/Source
Revision
219743
Author
[email protected]
Date
2017-07-21 14:16:29 -0700 (Fri, 21 Jul 2017)

Log Message

Use more references in event dispatch code
https://bugs.webkit.org/show_bug.cgi?id=174681

Reviewed by Geoffrey Garen.

Source/WebCore:

Make EventListener::handleEvent() take a ScriptExecutionContext&, Event&.
Then make everything build again. Various null checks and assertions
disappear in the process.

* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSErrorHandler.h:
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::initializeJSFunction):
(WebCore::JSEventListener::handleEvent):
(WebCore::eventHandlerAttribute):
* bindings/js/JSEventListener.h:
(WebCore::JSEventListener::jsFunction):
* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::initializeJSFunction):
* bindings/js/JSLazyEventListener.h:
* dom/EventListener.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::fireEventListeners):
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::defaultEventHandler):
* html/ImageDocument.cpp:
(WebCore::ImageEventListener::handleEvent):
* inspector/CommandLineAPIHost.cpp:
(WebCore::listenerEntriesFromListenerInfo):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForEventListener):
* inspector/InspectorIndexedDBAgent.cpp:
* platform/Widget.h:
(WebCore::Widget::handleEvent):
* platform/cocoa/WebPlaybackSessionModelMediaElement.h:
* platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
(WebCore::WebPlaybackSessionModelMediaElement::handleEvent):
* platform/cocoa/WebVideoFullscreenModelVideoElement.h:
* platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
(WebVideoFullscreenModelVideoElement::handleEvent):
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefTargetEventListener::handleEvent):
* svg/animation/SVGSMILElement.cpp:
(WebCore::ConditionEventListener::handleEvent):
(WebCore::SVGSMILElement::handleConditionEvent):
* svg/animation/SVGSMILElement.h:

Source/WebKit:

* WebProcess/Plugins/PDF/PDFPluginAnnotation.h:
* WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
(WebKit::PDFPluginAnnotation::handleEvent):
(WebKit::PDFPluginAnnotation::PDFPluginAnnotationEventListener::handleEvent):
* WebProcess/Plugins/PDF/PDFPluginPasswordField.h:
* WebProcess/Plugins/PDF/PDFPluginPasswordField.mm:
(WebKit::PDFPluginPasswordField::handleEvent):
* WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h:
* WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
(WebKit::PDFPluginTextAnnotation::handleEvent):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::createWebEvent):
(WebKit::PluginView::handleEvent):
* WebProcess/Plugins/PluginView.h:

Source/WebKitLegacy/mac:

* DOM/ObjCEventListener.h:
* DOM/ObjCEventListener.mm:
(WebCore::ObjCEventListener::handleEvent):
* WebCoreSupport/WebFrameLoaderClient.mm:
(NetscapePluginWidget::handleEvent):

Source/WebKitLegacy/win:

* DOMEventsClasses.cpp:
(WebEventListener::handleEvent):
* DOMEventsClasses.h:
* Plugins/PluginView.cpp:
(WebCore::PluginView::handleEvent):
* Plugins/PluginView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219742 => 219743)


--- trunk/Source/WebCore/ChangeLog	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/ChangeLog	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1,3 +1,53 @@
+2017-07-21  Andreas Kling  <[email protected]>
+
+        Use more references in event dispatch code
+        https://bugs.webkit.org/show_bug.cgi?id=174681
+
+        Reviewed by Geoffrey Garen.
+
+        Make EventListener::handleEvent() take a ScriptExecutionContext&, Event&.
+        Then make everything build again. Various null checks and assertions
+        disappear in the process.
+
+        * bindings/js/JSErrorHandler.cpp:
+        (WebCore::JSErrorHandler::handleEvent):
+        * bindings/js/JSErrorHandler.h:
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSEventListener::initializeJSFunction):
+        (WebCore::JSEventListener::handleEvent):
+        (WebCore::eventHandlerAttribute):
+        * bindings/js/JSEventListener.h:
+        (WebCore::JSEventListener::jsFunction):
+        * bindings/js/JSLazyEventListener.cpp:
+        (WebCore::JSLazyEventListener::initializeJSFunction):
+        * bindings/js/JSLazyEventListener.h:
+        * dom/EventListener.h:
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::fireEventListeners):
+        * html/HTMLPlugInElement.cpp:
+        (WebCore::HTMLPlugInElement::defaultEventHandler):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageEventListener::handleEvent):
+        * inspector/CommandLineAPIHost.cpp:
+        (WebCore::listenerEntriesFromListenerInfo):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForEventListener):
+        * inspector/InspectorIndexedDBAgent.cpp:
+        * platform/Widget.h:
+        (WebCore::Widget::handleEvent):
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.h:
+        * platform/cocoa/WebPlaybackSessionModelMediaElement.mm:
+        (WebCore::WebPlaybackSessionModelMediaElement::handleEvent):
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.h:
+        * platform/cocoa/WebVideoFullscreenModelVideoElement.mm:
+        (WebVideoFullscreenModelVideoElement::handleEvent):
+        * svg/SVGTRefElement.cpp:
+        (WebCore::SVGTRefTargetEventListener::handleEvent):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::ConditionEventListener::handleEvent):
+        (WebCore::SVGSMILElement::handleConditionEvent):
+        * svg/animation/SVGSMILElement.h:
+
 2017-07-21  Zalan Bujtas  <[email protected]>
 
         iBooks: Overlapping/missing content at beginning/end of paragraph.

Modified: trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSErrorHandler.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -57,24 +57,20 @@
 {
 }
 
-void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
+void JSErrorHandler::handleEvent(ScriptExecutionContext& scriptExecutionContext, Event& event)
 {
-    if (!is<ErrorEvent>(*event))
+    if (!is<ErrorEvent>(event))
         return JSEventListener::handleEvent(scriptExecutionContext, event);
 
-    ASSERT(scriptExecutionContext);
-    if (!scriptExecutionContext)
-        return;
+    ErrorEvent& errorEvent = downcast<ErrorEvent>(event);
 
-    ErrorEvent& errorEvent = downcast<ErrorEvent>(*event);
+    JSLockHolder lock(scriptExecutionContext.vm());
 
-    JSLockHolder lock(scriptExecutionContext->vm());
-
     JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
     if (!jsFunction)
         return;
 
-    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
+    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(&scriptExecutionContext, isolatedWorld());
     if (!globalObject)
         return;
 
@@ -87,7 +83,7 @@
         Ref<JSErrorHandler> protectedThis(*this);
 
         Event* savedEvent = globalObject->currentEvent();
-        globalObject->setCurrentEvent(event);
+        globalObject->setCurrentEvent(&event);
 
         MarkedArgumentBuffer args;
         args.append(toJS<IDLDOMString>(*exec, errorEvent.message()));
@@ -99,14 +95,14 @@
         VM& vm = globalObject->vm();
         VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
 
-        InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData);
+        InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&scriptExecutionContext, callType, callData);
 
         NakedPtr<JSC::Exception> exception;
-        JSValue returnValue = scriptExecutionContext->isDocument()
+        JSValue returnValue = scriptExecutionContext.isDocument()
             ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, jsFunction, callType, callData, globalObject, args, exception)
             : JSC::profiledCall(exec, JSC::ProfilingReason::Other, jsFunction, callType, callData, globalObject, args, exception);
 
-        InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
+        InspectorInstrumentation::didCallFunction(cookie, &scriptExecutionContext);
 
         globalObject->setCurrentEvent(savedEvent);
 
@@ -114,7 +110,7 @@
             reportException(exec, exception);
         else {
             if (returnValue.isTrue())
-                event->preventDefault();
+                event.preventDefault();
         }
     }
 }

Modified: trunk/Source/WebCore/bindings/js/JSErrorHandler.h (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSErrorHandler.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSErrorHandler.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -45,7 +45,7 @@
 
 private:
     JSErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
-    void handleEvent(ScriptExecutionContext*, Event*) final;
+    void handleEvent(ScriptExecutionContext&, Event&) final;
 };
 
 // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because

Modified: trunk/Source/WebCore/bindings/js/JSEventListener.cpp (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSEventListener.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSEventListener.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -60,7 +60,7 @@
 {
 }
 
-JSObject* JSEventListener::initializeJSFunction(ScriptExecutionContext*) const
+JSObject* JSEventListener::initializeJSFunction(ScriptExecutionContext&) const
 {
     return nullptr;
 }
@@ -84,13 +84,12 @@
         event.setReturnValue(returnValue);
 }
 
-void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
+void JSEventListener::handleEvent(ScriptExecutionContext& scriptExecutionContext, Event& event)
 {
-    ASSERT(scriptExecutionContext);
-    if (!scriptExecutionContext || scriptExecutionContext->isJSExecutionForbidden())
+    if (scriptExecutionContext.isJSExecutionForbidden())
         return;
 
-    VM& vm = scriptExecutionContext->vm();
+    VM& vm = scriptExecutionContext.vm();
     JSLockHolder lock(vm);
     auto scope = DECLARE_CATCH_SCOPE(vm);
     // See https://dom.spec.whatwg.org/#dispatching-events spec on calling handleEvent.
@@ -101,15 +100,15 @@
     if (!jsFunction)
         return;
 
-    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, m_isolatedWorld);
+    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(&scriptExecutionContext, m_isolatedWorld);
     if (!globalObject)
         return;
 
-    if (scriptExecutionContext->isDocument()) {
+    if (scriptExecutionContext.isDocument()) {
         JSDOMWindow* window = jsCast<JSDOMWindow*>(globalObject);
         if (!window->wrapped().isCurrentlyDisplayedInFrame())
             return;
-        if (wasCreatedFromMarkup() && !scriptExecutionContext->contentSecurityPolicy()->allowInlineEventHandlers(sourceURL(), sourcePosition().m_line))
+        if (wasCreatedFromMarkup() && !scriptExecutionContext.contentSecurityPolicy()->allowInlineEventHandlers(sourceURL(), sourcePosition().m_line))
             return;
         // FIXME: Is this check needed for other contexts?
         ScriptController& script = window->wrapped().frame()->script();
@@ -129,7 +128,7 @@
             auto* exception = scope.exception();
             scope.clearException();
 
-            event->target()->uncaughtExceptionInEventHandler();
+            event.target()->uncaughtExceptionInEventHandler();
             reportException(exec, exception);
             return;
         }
@@ -140,27 +139,27 @@
         Ref<JSEventListener> protectedThis(*this);
 
         MarkedArgumentBuffer args;
-        args.append(toJS(exec, globalObject, event));
+        args.append(toJS(exec, globalObject, &event));
 
         Event* savedEvent = globalObject->currentEvent();
-        globalObject->setCurrentEvent(event);
+        globalObject->setCurrentEvent(&event);
 
         VMEntryScope entryScope(vm, vm.entryScope ? vm.entryScope->globalObject() : globalObject);
 
-        InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(scriptExecutionContext, callType, callData);
+        InspectorInstrumentationCookie cookie = JSMainThreadExecState::instrumentFunctionCall(&scriptExecutionContext, callType, callData);
 
-        JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event->currentTarget()) : jsFunction;
+        JSValue thisValue = handleEventFunction == jsFunction ? toJS(exec, globalObject, event.currentTarget()) : jsFunction;
         NakedPtr<JSC::Exception> exception;
-        JSValue retval = scriptExecutionContext->isDocument()
+        JSValue retval = scriptExecutionContext.isDocument()
             ? JSMainThreadExecState::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception)
             : JSC::profiledCall(exec, JSC::ProfilingReason::Other, handleEventFunction, callType, callData, thisValue, args, exception);
 
-        InspectorInstrumentation::didCallFunction(cookie, scriptExecutionContext);
+        InspectorInstrumentation::didCallFunction(cookie, &scriptExecutionContext);
 
         globalObject->setCurrentEvent(savedEvent);
 
-        if (is<WorkerGlobalScope>(*scriptExecutionContext)) {
-            auto scriptController = downcast<WorkerGlobalScope>(*scriptExecutionContext).script();
+        if (is<WorkerGlobalScope>(scriptExecutionContext)) {
+            auto scriptController = downcast<WorkerGlobalScope>(scriptExecutionContext).script();
             bool terminatorCausedException = (scope.exception() && isTerminatedExecutionException(vm, scope.exception()));
             if (terminatorCausedException || scriptController->isTerminatingExecution())
                 scriptController->forbidExecution();
@@ -167,15 +166,15 @@
         }
 
         if (exception) {
-            event->target()->uncaughtExceptionInEventHandler();
+            event.target()->uncaughtExceptionInEventHandler();
             reportException(exec, exception);
         } else {
-            if (is<BeforeUnloadEvent>(*event))
-                handleBeforeUnloadEventReturnValue(downcast<BeforeUnloadEvent>(*event), convert<IDLNullable<IDLDOMString>>(*exec, retval));
+            if (is<BeforeUnloadEvent>(event))
+                handleBeforeUnloadEventReturnValue(downcast<BeforeUnloadEvent>(event), convert<IDLNullable<IDLDOMString>>(*exec, retval));
 
             if (m_isAttribute) {
                 if (retval.isFalse())
-                    event->preventDefault();
+                    event.preventDefault();
             }
         }
     }
@@ -202,7 +201,7 @@
     if (!listener)
         return jsNull();
 
-    auto* function = listener->jsFunction(&context);
+    auto* function = listener->jsFunction(context);
     if (!function)
         return jsNull();
 

Modified: trunk/Source/WebCore/bindings/js/JSEventListener.h (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSEventListener.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSEventListener.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -65,7 +65,7 @@
     // Returns true if this event listener was created for an event handler attribute, like "onload" or "onclick".
     bool isAttribute() const { return m_isAttribute; }
 
-    JSC::JSObject* jsFunction(ScriptExecutionContext*) const;
+    JSC::JSObject* jsFunction(ScriptExecutionContext&) const;
     DOMWrapperWorld& isolatedWorld() const { return m_isolatedWorld; }
 
     JSC::JSObject* wrapper() const { return m_wrapper.get(); }
@@ -75,13 +75,13 @@
     virtual TextPosition sourcePosition() const { return TextPosition(); }
 
 private:
-    virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const;
+    virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext&) const;
     void visitJSFunction(JSC::SlotVisitor&) override;
     bool virtualisAttribute() const override;
 
 protected:
     JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
-    void handleEvent(ScriptExecutionContext*, Event*) override;
+    void handleEvent(ScriptExecutionContext&, Event&) override;
 
 private:
     mutable JSC::Weak<JSC::JSObject> m_jsFunction;
@@ -107,7 +107,7 @@
 JSC::JSValue documentEventHandlerAttribute(Document&, const AtomicString& eventType, DOMWrapperWorld&);
 void setDocumentEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, Document&, const AtomicString& eventType, JSC::JSValue);
 
-inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* scriptExecutionContext) const
+inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext& scriptExecutionContext) const
 {
     // initializeJSFunction can trigger code that deletes this event listener
     // before we're done. It should always return 0 in this case.

Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -76,12 +76,9 @@
 #endif
 }
 
-JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext* executionContext) const
+JSObject* JSLazyEventListener::initializeJSFunction(ScriptExecutionContext& executionContext) const
 {
     ASSERT(is<Document>(executionContext));
-    if (!executionContext)
-        return nullptr;
-
     ASSERT(!m_code.isNull());
     ASSERT(!m_eventParameterName.isNull());
     if (m_code.isNull() || m_eventParameterName.isNull())
@@ -91,7 +88,7 @@
     // element's document. The script execution context may be different from the node's document if the
     // node's document was created by _javascript_.
     // [1] https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler
-    Document& document = m_originalNode ? m_originalNode->document() : downcast<Document>(*executionContext);
+    Document& document = m_originalNode ? m_originalNode->document() : downcast<Document>(executionContext);
 
     if (!document.frame())
         return nullptr;
@@ -103,7 +100,7 @@
     if (!script.canExecuteScripts(AboutToExecuteScript) || script.isPaused())
         return nullptr;
 
-    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(executionContext, isolatedWorld());
+    JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(&executionContext, isolatedWorld());
     if (!globalObject)
         return nullptr;
 

Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.h (219742 => 219743)


--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -46,7 +46,7 @@
 
     JSLazyEventListener(const String& functionName, const String& eventParameterName, const String& code, ContainerNode*, const String& sourceURL, const TextPosition&, JSC::JSObject* wrapper, DOMWrapperWorld& isolatedWorld);
 
-    JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const override;
+    JSC::JSObject* initializeJSFunction(ScriptExecutionContext&) const override;
     bool wasCreatedFromMarkup() const override { return true; }
 
     String m_functionName;

Modified: trunk/Source/WebCore/dom/EventListener.h (219742 => 219743)


--- trunk/Source/WebCore/dom/EventListener.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/dom/EventListener.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -47,7 +47,7 @@
 
     virtual ~EventListener() { }
     virtual bool operator==(const EventListener&) const = 0;
-    virtual void handleEvent(ScriptExecutionContext*, Event*) = 0;
+    virtual void handleEvent(ScriptExecutionContext&, Event&) = 0;
     virtual bool wasCreatedFromMarkup() const { return false; }
 
     virtual void visitJSFunction(JSC::SlotVisitor&) { }

Modified: trunk/Source/WebCore/dom/EventTarget.cpp (219742 => 219743)


--- trunk/Source/WebCore/dom/EventTarget.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/dom/EventTarget.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -232,12 +232,13 @@
 {
     Ref<EventTarget> protectedThis(*this);
     ASSERT(!listeners.isEmpty());
+    ASSERT(scriptExecutionContext());
 
-    auto* context = scriptExecutionContext();
+    auto& context = *scriptExecutionContext();
     bool contextIsDocument = is<Document>(context);
     InspectorInstrumentationCookie willDispatchEventCookie;
     if (contextIsDocument)
-        willDispatchEventCookie = InspectorInstrumentation::willDispatchEvent(downcast<Document>(*context), event, true);
+        willDispatchEventCookie = InspectorInstrumentation::willDispatchEvent(downcast<Document>(context), event, true);
 
     for (auto& registeredListener : listeners) {
         if (UNLIKELY(registeredListener->wasRemoved()))
@@ -260,8 +261,8 @@
         if (registeredListener->isPassive())
             event.setInPassiveListener(true);
 
-        InspectorInstrumentation::willHandleEvent(context, event);
-        registeredListener->callback().handleEvent(context, &event);
+        InspectorInstrumentation::willHandleEvent(&context, event);
+        registeredListener->callback().handleEvent(context, event);
 
         if (registeredListener->isPassive())
             event.setInPassiveListener(false);

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (219742 => 219743)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -213,7 +213,7 @@
         RefPtr<Widget> widget = downcast<RenderWidget>(*renderer).widget();
         if (!widget)
             return;
-        widget->handleEvent(&event);
+        widget->handleEvent(event);
         if (event.defaultHandled())
             return;
     }

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (219742 => 219743)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -65,7 +65,7 @@
     }
 
     bool operator==(const EventListener&) const override;
-    void handleEvent(ScriptExecutionContext*, Event*) override;
+    void handleEvent(ScriptExecutionContext&, Event&) override;
 
     ImageDocument& m_document;
 };
@@ -401,12 +401,12 @@
     }
 }
 
-void ImageEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+void ImageEventListener::handleEvent(ScriptExecutionContext&, Event& event)
 {
-    if (event->type() == eventNames().resizeEvent)
+    if (event.type() == eventNames().resizeEvent)
         m_document.windowSizeChanged();
-    else if (event->type() == eventNames().clickEvent && is<MouseEvent>(*event)) {
-        MouseEvent& mouseEvent = downcast<MouseEvent>(*event);
+    else if (event.type() == eventNames().clickEvent && is<MouseEvent>(event)) {
+        MouseEvent& mouseEvent = downcast<MouseEvent>(event);
         m_document.imageClicked(mouseEvent.offsetX(), mouseEvent.offsetY());
     }
 }

Modified: trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp (219742 => 219743)


--- trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/inspector/CommandLineAPIHost.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -107,7 +107,7 @@
         if (&jsListener->isolatedWorld() != &currentWorld(&state))
             continue;
 
-        auto function = jsListener->jsFunction(&document);
+        auto function = jsListener->jsFunction(document);
         if (!function)
             continue;
 

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (219742 => 219743)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1543,7 +1543,7 @@
     if (auto scriptListener = JSEventListener::cast(eventListener.ptr())) {
         JSC::JSLockHolder lock(scriptListener->isolatedWorld().vm());
         state = execStateFromNode(scriptListener->isolatedWorld(), &node->document());
-        handler = scriptListener->jsFunction(&node->document());
+        handler = scriptListener->jsFunction(node->document());
         if (handler && state) {
             body = handler->toString(state)->value(state);
             if (auto function = jsDynamicDowncast<JSC::JSFunction*>(state->vm(), handler)) {

Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (219742 => 219743)


--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -115,14 +115,14 @@
         return this == &other;
     }
 
-    void handleEvent(ScriptExecutionContext*, Event* event) final
+    void handleEvent(ScriptExecutionContext&, Event& event) final
     {
-        if (event->type() != eventNames().successEvent) {
+        if (event.type() != eventNames().successEvent) {
             m_executableWithDatabase->requestCallback().sendFailure("Unexpected event type.");
             return;
         }
 
-        auto& request = static_cast<IDBOpenDBRequest&>(*event->target());
+        auto& request = static_cast<IDBOpenDBRequest&>(*event.target());
 
         auto result = request.result();
         if (result.hasException()) {
@@ -357,14 +357,14 @@
         return this == &other;
     }
 
-    void handleEvent(ScriptExecutionContext* context, Event* event) override
+    void handleEvent(ScriptExecutionContext&, Event& event) override
     {
-        if (event->type() != eventNames().successEvent) {
+        if (event.type() != eventNames().successEvent) {
             m_requestCallback->sendFailure("Unexpected event type.");
             return;
         }
 
-        auto& request = static_cast<IDBRequest&>(*event->target());
+        auto& request = static_cast<IDBRequest&>(*event.target());
 
         auto result = request.result();
         if (result.hasException()) {
@@ -398,10 +398,6 @@
             return;
         }
 
-        auto* state = context ? context->execState() : nullptr;
-        if (!state)
-            return;
-
         auto dataEntry = DataEntry::create()
             .setKey(m_injectedScript.wrapObject(cursor->key(), String(), true))
             .setPrimaryKey(m_injectedScript.wrapObject(cursor->primaryKey(), String(), true))
@@ -646,11 +642,11 @@
         return this == &other;
     }
 
-    void handleEvent(ScriptExecutionContext*, Event* event) override
+    void handleEvent(ScriptExecutionContext&, Event& event) override
     {
         if (!m_requestCallback->isActive())
             return;
-        if (event->type() != eventNames().completeEvent) {
+        if (event.type() != eventNames().completeEvent) {
             m_requestCallback->sendFailure("Unexpected event type.");
             return;
         }

Modified: trunk/Source/WebCore/platform/Widget.h (219742 => 219743)


--- trunk/Source/WebCore/platform/Widget.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/platform/Widget.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -149,7 +149,7 @@
     ScrollView* parent() const { return m_parent; }
     FrameView* root() const;
 
-    virtual void handleEvent(Event*) { }
+    virtual void handleEvent(Event&) { }
 
     virtual void notifyWidget(WidgetNotification) { }
 

Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h (219742 => 219743)


--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -51,7 +51,7 @@
     WEBCORE_EXPORT void setMediaElement(HTMLMediaElement*);
     HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); }
 
-    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) final;
+    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&) final;
     void updateForEventName(const WTF::AtomicString&);
     bool operator==(const EventListener& rhs) const final { return static_cast<const WebCore::EventListener*>(this) == &rhs; }
 

Modified: trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm (219742 => 219743)


--- trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/platform/cocoa/WebPlaybackSessionModelMediaElement.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -85,9 +85,9 @@
     updateForEventName(eventNameAll());
 }
 
-void WebPlaybackSessionModelMediaElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
+void WebPlaybackSessionModelMediaElement::handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event& event)
 {
-    updateForEventName(event->type());
+    updateForEventName(event.type());
 }
 
 void WebPlaybackSessionModelMediaElement::updateForEventName(const WTF::AtomicString& eventName)

Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h (219742 => 219743)


--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -57,7 +57,7 @@
     WEBCORE_EXPORT void setVideoFullscreenLayer(PlatformLayer*, WTF::Function<void()>&& completionHandler = [] { });
     WEBCORE_EXPORT void waitForPreparedForInlineThen(WTF::Function<void()>&& completionHandler = [] { });
     
-    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
+    WEBCORE_EXPORT void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&) override;
     void updateForEventName(const WTF::AtomicString&);
     bool operator==(const EventListener& rhs) const override { return static_cast<const WebCore::EventListener*>(this) == &rhs; }
 

Modified: trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm (219742 => 219743)


--- trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/platform/cocoa/WebVideoFullscreenModelVideoElement.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -81,9 +81,9 @@
     updateForEventName(eventNameAll());
 }
 
-void WebVideoFullscreenModelVideoElement::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event* event)
+void WebVideoFullscreenModelVideoElement::handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event& event)
 {
-    updateForEventName(event->type());
+    updateForEventName(event.type());
 }
 
 void WebVideoFullscreenModelVideoElement::updateForEventName(const WTF::AtomicString& eventName)

Modified: trunk/Source/WebCore/svg/SVGTRefElement.cpp (219742 => 219743)


--- trunk/Source/WebCore/svg/SVGTRefElement.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/svg/SVGTRefElement.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -72,7 +72,7 @@
 private:
     explicit SVGTRefTargetEventListener(SVGTRefElement& trefElement);
 
-    void handleEvent(ScriptExecutionContext*, Event*) final;
+    void handleEvent(ScriptExecutionContext&, Event&) final;
     bool operator==(const EventListener&) const final;
 
     SVGTRefElement& m_trefElement;
@@ -114,13 +114,13 @@
     return false;
 }
 
-void SVGTRefTargetEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+void SVGTRefTargetEventListener::handleEvent(ScriptExecutionContext&, Event& event)
 {
     ASSERT(isAttached());
 
-    if (event->type() == eventNames().DOMSubtreeModifiedEvent && &m_trefElement != event->target())
+    if (event.type() == eventNames().DOMSubtreeModifiedEvent && &m_trefElement != event.target())
         m_trefElement.updateReferencedText(m_target.get());
-    else if (event->type() == eventNames().DOMNodeRemovedFromDocumentEvent)
+    else if (event.type() == eventNames().DOMNodeRemovedFromDocumentEvent)
         m_trefElement.detachTarget();
 }
 

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (219742 => 219743)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -91,7 +91,7 @@
     {
     }
 
-    void handleEvent(ScriptExecutionContext*, Event*) final;
+    void handleEvent(ScriptExecutionContext&, Event&) final;
 
     SVGSMILElement* m_animation;
     SVGSMILElement::Condition* m_condition;
@@ -104,11 +104,11 @@
     return false;
 }
 
-void ConditionEventListener::handleEvent(ScriptExecutionContext*, Event* event) 
+void ConditionEventListener::handleEvent(ScriptExecutionContext&, Event&)
 {
     if (!m_animation)
         return;
-    m_animation->handleConditionEvent(event, m_condition);
+    m_animation->handleConditionEvent(m_condition);
 }
 
 SVGSMILElement::Condition::Condition(Type type, BeginOrEnd beginOrEnd, const String& baseID, const String& name, SMILTime offset, int repeats)
@@ -1195,7 +1195,7 @@
     m_timeDependents.remove(animation);
 }
     
-void SVGSMILElement::handleConditionEvent(Event*, Condition* condition)
+void SVGSMILElement::handleConditionEvent(Condition* condition)
 {
     SMILTime elapsed = this->elapsed();
     if (condition->m_beginOrEnd == Begin)

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (219742 => 219743)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -166,7 +166,7 @@
     void disconnectConditions();
 
     // Event base timing
-    void handleConditionEvent(Event*, Condition*);
+    void handleConditionEvent(Condition*);
 
     // Syncbase timing
     enum NewOrExistingInterval { NewInterval, ExistingInterval };

Modified: trunk/Source/WebKit/ChangeLog (219742 => 219743)


--- trunk/Source/WebKit/ChangeLog	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/ChangeLog	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1,3 +1,25 @@
+2017-07-21  Andreas Kling  <[email protected]>
+
+        Use more references in event dispatch code
+        https://bugs.webkit.org/show_bug.cgi?id=174681
+
+        Reviewed by Geoffrey Garen.
+
+        * WebProcess/Plugins/PDF/PDFPluginAnnotation.h:
+        * WebProcess/Plugins/PDF/PDFPluginAnnotation.mm:
+        (WebKit::PDFPluginAnnotation::handleEvent):
+        (WebKit::PDFPluginAnnotation::PDFPluginAnnotationEventListener::handleEvent):
+        * WebProcess/Plugins/PDF/PDFPluginPasswordField.h:
+        * WebProcess/Plugins/PDF/PDFPluginPasswordField.mm:
+        (WebKit::PDFPluginPasswordField::handleEvent):
+        * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h:
+        * WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm:
+        (WebKit::PDFPluginTextAnnotation::handleEvent):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::createWebEvent):
+        (WebKit::PluginView::handleEvent):
+        * WebProcess/Plugins/PluginView.h:
+
 2017-07-21  Chris Dumez  <[email protected]>
 
         WebResourceLoadStatisticsStore::m_operatingDates is unsafely modified from several threads

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -64,13 +64,13 @@
     m_handler = nullptr;
 }
 
-void GObjectEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+void GObjectEventListener::handleEvent(ScriptExecutionContext&, Event& event)
 {
     GValue parameters[2] = { G_VALUE_INIT, G_VALUE_INIT };
     g_value_init(&parameters[0], WEBKIT_DOM_TYPE_EVENT_TARGET);
     g_value_set_object(&parameters[0], m_target);
 
-    GRefPtr<WebKitDOMEvent> domEvent = adoptGRef(WebKit::kit(event));
+    GRefPtr<WebKitDOMEvent> domEvent = adoptGRef(WebKit::kit(&event));
     g_value_init(&parameters[1], WEBKIT_DOM_TYPE_EVENT);
     g_value_set_object(&parameters[1], domEvent.get());
 

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -63,7 +63,7 @@
     ~GObjectEventListener();
     void gobjectDestroyed();
 
-    void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
+    void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&) override;
 
     GObject* m_target;
     // We do not need to keep a reference to the m_coreTarget, because

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -72,7 +72,7 @@
     PDFLayerController *pdfLayerController() const { return m_pdfLayerController; }
     WebCore::EventListener* eventListener() const { return m_eventListener.get(); }
 
-    virtual bool handleEvent(WebCore::Event*);
+    virtual bool handleEvent(WebCore::Event&);
 
 private:
     virtual Ref<WebCore::Element> createAnnotationElement() = 0;
@@ -96,7 +96,7 @@
         {
         }
 
-        void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) override;
+        void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&) override;
 
         PDFPluginAnnotation* m_annotation;
     };

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -110,9 +110,9 @@
     styledElement->setInlineStyleProperty(CSSPropertyTop, documentSize.height() - annotationRect.origin.y - annotationRect.size.height - scrollPosition.y(), CSSPrimitiveValue::CSS_PX);
 }
 
-bool PDFPluginAnnotation::handleEvent(Event* event)
+bool PDFPluginAnnotation::handleEvent(Event& event)
 {
-    if (event->type() == eventNames().blurEvent || event->type() == eventNames().changeEvent) {
+    if (event.type() == eventNames().blurEvent || event.type() == eventNames().changeEvent) {
         m_plugin->setActiveAnnotation(0);
         return true;
     }
@@ -120,7 +120,7 @@
     return false;
 }
 
-void PDFPluginAnnotation::PDFPluginAnnotationEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+void PDFPluginAnnotation::PDFPluginAnnotationEventListener::handleEvent(ScriptExecutionContext&, Event& event)
 {
     if (m_annotation)
         m_annotation->handleEvent(event);

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.h (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -47,7 +47,7 @@
 
     Ref<WebCore::Element> createAnnotationElement() override;
 
-    bool handleEvent(WebCore::Event*) override;
+    bool handleEvent(WebCore::Event&) override;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginPasswordField.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -65,14 +65,14 @@
 {
 }
 
-bool PDFPluginPasswordField::handleEvent(WebCore::Event* event)
+bool PDFPluginPasswordField::handleEvent(WebCore::Event& event)
 {
-    if (event->isKeyboardEvent() && event->type() == eventNames().keyupEvent) {
-        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
+    if (event.isKeyboardEvent() && event.type() == eventNames().keyupEvent) {
+        auto& keyboardEvent = downcast<KeyboardEvent>(event);
 
-        if (keyboardEvent->keyIdentifier() == "Enter") {
+        if (keyboardEvent.keyIdentifier() == "Enter") {
             plugin()->attemptToUnlockPDF(value());
-            event->preventDefault();
+            event.preventDefault();
             return true;
         }
     }

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -58,7 +58,7 @@
     String value() const;
 
 private:
-    bool handleEvent(WebCore::Event*) override;
+    bool handleEvent(WebCore::Event&) override;
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -128,24 +128,24 @@
     return downcast<HTMLTextFormControlElement>(element())->value();
 }
 
-bool PDFPluginTextAnnotation::handleEvent(Event* event)
+bool PDFPluginTextAnnotation::handleEvent(Event& event)
 {
     if (PDFPluginAnnotation::handleEvent(event))
         return true;
 
-    if (event->isKeyboardEvent() && event->type() == eventNames().keydownEvent) {
-        KeyboardEvent* keyboardEvent = static_cast<KeyboardEvent*>(event);
+    if (event.isKeyboardEvent() && event.type() == eventNames().keydownEvent) {
+        auto& keyboardEvent = downcast<KeyboardEvent>(event);
 
-        if (keyboardEvent->keyIdentifier() == "U+0009") {
-            if (keyboardEvent->ctrlKey() || keyboardEvent->metaKey() || keyboardEvent->altGraphKey())
+        if (keyboardEvent.keyIdentifier() == "U+0009") {
+            if (keyboardEvent.ctrlKey() || keyboardEvent.metaKey() || keyboardEvent.altGraphKey())
                 return false;
 
-            if (keyboardEvent->shiftKey())
+            if (keyboardEvent.shiftKey())
                 plugin()->focusPreviousAnnotation();
             else
                 plugin()->focusNextAnnotation();
             
-            event->preventDefault();
+            event.preventDefault();
             return true;
         }
     }

Modified: trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -855,24 +855,24 @@
     return m_plugin->getSelectionString();
 }
 
-std::unique_ptr<WebEvent> PluginView::createWebEvent(MouseEvent* event) const
+std::unique_ptr<WebEvent> PluginView::createWebEvent(MouseEvent& event) const
 {
     WebEvent::Type type = WebEvent::NoType;
     unsigned clickCount = 1;
-    if (event->type() == eventNames().mousedownEvent)
+    if (event.type() == eventNames().mousedownEvent)
         type = WebEvent::MouseDown;
-    else if (event->type() == eventNames().mouseupEvent)
+    else if (event.type() == eventNames().mouseupEvent)
         type = WebEvent::MouseUp;
-    else if (event->type() == eventNames().mouseoverEvent) {
+    else if (event.type() == eventNames().mouseoverEvent) {
         type = WebEvent::MouseMove;
         clickCount = 0;
-    } else if (event->type() == eventNames().clickEvent)
+    } else if (event.type() == eventNames().clickEvent)
         return nullptr;
     else
         ASSERT_NOT_REACHED();
 
     WebMouseEvent::Button button = WebMouseEvent::NoButton;
-    switch (event->button()) {
+    switch (event.button()) {
     case WebCore::LeftButton:
         button = WebMouseEvent::LeftButton;
         break;
@@ -888,19 +888,19 @@
     }
 
     unsigned modifiers = 0;
-    if (event->shiftKey())
+    if (event.shiftKey())
         modifiers |= WebEvent::ShiftKey;
-    if (event->ctrlKey())
+    if (event.ctrlKey())
         modifiers |= WebEvent::ControlKey;
-    if (event->altKey())
+    if (event.altKey())
         modifiers |= WebEvent::AltKey;
-    if (event->metaKey())
+    if (event.metaKey())
         modifiers |= WebEvent::MetaKey;
 
-    return std::make_unique<WebMouseEvent>(type, button, m_plugin->convertToRootView(IntPoint(event->offsetX(), event->offsetY())), event->screenLocation(), 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(modifiers), 0, 0);
+    return std::make_unique<WebMouseEvent>(type, button, m_plugin->convertToRootView(IntPoint(event.offsetX(), event.offsetY())), event.screenLocation(), 0, 0, 0, clickCount, static_cast<WebEvent::Modifiers>(modifiers), 0, 0);
 }
 
-void PluginView::handleEvent(Event* event)
+void PluginView::handleEvent(Event& event)
 {
     if (!m_isInitialized || !m_plugin)
         return;
@@ -907,7 +907,7 @@
 
     const WebEvent* currentEvent = WebPage::currentEvent();
     std::unique_ptr<WebEvent> simulatedWebEvent;
-    if (is<MouseEvent>(*event) && downcast<MouseEvent>(*event).isSimulated()) {
+    if (is<MouseEvent>(event) && downcast<MouseEvent>(event).isSimulated()) {
         simulatedWebEvent = createWebEvent(downcast<MouseEvent>(event));
         currentEvent = simulatedWebEvent.get();
     }
@@ -916,9 +916,9 @@
 
     bool didHandleEvent = false;
 
-    if ((event->type() == eventNames().mousemoveEvent && currentEvent->type() == WebEvent::MouseMove)
-        || (event->type() == eventNames().mousedownEvent && currentEvent->type() == WebEvent::MouseDown)
-        || (event->type() == eventNames().mouseupEvent && currentEvent->type() == WebEvent::MouseUp)) {
+    if ((event.type() == eventNames().mousemoveEvent && currentEvent->type() == WebEvent::MouseMove)
+        || (event.type() == eventNames().mousedownEvent && currentEvent->type() == WebEvent::MouseDown)
+        || (event.type() == eventNames().mouseupEvent && currentEvent->type() == WebEvent::MouseUp)) {
         // FIXME: Clicking in a scroll bar should not change focus.
         if (currentEvent->type() == WebEvent::MouseDown) {
             focusPluginElement();
@@ -927,27 +927,27 @@
             frame()->eventHandler().setCapturingMouseEventsElement(nullptr);
 
         didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
-        if (event->type() != eventNames().mousemoveEvent)
+        if (event.type() != eventNames().mousemoveEvent)
             pluginDidReceiveUserInteraction();
-    } else if (eventNames().isWheelEventType(event->type())
+    } else if (eventNames().isWheelEventType(event.type())
         && currentEvent->type() == WebEvent::Wheel && m_plugin->wantsWheelEvents()) {
         didHandleEvent = m_plugin->handleWheelEvent(static_cast<const WebWheelEvent&>(*currentEvent));
         pluginDidReceiveUserInteraction();
-    } else if (event->type() == eventNames().mouseoverEvent && currentEvent->type() == WebEvent::MouseMove)
+    } else if (event.type() == eventNames().mouseoverEvent && currentEvent->type() == WebEvent::MouseMove)
         didHandleEvent = m_plugin->handleMouseEnterEvent(static_cast<const WebMouseEvent&>(*currentEvent));
-    else if (event->type() == eventNames().mouseoutEvent && currentEvent->type() == WebEvent::MouseMove)
+    else if (event.type() == eventNames().mouseoutEvent && currentEvent->type() == WebEvent::MouseMove)
         didHandleEvent = m_plugin->handleMouseLeaveEvent(static_cast<const WebMouseEvent&>(*currentEvent));
-    else if (event->type() == eventNames().contextmenuEvent && currentEvent->type() == WebEvent::MouseDown) {
+    else if (event.type() == eventNames().contextmenuEvent && currentEvent->type() == WebEvent::MouseDown) {
         didHandleEvent = m_plugin->handleContextMenuEvent(static_cast<const WebMouseEvent&>(*currentEvent));
         pluginDidReceiveUserInteraction();
-    } else if ((event->type() == eventNames().keydownEvent && currentEvent->type() == WebEvent::KeyDown)
-               || (event->type() == eventNames().keyupEvent && currentEvent->type() == WebEvent::KeyUp)) {
+    } else if ((event.type() == eventNames().keydownEvent && currentEvent->type() == WebEvent::KeyDown)
+               || (event.type() == eventNames().keyupEvent && currentEvent->type() == WebEvent::KeyUp)) {
         didHandleEvent = m_plugin->handleKeyboardEvent(static_cast<const WebKeyboardEvent&>(*currentEvent));
         pluginDidReceiveUserInteraction();
     }
 
     if (didHandleEvent)
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
     
 bool PluginView::handleEditingCommand(const String& commandName, const String& argument)

Modified: trunk/Source/WebKit/WebProcess/Plugins/PluginView.h (219742 => 219743)


--- trunk/Source/WebKit/WebProcess/Plugins/PluginView.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKit/WebProcess/Plugins/PluginView.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -176,7 +176,7 @@
     void setFocus(bool) override;
     void frameRectsChanged() override;
     void setParent(WebCore::ScrollView*) override;
-    void handleEvent(WebCore::Event*) override;
+    void handleEvent(WebCore::Event&) override;
     void notifyWidget(WebCore::WidgetNotification) override;
     void show() override;
     void hide() override;
@@ -238,7 +238,7 @@
     void didFinishLoad(WebFrame*) override;
     void didFailLoad(WebFrame*, bool wasCancelled) override;
 
-    std::unique_ptr<WebEvent> createWebEvent(WebCore::MouseEvent*) const;
+    std::unique_ptr<WebEvent> createWebEvent(WebCore::MouseEvent&) const;
 
     RefPtr<WebCore::HTMLPlugInElement> m_pluginElement;
     RefPtr<Plugin> m_plugin;

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (219742 => 219743)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1,3 +1,16 @@
+2017-07-21  Andreas Kling  <[email protected]>
+
+        Use more references in event dispatch code
+        https://bugs.webkit.org/show_bug.cgi?id=174681
+
+        Reviewed by Geoffrey Garen.
+
+        * DOM/ObjCEventListener.h:
+        * DOM/ObjCEventListener.mm:
+        (WebCore::ObjCEventListener::handleEvent):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (NetscapePluginWidget::handleEvent):
+
 2017-07-21  Brady Eidson  <[email protected]>
 
         Get rid of WebCore IconDatabase code.

Modified: trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.h (219742 => 219743)


--- trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -52,7 +52,7 @@
         ObjCEventListener(ObjCListener);
         virtual ~ObjCEventListener();
         virtual bool operator==(const EventListener&) const;
-        virtual void handleEvent(ScriptExecutionContext*, Event*);
+        virtual void handleEvent(ScriptExecutionContext&, Event&);
 
         RetainPtr<ObjCListener> m_listener;
     };

Modified: trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.mm (219742 => 219743)


--- trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/mac/DOM/ObjCEventListener.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -72,10 +72,10 @@
     listenerMap->remove(m_listener.get());
 }
 
-void ObjCEventListener::handleEvent(ScriptExecutionContext*, Event* event)
+void ObjCEventListener::handleEvent(ScriptExecutionContext&, Event& event)
 {
     ObjCListener listener = m_listener.get();
-    [listener handleEvent:kit(event)];
+    [listener handleEvent:kit(&event)];
 }
 
 bool ObjCEventListener::operator==(const EventListener& listener) const

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (219742 => 219743)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1842,7 +1842,7 @@
         return false;
     }
 
-    virtual void handleEvent(Event* event)
+    virtual void handleEvent(Event& event)
     {
         Frame* frame = Frame::frameForWidget(*this);
         if (!frame)
@@ -1849,14 +1849,14 @@
             return;
         
         NSEvent* currentNSEvent = frame->eventHandler().currentNSEvent();
-        if (event->type() == eventNames().mousemoveEvent)
+        if (event.type() == eventNames().mousemoveEvent)
             [(WebBaseNetscapePluginView *)platformWidget() handleMouseMoved:currentNSEvent];
-        else if (event->type() == eventNames().mouseoverEvent)
+        else if (event.type() == eventNames().mouseoverEvent)
             [(WebBaseNetscapePluginView *)platformWidget() handleMouseEntered:currentNSEvent];
-        else if (event->type() == eventNames().mouseoutEvent)
+        else if (event.type() == eventNames().mouseoutEvent)
             [(WebBaseNetscapePluginView *)platformWidget() handleMouseExited:currentNSEvent];
-        else if (event->type() == eventNames().contextmenuEvent)
-            event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
+        else if (event.type() == eventNames().contextmenuEvent)
+            event.setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
     }
 
     virtual void clipRectChanged()

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2017-07-21 21:16:29 UTC (rev 219743)
@@ -1,3 +1,17 @@
+2017-07-21  Andreas Kling  <[email protected]>
+
+        Use more references in event dispatch code
+        https://bugs.webkit.org/show_bug.cgi?id=174681
+
+        Reviewed by Geoffrey Garen.
+
+        * DOMEventsClasses.cpp:
+        (WebEventListener::handleEvent):
+        * DOMEventsClasses.h:
+        * Plugins/PluginView.cpp:
+        (WebCore::PluginView::handleEvent):
+        * Plugins/PluginView.h:
+
 2017-07-20  Brady Eidson  <[email protected]>
 
         Remove WebIconDatabase from WebKitLegacy/win.

Modified: trunk/Source/WebKitLegacy/win/DOMEventsClasses.cpp (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/DOMEventsClasses.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/DOMEventsClasses.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -74,9 +74,9 @@
         && reinterpret_cast<const WebEventListener*>(&other)->m_iDOMEventListener == m_iDOMEventListener);
 }
 
-void WebEventListener::handleEvent(WebCore::ScriptExecutionContext* s, WebCore::Event* e)
+void WebEventListener::handleEvent(WebCore::ScriptExecutionContext& s, WebCore::Event& e)
 {
-    RefPtr<WebCore::Event> ePtr(e);
+    RefPtr<WebCore::Event> ePtr(&e);
     COMPtr<IDOMEvent> domEvent = DOMEvent::createInstance(WTFMove(ePtr));
     m_iDOMEventListener->handleEvent(domEvent.get());
 }

Modified: trunk/Source/WebKitLegacy/win/DOMEventsClasses.h (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/DOMEventsClasses.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/DOMEventsClasses.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -46,7 +46,7 @@
     WebEventListener(IDOMEventListener*);
     ~WebEventListener();
     virtual bool operator==(const EventListener&) const;
-    virtual void handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*);
+    virtual void handleEvent(WebCore::ScriptExecutionContext&, WebCore::Event&);
     static Ref<WebEventListener> create(IDOMEventListener*);
 private:
     IDOMEventListener* m_iDOMEventListener;

Modified: trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/Plugins/PluginView.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -162,7 +162,7 @@
     updatePluginWidget();
 }
 
-void PluginView::handleEvent(Event* event)
+void PluginView::handleEvent(Event& event)
 {
     if (!m_plugin || m_isWindowed)
         return;
@@ -170,12 +170,12 @@
     // Protect the plug-in from deletion while dispatching the event.
     RefPtr<PluginView> protect(this);
 
-    if (event->isMouseEvent())
-        handleMouseEvent(static_cast<MouseEvent*>(event));
-    else if (event->isKeyboardEvent())
-        handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
-    else if (event->type() == eventNames().contextmenuEvent)
-        event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
+    if (event.isMouseEvent())
+        handleMouseEvent(downcast<MouseEvent>(event));
+    else if (event.isKeyboardEvent())
+        handleKeyboardEvent(downcast<KeyboardEvent>(event));
+    else if (event.type() == eventNames().contextmenuEvent)
+        event.setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
 }
 
 void PluginView::init()

Modified: trunk/Source/WebKitLegacy/win/Plugins/PluginView.h (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/Plugins/PluginView.h	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/Plugins/PluginView.h	2017-07-21 21:16:29 UTC (rev 219743)
@@ -190,7 +190,7 @@
         // This clip includes any clips that the widget itself sets up for its children.
         IntRect windowClipRect() const;
 
-        void handleEvent(Event*) override;
+        void handleEvent(Event&) override;
         void setParent(ScrollView*) override;
         void setParentVisible(bool) override;
 
@@ -291,8 +291,8 @@
         void updatePluginWidget();
         void paintMissingPluginIcon(GraphicsContext&, const IntRect&);
 
-        void handleKeyboardEvent(KeyboardEvent*);
-        void handleMouseEvent(MouseEvent*);
+        void handleKeyboardEvent(KeyboardEvent&);
+        void handleMouseEvent(MouseEvent&);
 
         void paintIntoTransformedContext(HDC);
         RefPtr<Image> snapshot();

Modified: trunk/Source/WebKitLegacy/win/Plugins/PluginViewWin.cpp (219742 => 219743)


--- trunk/Source/WebKitLegacy/win/Plugins/PluginViewWin.cpp	2017-07-21 21:04:43 UTC (rev 219742)
+++ trunk/Source/WebKitLegacy/win/Plugins/PluginViewWin.cpp	2017-07-21 21:16:29 UTC (rev 219743)
@@ -576,21 +576,21 @@
     paintIntoTransformedContext(windowsContext.hdc());
 }
 
-void PluginView::handleKeyboardEvent(KeyboardEvent* event)
+void PluginView::handleKeyboardEvent(KeyboardEvent& event)
 {
     ASSERT(m_plugin && !m_isWindowed);
 
     NPEvent npEvent;
 
-    npEvent.wParam = event->keyCode();
+    npEvent.wParam = event.keyCode();
 
-    if (event->type() == eventNames().keydownEvent) {
+    if (event.type() == eventNames().keydownEvent) {
         npEvent.event = WM_KEYDOWN;
         npEvent.lParam = 0;
-    } else if (event->type() == eventNames().keypressEvent) {
+    } else if (event.type() == eventNames().keypressEvent) {
         npEvent.event = WM_CHAR;
         npEvent.lParam = 0;
-    } else if (event->type() == eventNames().keyupEvent) {
+    } else if (event.type() == eventNames().keyupEvent) {
         npEvent.event = WM_KEYUP;
         npEvent.lParam = 0x8000;
     } else
@@ -598,33 +598,33 @@
 
     JSC::JSLock::DropAllLocks dropAllLocks(commonVM());
     if (dispatchNPEvent(npEvent))
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 }
 
 extern bool ignoreNextSetCursor;
 
-void PluginView::handleMouseEvent(MouseEvent* event)
+void PluginView::handleMouseEvent(MouseEvent& event)
 {
     ASSERT(m_plugin && !m_isWindowed);
 
     NPEvent npEvent;
 
-    IntPoint p = contentsToNativeWindow(downcast<FrameView>(parent()), IntPoint(event->pageX(), event->pageY()));
+    IntPoint p = contentsToNativeWindow(downcast<FrameView>(parent()), IntPoint(event.pageX(), event.pageY()));
 
     npEvent.lParam = MAKELPARAM(p.x(), p.y());
     npEvent.wParam = 0;
 
-    if (event->ctrlKey())
+    if (event.ctrlKey())
         npEvent.wParam |= MK_CONTROL;
-    if (event->shiftKey())
+    if (event.shiftKey())
         npEvent.wParam |= MK_SHIFT;
 
-    if (event->type() == eventNames().mousemoveEvent
-        || event->type() == eventNames().mouseoutEvent
-        || event->type() == eventNames().mouseoverEvent) {
+    if (event.type() == eventNames().mousemoveEvent
+        || event.type() == eventNames().mouseoutEvent
+        || event.type() == eventNames().mouseoverEvent) {
         npEvent.event = WM_MOUSEMOVE;
-        if (event->buttonDown())
-            switch (event->button()) {
+        if (event.buttonDown())
+            switch (event.button()) {
             case LeftButton:
                 npEvent.wParam |= MK_LBUTTON;
                 break;
@@ -635,9 +635,9 @@
                 npEvent.wParam |= MK_RBUTTON;
                 break;
             }
-    } else if (event->type() == eventNames().mousedownEvent) {
+    } else if (event.type() == eventNames().mousedownEvent) {
         focusPluginElement();
-        switch (event->button()) {
+        switch (event.button()) {
         case LeftButton:
             npEvent.event = WM_LBUTTONDOWN;
             break;
@@ -648,8 +648,8 @@
             npEvent.event = WM_RBUTTONDOWN;
             break;
         }
-    } else if (event->type() == eventNames().mouseupEvent) {
-        switch (event->button()) {
+    } else if (event.type() == eventNames().mouseupEvent) {
+        switch (event.button()) {
         case LeftButton:
             npEvent.event = WM_LBUTTONUP;
             break;
@@ -666,7 +666,7 @@
     JSC::JSLock::DropAllLocks dropAllLocks(commonVM());
     // FIXME: Consider back porting the http://webkit.org/b/58108 fix here.
     if (dispatchNPEvent(npEvent))
-        event->setDefaultHandled();
+        event.setDefaultHandled();
 
     // Currently, Widget::setCursor is always called after this function in EventHandler.cpp
     // and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to