Skip to content
Permalink
Browse files
Unreviewed, rolling out r206950.
https://bugs.webkit.org/show_bug.cgi?id=163169

broke an API test (Requested by thorton on #webkit).

Reverted changeset:

"Share more code between iOS and macOS ViewGestureController"
https://bugs.webkit.org/show_bug.cgi?id=163158
http://trac.webkit.org/changeset/206950

Canonical link: https://commits.webkit.org/181007@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
webkit-commit-queue committed Oct 8, 2016
1 parent 07cc4e1 commit ccf52b2c46e06be1fb02d00d2cc1214f701ddefd
@@ -1,3 +1,16 @@
2016-10-08 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r206950.
https://bugs.webkit.org/show_bug.cgi?id=163169

broke an API test (Requested by thorton on #webkit).

Reverted changeset:

"Share more code between iOS and macOS ViewGestureController"
https://bugs.webkit.org/show_bug.cgi?id=163158
http://trac.webkit.org/changeset/206950

2016-10-08 Tim Horton <timothy_horton@apple.com>

Share more code between iOS and macOS ViewGestureController
@@ -2198,7 +2198,7 @@ - (void)setAllowsBackForwardNavigationGestures:(BOOL)allowsBackForwardNavigation
if (!_gestureController) {
_gestureController = std::make_unique<WebKit::ViewGestureController>(*_page);
_gestureController->installSwipeHandler(self, [self scrollView]);
_gestureController->setAlternateBackForwardListSourcePage([_configuration _alternateWebViewForNavigationGestures]->_page.get());
_gestureController->setAlternateBackForwardListSourceView([_configuration _alternateWebViewForNavigationGestures]);
}
} else
_gestureController = nullptr;
@@ -29,7 +29,6 @@
#import "Logging.h"
#import "RemoteLayerTreeDrawingAreaProxy.h"
#import "ViewGestureControllerMessages.h"
#import "WebBackForwardList.h"
#import "WebPageProxy.h"
#import "WebProcessProxy.h"
#import <wtf/MathExtras.h>
@@ -60,7 +59,7 @@ ViewGestureController::ViewGestureController(WebPageProxy& webPageProxy)
: m_webPageProxy(webPageProxy)
, m_swipeActiveLoadMonitoringTimer(RunLoop::main(), this, &ViewGestureController::checkForActiveLoads)
#if PLATFORM(MAC)
, m_pendingSwipeTracker(webPageProxy, *this)
, m_pendingSwipeTracker(webPageProxy, std::bind(&ViewGestureController::trackSwipeGesture, this, std::placeholders::_1, std::placeholders::_2))
#endif
{
m_webPageProxy.process().addMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID(), *this);
@@ -84,24 +83,6 @@ ViewGestureController* ViewGestureController::gestureControllerForPage(uint64_t
return nullptr;
return gestureControllerIter->value;
}

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();
}


void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
{
@@ -28,19 +28,22 @@

#include "MessageReceiver.h"
#include "SameDocumentNavigationType.h"
#include "WeakObjCPtr.h"
#include <WebCore/Color.h>
#include <WebCore/FloatRect.h>
#include <chrono>
#include <wtf/BlockPtr.h>
#include <wtf/RetainPtr.h>
#include <wtf/RunLoop.h>
#include <wtf/WeakPtr.h>

// FIXME: Move this file out of the mac/ subdirectory.

OBJC_CLASS CALayer;

#if PLATFORM(IOS)
OBJC_CLASS UIView;
OBJC_CLASS WKSwipeTransitionController;
OBJC_CLASS WKWebView;
OBJC_CLASS _UINavigationInteractiveTransitionBase;
OBJC_CLASS _UIViewControllerOneToOneTransitionContext;
OBJC_CLASS _UIViewControllerTransitionContext;
@@ -106,15 +109,13 @@ class ViewGestureController : private IPC::MessageReceiver {
bool isPhysicallySwipingLeft(SwipeDirection) const;
#else
void installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView);
void setAlternateBackForwardListSourceView(WKWebView *);
bool canSwipeInDirection(SwipeDirection);
void beginSwipeGesture(_UINavigationInteractiveTransitionBase *, SwipeDirection);
void endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *, bool cancelled);
void willCommitPostSwipeTransitionLayerTree(bool);
void setRenderTreeSize(uint64_t);
#endif

void setAlternateBackForwardListSourcePage(WebPageProxy*);

bool canSwipeInDirection(SwipeDirection) const;

WebCore::Color backgroundColorForCurrentSnapshot() const { return m_backgroundColorForCurrentSnapshot; }

@@ -201,7 +202,7 @@ class ViewGestureController : private IPC::MessageReceiver {

class PendingSwipeTracker {
public:
PendingSwipeTracker(WebPageProxy&, ViewGestureController&);
PendingSwipeTracker(WebPageProxy&, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback);
bool handleEvent(NSEvent *);
void eventWasNotHandledByWebCore(NSEvent *);

@@ -226,7 +227,7 @@ class ViewGestureController : private IPC::MessageReceiver {

bool m_shouldIgnorePinnedState { false };

ViewGestureController& m_viewGestureController;
std::function<void(NSEvent *, SwipeDirection)> m_trackSwipeCallback;
WebPageProxy& m_webPageProxy;
};
#endif
@@ -237,9 +238,6 @@ class ViewGestureController : private IPC::MessageReceiver {
RunLoop::Timer<ViewGestureController> m_swipeActiveLoadMonitoringTimer;

WebCore::Color m_backgroundColorForCurrentSnapshot;

WeakPtr<WebPageProxy> m_alternateBackForwardListSourcePage;
RefPtr<WebPageProxy> m_webPageProxyForBackForwardListForCurrentSwipe;

#if PLATFORM(MAC)
RefPtr<ViewSnapshot> m_currentSwipeSnapshot;
@@ -279,6 +277,8 @@ class ViewGestureController : private IPC::MessageReceiver {
RetainPtr<WKSwipeTransitionController> m_swipeInteractiveTransitionDelegate;
RetainPtr<_UIViewControllerOneToOneTransitionContext> m_swipeTransitionContext;
uint64_t m_snapshotRemovalTargetRenderTreeSize { 0 };
WeakObjCPtr<WKWebView> m_alternateBackForwardListSourceView;
RefPtr<WebPageProxy> m_webPageProxyForBackForwardListForCurrentSwipe;
uint64_t m_gesturePendingSnapshotRemoval { 0 };
#endif

@@ -450,7 +450,6 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
, m_configurationPreferenceValues(m_configuration->preferenceValues())
, m_potentiallyChangedViewStateFlags(ViewState::NoFlags)
, m_viewStateChangeWantsSynchronousReply(false)
, m_weakPtrFactory(this)
{
m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
@@ -1129,8 +1129,6 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
#if ENABLE(GAMEPAD)
void gamepadActivity(const Vector<GamepadData>&);
#endif

WeakPtr<WebPageProxy> createWeakPtr() const { return m_weakPtrFactory.createWeakPtr(); }

private:
WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
@@ -1891,8 +1889,6 @@ class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
#if ENABLE(DOWNLOAD_ATTRIBUTE)
bool m_syncNavigationActionHasDownloadAttribute { false };
#endif

WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
};

} // namespace WebKit
@@ -34,7 +34,6 @@
#import "ViewSnapshotStore.h"
#import "WKBackForwardListItemInternal.h"
#import "WKWebViewInternal.h"
#import "WeakObjCPtr.h"
#import "WebBackForwardList.h"
#import "WebPageGroup.h"
#import "WebPageMessages.h"
@@ -141,6 +140,11 @@ - (UIPanGestureRecognizer *)gestureRecognizerForInteractiveTransition:(_UINaviga
[m_swipeInteractiveTransitionDelegate invalidate];
}

void ViewGestureController::setAlternateBackForwardListSourceView(WKWebView *view)
{
m_alternateBackForwardListSourceView = view;
}

void ViewGestureController::installSwipeHandler(UIView *gestureRecognizerView, UIView *swipingView)
{
ASSERT(!m_swipeInteractiveTransitionDelegate);
@@ -155,9 +159,7 @@ - (UIPanGestureRecognizer *)gestureRecognizerForInteractiveTransition:(_UINaviga

m_webPageProxy.recordAutomaticNavigationSnapshot();

RefPtr<WebPageProxy> alternateBackForwardListSourcePage = m_alternateBackForwardListSourcePage.get();
m_webPageProxyForBackForwardListForCurrentSwipe = alternateBackForwardListSourcePage ? alternateBackForwardListSourcePage.get() : &m_webPageProxy;

m_webPageProxyForBackForwardListForCurrentSwipe = m_alternateBackForwardListSourceView.get() ? m_alternateBackForwardListSourceView.get()->_page : &m_webPageProxy;
m_webPageProxyForBackForwardListForCurrentSwipe->navigationGestureDidBegin();
if (&m_webPageProxy != m_webPageProxyForBackForwardListForCurrentSwipe)
m_webPageProxy.navigationGestureDidBegin();
@@ -237,6 +239,14 @@ - (UIPanGestureRecognizer *)gestureRecognizerForInteractiveTransition:(_UINaviga
m_activeGestureType = ViewGestureType::Swipe;
}

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();
}

void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *context, bool cancelled)
{
[context _setTransitionIsInFlight:NO];
@@ -272,8 +272,8 @@ static bool deltaShouldCancelSwipe(float x, float y)
return std::abs(y) >= std::abs(x) * minimumScrollEventRatioForSwipe;
}

ViewGestureController::PendingSwipeTracker::PendingSwipeTracker(WebPageProxy& webPageProxy, ViewGestureController& viewGestureController)
: m_viewGestureController(viewGestureController)
ViewGestureController::PendingSwipeTracker::PendingSwipeTracker(WebPageProxy& webPageProxy, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback)
: m_trackSwipeCallback(WTFMove(trackSwipeCallback))
, m_webPageProxy(webPageProxy)
{
}
@@ -292,16 +292,21 @@ static bool deltaShouldCancelSwipe(float x, float y)
bool isPinnedToLeft = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToLeftSide();
bool isPinnedToRight = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToRightSide();

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)
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)
return false;

potentialSwipeDirection = tryingToSwipeBack ? SwipeDirection::Back : SwipeDirection::Forward;
return m_viewGestureController.canSwipeInDirection(potentialSwipeDirection);
potentialSwipeDirection = willSwipeBack ? ViewGestureController::SwipeDirection::Back : ViewGestureController::SwipeDirection::Forward;

return true;
}

bool ViewGestureController::handleScrollWheelEvent(NSEvent *event)
@@ -367,7 +372,7 @@ static bool deltaShouldCancelSwipe(float x, float y)
}

if (std::abs(m_cumulativeDelta.width()) >= minimumHorizontalSwipeDistance)
m_viewGestureController.trackSwipeGesture(event, m_direction);
m_trackSwipeCallback(event, m_direction);
else
m_state = State::InsufficientMagnitude;

0 comments on commit ccf52b2

Please sign in to comment.