Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (163179 => 163180)
--- trunk/Source/WebCore/CMakeLists.txt 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/CMakeLists.txt 2014-01-31 19:04:21 UTC (rev 163180)
@@ -1769,6 +1769,7 @@
page/UserContentController.cpp
page/UserContentURLPattern.cpp
page/VisitedLinkProvider.cpp
+ page/WheelEventDeltaTracker.cpp
page/WindowFeatures.cpp
page/WindowFocusAllowedIndicator.cpp
page/WorkerNavigator.cpp
Modified: trunk/Source/WebCore/ChangeLog (163179 => 163180)
--- trunk/Source/WebCore/ChangeLog 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/ChangeLog 2014-01-31 19:04:21 UTC (rev 163180)
@@ -1,3 +1,57 @@
+2014-01-31 Beth Dakin <[email protected]>
+
+ Sideways 'wobble' when scrolling with trackpad on Mavericks
+ https://bugs.webkit.org/show_bug.cgi?id=127521
+ -and corresponding-
+ <rdar://problem/14137306>
+
+ Reviewed by Simon Fraser.
+
+ This patch takes http://trac.webkit.org/changeset/154535 which introduced
+ filtering wheel events for overflow areas to try to make them less sensitive to X
+ deltas when scrolling in a primarily Y direction, and it factors that code out
+ into its own class, now called WheelEventDeltaTracker. So now this new class can
+ use the same code to filter events for WebKit2’s EventDispatcher.
+
+ Files for WheelEventDeltaTracker.
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ WK2 needs these new WheelEventDeltaTracker functions.
+ * WebCore.exp.in:
+
+ Move a bunch of code over to WheelEventDeltaTracker and use
+ m_recentWheelEventTracker to serve the same purpose.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::EventHandler):
+ (WebCore::EventHandler::handleWheelEvent):
+ (WebCore::EventHandler::defaultWheelEventHandler):
+ * page/EventHandler.h:
+
+ Allow horizontal rubber banding now that we have some event filtering in place.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::FrameView):
+
+ New files. Most of this code was from EventHandler.
+ * page/WheelEventDeltaTracker.cpp: Added.
+ (WebCore::WheelEventDeltaTracker::WheelEventDeltaTracker):
+ (WebCore::WheelEventDeltaTracker::~WheelEventDeltaTracker):
+ (WebCore::WheelEventDeltaTracker::beginTrackingDeltas):
+ (WebCore::WheelEventDeltaTracker::endTrackingDeltas):
+ (WebCore::WheelEventDeltaTracker::recordWheelEventDelta):
+ (WebCore::deltaIsPredominantlyVertical):
+ (WebCore::WheelEventDeltaTracker::dominantScrollGestureDirection):
+ * page/WheelEventDeltaTracker.h: Added.
+ (WebCore::WheelEventDeltaTracker::isTrackingDeltas):
+
+ New function to clone events while zero-ing out certain deltas.
+ * platform/PlatformWheelEvent.h:
+ (WebCore::PlatformWheelEvent::copyIgnoringHorizontalDelta):
+ (WebCore::PlatformWheelEvent::copyIgnoringVerticalDelta):
+
2014-01-31 Simon Fraser <[email protected]>
Don't do logging from Range::collectSelectionRects() on iOS
Modified: trunk/Source/WebCore/GNUmakefile.list.am (163179 => 163180)
--- trunk/Source/WebCore/GNUmakefile.list.am 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2014-01-31 19:04:21 UTC (rev 163180)
@@ -4224,6 +4224,8 @@
Source/WebCore/page/VisitedLinkProvider.h \
Source/WebCore/page/WebCoreKeyboardUIMode.h \
Source/WebCore/page/WebKitPoint.h \
+ Source/WebCore/page/WheelEventDeltaTracker.cpp \
+ Source/WebCore/page/WheelEventDeltaTracker.h \
Source/WebCore/page/WindowFeatures.cpp \
Source/WebCore/page/WindowFeatures.h \
Source/WebCore/page/WindowFocusAllowedIndicator.cpp \
Modified: trunk/Source/WebCore/WebCore.exp.in (163179 => 163180)
--- trunk/Source/WebCore/WebCore.exp.in 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/WebCore.exp.in 2014-01-31 19:04:21 UTC (rev 163180)
@@ -867,6 +867,10 @@
__ZN7WebCore22externalRepresentationEPNS_7ElementEj
__ZN7WebCore22systemMarketingVersionEv
__ZN7WebCore22userPreferredLanguagesEv
+__ZN7WebCore22WheelEventDeltaTracker17endTrackingDeltasEv
+__ZN7WebCore22WheelEventDeltaTracker19beginTrackingDeltasEv
+__ZN7WebCore22WheelEventDeltaTracker21recordWheelEventDeltaERKNS_18PlatformWheelEventE
+__ZN7WebCore22WheelEventDeltaTrackerC1Ev
__ZN7WebCore23ApplicationCacheStorage14setMaximumSizeEx
__ZN7WebCore23ApplicationCacheStorage16deleteAllEntriesEv
__ZN7WebCore23ApplicationCacheStorage16storeCopyOfCacheERKN3WTF6StringEPNS_20ApplicationCacheHostE
@@ -1659,6 +1663,7 @@
__ZNK7WebCore21RenderLayerCompositor11scrollLayerEv
__ZNK7WebCore21RenderLayerCompositor15rootRenderLayerEv
__ZNK7WebCore21UserContentURLPattern7matchesERKNS_3URLE
+__ZNK7WebCore22WheelEventDeltaTracker30dominantScrollGestureDirectionEv
__ZNK7WebCore23ApplicationCacheStorage11maximumSizeEv
__ZNK7WebCore23AuthenticationChallenge20authenticationClientEv
__ZNK7WebCore23FrameLoaderStateMachine15firstLayoutDoneEv
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (163179 => 163180)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2014-01-31 19:04:21 UTC (rev 163180)
@@ -7067,6 +7067,7 @@
<ClCompile Include="..\page\UserContentURLPattern.cpp" />
<ClCompile Include="..\page\VisitedLinkProvider.cpp" />
<ClCompile Include="..\fileapi\WebKitBlobBuilder.cpp" />
+ <ClCompile Include="..\page\WheelEventDeltaTracker.cpp" />
<ClCompile Include="..\page\WindowFeatures.cpp" />
<ClCompile Include="..\page\WindowFocusAllowedIndicator.cpp" />
<ClCompile Include="..\page\WorkerNavigator.cpp" />
@@ -18847,6 +18848,7 @@
<ClInclude Include="..\page\VisitedLinkProvider.h" />
<ClInclude Include="..\fileapi\WebKitBlobBuilder.h" />
<ClInclude Include="..\page\WebKitPoint.h" />
+ <ClInclude Include="..\page\WheelEventDeltaTracker.h" />
<ClInclude Include="..\page\WindowFeatures.h" />
<ClInclude Include="..\page\WindowFocusAllowedIndicator.h" />
<ClInclude Include="..\page\WorkerNavigator.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (163179 => 163180)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2014-01-31 19:04:21 UTC (rev 163180)
@@ -798,6 +798,9 @@
<ClCompile Include="..\fileapi\WebKitBlobBuilder.cpp">
<Filter>page</Filter>
</ClCompile>
+ <ClCompile Include="..\page\WheelEventDeltaTracker.cpp">
+ <Filter>page</Filter>
+ </ClCompile>
<ClCompile Include="..\page\WindowFeatures.cpp">
<Filter>page</Filter>
</ClCompile>
@@ -7661,6 +7664,9 @@
<ClInclude Include="..\page\WebKitPoint.h">
<Filter>page</Filter>
</ClInclude>
+ <ClInclude Include="..\page\WheelEventDeltaTracker.h">
+ <Filter>page</Filter>
+ </ClInclude>
<ClInclude Include="..\page\WindowFeatures.h">
<Filter>page</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (163179 => 163180)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-01-31 19:04:21 UTC (rev 163180)
@@ -3202,6 +3202,8 @@
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, ); }; };
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, ); }; };
93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D27902DE43D7018635CA /* TextResourceDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10142,6 +10144,8 @@
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>"; };
@@ -16207,6 +16211,8 @@
BE983D95052A2E0A00892D85 /* WebCoreKeyboardUIMode.h */,
494BD7930F55C8EE00747828 /* WebKitPoint.h */,
494BD7940F55C8EE00747828 /* WebKitPoint.idl */,
+ 93EC449F188F4BB800661DF1 /* WheelEventDeltaTracker.cpp */,
+ 93EC44A0188F4BB800661DF1 /* WheelEventDeltaTracker.h */,
BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */,
BC8243E70D0CFD7500460C8F /* WindowFeatures.h */,
7E99AF520B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp */,
@@ -23709,6 +23715,7 @@
77A17A7B12F2890B004E02F6 /* GraphicsTypes3D.h in Headers */,
A12705C31656BD6500C2E27C /* GridPosition.h in Headers */,
A12A1050166444FD008FA311 /* GridTrackSize.h in Headers */,
+ 93EC44A2188F4BB800661DF1 /* WheelEventDeltaTracker.h in Headers */,
C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */,
078E094017D16E1C00420AA1 /* RTCIceCandidateDescriptor.h in Headers */,
@@ -27187,6 +27194,7 @@
A871DB2D0A150BD600B12A68 /* HTMLTablePartElement.cpp in Sources */,
A871DB300A150BD600B12A68 /* HTMLTableRowElement.cpp in Sources */,
93442CA00D2B336000338FF9 /* HTMLTableRowsCollection.cpp in Sources */,
+ 93EC44A1188F4BB800661DF1 /* WheelEventDeltaTracker.cpp in Sources */,
A871DB260A150BD600B12A68 /* HTMLTableSectionElement.cpp in Sources */,
E19AC3F01824DC7900349426 /* CryptoAlgorithmSHA256.cpp in Sources */,
511EF2CB17F0FD3500E4FA16 /* JSIDBVersionChangeEvent.cpp in Sources */,
Modified: trunk/Source/WebCore/page/EventHandler.cpp (163179 => 163180)
--- trunk/Source/WebCore/page/EventHandler.cpp 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2014-01-31 19:04:21 UTC (rev 163180)
@@ -355,7 +355,7 @@
#endif
, m_mousePositionIsUnknown(true)
, m_mouseDownTimestamp(0)
- , m_inTrackingScrollGesturePhase(false)
+ , m_recentWheelEventDeltaTracker(adoptPtr(new WheelEventDeltaTracker))
, m_widgetIsLatched(false)
#if PLATFORM(MAC)
, m_mouseDownView(nil)
@@ -2467,41 +2467,6 @@
}
#endif
-void EventHandler::recordWheelEventDelta(const PlatformWheelEvent& event)
-{
- const size_t recentEventCount = 3;
-
- m_recentWheelEventDeltas.append(FloatSize(event.deltaX(), event.deltaY()));
- if (m_recentWheelEventDeltas.size() > recentEventCount)
- m_recentWheelEventDeltas.removeFirst();
-}
-
-static bool deltaIsPredominantlyVertical(const FloatSize& delta)
-{
- return fabs(delta.height()) > fabs(delta.width());
-}
-
-EventHandler::DominantScrollGestureDirection EventHandler::dominantScrollGestureDirection() const
-{
- bool allVertical = m_recentWheelEventDeltas.size();
- bool allHorizontal = m_recentWheelEventDeltas.size();
-
- Deque<FloatSize>::const_iterator end = m_recentWheelEventDeltas.end();
- for (Deque<FloatSize>::const_iterator it = m_recentWheelEventDeltas.begin(); it != end; ++it) {
- bool isVertical = deltaIsPredominantlyVertical(*it);
- allVertical &= isVertical;
- allHorizontal &= !isVertical;
- }
-
- if (allVertical)
- return DominantScrollDirectionVertical;
-
- if (allHorizontal)
- return DominantScrollDirectionHorizontal;
-
- return DominantScrollDirectionNone;
-}
-
bool EventHandler::handleWheelEvent(const PlatformWheelEvent& e)
{
Document* document = m_frame.document();
@@ -2555,18 +2520,17 @@
#if PLATFORM(MAC)
switch (event.phase()) {
case PlatformWheelEventPhaseBegan:
- m_recentWheelEventDeltas.clear();
- m_inTrackingScrollGesturePhase = true;
+ m_recentWheelEventDeltaTracker->beginTrackingDeltas();
break;
case PlatformWheelEventPhaseEnded:
- m_inTrackingScrollGesturePhase = false;
+ m_recentWheelEventDeltaTracker->endTrackingDeltas();
break;
default:
break;
}
#endif
- recordWheelEventDelta(event);
+ m_recentWheelEventDeltaTracker->recordWheelEventDelta(event);
if (element) {
// Figure out which view to send the event to.
@@ -2601,18 +2565,20 @@
Element* stopElement = m_previousWheelScrolledElement.get();
ScrollGranularity granularity = wheelGranularityToScrollGranularity(wheelEvent->deltaMode());
+ DominantScrollGestureDirection dominantDirection = DominantScrollGestureDirection::None;
+
+ // Workaround for scrolling issues <rdar://problem/14758615>.
+#if PLATFORM(MAC)
+ if (m_recentWheelEventDeltaTracker->isTrackingDeltas())
+ dominantDirection = m_recentWheelEventDeltaTracker->dominantScrollGestureDirection();
+#endif
- DominantScrollGestureDirection dominantDirection = DominantScrollDirectionNone;
- // Workaround for scrolling issues in iTunes (<rdar://problem/14758615>).
- if (m_inTrackingScrollGesturePhase && applicationIsITunes())
- dominantDirection = dominantScrollGestureDirection();
-
// 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 != DominantScrollDirectionVertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
+ if (dominantDirection != DominantScrollGestureDirection::Vertical && scrollNode(wheelEvent->deltaX(), granularity, ScrollRight, ScrollLeft, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
wheelEvent->setDefaultHandled();
- if (dominantDirection != DominantScrollDirectionHorizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
+ if (dominantDirection != DominantScrollGestureDirection::Horizontal && scrollNode(wheelEvent->deltaY(), granularity, ScrollDown, ScrollUp, startNode, &stopElement, roundedIntPoint(wheelEvent->absoluteLocation())))
wheelEvent->setDefaultHandled();
if (!m_latchedWheelEventElement)
Modified: trunk/Source/WebCore/page/EventHandler.h (163179 => 163180)
--- trunk/Source/WebCore/page/EventHandler.h 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/page/EventHandler.h 2014-01-31 19:04:21 UTC (rev 163180)
@@ -37,7 +37,7 @@
#include "TextEventInputType.h"
#include "TextGranularity.h"
#include "Timer.h"
-#include <wtf/Deque.h>
+#include "WheelEventDeltaTracker.h"
#include <wtf/Forward.h>
#include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h>
@@ -329,13 +329,6 @@
bool logicalScrollOverflow(ScrollLogicalDirection, ScrollGranularity, Node* startingNode = 0);
bool shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&, const PlatformWheelEvent&) const;
- void recordWheelEventDelta(const PlatformWheelEvent&);
- enum DominantScrollGestureDirection {
- DominantScrollDirectionNone,
- DominantScrollDirectionVertical,
- DominantScrollDirectionHorizontal
- };
- DominantScrollGestureDirection dominantScrollGestureDirection() const;
bool mouseDownMayStartSelect() const { return m_mouseDownMayStartSelect; }
@@ -521,9 +514,8 @@
double m_mouseDownTimestamp;
PlatformMouseEvent m_mouseDown;
- Deque<FloatSize> m_recentWheelEventDeltas;
+ OwnPtr<WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
RefPtr<Element> m_latchedWheelEventElement;
- bool m_inTrackingScrollGesturePhase;
bool m_widgetIsLatched;
RefPtr<Element> m_previousWheelScrolledElement;
Modified: trunk/Source/WebCore/page/FrameView.cpp (163179 => 163180)
--- trunk/Source/WebCore/page/FrameView.cpp 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/page/FrameView.cpp 2014-01-31 19:04:21 UTC (rev 163180)
@@ -197,7 +197,7 @@
if (frame.isMainFrame()) {
ScrollableArea::setVerticalScrollElasticity(ScrollElasticityAllowed);
- ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAutomatic);
+ ScrollableArea::setHorizontalScrollElasticity(ScrollElasticityAllowed);
}
}
Added: trunk/Source/WebCore/page/WheelEventDeltaTracker.cpp (0 => 163180)
--- trunk/Source/WebCore/page/WheelEventDeltaTracker.cpp (rev 0)
+++ trunk/Source/WebCore/page/WheelEventDeltaTracker.cpp 2014-01-31 19:04:21 UTC (rev 163180)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "config.h"
+
+#include "WheelEventDeltaTracker.h"
+
+#include "PlatformWheelEvent.h"
+
+namespace WebCore {
+
+WheelEventDeltaTracker::WheelEventDeltaTracker()
+ : m_isTrackingDeltas(false)
+{
+}
+
+WheelEventDeltaTracker::~WheelEventDeltaTracker()
+{
+}
+
+void WheelEventDeltaTracker::beginTrackingDeltas()
+{
+ m_recentWheelEventDeltas.clear();
+ m_isTrackingDeltas = true;
+}
+
+void WheelEventDeltaTracker::endTrackingDeltas()
+{
+ m_isTrackingDeltas = false;
+}
+
+void WheelEventDeltaTracker::recordWheelEventDelta(const PlatformWheelEvent& event)
+{
+ m_recentWheelEventDeltas.append(FloatSize(event.deltaX(), event.deltaY()));
+ if (m_recentWheelEventDeltas.size() > recentEventCount)
+ m_recentWheelEventDeltas.removeFirst();
+}
+
+static bool deltaIsPredominantlyVertical(const FloatSize& delta)
+{
+ return fabs(delta.height()) > fabs(delta.width());
+}
+
+DominantScrollGestureDirection WheelEventDeltaTracker::dominantScrollGestureDirection() const
+{
+ bool allVertical = m_recentWheelEventDeltas.size();
+ bool allHorizontal = m_recentWheelEventDeltas.size();
+
+ auto end = m_recentWheelEventDeltas.end();
+ for (auto it = m_recentWheelEventDeltas.begin(); it != end; ++it) {
+ bool isVertical = deltaIsPredominantlyVertical(*it);
+ allVertical &= isVertical;
+ allHorizontal &= !isVertical;
+ }
+
+ if (allVertical)
+ return DominantScrollGestureDirection::Vertical;
+
+ if (allHorizontal)
+ return DominantScrollGestureDirection::Horizontal;
+
+ return DominantScrollGestureDirection::None;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/page/WheelEventDeltaTracker.h (0 => 163180)
--- trunk/Source/WebCore/page/WheelEventDeltaTracker.h (rev 0)
+++ trunk/Source/WebCore/page/WheelEventDeltaTracker.h 2014-01-31 19:04:21 UTC (rev 163180)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 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 WheelEventDeltaTracker_h
+#define WheelEventDeltaTracker_h
+
+#include "FloatSize.h"
+#include <wtf/Deque.h>
+
+namespace WebCore {
+
+class PlatformWheelEvent;
+
+const size_t recentEventCount = 3;
+
+enum class DominantScrollGestureDirection {
+ None,
+ Vertical,
+ Horizontal
+};
+
+class WheelEventDeltaTracker {
+public:
+ WheelEventDeltaTracker();
+ virtual ~WheelEventDeltaTracker();
+
+ void beginTrackingDeltas();
+ void endTrackingDeltas();
+
+ bool isTrackingDeltas() const { return m_isTrackingDeltas; }
+
+ void recordWheelEventDelta(const PlatformWheelEvent&);
+ DominantScrollGestureDirection dominantScrollGestureDirection() const;
+
+private:
+ Deque<FloatSize, recentEventCount> m_recentWheelEventDeltas;
+ bool m_isTrackingDeltas;
+
+};
+
+} // namespace WebCore
+
+#endif // WheelEventDeltaTracker_h
Modified: trunk/Source/WebCore/platform/PlatformWheelEvent.h (163179 => 163180)
--- trunk/Source/WebCore/platform/PlatformWheelEvent.h 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebCore/platform/PlatformWheelEvent.h 2014-01-31 19:04:21 UTC (rev 163180)
@@ -119,6 +119,20 @@
return copy;
}
+ PlatformWheelEvent copyIgnoringHorizontalDelta() const
+ {
+ PlatformWheelEvent copy = *this;
+ copy.m_deltaX = 0;
+ return copy;
+ }
+
+ PlatformWheelEvent copyIgnoringVerticalDelta() const
+ {
+ PlatformWheelEvent copy = *this;
+ copy.m_deltaY = 0;
+ return copy;
+ }
+
const IntPoint& position() const { return m_position; } // PlatformWindow coordinates.
const IntPoint& globalPosition() const { return m_globalPosition; } // Screen coordinates.
Modified: trunk/Source/WebKit2/ChangeLog (163179 => 163180)
--- trunk/Source/WebKit2/ChangeLog 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebKit2/ChangeLog 2014-01-31 19:04:21 UTC (rev 163180)
@@ -1,3 +1,18 @@
+2014-01-31 Beth Dakin <[email protected]>
+
+ Sideways 'wobble' when scrolling with trackpad on Mavericks
+ https://bugs.webkit.org/show_bug.cgi?id=127521
+ -and corresponding-
+ <rdar://problem/14137306>
+
+ Reviewed by Simon Fraser.
+
+ Start using WebCore::WheelEventDeltaTracker to filter events.
+ * WebProcess/WebPage/EventDispatcher.cpp:
+ (WebKit::EventDispatcher::EventDispatcher):
+ (WebKit::EventDispatcher::wheelEvent):
+ * WebProcess/WebPage/EventDispatcher.h:
+
2014-01-31 Zan Dobersek <[email protected]>
Fix the forward declaration of RawPluginMetaData in NetscapePluginModule.h
Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp (163179 => 163180)
--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp 2014-01-31 19:04:21 UTC (rev 163180)
@@ -53,6 +53,7 @@
EventDispatcher::EventDispatcher()
: m_queue(WorkQueue::create("com.apple.WebKit.EventDispatcher"))
+ , m_recentWheelEventDeltaTracker(adoptPtr(new WheelEventDeltaTracker))
{
}
@@ -88,11 +89,37 @@
void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEvent, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
{
+ PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
+
+#if PLATFORM(MAC)
+ switch (wheelEvent.phase()) {
+ case PlatformWheelEventPhaseBegan:
+ m_recentWheelEventDeltaTracker->beginTrackingDeltas();
+ break;
+ case PlatformWheelEventPhaseEnded:
+ m_recentWheelEventDeltaTracker->endTrackingDeltas();
+ 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();
+ }
+#endif
+
#if ENABLE(ASYNC_SCROLLING)
MutexLocker locker(m_scrollingTreesMutex);
if (ThreadedScrollingTree* scrollingTree = m_scrollingTrees.get(pageID)) {
- PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
-
// FIXME: It's pretty horrible that we're updating the back/forward state here.
// WebCore should always know the current state and know when it changes so the
// scrolling tree can be notified.
Modified: trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h (163179 => 163180)
--- trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h 2014-01-31 18:59:59 UTC (rev 163179)
+++ trunk/Source/WebKit2/WebProcess/WebPage/EventDispatcher.h 2014-01-31 19:04:21 UTC (rev 163180)
@@ -27,6 +27,8 @@
#define EventDispatcher_h
#include "Connection.h"
+
+#include <WebCore/WheelEventDeltaTracker.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
@@ -76,6 +78,7 @@
Mutex m_scrollingTreesMutex;
HashMap<uint64_t, RefPtr<WebCore::ThreadedScrollingTree>> m_scrollingTrees;
#endif
+ OwnPtr<WebCore::WheelEventDeltaTracker> m_recentWheelEventDeltaTracker;
};
} // namespace WebKit