<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[162984] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/162984">162984</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-01-28 16:50:56 -0800 (Tue, 28 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebKit2 View Gestures (Swipe): Give WebCore the first crack at scroll events if it needs it
https://bugs.webkit.org/show_bug.cgi?id=127396
Reviewed by Anders Carlsson.
* UIProcess/API/ios/PageClientImplIOS.h:
* UIProcess/API/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
* UIProcess/API/mac/WKView.mm:
(-[WKView _wheelEventWasNotHandledByWebCore:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveEvent):
In addition to informing the page client about un-handled wheel events,
inform the ViewGestureController, in a roundabout way.
* UIProcess/mac/ViewGestureController.h:
Add and use SwipeDirection enum instead of 'bool willSwipeLeft'.
* UIProcess/mac/ViewGestureController.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::handleScrollWheelEvent):
If we get a Begin scroll wheel event, any previously deferred
swipes are invalid.
If the page has subframes or wheel handlers, defer starting the
swipe until we get a wheelEventWasNotHandledByWebCore back from the WebProcess.
(WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
Start the swipe if the WebProcess didn't eat the event.
(WebKit::ViewGestureController::trackSwipeGesture):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::handleSwipeGesture):
Use SwipeDirection.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacPageClientImplh">trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacPageClientImplmm">trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewInternalh">trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllermm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2014-01-28 Tim Horton <timothy_horton@apple.com>
+
+ WebKit2 View Gestures (Swipe): Give WebCore the first crack at scroll events if it needs it
+ https://bugs.webkit.org/show_bug.cgi?id=127396
+
+ Reviewed by Anders Carlsson.
+
+ * UIProcess/API/ios/PageClientImplIOS.h:
+ * UIProcess/API/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
+ * UIProcess/API/mac/PageClientImpl.h:
+ * UIProcess/API/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore):
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _wheelEventWasNotHandledByWebCore:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didReceiveEvent):
+ In addition to informing the page client about un-handled wheel events,
+ inform the ViewGestureController, in a roundabout way.
+
+ * UIProcess/mac/ViewGestureController.h:
+ Add and use SwipeDirection enum instead of 'bool willSwipeLeft'.
+
+ * UIProcess/mac/ViewGestureController.mm:
+ (WebKit::ViewGestureController::ViewGestureController):
+ (WebKit::ViewGestureController::handleScrollWheelEvent):
+ If we get a Begin scroll wheel event, any previously deferred
+ swipes are invalid.
+
+ If the page has subframes or wheel handlers, defer starting the
+ swipe until we get a wheelEventWasNotHandledByWebCore back from the WebProcess.
+
+ (WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
+ Start the swipe if the WebProcess didn't eat the event.
+
+ (WebKit::ViewGestureController::trackSwipeGesture):
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::handleSwipeGesture):
+ Use SwipeDirection.
+
</ins><span class="cx"> 2014-01-28 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix build.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.h (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.h        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.h        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -98,6 +98,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> virtual RetainPtr<CGImageRef> takeViewSnapshot() override;
</span><ins>+ virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
</ins><span class="cx">
</span><span class="cx"> virtual void mainDocumentDidReceiveMobileDocType() override;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/ios/PageClientImplIOS.mm        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -328,6 +328,11 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> void PageClientImpl::mainDocumentDidReceiveMobileDocType()
</span><span class="cx"> {
</span><span class="cx"> [m_view _didReceiveMobileDocTypeForMainFrame];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -115,6 +115,7 @@
</span><span class="cx"> virtual void updateAcceleratedCompositingMode(const LayerTreeContext&);
</span><span class="cx">
</span><span class="cx"> virtual RetainPtr<CGImageRef> takeViewSnapshot() override;
</span><ins>+ virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
</ins><span class="cx">
</span><span class="cx"> virtual void accessibilityWebProcessTokenReceived(const IPC::DataReference&);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import "DictionaryPopupInfo.h"
</span><span class="cx"> #import "FindIndicator.h"
</span><span class="cx"> #import "NativeWebKeyboardEvent.h"
</span><ins>+#import "NativeWebWheelEvent.h"
</ins><span class="cx"> #import "StringUtilities.h"
</span><span class="cx"> #import "WKAPICast.h"
</span><span class="cx"> #import "WKFullScreenWindowController.h"
</span><span class="lines">@@ -444,6 +445,11 @@
</span><span class="cx"> return [m_wkView _takeViewSnapshot];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
+{
+ [m_wkView _wheelEventWasNotHandledByWebCore:event.nativeEvent()];
+}
+
</ins><span class="cx"> void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
</span><span class="cx"> {
</span><span class="cx"> [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -2564,6 +2564,11 @@
</span><span class="cx"> return adoptCF(CGImageCreateWithImageInRect(windowSnapshotImage.get(), NSRectToCGRect([window convertRectToBacking:croppedImageRect])));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event
+{
+ _data->_gestureController->wheelEventWasNotHandledByWebCore(event);
+}
+
</ins><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data
</span><span class="cx"> {
</span><span class="cx"> _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> - (CALayer *)_acceleratedCompositingModeRootLayer;
</span><span class="cx">
</span><span class="cx"> - (RetainPtr<CGImageRef>)_takeViewSnapshot;
</span><ins>+- (void)_wheelEventWasNotHandledByWebCore:(NSEvent *)event;
</ins><span class="cx">
</span><span class="cx"> - (void)_setAccessibilityWebProcessToken:(NSData *)data;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -174,6 +174,7 @@
</span><span class="cx"> virtual void setAcceleratedCompositingRootLayer(CALayer *) = 0;
</span><span class="cx"> virtual CALayer *acceleratedCompositingRootLayer() const = 0;
</span><span class="cx"> virtual RetainPtr<CGImageRef> takeViewSnapshot() = 0;
</span><ins>+ virtual void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) = 0;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if USE(APPKIT)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -3535,8 +3535,11 @@
</span><span class="cx"> OwnPtr<Vector<NativeWebWheelEvent>> oldestCoalescedEvent = m_currentlyProcessedWheelEvents.takeFirst();
</span><span class="cx">
</span><span class="cx"> // FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
</span><del>- if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
- m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
</del><ins>+ if (!handled) {
+ if (m_uiClient.implementsDidNotHandleWheelEvent())
+ m_uiClient.didNotHandleWheelEvent(this, oldestCoalescedEvent->last());
+ m_pageClient.wheelEventWasNotHandledByWebCore(oldestCoalescedEvent->last());
+ }
</ins><span class="cx">
</span><span class="cx"> if (!m_wheelEventQueue.isEmpty())
</span><span class="cx"> processNextQueuedWheelEvent();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx"> bool handleScrollWheelEvent(NSEvent *);
</span><span class="cx"> void didHitRenderTreeSizeThreshold();
</span><span class="cx">
</span><ins>+ void wheelEventWasNotHandledByWebCore(NSEvent *);
+
</ins><span class="cx"> void endActiveGesture();
</span><span class="cx">
</span><span class="cx"> enum class ViewGestureType {
</span><span class="lines">@@ -80,8 +82,10 @@
</span><span class="cx"> void endMagnificationGesture();
</span><span class="cx"> WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
</span><span class="cx">
</span><del>- void beginSwipeGesture(WebBackForwardListItem* targetItem, bool swipingLeft);
- void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, bool swipingLeft);
</del><ins>+ enum class SwipeDirection { Left, Right };
+ void trackSwipeGesture(NSEvent *, SwipeDirection);
+ void beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection);
+ void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection);
</ins><span class="cx"> void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
</span><span class="cx"> void removeSwipeSnapshot();
</span><span class="cx"> void swipeSnapshotWatchdogTimerFired(WebCore::Timer<ViewGestureController>*);
</span><span class="lines">@@ -103,6 +107,11 @@
</span><span class="cx"> RetainPtr<CALayer> m_swipeSnapshotLayer;
</span><span class="cx"> SwipeTransitionStyle m_swipeTransitionStyle;
</span><span class="cx"> WebCore::Timer<ViewGestureController> m_swipeWatchdogTimer;
</span><ins>+
+ // If we need to wait for content to decide if it is going to consume
+ // the scroll event that would have started a swipe, we'll fill these in.
+ bool m_hasPendingSwipe;
+ SwipeDirection m_pendingSwipeDirection;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm (162983 => 162984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm        2014-01-29 00:48:17 UTC (rev 162983)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.mm        2014-01-29 00:50:56 UTC (rev 162984)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">
</span><ins>+#import "NativeWebWheelEvent.h"
</ins><span class="cx"> #import "WebPageGroup.h"
</span><span class="cx"> #import "ViewGestureControllerMessages.h"
</span><span class="cx"> #import "ViewGestureGeometryCollectorMessages.h"
</span><span class="lines">@@ -98,6 +99,7 @@
</span><span class="cx"> , m_frameHandlesMagnificationGesture(false)
</span><span class="cx"> , m_swipeTransitionStyle(SwipeTransitionStyle::Overlap)
</span><span class="cx"> , m_swipeWatchdogTimer(this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
</span><ins>+ , m_hasPendingSwipe(false)
</ins><span class="cx"> {
</span><span class="cx"> m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
</span><span class="cx"> }
</span><span class="lines">@@ -249,6 +251,8 @@
</span><span class="cx"> if (event.phase != NSEventPhaseBegan)
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ m_hasPendingSwipe = false;
+
</ins><span class="cx"> if (fabs(event.scrollingDeltaX) < fabs(event.scrollingDeltaY))
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="lines">@@ -257,34 +261,56 @@
</span><span class="cx"> if (!willSwipeLeft && !willSwipeRight)
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ SwipeDirection direction = willSwipeLeft ? SwipeDirection::Left : SwipeDirection::Right;
+
</ins><span class="cx"> if (!event.hasPreciseScrollingDeltas)
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> if (![NSEvent isSwipeTrackingFromScrollEventsEnabled])
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ if (m_webPageProxy.willHandleHorizontalScrollEvents()) {
+ m_hasPendingSwipe = true;
+ m_pendingSwipeDirection = direction;
+ return false;
+ }
+
+ trackSwipeGesture(event, direction);
+
+ return true;
+}
+
+void ViewGestureController::wheelEventWasNotHandledByWebCore(NSEvent *event)
+{
+ if (!m_hasPendingSwipe)
+ return;
+
+ m_hasPendingSwipe = false;
+ trackSwipeGesture(event, m_pendingSwipeDirection);
+}
+
+void ViewGestureController::trackSwipeGesture(NSEvent *event, SwipeDirection direction)
+{
</ins><span class="cx"> ViewSnapshotStore::shared().recordSnapshot(m_webPageProxy);
</span><span class="cx">
</span><del>- CGFloat maxProgress = willSwipeLeft ? 1 : 0;
- CGFloat minProgress = willSwipeRight ? -1 : 0;
- RefPtr<WebBackForwardListItem> targetItem = willSwipeLeft ? m_webPageProxy.backForwardList().backItem() : m_webPageProxy.backForwardList().forwardItem();
</del><ins>+ CGFloat maxProgress = (direction == SwipeDirection::Left) ? 1 : 0;
+ CGFloat minProgress = (direction == SwipeDirection::Right) ? -1 : 0;
+ RefPtr<WebBackForwardListItem> targetItem = (direction == SwipeDirection::Left) ? m_webPageProxy.backForwardList().backItem() : m_webPageProxy.backForwardList().forwardItem();
</ins><span class="cx"> __block bool swipeCancelled = false;
</span><span class="cx">
</span><span class="cx"> [event trackSwipeEventWithOptions:0 dampenAmountThresholdMin:minProgress max:maxProgress usingHandler:^(CGFloat progress, NSEventPhase phase, BOOL isComplete, BOOL *stop) {
</span><span class="cx"> if (phase == NSEventPhaseBegan)
</span><del>- this->beginSwipeGesture(targetItem.get(), willSwipeLeft);
</del><ins>+ this->beginSwipeGesture(targetItem.get(), direction);
</ins><span class="cx"> CGFloat clampedProgress = std::min(std::max(progress, minProgress), maxProgress);
</span><del>- this->handleSwipeGesture(targetItem.get(), clampedProgress, willSwipeLeft);
</del><ins>+ this->handleSwipeGesture(targetItem.get(), clampedProgress, direction);
</ins><span class="cx"> if (phase == NSEventPhaseCancelled)
</span><span class="cx"> swipeCancelled = true;
</span><span class="cx"> if (isComplete)
</span><span class="cx"> this->endSwipeGesture(targetItem.get(), swipeCancelled);
</span><span class="cx"> }];
</span><del>-
- return true;
</del><span class="cx"> }
</span><span class="cx">
</span><del>-void ViewGestureController::beginSwipeGesture(WebBackForwardListItem* targetItem, bool swipingLeft)
</del><ins>+void ViewGestureController::beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection direction)
</ins><span class="cx"> {
</span><span class="cx"> m_activeGestureType = ViewGestureType::Swipe;
</span><span class="cx">
</span><span class="lines">@@ -333,13 +359,13 @@
</span><span class="cx"> [rootLayer setShadowPath:shadowPath.get()];
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (swipingLeft)
</del><ins>+ if (direction == SwipeDirection::Left)
</ins><span class="cx"> [rootLayer.superlayer insertSublayer:m_swipeSnapshotLayer.get() below:rootLayer];
</span><span class="cx"> else
</span><span class="cx"> [rootLayer.superlayer insertSublayer:m_swipeSnapshotLayer.get() above:rootLayer];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ViewGestureController::handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, bool swipingLeft)
</del><ins>+void ViewGestureController::handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection direction)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(m_activeGestureType == ViewGestureType::Swipe);
</span><span class="cx">
</span><span class="lines">@@ -348,13 +374,13 @@
</span><span class="cx"> double swipingLayerOffset = floor(width * progress);
</span><span class="cx">
</span><span class="cx"> if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap) {
</span><del>- if (swipingLeft)
</del><ins>+ if (direction == SwipeDirection::Left)
</ins><span class="cx"> [rootLayer setPosition:CGPointMake(swipingLayerOffset, 0)];
</span><span class="cx"> else
</span><span class="cx"> [m_swipeSnapshotLayer setPosition:CGPointMake(width + swipingLayerOffset, 0)];
</span><span class="cx"> } else if (m_swipeTransitionStyle == SwipeTransitionStyle::Push) {
</span><span class="cx"> [rootLayer setPosition:CGPointMake(swipingLayerOffset, 0)];
</span><del>- [m_swipeSnapshotLayer setPosition:CGPointMake((swipingLeft ? -width : width) + swipingLayerOffset, 0)];
</del><ins>+ [m_swipeSnapshotLayer setPosition:CGPointMake((direction == SwipeDirection::Left ? -width : width) + swipingLayerOffset, 0)];
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>