Specialize synchronous event tracking per event type
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2016 02:38:00 +0000 (02:38 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jun 2016 02:38:00 +0000 (02:38 +0000)
commitb701a05abc3140ffd7c951f7f64888bb28039594
treeb5a7335e8f8db1e788a7af73cdfe7f3b7a14fd91
parentb20177c909576d6cf54f6f04b6da1a079d51e606
Specialize synchronous event tracking per event type
https://bugs.webkit.org/show_bug.cgi?id=158826

Reviewed by Simon Fraser.

Source/WebCore:

First, kudos to Rick Byers for all his helps on passive event dispatch.
The specs are pretty damn good and his help reviewing patches is very useful.

This patch change synchronous event dispatch to happen per event
instead of per sequence touchstart->touchend.

The big advantage of this is we can dispatch more events asynchronously.
For example, to handle a tap programmatically, you can limit the active listener
to the touchend event. The touchstart and touchmove are now dispatched asynchronously.

The implementation is a simple extension to EventTrackingRegions.
Instead of a single synchronous region, we have one region per event type.
When processing the events, we only need to send the events synchronously
if that particular event type has a synchronous region.

Note that EventDispatcher's touch event support already supports
mixing synchronous and asynchronous events. The events are always processed
in order even if asynchronous events are pending when a synchronous dispatch
happens.

Tests: fast/events/touch/ios/tap-with-active-listener-inside-document-with-passive-listener.html
       fast/events/touch/ios/tap-with-active-listener-inside-window-with-passive-listener.html
       fast/events/touch/ios/tap-with-active-touch-end-listener.html
       fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html
       fast/events/touch/ios/tap-with-passive-touch-end-listener.html
       fast/events/touch/ios/tap-with-passive-touch-start-active-touch-end-listeners-on-elements.html
       fast/events/touch/ios/tap-with-passive-touch-start-active-touch-move-listeners-on-elements.html

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventTarget.cpp:
(WebCore::EventTarget::hasActiveTouchEventListeners): Deleted.
* dom/EventTarget.h:
* page/DebugPageOverlays.cpp:
(WebCore::NonFastScrollableRegionOverlay::updateRegion):
* page/Page.cpp:
(WebCore::Page::nonFastScrollableRects):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::absoluteEventTrackingRegionsForFrame):
* page/scrolling/ScrollingStateFrameScrollingNode.cpp:
(WebCore::ScrollingStateFrameScrollingNode::dumpProperties):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::shouldHandleWheelEventSynchronously):
(WebCore::ScrollingTree::eventTrackingTypeForPoint):
* page/scrolling/ScrollingTree.h:
* platform/EventTrackingRegions.cpp: Added.
(WebCore::EventTrackingRegions::trackingTypeForPoint):
(WebCore::EventTrackingRegions::isEmpty):
(WebCore::EventTrackingRegions::translate):
(WebCore::EventTrackingRegions::uniteSynchronousRegion):
(WebCore::EventTrackingRegions::unite):
(WebCore::operator==):
* platform/EventTrackingRegions.h:
(WebCore::EventTrackingRegions::isEmpty): Deleted.
(WebCore::EventTrackingRegions::trackingTypeForPoint): Deleted.
(WebCore::operator==): Deleted.

Source/WebKit2:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<EventTrackingRegions>::encode):
(IPC::ArgumentCoder<EventTrackingRegions>::decode):
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::eventTrackingTypeForPoint):
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::mergeTrackingTypes):
(WebKit::WebPageProxy::updateTouchEventTracking):
(WebKit::WebPageProxy::touchEventTrackingType):
(WebKit::WebPageProxy::handleTouchEventSynchronously):
(WebKit::WebPageProxy::handleTouchEventAsynchronously):
(WebKit::WebPageProxy::handleTouchEvent):
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::TouchEventTracking::isTrackingAnything):
(WebKit::WebPageProxy::TouchEventTracking::reset):

LayoutTests:

* fast/events/touch/ios/tap-with-active-listener-inside-document-with-passive-listener-expected.txt: Added.
* fast/events/touch/ios/tap-with-active-listener-inside-document-with-passive-listener.html: Added.
* fast/events/touch/ios/tap-with-active-listener-inside-window-with-passive-listener-expected.txt: Added.
* fast/events/touch/ios/tap-with-active-listener-inside-window-with-passive-listener.html: Added.
* fast/events/touch/ios/tap-with-active-touch-end-listener-expected.txt: Added.
* fast/events/touch/ios/tap-with-active-touch-end-listener.html: Added.
* fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html: Added.
* fast/events/touch/ios/tap-with-passive-touch-end-listener-expected.txt: Added.
* fast/events/touch/ios/tap-with-passive-touch-end-listener.html: Added.
* fast/events/touch/ios/tap-with-passive-touch-start-active-touch-end-listeners-on-elements-expected.txt: Added.
* fast/events/touch/ios/tap-with-passive-touch-start-active-touch-end-listeners-on-elements.html: Added.
* fast/events/touch/ios/tap-with-passive-touch-start-active-touch-move-listeners-on-elements-expected.txt: Added.
* fast/events/touch/ios/tap-with-passive-touch-start-active-touch-move-listeners-on-elements.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
43 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/tap-with-active-listener-inside-document-with-passive-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-active-listener-inside-document-with-passive-listener.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-active-listener-inside-window-with-passive-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-active-listener-inside-window-with-passive-listener.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-active-touch-end-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-active-touch-end-listener.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-listener-inside-active-listener.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-end-listener-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-end-listener.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-start-active-touch-end-listeners-on-elements-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-start-active-touch-end-listeners-on-elements.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-start-active-touch-move-listeners-on-elements-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/tap-with-passive-touch-start-active-touch-move-listeners-on-elements.html [new file with mode: 0644]
LayoutTests/tiled-drawing/scrolling/fixed/fixed-in-overflow-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-gain-scrolling-ancestor-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-in-fixed-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-lose-scrolling-ancestor-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/frameset-frame-scrollability-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/frameset-nested-frame-scrollability-expected.txt
LayoutTests/tiled-drawing/scrolling/frames/scroll-region-after-frame-layout-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/dom/EventTarget.h
Source/WebCore/page/DebugPageOverlays.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/platform/EventTrackingRegions.cpp [new file with mode: 0644]
Source/WebCore/platform/EventTrackingRegions.h
Source/WebCore/platform/graphics/Region.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h