Use _NSScrollingPredominantAxisFilter for wheel event filtering on Mac
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Aug 2015 15:23:21 +0000 (15:23 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Aug 2015 15:23:21 +0000 (15:23 +0000)
commit4ce5ac7298e2d2fa338cd409d69c4773b317ed7d
tree41783ae004b5b2966bb839b1a229c4215edd025c
parent594b7cfc2bc9bd8de00c30bde96c198dfa44999a
Use _NSScrollingPredominantAxisFilter for wheel event filtering on Mac
https://bugs.webkit.org/show_bug.cgi?id=147320

Reviewed by Simon Fraser.

Refactored to use a predominant axis filter instead of a predominant axis tracker. This allows us to
employ AppKit's _NSScrollingPredominantAxisFilter when possible, and use the wheel event delta tracker
Source/WebCore:

as a fallback. Here, we refactor EventHandler to use the new filters for overflow scrolling and replace
the MainFrame's WheelEventDeltaTracker with an appropriate type of WheelEventDeltaFilter.

In the case where an _NSScrollingPredominantAxisFilter is unavailable, the platform-invariant wheel
event delta filter simply uses the existing wheel event delta tracker to compute the current predominant
axis. It uses the predominant axis to determine which axis (if any) should have its delta zeroed out.

This patch also introduces NSScrollingInputFilterSPI.h, which either imports the internal input filter
header from AppKit or declares relevant interfaces and functions.

No new tests, since this change does not add new functionality.

* CMakeLists.txt: Add page/WheelEventDeltaFilter.cpp.
* WebCore.vcxproj/WebCore.vcxproj: Add WheelEventDeltaFilter.cpp and WheelEventDeltaFilter.h.
* WebCore.vcxproj/WebCore.vcxproj.filters: Add WheelEventDeltaFilter.cpp and WheelEventDeltaFilter.h.
* WebCore.xcodeproj/project.pbxproj: Add WheelEventDeltaFilter.cpp, WheelEventDeltaFilter.h, and their Mac counterparts.
* page/EventHandler.cpp:
(WebCore::didScrollInScrollableArea): Refactored to no longer handle axes separately.
(WebCore::handleWheelEventInAppropriateEnclosingBox): Ditto.
(WebCore::EventHandler::platformRecordWheelEvent): Refactored to update the wheel delta filter.
(WebCore::EventHandler::clearLatchedState): Ditto.
(WebCore::EventHandler::defaultWheelEventHandler): Refactored to use wheel delta filters. No longer splits wheel events
        and handles them on separate axes.
(WebCore::didScrollInScrollableAreaForSingleAxis): Deleted.
(WebCore::handleWheelEventInAppropriateEnclosingBoxForSingleAxis): Deleted.
* page/EventHandler.h:
* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame): Initializes the appropriate type of WheelEventDeltaFilter.
* page/MainFrame.h:
* page/WheelEventDeltaFilter.cpp: Added.
(WebCore::WheelEventDeltaFilter::WheelEventDeltaFilter):
(WebCore::WheelEventDeltaFilter::~WheelEventDeltaFilter):
(WebCore::WheelEventDeltaFilter::create):
(WebCore::BasicWheelEventDeltaFilter::BasicWheelEventDeltaFilter):
(WebCore::BasicWheelEventDeltaFilter::updateFromDelta):
(WebCore::BasicWheelEventDeltaFilter::beginFilteringDeltas):
(WebCore::BasicWheelEventDeltaFilter::endFilteringDeltas):
(WebCore::deltaIsPredominantlyVertical):
(WebCore::BasicWheelEventDeltaFilter::dominantScrollGestureDirection):
* page/WheelEventDeltaFilter.h: Refactored WheelEventDeltaTracker logic to work as a filter instead.
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::platformPrepareForWheelEvents): Refactored to use wheel delta filters.
(WebCore::EventHandler::platformRecordWheelEvent): Ditto.
* page/mac/WheelEventDeltaFilterMac.h: Wraps the new _NSScrollingPredominantAxisFilter.
* page/mac/WheelEventDeltaFilterMac.mm: Added.
(WebCore::WheelEventDeltaFilterMac::WheelEventDeltaFilterMac):
(WebCore::WheelEventDeltaFilterMac::beginFilteringDeltas):
(WebCore::WheelEventDeltaFilterMac::updateFromDelta):
(WebCore::WheelEventDeltaFilterMac::endFilteringDeltas):
* platform/PlatformWheelEvent.h:
(WebCore::PlatformWheelEvent::copyWithDeltas): Used to create a copy of the platform wheel event with filtered deltas.
(WebCore::PlatformWheelEvent::copyIgnoringHorizontalDelta): Deleted. No longer necessary, since we won't be handling wheel
        events on separate axes.
(WebCore::PlatformWheelEvent::copyIgnoringVerticalDelta): Ditto.
* platform/spi/mac/NSScrollingInputFilterSPI.h: Added.

Source/WebKit2:

as a fallback. Here, we refactor EventDispatcher to use the new filters for mainframe scrolling.

No new tests, since this change does not add new functionality.

* WebProcess/WebPage/EventDispatcher.cpp: Include WheelEventDeltaFilterMac.h when necessary.
(WebKit::EventDispatcher::EventDispatcher): Initialize a WheelEventDeltaFilterMac when possible. Otherwise,
    fall back to a BasicWheelEventDeltaFilter.
(WebKit::EventDispatcher::wheelEvent): Use filtered deltas to initialize the platform wheel event instead
    of zeroing out non-predominant axes.
* WebProcess/WebPage/EventDispatcher.h: Replace m_recentWheelEventDeltaTracker with m_recentWheelEventDeltaFilter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/WheelEventDeltaFilter.cpp [moved from Source/WebCore/page/WheelEventDeltaTracker.cpp with 54% similarity]
Source/WebCore/page/WheelEventDeltaFilter.h [new file with mode: 0644]
Source/WebCore/page/mac/EventHandlerMac.mm
Source/WebCore/page/mac/WheelEventDeltaFilterMac.h [moved from Source/WebCore/page/WheelEventDeltaTracker.h with 60% similarity]
Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm [new file with mode: 0644]
Source/WebCore/platform/PlatformWheelEvent.h
Source/WebCore/platform/spi/mac/NSScrollingInputFilterSPI.h [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/EventDispatcher.h