Implement touch event emulation in the WebCore layer
authorapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2012 10:10:54 +0000 (10:10 +0000)
committerapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2012 10:10:54 +0000 (10:10 +0000)
commit4331b5a507c034210a0f5693aefe1983fccd1124
tree2af4c78405573030339f21c09f3410d478494919
parent8264f2d0b737cb3e76fd7b58cd12686adfec2929
Implement touch event emulation in the WebCore layer
https://bugs.webkit.org/show_bug.cgi?id=77105

Reviewed by Ryosuke Niwa.

Source/WebCore:

This change essentially maps mouse events into single-touch events in the following way:
- mousedown -> touchstart
- mouseup -> touchend
- mousemove -> touchmove (between mousedown and mouseup).

Test: fast/events/touch/emulate-touch-events.html

* page/EventHandler.cpp:
(SyntheticTouchPoint): A synthetic touch point built from PlatformMouseEvent.
(WebCore::SyntheticTouchPoint::SyntheticTouchPoint):
(SyntheticSingleTouchEvent): A synthetic touch point event built from PlatformMouseEvent.
(WebCore::SyntheticSingleTouchEvent::SyntheticSingleTouchEvent):
(WebCore::EventHandler::handleMouseReleaseEvent): Invoke maybeDispatchSyntheticTouchEvent() and bail out if necessary.
(WebCore::EventHandler::handleMousePressEvent): Invoke maybeDispatchSyntheticTouchEvent() and bail out if necessary.
(WebCore::EventHandler::mouseMoved): Invoke maybeDispatchSyntheticTouchEvent() and bail out if necessary.
(WebCore::EventHandler::dispatchSyntheticTouchEventIfEnabled): Dispatch a synthetic touch event if necessary.
* page/EventHandler.h: Added new method.
* page/Settings.cpp:
(WebCore::Settings::Settings): Added m_touchEventEmulationEnabled initializer.
* page/Settings.h: Added m_touchEventEmulationEnabled, getter, and setter.
(WebCore::Settings::setTouchEventEmulationEnabled): Added.
(WebCore::Settings::isTouchEventEmulationEnabled): Added.
* platform/PlatformTouchPoint.h:
(WebCore::PlatformTouchPoint::PlatformTouchPoint): Unconditionally compile the parameterless ctor.
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setTouchEventEmulationEnabled): Added for testing.
* testing/InternalSettings.h: Added setTouchEventEmulationEnabled() for testing.
* testing/InternalSettings.idl: Added setTouchEventEmulationEnabled() for testing.

LayoutTests:

* fast/events/touch/emulate-touch-events-expected.txt: Added.
* fast/events/touch/emulate-touch-events.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106642 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/touch/emulate-touch-events-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/emulate-touch-events.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebCore/platform/PlatformTouchPoint.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl