Title: [254213] trunk/Source/WebKit
Revision
254213
Author
[email protected]
Date
2020-01-08 11:58:05 -0800 (Wed, 08 Jan 2020)

Log Message

Remove NATIVE_MOUSE_EVENT_HANDLER macros
https://bugs.webkit.org/show_bug.cgi?id=205897

Reviewed by Tim Horton.

Remove the NATIVE_MOUSE_EVENT_HANDLER and NATIVE_MOUSE_EVENT_HANDLER_INTERNAL which are almost identical,
calling a couple of shared functions instead. The only reason the eventName was used was for logging, so just
log the -[NSEvent type] instead.

* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::operator<<):
(WebKit::WebViewImpl::nativeMouseEventHandler):
(WebKit::WebViewImpl::nativeMouseEventHandlerInternal):
(WebKit::WebViewImpl::mouseEntered):
(WebKit::WebViewImpl::mouseExited):
(WebKit::WebViewImpl::otherMouseDown):
(WebKit::WebViewImpl::otherMouseDragged):
(WebKit::WebViewImpl::otherMouseUp):
(WebKit::WebViewImpl::rightMouseDown):
(WebKit::WebViewImpl::rightMouseDragged):
(WebKit::WebViewImpl::rightMouseUp):
(WebKit::WebViewImpl::mouseMovedInternal):
(WebKit::WebViewImpl::mouseDownInternal):
(WebKit::WebViewImpl::mouseUpInternal):
(WebKit::WebViewImpl::mouseDraggedInternal):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (254212 => 254213)


--- trunk/Source/WebKit/ChangeLog	2020-01-08 19:56:13 UTC (rev 254212)
+++ trunk/Source/WebKit/ChangeLog	2020-01-08 19:58:05 UTC (rev 254213)
@@ -1,3 +1,32 @@
+2020-01-08  Simon Fraser  <[email protected]>
+
+        Remove NATIVE_MOUSE_EVENT_HANDLER macros
+        https://bugs.webkit.org/show_bug.cgi?id=205897
+
+        Reviewed by Tim Horton.
+
+        Remove the NATIVE_MOUSE_EVENT_HANDLER and NATIVE_MOUSE_EVENT_HANDLER_INTERNAL which are almost identical,
+        calling a couple of shared functions instead. The only reason the eventName was used was for logging, so just
+        log the -[NSEvent type] instead.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::operator<<):
+        (WebKit::WebViewImpl::nativeMouseEventHandler):
+        (WebKit::WebViewImpl::nativeMouseEventHandlerInternal):
+        (WebKit::WebViewImpl::mouseEntered):
+        (WebKit::WebViewImpl::mouseExited):
+        (WebKit::WebViewImpl::otherMouseDown):
+        (WebKit::WebViewImpl::otherMouseDragged):
+        (WebKit::WebViewImpl::otherMouseUp):
+        (WebKit::WebViewImpl::rightMouseDown):
+        (WebKit::WebViewImpl::rightMouseDragged):
+        (WebKit::WebViewImpl::rightMouseUp):
+        (WebKit::WebViewImpl::mouseMovedInternal):
+        (WebKit::WebViewImpl::mouseDownInternal):
+        (WebKit::WebViewImpl::mouseUpInternal):
+        (WebKit::WebViewImpl::mouseDraggedInternal):
+
 2020-01-08  Wenson Hsieh  <[email protected]>
 
         Remove an unused variable in WebCoreArgumentCodersCocoa.mm after r254202

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (254212 => 254213)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2020-01-08 19:56:13 UTC (rev 254212)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2020-01-08 19:58:05 UTC (rev 254213)
@@ -664,6 +664,9 @@
     Vector<WebCore::KeypressCommand> collectKeyboardLayoutCommandsForEvent(NSEvent *);
     void interpretKeyEvent(NSEvent *, void(^completionHandler)(BOOL handled, const Vector<WebCore::KeypressCommand>&));
 
+    void nativeMouseEventHandler(NSEvent *);
+    void nativeMouseEventHandlerInternal(NSEvent *);
+    
     void mouseMovedInternal(NSEvent *);
     void mouseDownInternal(NSEvent *);
     void mouseUpInternal(NSEvent *);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (254212 => 254213)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-01-08 19:56:13 UTC (rev 254212)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2020-01-08 19:58:05 UTC (rev 254213)
@@ -5213,70 +5213,125 @@
     });
 }
 
-#define NATIVE_MOUSE_EVENT_HANDLER(EventName) \
-    void WebViewImpl::EventName(NSEvent *event) \
-    { \
-        if (m_ignoresNonWheelEvents) \
-            return; \
-        if (NSTextInputContext *context = [m_view inputContext]) { \
-            auto weakThis = makeWeakPtr(*this); \
-            RetainPtr<NSEvent> retainedEvent = event; \
-            [context handleEvent:event completionHandler:[weakThis, retainedEvent] (BOOL handled) { \
-                if (!weakThis) \
-                    return; \
-                if (handled) \
-                    LOG(TextInput, "%s was handled by text input context", String(#EventName).substring(0, String(#EventName).find("Internal")).ascii().data()); \
-                else { \
-                    NativeWebMouseEvent webEvent(retainedEvent.get(), weakThis->m_lastPressureEvent.get(), weakThis->m_view.getAutoreleased()); \
-                    weakThis->m_page->handleMouseEvent(webEvent); \
-                } \
-            }]; \
-            return; \
-        } \
-        NativeWebMouseEvent webEvent(event, m_lastPressureEvent.get(), m_view.getAutoreleased()); \
-        m_page->handleMouseEvent(webEvent); \
+#if !LOG_DISABLED
+static TextStream& operator<<(TextStream& ts, NSEventType eventType)
+{
+    switch (eventType) {
+    case NSEventTypeLeftMouseDown: ts << "NSEventTypeLeftMouseDown"; break;
+    case NSEventTypeLeftMouseUp: ts << "NSEventTypeLeftMouseUp"; break;
+    case NSEventTypeRightMouseDown: ts << "NSEventTypeRightMouseDown"; break;
+    case NSEventTypeRightMouseUp: ts << "NSEventTypeRightMouseUp"; break;
+    case NSEventTypeMouseMoved: ts << "NSEventTypeMouseMoved"; break;
+    case NSEventTypeLeftMouseDragged: ts << "NSEventTypeLeftMouseDragged"; break;
+    case NSEventTypeRightMouseDragged: ts << "NSEventTypeRightMouseDragged"; break;
+    case NSEventTypeMouseEntered: ts << "NSEventTypeMouseEntered"; break;
+    case NSEventTypeMouseExited: ts << "NSEventTypeMouseExited"; break;
+    case NSEventTypeKeyDown: ts << "NSEventTypeKeyDown"; break;
+    case NSEventTypeKeyUp: ts << "NSEventTypeKeyUp"; break;
+    case NSEventTypeScrollWheel: ts << "NSEventTypeScrollWheel"; break;
+    case NSEventTypeOtherMouseDown: ts << "NSEventTypeOtherMouseDown"; break;
+    case NSEventTypeOtherMouseUp: ts << "NSEventTypeOtherMouseUp"; break;
+    case NSEventTypeOtherMouseDragged: ts << "NSEventTypeOtherMouseDragged"; break;
+    default:
+        ts << "Other";
     }
-#define NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(EventName) \
-    void WebViewImpl::EventName(NSEvent *event) \
-    { \
-        if (m_ignoresNonWheelEvents || m_safeBrowsingWarning) \
-            return; \
-        if (NSTextInputContext *context = [m_view inputContext]) { \
-            auto weakThis = makeWeakPtr(*this); \
-            RetainPtr<NSEvent> retainedEvent = event; \
-            [context handleEvent:event completionHandler:[weakThis, retainedEvent] (BOOL handled) { \
-                if (!weakThis) \
-                    return; \
-                if (handled) \
-                    LOG(TextInput, "%s was handled by text input context", String(#EventName).substring(0, String(#EventName).find("Internal")).ascii().data()); \
-                else { \
-                    NativeWebMouseEvent webEvent(retainedEvent.get(), weakThis->m_lastPressureEvent.get(), weakThis->m_view.getAutoreleased()); \
-                    weakThis->m_page->handleMouseEvent(webEvent); \
-                } \
-            }]; \
-            return; \
-        } \
-        NativeWebMouseEvent webEvent(event, m_lastPressureEvent.get(), m_view.getAutoreleased()); \
-        m_page->handleMouseEvent(webEvent); \
+
+    return ts;
+}
+#endif
+
+void WebViewImpl::nativeMouseEventHandler(NSEvent *event)
+{
+    if (m_ignoresNonWheelEvents)
+        return;
+
+    if (NSTextInputContext *context = [m_view inputContext]) {
+        auto weakThis = makeWeakPtr(*this);
+        RetainPtr<NSEvent> retainedEvent = event;
+        [context handleEvent:event completionHandler:[weakThis, retainedEvent] (BOOL handled) {
+            if (!weakThis)
+                return;
+            if (handled)
+                LOG_WITH_STREAM(TextInput, stream << "Event " << [retainedEvent type] << " was handled by text input context");
+            else {
+                NativeWebMouseEvent webEvent(retainedEvent.get(), weakThis->m_lastPressureEvent.get(), weakThis->m_view.getAutoreleased());
+                weakThis->m_page->handleMouseEvent(webEvent);
+            }
+        }];
+        return;
     }
+    NativeWebMouseEvent webEvent(event, m_lastPressureEvent.get(), m_view.getAutoreleased());
+    m_page->handleMouseEvent(webEvent);
+}
 
-NATIVE_MOUSE_EVENT_HANDLER(mouseEntered)
-NATIVE_MOUSE_EVENT_HANDLER(mouseExited)
-NATIVE_MOUSE_EVENT_HANDLER(otherMouseDown)
-NATIVE_MOUSE_EVENT_HANDLER(otherMouseDragged)
-NATIVE_MOUSE_EVENT_HANDLER(otherMouseUp)
-NATIVE_MOUSE_EVENT_HANDLER(rightMouseDown)
-NATIVE_MOUSE_EVENT_HANDLER(rightMouseDragged)
-NATIVE_MOUSE_EVENT_HANDLER(rightMouseUp)
+void WebViewImpl::nativeMouseEventHandlerInternal(NSEvent *event)
+{
+    if (m_safeBrowsingWarning)
+        return;
 
-NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseMovedInternal)
-NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDownInternal)
-NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseUpInternal)
-NATIVE_MOUSE_EVENT_HANDLER_INTERNAL(mouseDraggedInternal)
+    nativeMouseEventHandler(event);
+}
 
-#undef NATIVE_MOUSE_EVENT_HANDLER
-#undef NATIVE_MOUSE_EVENT_HANDLER_INTERNAL
+void WebViewImpl::mouseEntered(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
 
+void WebViewImpl::mouseExited(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::otherMouseDown(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::otherMouseDragged(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::otherMouseUp(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::rightMouseDown(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::rightMouseDragged(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::rightMouseUp(NSEvent *event)
+{
+    nativeMouseEventHandler(event);
+}
+
+void WebViewImpl::mouseMovedInternal(NSEvent *event)
+{
+    nativeMouseEventHandlerInternal(event);
+}
+
+void WebViewImpl::mouseDownInternal(NSEvent *event)
+{
+    nativeMouseEventHandlerInternal(event);
+}
+
+void WebViewImpl::mouseUpInternal(NSEvent *event)
+{
+    nativeMouseEventHandlerInternal(event);
+}
+
+void WebViewImpl::mouseDraggedInternal(NSEvent *event)
+{
+    nativeMouseEventHandlerInternal(event);
+}
+
 void WebViewImpl::mouseMoved(NSEvent *event)
 {
     if (m_ignoresNonWheelEvents)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to