<!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>[206950] 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/206950">206950</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2016-10-08 01:31:00 -0700 (Sat, 08 Oct 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Share more code between iOS and macOS ViewGestureController
https://bugs.webkit.org/show_bug.cgi?id=163158
Reviewed by Simon Fraser.
Share canSwipeInDirection() and the (unused on Mac) alternate back-forward list mechanism.
Make ViewGestureController operate in terms of WebPageProxy, not WKWebView,
because it shouldn't know anything about WKWebView.
Refactor scrollEventCanBecomeSwipe a bit to be less repetitive.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView setAllowsBackForwardNavigationGestures:]):
* UIProcess/Cocoa/ViewGestureController.cpp:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::setAlternateBackForwardListSourcePage):
(WebKit::ViewGestureController::canSwipeInDirection):
(WebKit::ViewGestureController::gestureControllerForPage): Deleted.
* UIProcess/Cocoa/ViewGestureController.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::createWeakPtr):
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::setAlternateBackForwardListSourceView): Deleted.
(WebKit::ViewGestureController::canSwipeInDirection): Deleted.
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaViewGestureControllercpp">trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaViewGestureControllerh">trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm">trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-10-08 Tim Horton <timothy_horton@apple.com>
+
+ Share more code between iOS and macOS ViewGestureController
+ https://bugs.webkit.org/show_bug.cgi?id=163158
+
+ Reviewed by Simon Fraser.
+
+ Share canSwipeInDirection() and the (unused on Mac) alternate back-forward list mechanism.
+ Make ViewGestureController operate in terms of WebPageProxy, not WKWebView,
+ because it shouldn't know anything about WKWebView.
+ Refactor scrollEventCanBecomeSwipe a bit to be less repetitive.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView setAllowsBackForwardNavigationGestures:]):
+ * UIProcess/Cocoa/ViewGestureController.cpp:
+ (WebKit::ViewGestureController::ViewGestureController):
+ (WebKit::ViewGestureController::setAlternateBackForwardListSourcePage):
+ (WebKit::ViewGestureController::canSwipeInDirection):
+ (WebKit::ViewGestureController::gestureControllerForPage): Deleted.
+ * UIProcess/Cocoa/ViewGestureController.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::createWeakPtr):
+ * UIProcess/ios/ViewGestureControllerIOS.mm:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::setAlternateBackForwardListSourceView): Deleted.
+ (WebKit::ViewGestureController::canSwipeInDirection): Deleted.
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker):
+ (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
+ (WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe):
+
</ins><span class="cx"> 2016-10-07 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Get rid of API::Session and WKSessionRef
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -2198,7 +2198,7 @@
</span><span class="cx"> if (!_gestureController) {
</span><span class="cx"> _gestureController = std::make_unique<WebKit::ViewGestureController>(*_page);
</span><span class="cx"> _gestureController->installSwipeHandler(self, [self scrollView]);
</span><del>- _gestureController->setAlternateBackForwardListSourceView([_configuration _alternateWebViewForNavigationGestures]);
</del><ins>+ _gestureController->setAlternateBackForwardListSourcePage([_configuration _alternateWebViewForNavigationGestures]->_page.get());
</ins><span class="cx"> }
</span><span class="cx"> } else
</span><span class="cx"> _gestureController = nullptr;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaViewGestureControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "RemoteLayerTreeDrawingAreaProxy.h"
</span><span class="cx"> #import "ViewGestureControllerMessages.h"
</span><ins>+#import "WebBackForwardList.h"
</ins><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import <wtf/MathExtras.h>
</span><span class="lines">@@ -59,7 +60,7 @@
</span><span class="cx"> : m_webPageProxy(webPageProxy)
</span><span class="cx"> , m_swipeActiveLoadMonitoringTimer(RunLoop::main(), this, &ViewGestureController::checkForActiveLoads)
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>- , m_pendingSwipeTracker(webPageProxy, std::bind(&ViewGestureController::trackSwipeGesture, this, std::placeholders::_1, std::placeholders::_2))
</del><ins>+ , m_pendingSwipeTracker(webPageProxy, *this)
</ins><span class="cx"> #endif
</span><span class="cx"> {
</span><span class="cx"> m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
</span><span class="lines">@@ -83,7 +84,25 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> return gestureControllerIter->value;
</span><span class="cx"> }
</span><ins>+
+void ViewGestureController::setAlternateBackForwardListSourcePage(WebPageProxy* page)
+{
+ if (page)
+ m_alternateBackForwardListSourcePage = page->createWeakPtr();
+ else
+ m_alternateBackForwardListSourcePage.clear();
+}
+
+bool ViewGestureController::canSwipeInDirection(SwipeDirection direction) const
+{
+ RefPtr<WebPageProxy> alternateBackForwardListSourcePage = m_alternateBackForwardListSourcePage.get();
+ auto& backForwardList = alternateBackForwardListSourcePage ? alternateBackForwardListSourcePage->backForwardList() : m_webPageProxy.backForwardList();
+ if (direction == SwipeDirection::Back)
+ return !!backForwardList.backItem();
+ return !!backForwardList.forwardItem();
+}
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
</span><span class="cx"> {
</span><span class="cx"> if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::VisuallyNonEmptyLayout))
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx">
</span><span class="cx"> #include "MessageReceiver.h"
</span><span class="cx"> #include "SameDocumentNavigationType.h"
</span><del>-#include "WeakObjCPtr.h"
</del><span class="cx"> #include <WebCore/Color.h>
</span><span class="cx"> #include <WebCore/FloatRect.h>
</span><span class="cx"> #include <chrono>
</span><span class="lines">@@ -35,15 +34,13 @@
</span><span class="cx"> #include <wtf/BlockPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/RunLoop.h>
</span><ins>+#include <wtf/WeakPtr.h>
</ins><span class="cx">
</span><del>-// FIXME: Move this file out of the mac/ subdirectory.
-
</del><span class="cx"> OBJC_CLASS CALayer;
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> OBJC_CLASS UIView;
</span><span class="cx"> OBJC_CLASS WKSwipeTransitionController;
</span><del>-OBJC_CLASS WKWebView;
</del><span class="cx"> OBJC_CLASS _UINavigationInteractiveTransitionBase;
</span><span class="cx"> OBJC_CLASS _UIViewControllerOneToOneTransitionContext;
</span><span class="cx"> OBJC_CLASS _UIViewControllerTransitionContext;
</span><span class="lines">@@ -109,13 +106,15 @@
</span><span class="cx"> bool isPhysicallySwipingLeft(SwipeDirection) const;
</span><span class="cx"> #else
</span><span class="cx"> void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
</span><del>- void setAlternateBackForwardListSourceView(WKWebView *);
- bool canSwipeInDirection(SwipeDirection);
</del><span class="cx"> void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection);
</span><span class="cx"> void endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *, bool cancelled);
</span><span class="cx"> void willCommitPostSwipeTransitionLayerTree(bool);
</span><span class="cx"> void setRenderTreeSize(uint64_t);
</span><span class="cx"> #endif
</span><ins>+
+ void setAlternateBackForwardListSourcePage(WebPageProxy*);
+
+ bool canSwipeInDirection(SwipeDirection) const;
</ins><span class="cx">
</span><span class="cx"> WebCore::Color backgroundColorForCurrentSnapshot() const { return m_backgroundColorForCurrentSnapshot; }
</span><span class="cx">
</span><span class="lines">@@ -202,7 +201,7 @@
</span><span class="cx">
</span><span class="cx"> class PendingSwipeTracker {
</span><span class="cx"> public:
</span><del>- PendingSwipeTracker(WebPageProxy&, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback);
</del><ins>+ PendingSwipeTracker(WebPageProxy&, ViewGestureController&);
</ins><span class="cx"> bool handleEvent(NSEvent *);
</span><span class="cx"> void eventWasNotHandledByWebCore(NSEvent *);
</span><span class="cx">
</span><span class="lines">@@ -227,7 +226,7 @@
</span><span class="cx">
</span><span class="cx"> bool m_shouldIgnorePinnedState { false };
</span><span class="cx">
</span><del>- std::function<void(NSEvent *, SwipeDirection)> m_trackSwipeCallback;
</del><ins>+ ViewGestureController& m_viewGestureController;
</ins><span class="cx"> WebPageProxy& m_webPageProxy;
</span><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="lines">@@ -238,6 +237,9 @@
</span><span class="cx"> RunLoop::Timer<ViewGestureController> m_swipeActiveLoadMonitoringTimer;
</span><span class="cx">
</span><span class="cx"> WebCore::Color m_backgroundColorForCurrentSnapshot;
</span><ins>+
+ WeakPtr<WebPageProxy> m_alternateBackForwardListSourcePage;
+ RefPtr<WebPageProxy> m_webPageProxyForBackForwardListForCurrentSwipe;
</ins><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> RefPtr<ViewSnapshot> m_currentSwipeSnapshot;
</span><span class="lines">@@ -277,8 +279,6 @@
</span><span class="cx"> RetainPtr<WKSwipeTransitionController> m_swipeInteractiveTransitionDelegate;
</span><span class="cx"> RetainPtr<_UIViewControllerOneToOneTransitionContext> m_swipeTransitionContext;
</span><span class="cx"> uint64_t m_snapshotRemovalTargetRenderTreeSize { 0 };
</span><del>- WeakObjCPtr<WKWebView> m_alternateBackForwardListSourceView;
- RefPtr<WebPageProxy> m_webPageProxyForBackForwardListForCurrentSwipe;
</del><span class="cx"> uint64_t m_gesturePendingSnapshotRemoval { 0 };
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -450,6 +450,7 @@
</span><span class="cx"> , m_configurationPreferenceValues(m_configuration->preferenceValues())
</span><span class="cx"> , m_potentiallyChangedViewStateFlags(ViewState::NoFlags)
</span><span class="cx"> , m_viewStateChangeWantsSynchronousReply(false)
</span><ins>+ , m_weakPtrFactory(this)
</ins><span class="cx"> {
</span><span class="cx"> m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
</span><span class="cx"> m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -1129,6 +1129,8 @@
</span><span class="cx"> #if ENABLE(GAMEPAD)
</span><span class="cx"> void gamepadActivity(const Vector<GamepadData>&);
</span><span class="cx"> #endif
</span><ins>+
+ WeakPtr<WebPageProxy> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
</span><span class="lines">@@ -1889,6 +1891,8 @@
</span><span class="cx"> #if ENABLE(DOWNLOAD_ATTRIBUTE)
</span><span class="cx"> bool m_syncNavigationActionHasDownloadAttribute { false };
</span><span class="cx"> #endif
</span><ins>+
+ WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import "ViewSnapshotStore.h"
</span><span class="cx"> #import "WKBackForwardListItemInternal.h"
</span><span class="cx"> #import "WKWebViewInternal.h"
</span><ins>+#import "WeakObjCPtr.h"
</ins><span class="cx"> #import "WebBackForwardList.h"
</span><span class="cx"> #import "WebPageGroup.h"
</span><span class="cx"> #import "WebPageMessages.h"
</span><span class="lines">@@ -140,11 +141,6 @@
</span><span class="cx"> [m_swipeInteractiveTransitionDelegate invalidate];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ViewGestureController::setAlternateBackForwardListSourceView(WKWebView *view)
-{
- m_alternateBackForwardListSourceView = view;
-}
-
</del><span class="cx"> void ViewGestureController::installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!m_swipeInteractiveTransitionDelegate);
</span><span class="lines">@@ -159,7 +155,9 @@
</span><span class="cx">
</span><span class="cx"> m_webPageProxy.recordAutomaticNavigationSnapshot();
</span><span class="cx">
</span><del>- m_webPageProxyForBackForwardListForCurrentSwipe = m_alternateBackForwardListSourceView.get() ? m_alternateBackForwardListSourceView.get()->_page : &m_webPageProxy;
</del><ins>+ RefPtr<WebPageProxy> alternateBackForwardListSourcePage = m_alternateBackForwardListSourcePage.get();
+ m_webPageProxyForBackForwardListForCurrentSwipe = alternateBackForwardListSourcePage ? alternateBackForwardListSourcePage.get() : &m_webPageProxy;
+
</ins><span class="cx"> m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidBegin();
</span><span class="cx"> if (&m_webPageProxy != m_webPageProxyForBackForwardListForCurrentSwipe)
</span><span class="cx"> m_webPageProxy.navigationGestureDidBegin();
</span><span class="lines">@@ -239,14 +237,6 @@
</span><span class="cx"> m_activeGestureType = ViewGestureType::Swipe;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool ViewGestureController::canSwipeInDirection(SwipeDirection direction)
-{
- auto& backForwardList = m_alternateBackForwardListSourceView.get() ? m_alternateBackForwardListSourceView.get()->_page->backForwardList() : m_webPageProxy.backForwardList();
- if (direction == SwipeDirection::Back)
- return !!backForwardList.backItem();
- return !!backForwardList.forwardItem();
-}
-
</del><span class="cx"> void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *context, bool cancelled)
</span><span class="cx"> {
</span><span class="cx"> [context _setTransitionIsInFlight:NO];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (206949 => 206950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2016-10-08 03:31:15 UTC (rev 206949)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2016-10-08 08:31:00 UTC (rev 206950)
</span><span class="lines">@@ -272,8 +272,8 @@
</span><span class="cx"> return std::abs(y) >= std::abs(x) * minimumScrollEventRatioForSwipe;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-ViewGestureController::PendingSwipeTracker::PendingSwipeTracker(WebPageProxy& webPageProxy, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback)
- : m_trackSwipeCallback(WTFMove(trackSwipeCallback))
</del><ins>+ViewGestureController::PendingSwipeTracker::PendingSwipeTracker(WebPageProxy& webPageProxy, ViewGestureController& viewGestureController)
+ : m_viewGestureController(viewGestureController)
</ins><span class="cx"> , m_webPageProxy(webPageProxy)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -292,21 +292,16 @@
</span><span class="cx"> bool isPinnedToLeft = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToLeftSide();
</span><span class="cx"> bool isPinnedToRight = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToRightSide();
</span><span class="cx">
</span><del>- bool willSwipeBack = false;
- bool willSwipeForward = false;
- if (m_webPageProxy.userInterfaceLayoutDirection() == WebCore::UserInterfaceLayoutDirection::LTR) {
- willSwipeBack = event.scrollingDeltaX > 0 && isPinnedToLeft && m_webPageProxy.backForwardList().backItem();
- willSwipeForward = event.scrollingDeltaX < 0 && isPinnedToRight && m_webPageProxy.backForwardList().forwardItem();
- } else {
- willSwipeBack = event.scrollingDeltaX < 0 && isPinnedToRight && m_webPageProxy.backForwardList().backItem();
- willSwipeForward = event.scrollingDeltaX > 0 && isPinnedToLeft && m_webPageProxy.backForwardList().forwardItem();
- }
- if (!willSwipeBack && !willSwipeForward)
</del><ins>+ bool tryingToSwipeBack = event.scrollingDeltaX > 0 && isPinnedToLeft;
+ bool tryingToSwipeForward = event.scrollingDeltaX < 0 && isPinnedToRight;
+ if (m_webPageProxy.userInterfaceLayoutDirection() != WebCore::UserInterfaceLayoutDirection::LTR)
+ std::swap(tryingToSwipeBack, tryingToSwipeForward);
+
+ if (!tryingToSwipeBack && !tryingToSwipeForward)
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- potentialSwipeDirection = willSwipeBack ? ViewGestureController::SwipeDirection::Back : ViewGestureController::SwipeDirection::Forward;
-
- return true;
</del><ins>+ potentialSwipeDirection = tryingToSwipeBack ? SwipeDirection::Back : SwipeDirection::Forward;
+ return m_viewGestureController.canSwipeInDirection(potentialSwipeDirection);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ViewGestureController::handleScrollWheelEvent(NSEvent *event)
</span><span class="lines">@@ -372,7 +367,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (std::abs(m_cumulativeDelta.width()) >= minimumHorizontalSwipeDistance)
</span><del>- m_trackSwipeCallback(event, m_direction);
</del><ins>+ m_viewGestureController.trackSwipeGesture(event, m_direction);
</ins><span class="cx"> else
</span><span class="cx"> m_state = State::InsufficientMagnitude;
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>