Force mouse events should go through normal mouse event handling code paths
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Apr 2015 19:55:55 +0000 (19:55 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Apr 2015 19:55:55 +0000 (19:55 +0000)
commit53bc26368a521213036f84d9d170d8e3987f36e9
treec9897b9b76c1e161b43b960349e4083924d979b2
parent1148e1cf387c356052745fef30589f9979dcabc0
Force mouse events should go through normal mouse event handling code paths
https://bugs.webkit.org/show_bug.cgi?id=143749
-and corresponding-
rdar://problem/20472895

Reviewed by Dean Jackson.

Source/WebCore:

This patch moves all of the code to dispatch mouseforcedown, mouseforceup, and
mouseforcechanged into normal mouse event dispatching code. This patch leaves
behind the cancel and click events because we plan to remove those, and it also
leaves mouseforcewillbegin because that is necessarily a very different event more
tied to the NSImmediateActionGestureRecognizer than these other events which are
tied to NSResponder’s pressureChangeWithEvent.

New helper functions.
* dom/Document.cpp:
(WebCore::Document::hasListenerTypeForEventType):
* dom/Document.h:
* dom/Element.cpp:
(WebCore::isForceEvent):

Move the code to ensure the force events have listeners in order to fire to
dispatchMouseEvent, and delete the old implementations.
(WebCore::Element::dispatchMouseEvent):
(WebCore::Element::dispatchMouseForceChanged): Deleted.
(WebCore::Element::dispatchMouseForceDown): Deleted.
(WebCore::Element::dispatchMouseForceUp): Deleted.
* dom/Element.h:

Perform a hit test and pipe the events through dispatchMouseEvent().
* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseForceEvent):
* page/EventHandler.h:

New types for the new events.
* platform/PlatformEvent.h:

Forward to EventHandler.
* replay/UserInputBridge.cpp:
(WebCore::UserInputBridge::handleMouseForceEvent):
* replay/UserInputBridge.h:

Source/WebKit2:

This patch makes pressureChangeWithEvent create NativeWebMouseEvents with the
NSEventTypePressures that is gets and sends those down to the web process.

Re-name pressureEvent to lastPressureEvent. Now that event can sometimes be an
NSEventTypePressure, the new name makes it clear how the second parameter differs
from the first.
* Shared/NativeWebMouseEvent.h:

New event types for the new types of events.
* Shared/WebEvent.h:
* Shared/WebEventConversion.cpp:
(WebKit::WebKit2PlatformMouseEvent::WebKit2PlatformMouseEvent):
* Shared/mac/NativeWebMouseEventMac.mm:
(WebKit::NativeWebMouseEvent::NativeWebMouseEvent):
* Shared/mac/WebEventFactory.h:

All of the square-peg, round-hole problems of massaging the NSEventTypePressures
events into WebMouseEvents is taken care of here.
* Shared/mac/WebEventFactory.mm:
(WebKit::mouseButtonForEvent):
(WebKit::globalPointForEvent):
(WebKit::pointForEvent):
(WebKit::WebEventFactory::createWebMouseEvent):

Instead of calling the old inputDeviceForceDidChange, create a NativeWebMouseEvent
and handle it.
* UIProcess/API/mac/WKView.mm:
(-[WKView pressureChangeWithEvent:]):

Handle the new types.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveEvent):

Can delete inputDeviceForceDidChange since it’s no longer used.
(WebKit::WebPageProxy::inputDeviceForceDidChange): Deleted.
* UIProcess/WebPageProxy.h:

Handle the new types of mouse events properly.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::handleMouseEvent):

Delete inputDeviceForceDidChange() and m_lastForceStage.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::inputDeviceForceDidChange): Deleted.

Handle new WebEvent types.
* WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp:

Tools:

Add mouseForceDown/mouseForceUp/mouseForceChanged support to WebKitTestRunner.
Since there is not a way to create an NSEventTypePressure from scratch, we
subclass NSEvent and override all of the critical methods.

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::mouseForceDown):
(WTR::EventSendingController::mouseForceUp):
(WTR::EventSendingController::mouseForceChanged):
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):
* WebKitTestRunner/mac/EventSenderProxy.mm:
(-[EventSenderPressureEvent initAtLocation:globalLocation:stage:pressure:phase:time:eventNumber:]):
(-[EventSenderPressureEvent timestamp]):
(-[EventSenderPressureEvent type]):
(-[EventSenderPressureEvent locationInWindow]):
(-[EventSenderPressureEvent location]):
(-[EventSenderPressureEvent stage]):
(-[EventSenderPressureEvent pressure]):
(-[EventSenderPressureEvent phase]):
(-[EventSenderPressureEvent eventNumber]):
(WTR::EventSenderProxy::mouseForceDown):
(WTR::EventSenderProxy::mouseForceUp):
(WTR::EventSenderProxy::mouseForceChanged):

LayoutTests:

Just a few new tests. More to come.
* fast/events/mouse-force-changed-expected.txt: Added.
* fast/events/mouse-force-changed.html: Added.
* fast/events/mouse-force-down-expected.txt: Added.
* fast/events/mouse-force-down.html: Added.
* fast/events/mouse-force-up-expected.txt: Added.
* fast/events/mouse-force-up.html: Added.

Right now the new tests will only work on Mac 10.10.3 and beyond.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/ios-simulator/TestExpectations:
* platform/mac-mavericks/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182963 268f45cc-cd09-0410-ab3c-d52691b4dbfc
45 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/mouse-force-changed-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mouse-force-changed.html [new file with mode: 0644]
LayoutTests/fast/events/mouse-force-down-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mouse-force-down.html [new file with mode: 0644]
LayoutTests/fast/events/mouse-force-up-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/mouse-force-up.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/mac-mavericks/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/platform/PlatformEvent.h
Source/WebCore/replay/UserInputBridge.cpp
Source/WebCore/replay/UserInputBridge.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/NativeWebMouseEvent.h
Source/WebKit2/Shared/WebEvent.h
Source/WebKit2/Shared/WebEventConversion.cpp
Source/WebKit2/Shared/mac/NativeWebMouseEventMac.mm
Source/WebKit2/Shared/mac/WebEventFactory.h
Source/WebKit2/Shared/mac/WebEventFactory.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/WebProcess/Plugins/Netscape/x11/NetscapePluginX11.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Tools/ChangeLog
Tools/WebKitTestRunner/EventSenderProxy.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/mac/EventSenderProxy.mm