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)
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

index e7f5f394b361ec6a5f8e4c59692f645150c00099..c6af173bcb941040fecd3cf3544b5d28581a5a92 100644 (file)
@@ -2003,7 +2003,7 @@ set(WebCore_SOURCES
     page/UserContentController.cpp
     page/UserContentURLPattern.cpp
     page/VisitedLinkStore.cpp
-    page/WheelEventDeltaTracker.cpp
+    page/WheelEventDeltaFilter.cpp
     page/WheelEventTestTrigger.cpp
     page/WindowFeatures.cpp
     page/WindowFocusAllowedIndicator.cpp
index 2245c9bbe078c712656d3ea911fca8619119522f..a2af9e41d457485e636453709cd500716aeed677 100644 (file)
@@ -1,3 +1,68 @@
+2015-08-24  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        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
+        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.
+
 2015-08-24  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, fix typo in a comment ("unsused" -> "unused")
index e03d3d774184a51a259ea29c48f5997e0e496c18..7ce8a3f0bb1509b9ae488482880956d1abca74b2 100644 (file)
     <ClCompile Include="..\page\UserContentURLPattern.cpp" />
     <ClCompile Include="..\page\VisitedLinkStore.cpp" />
     <ClCompile Include="..\fileapi\WebKitBlobBuilder.cpp" />
-    <ClCompile Include="..\page\WheelEventDeltaTracker.cpp" />
+    <ClCompile Include="..\page\WheelEventDeltaFilter.cpp" />
     <ClCompile Include="..\page\WheelEventTestTrigger.cpp" />
     <ClCompile Include="..\page\WindowFeatures.cpp" />
     <ClCompile Include="..\page\WindowFocusAllowedIndicator.cpp" />
     <ClInclude Include="..\page\VisitedLinkStore.h" />
     <ClInclude Include="..\fileapi\WebKitBlobBuilder.h" />
     <ClInclude Include="..\page\WebKitPoint.h" />
-    <ClInclude Include="..\page\WheelEventDeltaTracker.h" />
+    <ClInclude Include="..\page\WheelEventDeltaFilter.h" />
     <ClInclude Include="..\page\WheelEventTestTrigger.h" />
     <ClInclude Include="..\page\WindowFeatures.h" />
     <ClInclude Include="..\page\WindowFocusAllowedIndicator.h" />
index 47b1d7c9c4e23ed7dc42f5af990fb07f4deee789..21b40367b2f9b2b8eeeb5fb1ba3fbbf579441324 100644 (file)
     <ClCompile Include="..\fileapi\WebKitBlobBuilder.cpp">
       <Filter>page</Filter>
     </ClCompile>
-    <ClCompile Include="..\page\WheelEventDeltaTracker.cpp">
+    <ClCompile Include="..\page\WheelEventDeltaFilter.cpp">
       <Filter>page</Filter>
     </ClCompile>
     <ClCompile Include="..\page\WheelEventTestTrigger.cpp">
     <ClInclude Include="..\page\WebKitPoint.h">
       <Filter>page</Filter>
     </ClInclude>
-    <ClInclude Include="..\page\WheelEventDeltaTracker.h">
+    <ClInclude Include="..\page\WheelEventDeltaFilter.h">
       <Filter>page</Filter>
     </ClInclude>
     <ClInclude Include="..\page\WheelEventTestTrigger.h">
index 1807e4c920332f5ebca448c07920d50c362c8299..a7e970e6c238b4f8822440cd2dc95f5bd2acbb0e 100644 (file)
                2E0888D41148848A00AF4265 /* JSDOMFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */; };
                2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; };
                2E0888E6114884E200AF4265 /* JSDOMFormDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888E5114884E200AF4265 /* JSDOMFormDataCustom.cpp */; };
+               2E19516B1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */; };
                2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */; };
                2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99CC10E2BBDA00496337 /* JSBlob.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E2D99E710E2BC1C00496337 /* DOMBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99E510E2BC1C00496337 /* DOMBlob.h */; };
                2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */; };
                2E94F43B119207DA00B7F75D /* JSFileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E94F439119207DA00B7F75D /* JSFileReader.cpp */; };
                2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; };
+               2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; };
                2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */; };
                2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; };
+               2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2ECF7ADC10162B3800427DE7 /* JSErrorEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2ECF7ADA10162B3800427DE7 /* JSErrorEvent.cpp */; };
                2ECF7ADD10162B3800427DE7 /* JSErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */; };
                2ECF7AE110162B5800427DE7 /* ErrorEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2ECF7ADE10162B5800427DE7 /* ErrorEvent.cpp */; };
                2EDF369C122C94B4002F7D4E /* FileReaderSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EDF369A122C94B4002F7D4E /* FileReaderSync.cpp */; };
                2EDF369D122C94B4002F7D4E /* FileReaderSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369B122C94B4002F7D4E /* FileReaderSync.h */; };
                2EDF369F122C94C8002F7D4E /* FileException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369E122C94C8002F7D4E /* FileException.h */; };
+               2EEEE55C1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */; };
                2EF1BFEA121C9F4200C27627 /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EF1BFE8121C9F4200C27627 /* FileStream.cpp */; };
                2EF1BFEB121C9F4200C27627 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF1BFE9121C9F4200C27627 /* FileStream.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF1BFF8121CB0CE00C27627 /* FileStreamClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93EB169509F880B00091F8FF /* WebCoreSystemInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */; };
                93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */; };
-               93EC44A1188F4BB800661DF1 /* WheelEventDeltaTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */; };
-               93EC44A2188F4BB800661DF1 /* WheelEventDeltaTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93EF7D551954F13900DFB71D /* ScrollingStateNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EF7D541954E98F00DFB71D /* ScrollingStateNode.mm */; };
                93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
                93F198E608245E59001E9ABC /* HTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23F02DE4396018635CA /* HTMLElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F3D4C47912E07663003DA150 /* InspectorDOMDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D4C47712E07663003DA150 /* InspectorDOMDebuggerAgent.h */; };
                F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */; };
                F3F5CF1312ED81B30084C569 /* InspectorDatabaseInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */; };
+               F40EA8AB1B867E4400CE5581 /* NSScrollingInputFilterSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F42FFB461984B71600F6837F /* LengthRepeat.h in Headers */ = {isa = PBXBuildFile; fileRef = F42FFB451984B71600F6837F /* LengthRepeat.h */; };
                F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */; };
                F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */ = {isa = PBXBuildFile; fileRef = F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMFormData.cpp; sourceTree = "<group>"; };
                2E0888D31148848A00AF4265 /* JSDOMFormData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMFormData.h; sourceTree = "<group>"; };
                2E0888E5114884E200AF4265 /* JSDOMFormDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMFormDataCustom.cpp; sourceTree = "<group>"; };
+               2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEventDeltaFilter.cpp; sourceTree = "<group>"; };
                2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlob.cpp; sourceTree = "<group>"; };
                2E2D99CC10E2BBDA00496337 /* JSBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlob.h; sourceTree = "<group>"; };
                2E2D99E510E2BC1C00496337 /* DOMBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMBlob.h; sourceTree = "<group>"; };
                2E75841C12779ADA0062628B /* FileReaderLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileReaderLoaderClient.h; sourceTree = "<group>"; };
                2E94F439119207DA00B7F75D /* JSFileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileReader.cpp; sourceTree = "<group>"; };
                2E94F43A119207DA00B7F75D /* JSFileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReader.h; sourceTree = "<group>"; };
+               2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilterMac.h; sourceTree = "<group>"; };
                2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptLoaderClient.h; sourceTree = "<group>"; };
                2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobResourceHandle.cpp; sourceTree = "<group>"; };
                2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobResourceHandle.h; sourceTree = "<group>"; };
+               2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilter.h; sourceTree = "<group>"; };
                2ECF7ADA10162B3800427DE7 /* JSErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorEvent.cpp; sourceTree = "<group>"; };
                2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorEvent.h; sourceTree = "<group>"; };
                2ECF7ADE10162B5800427DE7 /* ErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorEvent.cpp; sourceTree = "<group>"; };
                2EDF369A122C94B4002F7D4E /* FileReaderSync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileReaderSync.cpp; sourceTree = "<group>"; };
                2EDF369B122C94B4002F7D4E /* FileReaderSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileReaderSync.h; sourceTree = "<group>"; };
                2EDF369E122C94C8002F7D4E /* FileException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileException.h; sourceTree = "<group>"; };
+               2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WheelEventDeltaFilterMac.mm; sourceTree = "<group>"; };
                2EF1BFE8121C9F4200C27627 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStream.cpp; sourceTree = "<group>"; };
                2EF1BFE9121C9F4200C27627 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = "<group>"; };
                2EF1BFF8121CB0CE00C27627 /* FileStreamClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStreamClient.h; sourceTree = "<group>"; };
                93EB169409F880B00091F8FF /* WebCoreSystemInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreSystemInterface.mm; sourceTree = "<group>"; };
                93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreSystemInterface.h; sourceTree = "<group>"; };
                93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
-               93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEventDeltaTracker.cpp; sourceTree = "<group>"; };
-               93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaTracker.h; sourceTree = "<group>"; };
                93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
                93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
                93EEC1E809C2877700C515D1 /* DocumentType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DocumentType.idl; sourceTree = "<group>"; };
                F3D4C47712E07663003DA150 /* InspectorDOMDebuggerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMDebuggerAgent.h; sourceTree = "<group>"; };
                F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorConsoleInstrumentation.h; sourceTree = "<group>"; };
                F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseInstrumentation.h; sourceTree = "<group>"; };
+               F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSScrollingInputFilterSPI.h; sourceTree = "<group>"; };
                F42FFB451984B71600F6837F /* LengthRepeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthRepeat.h; sourceTree = "<group>"; };
                F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = "<group>"; };
                F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapOffsets.h; sourceTree = "<group>"; };
                                7C48A6D2191C9D8E00026674 /* WebKitNamespace.idl */,
                                494BD7930F55C8EE00747828 /* WebKitPoint.h */,
                                494BD7940F55C8EE00747828 /* WebKitPoint.idl */,
-                               93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */,
-                               93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */,
+                               2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */,
+                               2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */,
                                7AE335EF1ACB09E200E401EF /* WheelEventTestTrigger.cpp */,
                                7AE335F01ACB09E200E401EF /* WheelEventTestTrigger.h */,
                                7C4189AC1B07CBF2000FA757 /* WindowEventHandlers.idl */,
                                9321D58F1A3906FA008052BE /* NSImmediateActionGestureRecognizerSPI.h */,
                                937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */,
                                93F1E1EB1A40FDDC00348D13 /* NSPopoverSPI.h */,
+                               F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */,
                                2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
                                2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
                                937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */,
                                2D4F96F41A1ECC240098BF88 /* TextIndicatorWindow.mm */,
                                26255F0218878E110006E1FD /* UserAgentMac.mm */,
                                F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
+                               2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */,
+                               2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */,
                        );
                        path = mac;
                        sourceTree = "<group>";
                                FD31600812B0267600C1A359 /* AudioDestinationNode.h in Headers */,
                                FD31608012B026F700C1A359 /* AudioDSPKernel.h in Headers */,
                                FD31608212B026F700C1A359 /* AudioDSPKernelProcessor.h in Headers */,
+                               F40EA8AB1B867E4400CE5581 /* NSScrollingInputFilterSPI.h in Headers */,
                                FD31608312B026F700C1A359 /* AudioFileReader.h in Headers */,
                                CD5596921475B678001D0BD0 /* AudioFileReaderIOS.h in Headers */,
                                FD3160BF12B0272A00C1A359 /* AudioFileReaderMac.h in Headers */,
                                CE12524D1A1A77DE00864480 /* IOPMLibSPI.h in Headers */,
                                44DEF6431A6FF92700D45EEC /* IOReturnSPI.h in Headers */,
                                2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */,
+                               2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */,
                                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
                                44DFF6431A6FF92700D45EEC /* IOSurfaceSPI.h in Headers */,
                                44EFF6431A6FF92700D45EEC /* IOTypesSPI.h in Headers */,
                                1AFE119A0CBFFCC4003017FA /* JSSQLResultSetRowList.h in Headers */,
                                B59DD6A511902A62007E9684 /* JSSQLStatementCallback.h in Headers */,
                                B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */,
+                               2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */,
                                BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */,
                                B59DD69D11902A42007E9684 /* JSSQLTransactionCallback.h in Headers */,
                                B59DD6A111902A52007E9684 /* JSSQLTransactionErrorCallback.h in Headers */,
                                A91C9FC31B659A6700AFFD54 /* AccessibilityTreeItem.h in Headers */,
                                F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */,
                                85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */,
-                               93EC44A2188F4BB800661DF1 /* WheelEventDeltaTracker.h in Headers */,
                                7AE335F21ACB09E200E401EF /* WheelEventTestTrigger.h in Headers */,
                                9380F47409A11AB4001FDB34 /* Widget.h in Headers */,
                                1411DCB1164C39A800D49BC1 /* WidthCache.h in Headers */,
                                B22279AD0D00BF220071B782 /* SVGDefsElement.cpp in Sources */,
                                B22279B00D00BF220071B782 /* SVGDescElement.cpp in Sources */,
                                B22279B30D00BF220071B782 /* SVGDocument.cpp in Sources */,
+                               2EEEE55C1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm in Sources */,
                                B28C6A270D00C44800334AA4 /* SVGDocumentExtensions.cpp in Sources */,
                                B22279B60D00BF220071B782 /* SVGElement.cpp in Sources */,
                                A833C8520A2CF52800D57664 /* SVGElementFactory.cpp in Sources */,
                                B2227A8B0D00BF220071B782 /* SVGPointList.cpp in Sources */,
                                B2227A8E0D00BF220071B782 /* SVGPolyElement.cpp in Sources */,
                                B2227A900D00BF220071B782 /* SVGPolygonElement.cpp in Sources */,
+                               2E19516B1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp in Sources */,
                                B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
                                B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
                                B543B85717EB758F003BE93A /* SVGPropertyInfo.cpp in Sources */,
                                CD8203111395ACE700F956C6 /* WebWindowAnimation.mm in Sources */,
                                F55B3DDF1251F12D003EF269 /* WeekInputType.cpp in Sources */,
                                85031B500A44EFC700F992E0 /* WheelEvent.cpp in Sources */,
-                               93EC44A1188F4BB800661DF1 /* WheelEventDeltaTracker.cpp in Sources */,
                                7AE335F11ACB09E200E401EF /* WheelEventTestTrigger.cpp in Sources */,
                                9380F47309A11AB4001FDB34 /* Widget.cpp in Sources */,
                                E453904D0EAFD637003695C8 /* WidgetIOS.mm in Sources */,
index 7a511dd4eb90a9332b47bf3e302748a96cae1e93..a4218d460b26357b0f6dfe6506f0e4f0b1fc5f71 100644 (file)
@@ -287,17 +287,22 @@ static inline ScrollGranularity wheelGranularityToScrollGranularity(unsigned del
     }
 }
 
-static inline bool didScrollInScrollableAreaForSingleAxis(ScrollableArea* scrollableArea, WheelEvent* wheelEvent, ScrollEventAxis axis)
+static inline bool didScrollInScrollableArea(ScrollableArea* scrollableArea, WheelEvent* wheelEvent)
 {
-    float delta = axis == ScrollEventAxis::Vertical ? wheelEvent->deltaY() : wheelEvent->deltaX();
-    ScrollDirection negativeDirection = axis == ScrollEventAxis::Vertical ? ScrollUp : ScrollLeft;
-    ScrollDirection positiveDirection = axis == ScrollEventAxis::Vertical ? ScrollDown : ScrollRight;
-    return scrollableArea->scroll(delta < 0 ? negativeDirection : positiveDirection, wheelGranularityToScrollGranularity(wheelEvent->deltaMode()), delta > 0 ? delta : -delta);
+    ScrollGranularity scrollGranularity = wheelGranularityToScrollGranularity(wheelEvent->deltaMode());
+    bool didHandleWheelEvent = false;
+    if (float absoluteDelta = std::abs(wheelEvent->deltaX()))
+        didHandleWheelEvent |= scrollableArea->scroll(wheelEvent->deltaX() > 0 ? ScrollRight : ScrollLeft, scrollGranularity, absoluteDelta);
+    
+    if (float absoluteDelta = std::abs(wheelEvent->deltaY()))
+        didHandleWheelEvent |= scrollableArea->scroll(wheelEvent->deltaY() > 0 ? ScrollDown : ScrollUp, scrollGranularity, absoluteDelta);
+    
+    return didHandleWheelEvent;
 }
 
-static inline bool handleWheelEventInAppropriateEnclosingBoxForSingleAxis(Node* startNode, WheelEvent* wheelEvent, Element** stopElement, ScrollEventAxis axis)
+static inline bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, WheelEvent* wheelEvent, Element** stopElement, const FloatSize& filteredPlatformDelta)
 {
-    bool shouldHandleEvent = (axis == ScrollEventAxis::Vertical && wheelEvent->deltaY()) || (axis == ScrollEventAxis::Horizontal && wheelEvent->deltaX());
+    bool shouldHandleEvent = wheelEvent->deltaX() || wheelEvent->deltaY();
 #if PLATFORM(MAC)
     shouldHandleEvent |= wheelEvent->phase() == PlatformWheelEventPhaseEnded;
 #if ENABLE(CSS_SCROLL_SNAP)
@@ -309,7 +314,7 @@ static inline bool handleWheelEventInAppropriateEnclosingBoxForSingleAxis(Node*
 
     RenderBox& initialEnclosingBox = startNode->renderer()->enclosingBox();
     if (initialEnclosingBox.isListBox())
-        return didScrollInScrollableAreaForSingleAxis(static_cast<RenderListBox*>(&initialEnclosingBox), wheelEvent, axis);
+        return didScrollInScrollableArea(static_cast<RenderListBox*>(&initialEnclosingBox), wheelEvent);
 
     RenderBox* currentEnclosingBox = &initialEnclosingBox;
     while (currentEnclosingBox) {
@@ -317,9 +322,9 @@ static inline bool handleWheelEventInAppropriateEnclosingBoxForSingleAxis(Node*
             const PlatformWheelEvent* platformEvent = wheelEvent->wheelEvent();
             bool scrollingWasHandled;
             if (platformEvent != nullptr)
-                scrollingWasHandled = boxLayer->handleWheelEvent(axis == ScrollEventAxis::Vertical ? platformEvent->copyIgnoringHorizontalDelta() : platformEvent->copyIgnoringVerticalDelta());
+                scrollingWasHandled = boxLayer->handleWheelEvent(platformEvent->copyWithDeltas(filteredPlatformDelta.width(), filteredPlatformDelta.height()));
             else
-                scrollingWasHandled = didScrollInScrollableAreaForSingleAxis(boxLayer, wheelEvent, axis);
+                scrollingWasHandled = didScrollInScrollableArea(boxLayer, wheelEvent);
 
             if (scrollingWasHandled) {
                 if (stopElement)
@@ -2670,7 +2675,7 @@ void EventHandler::platformPrepareForWheelEvents(const PlatformWheelEvent&, cons
 
 void EventHandler::platformRecordWheelEvent(const PlatformWheelEvent& event)
 {
-    m_frame.mainFrame().wheelEventDeltaTracker()->recordWheelEventDelta(event);
+    m_frame.mainFrame().wheelEventDeltaFilter()->updateFromDelta(FloatSize(event.deltaX(), event.deltaY()));
 }
 
 bool EventHandler::platformCompleteWheelEvent(const PlatformWheelEvent& event, ContainerNode*, ScrollableArea*)
@@ -2775,7 +2780,7 @@ void EventHandler::clearLatchedState()
 #if PLATFORM(MAC)
     m_frame.mainFrame().resetLatchingState();
 #endif
-    m_frame.mainFrame().wheelEventDeltaTracker()->endTrackingDeltas();
+    m_frame.mainFrame().wheelEventDeltaFilter()->endFilteringDeltas();
 }
 
 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEvent)
@@ -2783,25 +2788,24 @@ void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv
     if (!startNode || !wheelEvent)
         return;
     
-    DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None;
-
+    FloatSize filteredPlatformDelta(wheelEvent->deltaX(), wheelEvent->deltaY());
+    if (const PlatformWheelEvent* platformWheelEvent = wheelEvent->wheelEvent()) {
+        filteredPlatformDelta.setWidth(platformWheelEvent->deltaX());
+        filteredPlatformDelta.setHeight(platformWheelEvent->deltaY());
+    }
+    
 #if PLATFORM(MAC)
     ScrollLatchingState* latchedState = m_frame.mainFrame().latchingState();
     Element* stopElement = latchedState ? latchedState->previousWheelScrolledElement() : nullptr;
 
-    // Workaround for scrolling issues <rdar://problem/14758615>.
-    if (m_frame.mainFrame().wheelEventDeltaTracker()->isTrackingDeltas())
-        dominantDirection = m_frame.mainFrame().wheelEventDeltaTracker()->dominantScrollGestureDirection();
+    if (m_frame.mainFrame().wheelEventDeltaFilter()->isFilteringDeltas())
+        filteredPlatformDelta = m_frame.mainFrame().wheelEventDeltaFilter()->filteredDelta();
 #else
     Element* stopElement = nullptr;
 #endif
     
-    // Break up into two scrolls if we need to.  Diagonal movement on 
-    // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
-    if (dominantDirection != DominantScrollGestureDirection::Vertical && handleWheelEventInAppropriateEnclosingBoxForSingleAxis(startNode, wheelEvent, &stopElement, ScrollEventAxis::Horizontal))
-        wheelEvent->setDefaultHandled();
     
-    if (dominantDirection != DominantScrollGestureDirection::Horizontal && handleWheelEventInAppropriateEnclosingBoxForSingleAxis(startNode, wheelEvent, &stopElement, ScrollEventAxis::Vertical))
+    if (handleWheelEventInAppropriateEnclosingBox(startNode, wheelEvent, &stopElement, filteredPlatformDelta))
         wheelEvent->setDefaultHandled();
     
 #if PLATFORM(MAC)
index 9e252c333fe1249f1d80c5194ecfa70c9e52ff70..e5f5f9dc8895654930377e45810ecb526b2ff81e 100644 (file)
@@ -37,7 +37,7 @@
 #include "TextEventInputType.h"
 #include "TextGranularity.h"
 #include "Timer.h"
-#include "WheelEventDeltaTracker.h"
+#include "WheelEventDeltaFilter.h"
 #include <memory>
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
index bfd1eac49ebaaf10c1ff0e7eeef762450e3dae9d..236bcbea021ee9ee0eafaf3d5a6edb677cf7c9ef 100644 (file)
 #include "PageOverlayController.h"
 #include "ScrollLatchingState.h"
 #include "Settings.h"
-#include "WheelEventDeltaTracker.h"
+#include "WheelEventDeltaFilter.h"
 #include <wtf/NeverDestroyed.h>
 
 #if PLATFORM(MAC)
 #include "ServicesOverlayController.h"
-#endif
+#endif /* PLATFORM(MAC) */
 
 namespace WebCore {
 
@@ -49,7 +49,7 @@ inline MainFrame::MainFrame(Page& page, PageConfiguration& configuration)
     , m_servicesOverlayController(std::make_unique<ServicesOverlayController>(*this))
 #endif
 #endif
-    , m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
+    , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
     , m_pageOverlayController(std::make_unique<PageOverlayController>(*this))
     , m_diagnosticLoggingClient(configuration.diagnosticLoggingClient)
 {
index 2841253880dd8fd1b5cfef2693bce1bb2f5206d5..7fc4c512c310c65f0f26d412ae05cc7a186c465e 100644 (file)
@@ -36,7 +36,7 @@ class PageConfiguration;
 class PageOverlayController;
 class ScrollLatchingState;
 class ServicesOverlayController;
-class WheelEventDeltaTracker;
+class WheelEventDeltaFilter;
 
 class MainFrame final : public Frame {
 public:
@@ -47,7 +47,7 @@ public:
     void selfOnlyRef();
     void selfOnlyDeref();
 
-    WheelEventDeltaTracker* wheelEventDeltaTracker() { return m_recentWheelEventDeltaTracker.get(); }
+    WheelEventDeltaFilter* wheelEventDeltaFilter() { return m_recentWheelEventDeltaFilter.get(); }
     PageOverlayController& pageOverlayController() { return *m_pageOverlayController; }
 
 #if PLATFORM(MAC)
@@ -77,7 +77,7 @@ private:
 #endif
 #endif
 
-    std::unique_ptr<WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
+    std::unique_ptr<WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
     std::unique_ptr<PageOverlayController> m_pageOverlayController;
     DiagnosticLoggingClient* m_diagnosticLoggingClient;
 };
similarity index 54%
rename from Source/WebCore/page/WheelEventDeltaTracker.cpp
rename to Source/WebCore/page/WheelEventDeltaFilter.cpp
index 3ed999327844d11468a1ccf526a7e539013ecb6a..ab5b8ee7c1444fb4a6c8a9b229d86dff13330b74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "config.h"
+#include "WheelEventDeltaFilter.h"
 
-#include "WheelEventDeltaTracker.h"
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+#include "WheelEventDeltaFilterMac.h"
+#endif
 
-#include "PlatformWheelEvent.h"
+#include "FloatSize.h"
 
 namespace WebCore {
-
-WheelEventDeltaTracker::WheelEventDeltaTracker()
-    : m_isTrackingDeltas(false)
+    
+WheelEventDeltaFilter::WheelEventDeltaFilter()
 {
 }
 
-WheelEventDeltaTracker::~WheelEventDeltaTracker()
+WheelEventDeltaFilter::~WheelEventDeltaFilter()
 {
 }
 
-void WheelEventDeltaTracker::beginTrackingDeltas()
+std::unique_ptr<WheelEventDeltaFilter> WheelEventDeltaFilter::create()
 {
-    m_recentWheelEventDeltas.clear();
-    m_isTrackingDeltas = true;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+    return std::make_unique<WheelEventDeltaFilterMac>();
+#else
+    return std::make_unique<BasicWheelEventDeltaFilter>();
+#endif
 }
 
-void WheelEventDeltaTracker::endTrackingDeltas()
+BasicWheelEventDeltaFilter::BasicWheelEventDeltaFilter()
+    : WheelEventDeltaFilter()
 {
-    m_isTrackingDeltas = false;
 }
 
-void WheelEventDeltaTracker::recordWheelEventDelta(const PlatformWheelEvent& event)
+const size_t basicWheelEventDeltaFilterWindowSize = 3;
+
+void BasicWheelEventDeltaFilter::updateFromDelta(const FloatSize& delta)
 {
-    m_recentWheelEventDeltas.append(FloatSize(event.deltaX(), event.deltaY()));
-    if (m_recentWheelEventDeltas.size() > recentEventCount)
+    m_currentFilteredDelta = delta;
+    if (!m_isFilteringDeltas)
+        return;
+    
+    m_recentWheelEventDeltas.append(delta);
+    if (m_recentWheelEventDeltas.size() > basicWheelEventDeltaFilterWindowSize)
         m_recentWheelEventDeltas.removeFirst();
+    
+    DominantScrollGestureDirection scrollDirection = dominantScrollGestureDirection();
+    if (scrollDirection == DominantScrollGestureDirection::Vertical)
+        m_currentFilteredDelta.setWidth(0);
+    else if (scrollDirection == DominantScrollGestureDirection::Horizontal)
+        m_currentFilteredDelta.setHeight(0);
 }
 
-static bool deltaIsPredominantlyVertical(const FloatSize& delta)
+void BasicWheelEventDeltaFilter::beginFilteringDeltas()
+{
+    m_recentWheelEventDeltas.clear();
+    m_isFilteringDeltas = true;
+}
+
+void BasicWheelEventDeltaFilter::endFilteringDeltas()
+{
+    m_currentFilteredDelta = FloatSize(0, 0);
+    m_isFilteringDeltas = false;
+}
+
+static inline bool deltaIsPredominantlyVertical(const FloatSize& delta)
 {
     return fabs(delta.height()) > fabs(delta.width());
 }
 
-DominantScrollGestureDirection WheelEventDeltaTracker::dominantScrollGestureDirection() const
+DominantScrollGestureDirection BasicWheelEventDeltaFilter::dominantScrollGestureDirection() const
 {
     bool allVertical = m_recentWheelEventDeltas.size();
     bool allHorizontal = m_recentWheelEventDeltas.size();
-
+    
     for (const auto& delta : m_recentWheelEventDeltas) {
         bool isVertical = deltaIsPredominantlyVertical(delta);
         allVertical &= isVertical;
@@ -76,11 +105,11 @@ DominantScrollGestureDirection WheelEventDeltaTracker::dominantScrollGestureDire
     
     if (allVertical)
         return DominantScrollGestureDirection::Vertical;
-
+    
     if (allHorizontal)
         return DominantScrollGestureDirection::Horizontal;
     
     return DominantScrollGestureDirection::None;
 }
 
-} // namespace WebCore
+};
diff --git a/Source/WebCore/page/WheelEventDeltaFilter.h b/Source/WebCore/page/WheelEventDeltaFilter.h
new file mode 100644 (file)
index 0000000..55b42e6
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WheelEventDeltaFilter_h
+#define WheelEventDeltaFilter_h
+
+#include "FloatSize.h"
+#include <wtf/Deque.h>
+
+namespace WebCore {
+
+class PlatformWheelEvent;
+
+class WheelEventDeltaFilter {
+public:
+    WheelEventDeltaFilter();
+    virtual ~WheelEventDeltaFilter();
+
+    WEBCORE_EXPORT static std::unique_ptr<WheelEventDeltaFilter> create();
+    WEBCORE_EXPORT virtual void updateFromDelta(const FloatSize&) = 0;
+    WEBCORE_EXPORT virtual void beginFilteringDeltas() = 0;
+    WEBCORE_EXPORT virtual void endFilteringDeltas() = 0;
+    WEBCORE_EXPORT bool isFilteringDeltas() const
+    {
+        return m_isFilteringDeltas;
+    }
+    
+    WEBCORE_EXPORT FloatSize filteredDelta() const
+    {
+        return m_currentFilteredDelta;
+    }
+
+protected:
+    FloatSize m_currentFilteredDelta;
+    bool m_isFilteringDeltas { false };
+};
+
+enum class DominantScrollGestureDirection {
+    None,
+    Vertical,
+    Horizontal
+};
+
+class BasicWheelEventDeltaFilter final : public WheelEventDeltaFilter {
+public:
+    BasicWheelEventDeltaFilter();
+    virtual void updateFromDelta(const FloatSize&) override;
+    virtual void beginFilteringDeltas() override;
+    virtual void endFilteringDeltas() override;
+
+private:
+    DominantScrollGestureDirection dominantScrollGestureDirection() const;
+
+    Deque<FloatSize> m_recentWheelEventDeltas;
+};
+
+}
+
+#endif
index 5569e34704916d1a436287148777910a88a0a330..005553161e41303092e645855f02c23df05a0391 100644 (file)
@@ -954,7 +954,7 @@ void EventHandler::platformPrepareForWheelEvents(const PlatformWheelEvent& wheel
                 latchingState->setScrollableContainer(scrollableContainer);
                 latchingState->setWidgetIsLatched(result.isOverWidget());
                 isOverWidget = latchingState->widgetIsLatched();
-                m_frame.mainFrame().wheelEventDeltaTracker()->beginTrackingDeltas();
+                m_frame.mainFrame().wheelEventDeltaFilter()->beginFilteringDeltas();
             }
         }
     } else if (wheelEvent.shouldResetLatching())
@@ -982,16 +982,15 @@ void EventHandler::platformRecordWheelEvent(const PlatformWheelEvent& wheelEvent
 {
     switch (wheelEvent.phase()) {
         case PlatformWheelEventPhaseBegan:
-            m_frame.mainFrame().wheelEventDeltaTracker()->beginTrackingDeltas();
+            m_frame.mainFrame().wheelEventDeltaFilter()->beginFilteringDeltas();
             break;
         case PlatformWheelEventPhaseEnded:
-            m_frame.mainFrame().wheelEventDeltaTracker()->endTrackingDeltas();
+            m_frame.mainFrame().wheelEventDeltaFilter()->endFilteringDeltas();
             break;
         default:
             break;
     }
-
-    m_frame.mainFrame().wheelEventDeltaTracker()->recordWheelEventDelta(wheelEvent);
+    m_frame.mainFrame().wheelEventDeltaFilter()->updateFromDelta(FloatSize(wheelEvent.deltaX(), wheelEvent.deltaY()));
 }
 
 static FrameView* frameViewForLatchingState(Frame& frame, ScrollLatchingState* latchingState)
similarity index 60%
rename from Source/WebCore/page/WheelEventDeltaTracker.h
rename to Source/WebCore/page/mac/WheelEventDeltaFilterMac.h
index f5cae9e6ee7318df029bf43bec88ac902da38e7c..a09eda7f565f6f6e3259dc2b98d8462e9418ba88 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef WheelEventDeltaFilterMac_h
+#define WheelEventDeltaFilterMac_h
 
-#ifndef WheelEventDeltaTracker_h
-#define WheelEventDeltaTracker_h
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
 
-#include "FloatSize.h"
-#include <wtf/Deque.h>
+#include "WheelEventDeltaFilter.h"
+#include <wtf/RetainPtr.h>
 
-namespace WebCore {
-
-class PlatformWheelEvent;
-
-const size_t recentEventCount = 3;
+OBJC_CLASS _NSScrollingPredominantAxisFilter;
 
-enum class DominantScrollGestureDirection {
-    None,
-    Vertical,
-    Horizontal
-};
+namespace WebCore {
 
-class WheelEventDeltaTracker final {
+class WheelEventDeltaFilterMac final : public WheelEventDeltaFilter {
 public:
-    WEBCORE_EXPORT WheelEventDeltaTracker();
-    WEBCORE_EXPORT ~WheelEventDeltaTracker();
+    WheelEventDeltaFilterMac();
 
-    WEBCORE_EXPORT void beginTrackingDeltas();
-    WEBCORE_EXPORT void endTrackingDeltas();
-
-    bool isTrackingDeltas() const { return m_isTrackingDeltas; }
-
-    WEBCORE_EXPORT void recordWheelEventDelta(const PlatformWheelEvent&);
-    WEBCORE_EXPORT DominantScrollGestureDirection dominantScrollGestureDirection() const;
+    virtual void updateFromDelta(const FloatSize&) override;
+    virtual void beginFilteringDeltas() override;
+    virtual void endFilteringDeltas() override;
 
 private:
-    Deque<FloatSize> m_recentWheelEventDeltas;
-    bool m_isTrackingDeltas;
-
+    RetainPtr<_NSScrollingPredominantAxisFilter> m_predominantAxisFilter;
+    double m_beginFilteringDeltasTime { 0 };
 };
 
-} // namespace WebCore
+}
+
+#endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 */
 
-#endif // WheelEventDeltaTracker_h
+#endif /* WheelEventDeltaFilterMac_h */
diff --git a/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm b/Source/WebCore/page/mac/WheelEventDeltaFilterMac.mm
new file mode 100644 (file)
index 0000000..4ef086f
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+
+#include "config.h"
+#include "WheelEventDeltaFilterMac.h"
+
+#import "NSScrollingInputFilterSPI.h"
+#import <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+WheelEventDeltaFilterMac::WheelEventDeltaFilterMac()
+    : WheelEventDeltaFilter()
+    , m_predominantAxisFilter(adoptNS([[_NSScrollingPredominantAxisFilter alloc] init]))
+{
+}
+
+void WheelEventDeltaFilterMac::beginFilteringDeltas()
+{
+    m_beginFilteringDeltasTime = monotonicallyIncreasingTime();
+    m_isFilteringDeltas = true;
+}
+
+void WheelEventDeltaFilterMac::updateFromDelta(const FloatSize& delta)
+{
+    if (!m_isFilteringDeltas)
+        return;
+
+    NSPoint filteredDeltaResult;
+    NSPoint filteredVelocityResult;
+    [m_predominantAxisFilter filterInputDelta:CGPointMake(delta.width(), delta.height()) timestamp:monotonicallyIncreasingTime() - m_beginFilteringDeltasTime outputDelta:&filteredDeltaResult velocity:&filteredVelocityResult];
+    m_currentFilteredDelta = FloatSize(filteredDeltaResult.x, filteredDeltaResult.y);
+}
+
+void WheelEventDeltaFilterMac::endFilteringDeltas()
+{
+    m_currentFilteredDelta = FloatSize(0, 0);
+    m_beginFilteringDeltasTime = 0;
+    [m_predominantAxisFilter reset];
+    m_isFilteringDeltas = false;
+}
+
+}
+
+#endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 */
index bdc19c4cf770b5cbfdbdeb33c8e0abd20ba239d2..029bb9e9c22577eccaee68497ecce11a79194f7f 100644 (file)
@@ -119,17 +119,11 @@ namespace WebCore {
             return copy;
         }
 
-        PlatformWheelEvent copyIgnoringHorizontalDelta() const
+        PlatformWheelEvent copyWithDeltas(float deltaX, float deltaY) const
         {
             PlatformWheelEvent copy = *this;
-            copy.m_deltaX = 0;
-            return copy;
-        }
-
-        PlatformWheelEvent copyIgnoringVerticalDelta() const
-        {
-            PlatformWheelEvent copy = *this;
-            copy.m_deltaY = 0;
+            copy.m_deltaX = deltaX;
+            copy.m_deltaY = deltaY;
             return copy;
         }
 
diff --git a/Source/WebCore/platform/spi/mac/NSScrollingInputFilterSPI.h b/Source/WebCore/platform/spi/mac/NSScrollingInputFilterSPI.h
new file mode 100644 (file)
index 0000000..83162a2
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AppKit/NSScrollingInputFilter_Private.h>
+
+#else
+
+@interface _NSScrollingPredominantAxisFilter : NSObject;
+- (void)filterInputDelta:(NSPoint)delta timestamp:(NSTimeInterval)timestamp outputDelta:(NSPoint*)pDelta velocity:(NSPoint *)pVelocity;
+- (void)reset;
+@end
+
+#endif /* USE(APPLE_INTERNAL_SDK) */
+
+#endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 */
index 1cc386d61a6be4498fac300cf0e8f9fe35dd5281..f7e69ae9df67a5d004d7229e0009f86861afe50a 100644 (file)
@@ -1,3 +1,23 @@
+2015-08-24  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        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
+        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.
+
 2015-08-23  Andy Estes  <aestes@apple.com>
 
         [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
index 8c4a0ac4b5c6d8af7f30cdba58d9b84a57432d33..fe4fc9a52aed8abb16baa5a22696fb35c3b140ea 100644 (file)
@@ -54,7 +54,7 @@ Ref<EventDispatcher> EventDispatcher::create()
 
 EventDispatcher::EventDispatcher()
     : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
-    , m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
+    , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
 {
 }
 
@@ -95,26 +95,19 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
 #if PLATFORM(COCOA)
     switch (wheelEvent.phase()) {
     case PlatformWheelEventPhaseBegan:
-        m_recentWheelEventDeltaTracker->beginTrackingDeltas();
+        m_recentWheelEventDeltaFilter->beginFilteringDeltas();
         break;
     case PlatformWheelEventPhaseEnded:
-        m_recentWheelEventDeltaTracker->endTrackingDeltas();
+        m_recentWheelEventDeltaFilter->endFilteringDeltas();
         break;
     default:
         break;
     }
 
-    if (m_recentWheelEventDeltaTracker->isTrackingDeltas()) {
-        m_recentWheelEventDeltaTracker->recordWheelEventDelta(platformWheelEvent);
-
-        DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None;
-        dominantDirection = m_recentWheelEventDeltaTracker->dominantScrollGestureDirection();
-
-        // Workaround for scrolling issues <rdar://problem/14758615>.
-        if (dominantDirection == DominantScrollGestureDirection::Vertical && platformWheelEvent.deltaX())
-            platformWheelEvent = platformWheelEvent.copyIgnoringHorizontalDelta();
-        else if (dominantDirection == DominantScrollGestureDirection::Horizontal && platformWheelEvent.deltaY())
-            platformWheelEvent = platformWheelEvent.copyIgnoringVerticalDelta();
+    if (m_recentWheelEventDeltaFilter->isFilteringDeltas()) {
+        m_recentWheelEventDeltaFilter->updateFromDelta(FloatSize(platformWheelEvent.deltaX(), platformWheelEvent.deltaY()));
+        FloatSize filteredDelta = m_recentWheelEventDeltaFilter->filteredDelta();
+        platformWheelEvent = platformWheelEvent.copyWithDeltas(filteredDelta.width(), filteredDelta.height());
     }
 #endif
 
index a97ac80ce1779bf2a5f198342457a5ee4b20938f..602198b7de5886e1184e35b339453504510b88c3 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "Connection.h"
 
-#include <WebCore/WheelEventDeltaTracker.h>
+#include <WebCore/WheelEventDeltaFilter.h>
 #include <WebEvent.h>
 #include <memory>
 #include <wtf/HashMap.h>
@@ -95,7 +95,7 @@ private:
     Lock m_scrollingTreesMutex;
     HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
 #endif
-    std::unique_ptr<WebCore::WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
+    std::unique_ptr<WebCore::WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
 #if ENABLE(IOS_TOUCH_EVENTS)
     Lock m_touchEventsLock;
     HashMap<uint64_t, TouchEventQueue> m_touchEvents;