Changeset 188860 in webkit


Ignore:
Timestamp:
Aug 24, 2015 8:23:21 AM (9 years ago)
Author:
Wenson Hsieh
Message:

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.
Location:
trunk/Source
Files:
2 added
14 edited
1 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r188820 r188860  
    20042004    page/UserContentURLPattern.cpp
    20052005    page/VisitedLinkStore.cpp
    2006     page/WheelEventDeltaTracker.cpp
     2006    page/WheelEventDeltaFilter.cpp
    20072007    page/WheelEventTestTrigger.cpp
    20082008    page/WindowFeatures.cpp
  • trunk/Source/WebCore/ChangeLog

    r188859 r188860  
     12015-08-24  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Use _NSScrollingPredominantAxisFilter for wheel event filtering on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=147320
     5
     6        Reviewed by Simon Fraser.
     7
     8        Refactored to use a predominant axis filter instead of a predominant axis tracker. This allows us to
     9        employ AppKit's _NSScrollingPredominantAxisFilter when possible, and use the wheel event delta tracker
     10        as a fallback. Here, we refactor EventHandler to use the new filters for overflow scrolling and replace
     11        the MainFrame's WheelEventDeltaTracker with an appropriate type of WheelEventDeltaFilter.
     12
     13        In the case where an _NSScrollingPredominantAxisFilter is unavailable, the platform-invariant wheel
     14        event delta filter simply uses the existing wheel event delta tracker to compute the current predominant
     15        axis. It uses the predominant axis to determine which axis (if any) should have its delta zeroed out.
     16
     17        This patch also introduces NSScrollingInputFilterSPI.h, which either imports the internal input filter
     18        header from AppKit or declares relevant interfaces and functions.
     19
     20        No new tests, since this change does not add new functionality.
     21
     22        * CMakeLists.txt: Add page/WheelEventDeltaFilter.cpp.
     23        * WebCore.vcxproj/WebCore.vcxproj: Add WheelEventDeltaFilter.cpp and WheelEventDeltaFilter.h.
     24        * WebCore.vcxproj/WebCore.vcxproj.filters: Add WheelEventDeltaFilter.cpp and WheelEventDeltaFilter.h.
     25        * WebCore.xcodeproj/project.pbxproj: Add WheelEventDeltaFilter.cpp, WheelEventDeltaFilter.h, and their Mac counterparts.
     26        * page/EventHandler.cpp:
     27        (WebCore::didScrollInScrollableArea): Refactored to no longer handle axes separately.
     28        (WebCore::handleWheelEventInAppropriateEnclosingBox): Ditto.
     29        (WebCore::EventHandler::platformRecordWheelEvent): Refactored to update the wheel delta filter.
     30        (WebCore::EventHandler::clearLatchedState): Ditto.
     31        (WebCore::EventHandler::defaultWheelEventHandler): Refactored to use wheel delta filters. No longer splits wheel events
     32                and handles them on separate axes.
     33        (WebCore::didScrollInScrollableAreaForSingleAxis): Deleted.
     34        (WebCore::handleWheelEventInAppropriateEnclosingBoxForSingleAxis): Deleted.
     35        * page/EventHandler.h:
     36        * page/MainFrame.cpp:
     37        (WebCore::MainFrame::MainFrame): Initializes the appropriate type of WheelEventDeltaFilter.
     38        * page/MainFrame.h:
     39        * page/WheelEventDeltaFilter.cpp: Added.
     40        (WebCore::WheelEventDeltaFilter::WheelEventDeltaFilter):
     41        (WebCore::WheelEventDeltaFilter::~WheelEventDeltaFilter):
     42        (WebCore::WheelEventDeltaFilter::create):
     43        (WebCore::BasicWheelEventDeltaFilter::BasicWheelEventDeltaFilter):
     44        (WebCore::BasicWheelEventDeltaFilter::updateFromDelta):
     45        (WebCore::BasicWheelEventDeltaFilter::beginFilteringDeltas):
     46        (WebCore::BasicWheelEventDeltaFilter::endFilteringDeltas):
     47        (WebCore::deltaIsPredominantlyVertical):
     48        (WebCore::BasicWheelEventDeltaFilter::dominantScrollGestureDirection):
     49        * page/WheelEventDeltaFilter.h: Refactored WheelEventDeltaTracker logic to work as a filter instead.
     50        * page/mac/EventHandlerMac.mm:
     51        (WebCore::EventHandler::platformPrepareForWheelEvents): Refactored to use wheel delta filters.
     52        (WebCore::EventHandler::platformRecordWheelEvent): Ditto.
     53        * page/mac/WheelEventDeltaFilterMac.h: Wraps the new _NSScrollingPredominantAxisFilter.
     54        * page/mac/WheelEventDeltaFilterMac.mm: Added.
     55        (WebCore::WheelEventDeltaFilterMac::WheelEventDeltaFilterMac):
     56        (WebCore::WheelEventDeltaFilterMac::beginFilteringDeltas):
     57        (WebCore::WheelEventDeltaFilterMac::updateFromDelta):
     58        (WebCore::WheelEventDeltaFilterMac::endFilteringDeltas):
     59        * platform/PlatformWheelEvent.h:
     60        (WebCore::PlatformWheelEvent::copyWithDeltas): Used to create a copy of the platform wheel event with filtered deltas.
     61        (WebCore::PlatformWheelEvent::copyIgnoringHorizontalDelta): Deleted. No longer necessary, since we won't be handling wheel
     62                events on separate axes.
     63        (WebCore::PlatformWheelEvent::copyIgnoringVerticalDelta): Ditto.
     64        * platform/spi/mac/NSScrollingInputFilterSPI.h: Added.
     65
    1662015-08-24  Michael Catanzaro  <mcatanzaro@igalia.com>
    267
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r188820 r188860  
    73427342    <ClCompile Include="..\page\VisitedLinkStore.cpp" />
    73437343    <ClCompile Include="..\fileapi\WebKitBlobBuilder.cpp" />
    7344     <ClCompile Include="..\page\WheelEventDeltaTracker.cpp" />
     7344    <ClCompile Include="..\page\WheelEventDeltaFilter.cpp" />
    73457345    <ClCompile Include="..\page\WheelEventTestTrigger.cpp" />
    73467346    <ClCompile Include="..\page\WindowFeatures.cpp" />
     
    2078020780    <ClInclude Include="..\fileapi\WebKitBlobBuilder.h" />
    2078120781    <ClInclude Include="..\page\WebKitPoint.h" />
    20782     <ClInclude Include="..\page\WheelEventDeltaTracker.h" />
     20782    <ClInclude Include="..\page\WheelEventDeltaFilter.h" />
    2078320783    <ClInclude Include="..\page\WheelEventTestTrigger.h" />
    2078420784    <ClInclude Include="..\page\WindowFeatures.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r188809 r188860  
    814814      <Filter>page</Filter>
    815815    </ClCompile>
    816     <ClCompile Include="..\page\WheelEventDeltaTracker.cpp">
     816    <ClCompile Include="..\page\WheelEventDeltaFilter.cpp">
    817817      <Filter>page</Filter>
    818818    </ClCompile>
     
    78457845      <Filter>page</Filter>
    78467846    </ClInclude>
    7847     <ClInclude Include="..\page\WheelEventDeltaTracker.h">
     7847    <ClInclude Include="..\page\WheelEventDeltaFilter.h">
    78487848      <Filter>page</Filter>
    78497849    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r188851 r188860  
    11791179                2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E0888D31148848A00AF4265 /* JSDOMFormData.h */; };
    11801180                2E0888E6114884E200AF4265 /* JSDOMFormDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888E5114884E200AF4265 /* JSDOMFormDataCustom.cpp */; };
     1181                2E19516B1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */; };
    11811182                2E2D99CD10E2BBDA00496337 /* JSBlob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */; };
    11821183                2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E2D99CC10E2BBDA00496337 /* JSBlob.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    12191220                2E94F43B119207DA00B7F75D /* JSFileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E94F439119207DA00B7F75D /* JSFileReader.cpp */; };
    12201221                2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; };
     1222                2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12211223                2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; };
    12221224                2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */; };
    12231225                2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; };
     1226                2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12241227                2ECF7ADC10162B3800427DE7 /* JSErrorEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2ECF7ADA10162B3800427DE7 /* JSErrorEvent.cpp */; };
    12251228                2ECF7ADD10162B3800427DE7 /* JSErrorEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */; };
     
    12361239                2EDF369D122C94B4002F7D4E /* FileReaderSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369B122C94B4002F7D4E /* FileReaderSync.h */; };
    12371240                2EDF369F122C94C8002F7D4E /* FileException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EDF369E122C94C8002F7D4E /* FileException.h */; };
     1241                2EEEE55C1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */; };
    12381242                2EF1BFEA121C9F4200C27627 /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EF1BFE8121C9F4200C27627 /* FileStream.cpp */; };
    12391243                2EF1BFEB121C9F4200C27627 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF1BFE9121C9F4200C27627 /* FileStream.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    35143518                93EB169709F880C00091F8FF /* WebCoreSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35153519                93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */; };
    3516                 93EC44A1188F4BB800661DF1 /* WheelEventDeltaTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */; };
    3517                 93EC44A2188F4BB800661DF1 /* WheelEventDeltaTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35183520                93EF7D551954F13900DFB71D /* ScrollingStateNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93EF7D541954E98F00DFB71D /* ScrollingStateNode.mm */; };
    35193521                93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D23C02DE4396018635CA /* HTMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    64616463                F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */; };
    64626464                F3F5CF1312ED81B30084C569 /* InspectorDatabaseInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */; };
     6465                F40EA8AB1B867E4400CE5581 /* NSScrollingInputFilterSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    64636466                F42FFB461984B71600F6837F /* LengthRepeat.h in Headers */ = {isa = PBXBuildFile; fileRef = F42FFB451984B71600F6837F /* LengthRepeat.h */; };
    64646467                F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */; };
     
    83888391                2E0888D31148848A00AF4265 /* JSDOMFormData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMFormData.h; sourceTree = "<group>"; };
    83898392                2E0888E5114884E200AF4265 /* JSDOMFormDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMFormDataCustom.cpp; sourceTree = "<group>"; };
     8393                2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEventDeltaFilter.cpp; sourceTree = "<group>"; };
    83908394                2E2D99CB10E2BBDA00496337 /* JSBlob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlob.cpp; sourceTree = "<group>"; };
    83918395                2E2D99CC10E2BBDA00496337 /* JSBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlob.h; sourceTree = "<group>"; };
     
    84308434                2E94F439119207DA00B7F75D /* JSFileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileReader.cpp; sourceTree = "<group>"; };
    84318435                2E94F43A119207DA00B7F75D /* JSFileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReader.h; sourceTree = "<group>"; };
     8436                2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilterMac.h; sourceTree = "<group>"; };
    84328437                2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptLoaderClient.h; sourceTree = "<group>"; };
    84338438                2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobResourceHandle.cpp; sourceTree = "<group>"; };
    84348439                2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobResourceHandle.h; sourceTree = "<group>"; };
     8440                2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilter.h; sourceTree = "<group>"; };
    84358441                2ECF7ADA10162B3800427DE7 /* JSErrorEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorEvent.cpp; sourceTree = "<group>"; };
    84368442                2ECF7ADB10162B3800427DE7 /* JSErrorEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorEvent.h; sourceTree = "<group>"; };
     
    84488454                2EDF369B122C94B4002F7D4E /* FileReaderSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileReaderSync.h; sourceTree = "<group>"; };
    84498455                2EDF369E122C94C8002F7D4E /* FileException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileException.h; sourceTree = "<group>"; };
     8456                2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WheelEventDeltaFilterMac.mm; sourceTree = "<group>"; };
    84508457                2EF1BFE8121C9F4200C27627 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileStream.cpp; sourceTree = "<group>"; };
    84518458                2EF1BFE9121C9F4200C27627 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = "<group>"; };
     
    1086910876                93EB169609F880C00091F8FF /* WebCoreSystemInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreSystemInterface.h; sourceTree = "<group>"; };
    1087010877                93EB355E09E37FD600F43799 /* MouseEventWithHitTestResults.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventWithHitTestResults.cpp; sourceTree = "<group>"; };
    10871                 93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WheelEventDeltaTracker.cpp; sourceTree = "<group>"; };
    10872                 93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaTracker.h; sourceTree = "<group>"; };
    1087310878                93EEC1E509C2877700C515D1 /* Attr.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Attr.idl; sourceTree = "<group>"; };
    1087410879                93EEC1E609C2877700C515D1 /* CharacterData.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CharacterData.idl; sourceTree = "<group>"; };
     
    1419014195                F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorConsoleInstrumentation.h; sourceTree = "<group>"; };
    1419114196                F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseInstrumentation.h; sourceTree = "<group>"; };
     14197                F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSScrollingInputFilterSPI.h; sourceTree = "<group>"; };
    1419214198                F42FFB451984B71600F6837F /* LengthRepeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthRepeat.h; sourceTree = "<group>"; };
    1419314199                F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = "<group>"; };
     
    1726717273                                494BD7930F55C8EE00747828 /* WebKitPoint.h */,
    1726817274                                494BD7940F55C8EE00747828 /* WebKitPoint.idl */,
    17269                                 93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */,
    17270                                 93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */,
     17275                                2E19516A1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp */,
     17276                                2EBBC3D71B65988300F5253D /* WheelEventDeltaFilter.h */,
    1727117277                                7AE335EF1ACB09E200E401EF /* WheelEventTestTrigger.cpp */,
    1727217278                                7AE335F01ACB09E200E401EF /* WheelEventTestTrigger.h */,
     
    1812618132                                937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */,
    1812718133                                93F1E1EB1A40FDDC00348D13 /* NSPopoverSPI.h */,
     18134                                F40EA8AA1B867D6500CE5581 /* NSScrollingInputFilterSPI.h */,
    1812818135                                2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
    1812918136                                2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
     
    1815918166                                26255F0218878E110006E1FD /* UserAgentMac.mm */,
    1816018167                                F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
     18168                                2EEEE55B1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm */,
     18169                                2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */,
    1816118170                        );
    1816218171                        path = mac;
     
    2403624045                                FD31608012B026F700C1A359 /* AudioDSPKernel.h in Headers */,
    2403724046                                FD31608212B026F700C1A359 /* AudioDSPKernelProcessor.h in Headers */,
     24047                                F40EA8AB1B867E4400CE5581 /* NSScrollingInputFilterSPI.h in Headers */,
    2403824048                                FD31608312B026F700C1A359 /* AudioFileReader.h in Headers */,
    2403924049                                CD5596921475B678001D0BD0 /* AudioFileReaderIOS.h in Headers */,
     
    2536025370                                44DEF6431A6FF92700D45EEC /* IOReturnSPI.h in Headers */,
    2536125371                                2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */,
     25372                                2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */,
    2536225373                                1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
    2536325374                                44DFF6431A6FF92700D45EEC /* IOSurfaceSPI.h in Headers */,
     
    2571625727                                B59DD6A511902A62007E9684 /* JSSQLStatementCallback.h in Headers */,
    2571725728                                B59DD6A911902A71007E9684 /* JSSQLStatementErrorCallback.h in Headers */,
     25729                                2EBBC3D81B65988300F5253D /* WheelEventDeltaFilter.h in Headers */,
    2571825730                                BC82432A0D0CE8A200460C8F /* JSSQLTransaction.h in Headers */,
    2571925731                                B59DD69D11902A42007E9684 /* JSSQLTransactionCallback.h in Headers */,
     
    2743827450                                F55B3DE01251F12D003EF269 /* WeekInputType.h in Headers */,
    2743927451                                85031B510A44EFC700F992E0 /* WheelEvent.h in Headers */,
    27440                                 93EC44A2188F4BB800661DF1 /* WheelEventDeltaTracker.h in Headers */,
    2744127452                                7AE335F21ACB09E200E401EF /* WheelEventTestTrigger.h in Headers */,
    2744227453                                9380F47409A11AB4001FDB34 /* Widget.h in Headers */,
     
    3037330384                                B22279B00D00BF220071B782 /* SVGDescElement.cpp in Sources */,
    3037430385                                B22279B30D00BF220071B782 /* SVGDocument.cpp in Sources */,
     30386                                2EEEE55C1B66A047008E2CBC /* WheelEventDeltaFilterMac.mm in Sources */,
    3037530387                                B28C6A270D00C44800334AA4 /* SVGDocumentExtensions.cpp in Sources */,
    3037630388                                B22279B60D00BF220071B782 /* SVGElement.cpp in Sources */,
     
    3046730479                                B2227A8E0D00BF220071B782 /* SVGPolyElement.cpp in Sources */,
    3046830480                                B2227A900D00BF220071B782 /* SVGPolygonElement.cpp in Sources */,
     30481                                2E19516B1B6598D200DF6EEF /* WheelEventDeltaFilter.cpp in Sources */,
    3046930482                                B2227A930D00BF220071B782 /* SVGPolylineElement.cpp in Sources */,
    3047030483                                B2227A960D00BF220071B782 /* SVGPreserveAspectRatio.cpp in Sources */,
     
    3076630779                                F55B3DDF1251F12D003EF269 /* WeekInputType.cpp in Sources */,
    3076730780                                85031B500A44EFC700F992E0 /* WheelEvent.cpp in Sources */,
    30768                                 93EC44A1188F4BB800661DF1 /* WheelEventDeltaTracker.cpp in Sources */,
    3076930781                                7AE335F11ACB09E200E401EF /* WheelEventTestTrigger.cpp in Sources */,
    3077030782                                9380F47309A11AB4001FDB34 /* Widget.cpp in Sources */,
  • trunk/Source/WebCore/page/EventHandler.cpp

    r186480 r188860  
    288288}
    289289
    290 static inline bool didScrollInScrollableAreaForSingleAxis(ScrollableArea* scrollableArea, WheelEvent* wheelEvent, ScrollEventAxis axis)
    291 {
    292     float delta = axis == ScrollEventAxis::Vertical ? wheelEvent->deltaY() : wheelEvent->deltaX();
    293     ScrollDirection negativeDirection = axis == ScrollEventAxis::Vertical ? ScrollUp : ScrollLeft;
    294     ScrollDirection positiveDirection = axis == ScrollEventAxis::Vertical ? ScrollDown : ScrollRight;
    295     return scrollableArea->scroll(delta < 0 ? negativeDirection : positiveDirection, wheelGranularityToScrollGranularity(wheelEvent->deltaMode()), delta > 0 ? delta : -delta);
    296 }
    297 
    298 static inline bool handleWheelEventInAppropriateEnclosingBoxForSingleAxis(Node* startNode, WheelEvent* wheelEvent, Element** stopElement, ScrollEventAxis axis)
    299 {
    300     bool shouldHandleEvent = (axis == ScrollEventAxis::Vertical && wheelEvent->deltaY()) || (axis == ScrollEventAxis::Horizontal && wheelEvent->deltaX());
     290static inline bool didScrollInScrollableArea(ScrollableArea* scrollableArea, WheelEvent* wheelEvent)
     291{
     292    ScrollGranularity scrollGranularity = wheelGranularityToScrollGranularity(wheelEvent->deltaMode());
     293    bool didHandleWheelEvent = false;
     294    if (float absoluteDelta = std::abs(wheelEvent->deltaX()))
     295        didHandleWheelEvent |= scrollableArea->scroll(wheelEvent->deltaX() > 0 ? ScrollRight : ScrollLeft, scrollGranularity, absoluteDelta);
     296   
     297    if (float absoluteDelta = std::abs(wheelEvent->deltaY()))
     298        didHandleWheelEvent |= scrollableArea->scroll(wheelEvent->deltaY() > 0 ? ScrollDown : ScrollUp, scrollGranularity, absoluteDelta);
     299   
     300    return didHandleWheelEvent;
     301}
     302
     303static inline bool handleWheelEventInAppropriateEnclosingBox(Node* startNode, WheelEvent* wheelEvent, Element** stopElement, const FloatSize& filteredPlatformDelta)
     304{
     305    bool shouldHandleEvent = wheelEvent->deltaX() || wheelEvent->deltaY();
    301306#if PLATFORM(MAC)
    302307    shouldHandleEvent |= wheelEvent->phase() == PlatformWheelEventPhaseEnded;
     
    310315    RenderBox& initialEnclosingBox = startNode->renderer()->enclosingBox();
    311316    if (initialEnclosingBox.isListBox())
    312         return didScrollInScrollableAreaForSingleAxis(static_cast<RenderListBox*>(&initialEnclosingBox), wheelEvent, axis);
     317        return didScrollInScrollableArea(static_cast<RenderListBox*>(&initialEnclosingBox), wheelEvent);
    313318
    314319    RenderBox* currentEnclosingBox = &initialEnclosingBox;
     
    318323            bool scrollingWasHandled;
    319324            if (platformEvent != nullptr)
    320                 scrollingWasHandled = boxLayer->handleWheelEvent(axis == ScrollEventAxis::Vertical ? platformEvent->copyIgnoringHorizontalDelta() : platformEvent->copyIgnoringVerticalDelta());
     325                scrollingWasHandled = boxLayer->handleWheelEvent(platformEvent->copyWithDeltas(filteredPlatformDelta.width(), filteredPlatformDelta.height()));
    321326            else
    322                 scrollingWasHandled = didScrollInScrollableAreaForSingleAxis(boxLayer, wheelEvent, axis);
     327                scrollingWasHandled = didScrollInScrollableArea(boxLayer, wheelEvent);
    323328
    324329            if (scrollingWasHandled) {
     
    26712676void EventHandler::platformRecordWheelEvent(const PlatformWheelEvent& event)
    26722677{
    2673     m_frame.mainFrame().wheelEventDeltaTracker()->recordWheelEventDelta(event);
     2678    m_frame.mainFrame().wheelEventDeltaFilter()->updateFromDelta(FloatSize(event.deltaX(), event.deltaY()));
    26742679}
    26752680
     
    27762781    m_frame.mainFrame().resetLatchingState();
    27772782#endif
    2778     m_frame.mainFrame().wheelEventDeltaTracker()->endTrackingDeltas();
     2783    m_frame.mainFrame().wheelEventDeltaFilter()->endFilteringDeltas();
    27792784}
    27802785
     
    27842789        return;
    27852790   
    2786     DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None;
    2787 
     2791    FloatSize filteredPlatformDelta(wheelEvent->deltaX(), wheelEvent->deltaY());
     2792    if (const PlatformWheelEvent* platformWheelEvent = wheelEvent->wheelEvent()) {
     2793        filteredPlatformDelta.setWidth(platformWheelEvent->deltaX());
     2794        filteredPlatformDelta.setHeight(platformWheelEvent->deltaY());
     2795    }
     2796   
    27882797#if PLATFORM(MAC)
    27892798    ScrollLatchingState* latchedState = m_frame.mainFrame().latchingState();
    27902799    Element* stopElement = latchedState ? latchedState->previousWheelScrolledElement() : nullptr;
    27912800
    2792     // Workaround for scrolling issues <rdar://problem/14758615>.
    2793     if (m_frame.mainFrame().wheelEventDeltaTracker()->isTrackingDeltas())
    2794         dominantDirection = m_frame.mainFrame().wheelEventDeltaTracker()->dominantScrollGestureDirection();
     2801    if (m_frame.mainFrame().wheelEventDeltaFilter()->isFilteringDeltas())
     2802        filteredPlatformDelta = m_frame.mainFrame().wheelEventDeltaFilter()->filteredDelta();
    27952803#else
    27962804    Element* stopElement = nullptr;
    27972805#endif
    27982806   
    2799     // Break up into two scrolls if we need to.  Diagonal movement on
    2800     // a MacBook pro is an example of a 2-dimensional mouse wheel event (where both deltaX and deltaY can be set).
    2801     if (dominantDirection != DominantScrollGestureDirection::Vertical && handleWheelEventInAppropriateEnclosingBoxForSingleAxis(startNode, wheelEvent, &stopElement, ScrollEventAxis::Horizontal))
    2802         wheelEvent->setDefaultHandled();
    2803    
    2804     if (dominantDirection != DominantScrollGestureDirection::Horizontal && handleWheelEventInAppropriateEnclosingBoxForSingleAxis(startNode, wheelEvent, &stopElement, ScrollEventAxis::Vertical))
     2807   
     2808    if (handleWheelEventInAppropriateEnclosingBox(startNode, wheelEvent, &stopElement, filteredPlatformDelta))
    28052809        wheelEvent->setDefaultHandled();
    28062810   
  • trunk/Source/WebCore/page/EventHandler.h

    r185231 r188860  
    3838#include "TextGranularity.h"
    3939#include "Timer.h"
    40 #include "WheelEventDeltaTracker.h"
     40#include "WheelEventDeltaFilter.h"
    4141#include <memory>
    4242#include <wtf/Forward.h>
  • trunk/Source/WebCore/page/MainFrame.cpp

    r184066 r188860  
    3333#include "ScrollLatchingState.h"
    3434#include "Settings.h"
    35 #include "WheelEventDeltaTracker.h"
     35#include "WheelEventDeltaFilter.h"
    3636#include <wtf/NeverDestroyed.h>
    3737
    3838#if PLATFORM(MAC)
    3939#include "ServicesOverlayController.h"
    40 #endif
     40#endif /* PLATFORM(MAC) */
    4141
    4242namespace WebCore {
     
    5050#endif
    5151#endif
    52     , m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
     52    , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
    5353    , m_pageOverlayController(std::make_unique<PageOverlayController>(*this))
    5454    , m_diagnosticLoggingClient(configuration.diagnosticLoggingClient)
  • trunk/Source/WebCore/page/MainFrame.h

    r184066 r188860  
    3737class ScrollLatchingState;
    3838class ServicesOverlayController;
    39 class WheelEventDeltaTracker;
     39class WheelEventDeltaFilter;
    4040
    4141class MainFrame final : public Frame {
     
    4848    void selfOnlyDeref();
    4949
    50     WheelEventDeltaTracker* wheelEventDeltaTracker() { return m_recentWheelEventDeltaTracker.get(); }
     50    WheelEventDeltaFilter* wheelEventDeltaFilter() { return m_recentWheelEventDeltaFilter.get(); }
    5151    PageOverlayController& pageOverlayController() { return *m_pageOverlayController; }
    5252
     
    7878#endif
    7979
    80     std::unique_ptr<WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
     80    std::unique_ptr<WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
    8181    std::unique_ptr<PageOverlayController> m_pageOverlayController;
    8282    DiagnosticLoggingClient* m_diagnosticLoggingClient;
  • trunk/Source/WebCore/page/WheelEventDeltaFilter.cpp

    r188859 r188860  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
     27#include "WheelEventDeltaFilter.h"
    2728
    28 #include "WheelEventDeltaTracker.h"
     29#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     30#include "WheelEventDeltaFilterMac.h"
     31#endif
    2932
    30 #include "PlatformWheelEvent.h"
     33#include "FloatSize.h"
    3134
    3235namespace WebCore {
    33 
    34 WheelEventDeltaTracker::WheelEventDeltaTracker()
    35     : m_isTrackingDeltas(false)
     36   
     37WheelEventDeltaFilter::WheelEventDeltaFilter()
    3638{
    3739}
    3840
    39 WheelEventDeltaTracker::~WheelEventDeltaTracker()
     41WheelEventDeltaFilter::~WheelEventDeltaFilter()
    4042{
    4143}
    4244
    43 void WheelEventDeltaTracker::beginTrackingDeltas()
     45std::unique_ptr<WheelEventDeltaFilter> WheelEventDeltaFilter::create()
     46{
     47#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     48    return std::make_unique<WheelEventDeltaFilterMac>();
     49#else
     50    return std::make_unique<BasicWheelEventDeltaFilter>();
     51#endif
     52}
     53
     54BasicWheelEventDeltaFilter::BasicWheelEventDeltaFilter()
     55    : WheelEventDeltaFilter()
     56{
     57}
     58
     59const size_t basicWheelEventDeltaFilterWindowSize = 3;
     60
     61void BasicWheelEventDeltaFilter::updateFromDelta(const FloatSize& delta)
     62{
     63    m_currentFilteredDelta = delta;
     64    if (!m_isFilteringDeltas)
     65        return;
     66   
     67    m_recentWheelEventDeltas.append(delta);
     68    if (m_recentWheelEventDeltas.size() > basicWheelEventDeltaFilterWindowSize)
     69        m_recentWheelEventDeltas.removeFirst();
     70   
     71    DominantScrollGestureDirection scrollDirection = dominantScrollGestureDirection();
     72    if (scrollDirection == DominantScrollGestureDirection::Vertical)
     73        m_currentFilteredDelta.setWidth(0);
     74    else if (scrollDirection == DominantScrollGestureDirection::Horizontal)
     75        m_currentFilteredDelta.setHeight(0);
     76}
     77
     78void BasicWheelEventDeltaFilter::beginFilteringDeltas()
    4479{
    4580    m_recentWheelEventDeltas.clear();
    46     m_isTrackingDeltas = true;
     81    m_isFilteringDeltas = true;
    4782}
    4883
    49 void WheelEventDeltaTracker::endTrackingDeltas()
     84void BasicWheelEventDeltaFilter::endFilteringDeltas()
    5085{
    51     m_isTrackingDeltas = false;
     86    m_currentFilteredDelta = FloatSize(0, 0);
     87    m_isFilteringDeltas = false;
    5288}
    5389
    54 void WheelEventDeltaTracker::recordWheelEventDelta(const PlatformWheelEvent& event)
    55 {
    56     m_recentWheelEventDeltas.append(FloatSize(event.deltaX(), event.deltaY()));
    57     if (m_recentWheelEventDeltas.size() > recentEventCount)
    58         m_recentWheelEventDeltas.removeFirst();
    59 }
    60 
    61 static bool deltaIsPredominantlyVertical(const FloatSize& delta)
     90static inline bool deltaIsPredominantlyVertical(const FloatSize& delta)
    6291{
    6392    return fabs(delta.height()) > fabs(delta.width());
    6493}
    6594
    66 DominantScrollGestureDirection WheelEventDeltaTracker::dominantScrollGestureDirection() const
     95DominantScrollGestureDirection BasicWheelEventDeltaFilter::dominantScrollGestureDirection() const
    6796{
    6897    bool allVertical = m_recentWheelEventDeltas.size();
    6998    bool allHorizontal = m_recentWheelEventDeltas.size();
    70 
     99   
    71100    for (const auto& delta : m_recentWheelEventDeltas) {
    72101        bool isVertical = deltaIsPredominantlyVertical(delta);
     
    77106    if (allVertical)
    78107        return DominantScrollGestureDirection::Vertical;
    79 
     108   
    80109    if (allHorizontal)
    81110        return DominantScrollGestureDirection::Horizontal;
     
    84113}
    85114
    86 } // namespace WebCore
     115};
  • trunk/Source/WebCore/page/WheelEventDeltaFilter.h

    r188859 r188860  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 
    27 #ifndef WheelEventDeltaTracker_h
    28 #define WheelEventDeltaTracker_h
     26#ifndef WheelEventDeltaFilter_h
     27#define WheelEventDeltaFilter_h
    2928
    3029#include "FloatSize.h"
     
    3534class PlatformWheelEvent;
    3635
    37 const size_t recentEventCount = 3;
     36class WheelEventDeltaFilter {
     37public:
     38    WheelEventDeltaFilter();
     39    virtual ~WheelEventDeltaFilter();
     40
     41    WEBCORE_EXPORT static std::unique_ptr<WheelEventDeltaFilter> create();
     42    WEBCORE_EXPORT virtual void updateFromDelta(const FloatSize&) = 0;
     43    WEBCORE_EXPORT virtual void beginFilteringDeltas() = 0;
     44    WEBCORE_EXPORT virtual void endFilteringDeltas() = 0;
     45    WEBCORE_EXPORT bool isFilteringDeltas() const
     46    {
     47        return m_isFilteringDeltas;
     48    }
     49   
     50    WEBCORE_EXPORT FloatSize filteredDelta() const
     51    {
     52        return m_currentFilteredDelta;
     53    }
     54
     55protected:
     56    FloatSize m_currentFilteredDelta;
     57    bool m_isFilteringDeltas { false };
     58};
    3859
    3960enum class DominantScrollGestureDirection {
     
    4364};
    4465
    45 class WheelEventDeltaTracker final {
     66class BasicWheelEventDeltaFilter final : public WheelEventDeltaFilter {
    4667public:
    47     WEBCORE_EXPORT WheelEventDeltaTracker();
    48     WEBCORE_EXPORT ~WheelEventDeltaTracker();
    49 
    50     WEBCORE_EXPORT void beginTrackingDeltas();
    51     WEBCORE_EXPORT void endTrackingDeltas();
    52 
    53     bool isTrackingDeltas() const { return m_isTrackingDeltas; }
    54 
    55     WEBCORE_EXPORT void recordWheelEventDelta(const PlatformWheelEvent&);
    56     WEBCORE_EXPORT DominantScrollGestureDirection dominantScrollGestureDirection() const;
     68    BasicWheelEventDeltaFilter();
     69    virtual void updateFromDelta(const FloatSize&) override;
     70    virtual void beginFilteringDeltas() override;
     71    virtual void endFilteringDeltas() override;
    5772
    5873private:
     74    DominantScrollGestureDirection dominantScrollGestureDirection() const;
     75
    5976    Deque<FloatSize> m_recentWheelEventDeltas;
    60     bool m_isTrackingDeltas;
    61 
    6277};
    6378
    64 } // namespace WebCore
     79}
    6580
    66 #endif // WheelEventDeltaTracker_h
     81#endif
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r187930 r188860  
    955955                latchingState->setWidgetIsLatched(result.isOverWidget());
    956956                isOverWidget = latchingState->widgetIsLatched();
    957                 m_frame.mainFrame().wheelEventDeltaTracker()->beginTrackingDeltas();
     957                m_frame.mainFrame().wheelEventDeltaFilter()->beginFilteringDeltas();
    958958            }
    959959        }
     
    983983    switch (wheelEvent.phase()) {
    984984        case PlatformWheelEventPhaseBegan:
    985             m_frame.mainFrame().wheelEventDeltaTracker()->beginTrackingDeltas();
     985            m_frame.mainFrame().wheelEventDeltaFilter()->beginFilteringDeltas();
    986986            break;
    987987        case PlatformWheelEventPhaseEnded:
    988             m_frame.mainFrame().wheelEventDeltaTracker()->endTrackingDeltas();
     988            m_frame.mainFrame().wheelEventDeltaFilter()->endFilteringDeltas();
    989989            break;
    990990        default:
    991991            break;
    992992    }
    993 
    994     m_frame.mainFrame().wheelEventDeltaTracker()->recordWheelEventDelta(wheelEvent);
     993    m_frame.mainFrame().wheelEventDeltaFilter()->updateFromDelta(FloatSize(wheelEvent.deltaX(), wheelEvent.deltaY()));
    995994}
    996995
  • trunk/Source/WebCore/page/mac/WheelEventDeltaFilterMac.h

    r188859 r188860  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
     26#ifndef WheelEventDeltaFilterMac_h
     27#define WheelEventDeltaFilterMac_h
    2628
    27 #ifndef WheelEventDeltaTracker_h
    28 #define WheelEventDeltaTracker_h
     29#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
    2930
    30 #include "FloatSize.h"
    31 #include <wtf/Deque.h>
     31#include "WheelEventDeltaFilter.h"
     32#include <wtf/RetainPtr.h>
     33
     34OBJC_CLASS _NSScrollingPredominantAxisFilter;
    3235
    3336namespace WebCore {
    3437
    35 class PlatformWheelEvent;
     38class WheelEventDeltaFilterMac final : public WheelEventDeltaFilter {
     39public:
     40    WheelEventDeltaFilterMac();
    3641
    37 const size_t recentEventCount = 3;
     42    virtual void updateFromDelta(const FloatSize&) override;
     43    virtual void beginFilteringDeltas() override;
     44    virtual void endFilteringDeltas() override;
    3845
    39 enum class DominantScrollGestureDirection {
    40     None,
    41     Vertical,
    42     Horizontal
     46private:
     47    RetainPtr<_NSScrollingPredominantAxisFilter> m_predominantAxisFilter;
     48    double m_beginFilteringDeltasTime { 0 };
    4349};
    4450
    45 class WheelEventDeltaTracker final {
    46 public:
    47     WEBCORE_EXPORT WheelEventDeltaTracker();
    48     WEBCORE_EXPORT ~WheelEventDeltaTracker();
     51}
    4952
    50     WEBCORE_EXPORT void beginTrackingDeltas();
    51     WEBCORE_EXPORT void endTrackingDeltas();
     53#endif /* PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 */
    5254
    53     bool isTrackingDeltas() const { return m_isTrackingDeltas; }
    54 
    55     WEBCORE_EXPORT void recordWheelEventDelta(const PlatformWheelEvent&);
    56     WEBCORE_EXPORT DominantScrollGestureDirection dominantScrollGestureDirection() const;
    57 
    58 private:
    59     Deque<FloatSize> m_recentWheelEventDeltas;
    60     bool m_isTrackingDeltas;
    61 
    62 };
    63 
    64 } // namespace WebCore
    65 
    66 #endif // WheelEventDeltaTracker_h
     55#endif /* WheelEventDeltaFilterMac_h */
  • trunk/Source/WebCore/platform/PlatformWheelEvent.h

    r182334 r188860  
    120120        }
    121121
    122         PlatformWheelEvent copyIgnoringHorizontalDelta() const
     122        PlatformWheelEvent copyWithDeltas(float deltaX, float deltaY) const
    123123        {
    124124            PlatformWheelEvent copy = *this;
    125             copy.m_deltaX = 0;
    126             return copy;
    127         }
    128 
    129         PlatformWheelEvent copyIgnoringVerticalDelta() const
    130         {
    131             PlatformWheelEvent copy = *this;
    132             copy.m_deltaY = 0;
     125            copy.m_deltaX = deltaX;
     126            copy.m_deltaY = deltaY;
    133127            return copy;
    134128        }
  • trunk/Source/WebKit2/ChangeLog

    r188851 r188860  
     12015-08-24  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Use _NSScrollingPredominantAxisFilter for wheel event filtering on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=147320
     5
     6        Reviewed by Simon Fraser.
     7
     8        Refactored to use a predominant axis filter instead of a predominant axis tracker. This allows us to
     9        employ AppKit's _NSScrollingPredominantAxisFilter when possible, and use the wheel event delta tracker
     10        as a fallback. Here, we refactor EventDispatcher to use the new filters for mainframe scrolling.
     11
     12        No new tests, since this change does not add new functionality.
     13
     14        * WebProcess/WebPage/EventDispatcher.cpp: Include WheelEventDeltaFilterMac.h when necessary.
     15        (WebKit::EventDispatcher::EventDispatcher): Initialize a WheelEventDeltaFilterMac when possible. Otherwise,
     16            fall back to a BasicWheelEventDeltaFilter.
     17        (WebKit::EventDispatcher::wheelEvent): Use filtered deltas to initialize the platform wheel event instead
     18            of zeroing out non-predominant axes.
     19        * WebProcess/WebPage/EventDispatcher.h: Replace m_recentWheelEventDeltaTracker with m_recentWheelEventDeltaFilter.
     20
    1212015-08-23  Andy Estes  <aestes@apple.com>
    222
  • trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp

    r188793 r188860  
    5555EventDispatcher::EventDispatcher()
    5656    : m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher", WorkQueue::Type::Serial, WorkQueue::QOS::UserInteractive))
    57     , m_recentWheelEventDeltaTracker(std::make_unique<WheelEventDeltaTracker>())
     57    , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create())
    5858{
    5959}
     
    9696    switch (wheelEvent.phase()) {
    9797    case PlatformWheelEventPhaseBegan:
    98         m_recentWheelEventDeltaTracker->beginTrackingDeltas();
     98        m_recentWheelEventDeltaFilter->beginFilteringDeltas();
    9999        break;
    100100    case PlatformWheelEventPhaseEnded:
    101         m_recentWheelEventDeltaTracker->endTrackingDeltas();
     101        m_recentWheelEventDeltaFilter->endFilteringDeltas();
    102102        break;
    103103    default:
     
    105105    }
    106106
    107     if (m_recentWheelEventDeltaTracker->isTrackingDeltas()) {
    108         m_recentWheelEventDeltaTracker->recordWheelEventDelta(platformWheelEvent);
    109 
    110         DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None;
    111         dominantDirection = m_recentWheelEventDeltaTracker->dominantScrollGestureDirection();
    112 
    113         // Workaround for scrolling issues <rdar://problem/14758615>.
    114         if (dominantDirection == DominantScrollGestureDirection::Vertical && platformWheelEvent.deltaX())
    115             platformWheelEvent = platformWheelEvent.copyIgnoringHorizontalDelta();
    116         else if (dominantDirection == DominantScrollGestureDirection::Horizontal && platformWheelEvent.deltaY())
    117             platformWheelEvent = platformWheelEvent.copyIgnoringVerticalDelta();
     107    if (m_recentWheelEventDeltaFilter->isFilteringDeltas()) {
     108        m_recentWheelEventDeltaFilter->updateFromDelta(FloatSize(platformWheelEvent.deltaX(), platformWheelEvent.deltaY()));
     109        FloatSize filteredDelta = m_recentWheelEventDeltaFilter->filteredDelta();
     110        platformWheelEvent = platformWheelEvent.copyWithDeltas(filteredDelta.width(), filteredDelta.height());
    118111    }
    119112#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h

    r188594 r188860  
    2929#include "Connection.h"
    3030
    31 #include <WebCore/WheelEventDeltaTracker.h>
     31#include <WebCore/WheelEventDeltaFilter.h>
    3232#include <WebEvent.h>
    3333#include <memory>
     
    9696    HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
    9797#endif
    98     std::unique_ptr<WebCore::WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
     98    std::unique_ptr<WebCore::WheelEventDeltaFilter> m_recentWheelEventDeltaFilter;
    9999#if ENABLE(IOS_TOUCH_EVENTS)
    100100    Lock m_touchEventsLock;
Note: See TracChangeset for help on using the changeset viewer.