Add events related to force click gesture
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Mar 2015 21:31:28 +0000 (21:31 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Mar 2015 21:31:28 +0000 (21:31 +0000)
commit2a95a4f41edbf5705ee16df739b53611ac154615
treef326265610007ed637d700e1ba566e4989b1ddda
parent0844fd166c2e31bccca2958a7b06ac9d854e059f
Add events related to force click gesture
https://bugs.webkit.org/show_bug.cgi?id=142836
-and corresponding-
rdar://problem/20210239

Reviewed by Dean Jackson.

Source/WebCore:

This patch adds six new events for the force click gesture:

webkitmouseforcewillbegin -> Event is sent just before mousedown to indicate that
force can be perceived if the user presses any harder. The author should prevent
default on this event to both prevent the user agent’s default force click
features and to receive the other 5 events.

webkitmouseforcechanged -> This event fires whenever force changes between the
mousedown and mouseup. It is a new type of mouse event that includes a force
variable which is a normalized number between 0 (corresponds to click) and 1
(corresponds to force click). In this patch, I have only added code to send this
event between mousedown and mouseforcedown, but as a followup patch, we plan to
send it through mouseup.

webkitmouseforcecancelled -> If the user releases their finger from the trackpad
after pressing hard enough to send webkitmouseforcewillbegin events but not hard
enough to force click, this event will be sent to indicate that the user bailed
out on the gesture.

webkitmouseforcedown -> The down part of the force click.

webkitmouseforceup -> The up part of the force click. This event is added in this
patch, but does not yet fire. That is work for a follow-up patch.

webkitmouseforceclick -> The equivalent of the click event for the force click.
Should fire just after webkitmouseforceup. This event is added in this patch, but
does not yet fire. That is work for a follow-up patch.

Add new files for WebKitMouseForceEvent to build systems.
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* WebCore.xcodeproj/project.pbxproj:

Plumbing for new events.
* dom/Document.idl:

Code to dispatch the new events. Currently the code that calls these functions is
in WebKit2.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseForceWillBegin):
(WebCore::Element::dispatchMouseForceChanged):
(WebCore::Element::dispatchMouseForceDown):
(WebCore::Element::dispatchMouseForceUp):
(WebCore::Element::dispatchMouseForceClick):
(WebCore::Element::dispatchMouseForceCancelled):
* dom/Element.h:

More plumbing.
* dom/Element.idl:
* dom/EventNames.h:
* dom/EventNames.in:

Our new type of mouse event that includes force.
* dom/WebKitMouseForceEvent.cpp: Added.
(WebCore::WebKitMouseForceEventInit::WebKitMouseForceEventInit):
(WebCore::WebKitMouseForceEvent::WebKitMouseForceEvent):
(WebCore::WebKitMouseForceEvent::~WebKitMouseForceEvent):
(WebCore::WebKitMouseForceEvent::eventInterface):
* dom/WebKitMouseForceEvent.h: Added.
* dom/WebKitMouseForceEvent.idl: Added.

More plumbing.
* html/HTMLAttributeNames.in:
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::createWindowEventHandlerNameMap):
* html/HTMLBodyElement.idl:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::createEventHandlerNameMap):
* page/DOMWindow.idl:
* page/EventHandler.h:
(WebCore::EventHandler::lastMouseDownEvent):

Source/WebKit2:

ActionMenuHitTestResult has a new bool indicating whether to not the HitTestResult
will prevent default.
* Shared/mac/ActionMenuHitTestResult.h:
* Shared/mac/ActionMenuHitTestResult.mm:
(WebKit::ActionMenuHitTestResult::encode):
(WebKit::ActionMenuHitTestResult::decode):

Send immediateActionDidUpdate and the normalized force over the the WebProcess.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::immediateActionDidUpdate):
* UIProcess/WebPageProxy.h:

We need a dummy animation controller when web content is overriding the default
behavior.
* UIProcess/mac/WKImmediateActionController.mm:

Send along the update information.
(-[WKImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):

Use the dummy animation controller if default has been prevented.
(-[WKImmediateActionController _defaultAnimationController]):
(-[WKImmediateActionController _updateImmediateActionItem]):

Keep track of whether m_lastActionMenuHitTes prevented the default immediate
action behavior.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

Call dispatchMouseForceMayBegin() at hit test time.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performActionMenuHitTestAtLocation):

Call dispatchMouseForceChanged() if appropriate.
(WebKit::WebPage::immediateActionDidUpdate):

Call dispatchMouseForceCancelled() if appropriate.
(WebKit::WebPage::immediateActionDidCancel):

Call dispatchMouseForceDown() if appropriate.
(WebKit::WebPage::immediateActionDidComplete):

Source/WTF:

New enable flag for the events.
* wtf/FeatureDefines.h:

LayoutTests:

* fast/dom/event-handler-attributes-expected.txt:
* fast/dom/event-handler-attributes.html:
* platform/mac/js/dom/global-constructors-attributes-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181907 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/event-handler-attributes-expected.txt
LayoutTests/fast/dom/event-handler-attributes.html
LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/DOMAllInOne.cpp
Source/WebCore/dom/Document.idl
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/Element.idl
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventNames.in
Source/WebCore/dom/WebKitMouseForceEvent.cpp [new file with mode: 0644]
Source/WebCore/dom/WebKitMouseForceEvent.h [new file with mode: 0644]
Source/WebCore/dom/WebKitMouseForceEvent.idl [new file with mode: 0644]
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/html/HTMLBodyElement.cpp
Source/WebCore/html/HTMLBodyElement.idl
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/page/DOMWindow.idl
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/ActionMenuHitTestResult.h
Source/WebKit2/Shared/mac/ActionMenuHitTestResult.mm
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
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