Diff
Modified: trunk/Source/WebKit2/ChangeLog (206935 => 206936)
--- trunk/Source/WebKit2/ChangeLog 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-07 21:11:59 UTC (rev 206936)
@@ -1,5 +1,18 @@
2016-10-07 Tim Horton <[email protected]>
+ Move ViewGestureController files to more accurate locations
+ https://bugs.webkit.org/show_bug.cgi?id=163141
+
+ Reviewed by Anders Carlsson.
+
+ * PlatformMac.cmake:
+ * UIProcess/Cocoa/ViewGestureController.cpp: Renamed from UIProcess/ViewGestureController.cpp.
+ * UIProcess/Cocoa/ViewGestureController.h: Renamed from UIProcess/mac/ViewGestureController.h.
+ * UIProcess/Cocoa/ViewGestureController.messages.in: Renamed from UIProcess/mac/ViewGestureController.messages.in.
+ * WebKit2.xcodeproj/project.pbxproj:
+
+2016-10-07 Tim Horton <[email protected]>
+
Adopt BlockPtr in ViewGestureController
https://bugs.webkit.org/show_bug.cgi?id=163132
Modified: trunk/Source/WebKit2/PlatformMac.cmake (206935 => 206936)
--- trunk/Source/WebKit2/PlatformMac.cmake 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/PlatformMac.cmake 2016-10-07 21:11:59 UTC (rev 206936)
@@ -154,7 +154,6 @@
Shared/mac/WebHitTestResultData.mm
Shared/mac/WebMemorySampler.mac.mm
- UIProcess/ViewGestureController.cpp
UIProcess/WebResourceLoadStatisticsStore.cpp
UIProcess/Automation/WebAutomationSession.cpp
@@ -233,6 +232,7 @@
UIProcess/Cocoa/SessionStateCoding.mm
UIProcess/Cocoa/UIDelegate.mm
UIProcess/Cocoa/VersionChecks.mm
+ UIProcess/Cocoa/ViewGestureController.cpp
UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
UIProcess/Cocoa/WebAutomationSessionCocoa.mm
@@ -469,11 +469,11 @@
list(APPEND WebKit2_MESSAGES_IN_FILES
Shared/API/Cocoa/RemoteObjectRegistry.messages.in
+ UIProcess/Cocoa/ViewGestureController.messages.in
UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in
UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.messages.in
UIProcess/mac/SecItemShimProxy.messages.in
- UIProcess/mac/ViewGestureController.messages.in
WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in
WebProcess/WebPage/ViewGestureGeometryCollector.messages.in
Copied: trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp (from rev 206935, trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp) (0 => 206936)
--- trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.cpp 2016-10-07 21:11:59 UTC (rev 206936)
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2013-2015 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.
+ */
+
+#import "config.h"
+#import "ViewGestureController.h"
+
+#import "Logging.h"
+#import "RemoteLayerTreeDrawingAreaProxy.h"
+#import "ViewGestureControllerMessages.h"
+#import "WebPageProxy.h"
+#import "WebProcessProxy.h"
+#import <wtf/MathExtras.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/text/StringBuilder.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration = 3s;
+static const std::chrono::milliseconds swipeSnapshotRemovalActiveLoadMonitoringInterval = 250ms;
+
+#if PLATFORM(MAC)
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 5s;
+#else
+static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 3s;
+#endif
+
+static HashMap<uint64_t, ViewGestureController*>& viewGestureControllersForAllPages()
+{
+ // The key in this map is the associated page ID.
+ static NeverDestroyed<HashMap<uint64_t, ViewGestureController*>> viewGestureControllers;
+ return viewGestureControllers.get();
+}
+
+ViewGestureController::ViewGestureController(WebPageProxy& webPageProxy)
+ : m_webPageProxy(webPageProxy)
+ , m_swipeActiveLoadMonitoringTimer(RunLoop::main(), this, &ViewGestureController::checkForActiveLoads)
+#if PLATFORM(MAC)
+ , 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);
+
+ viewGestureControllersForAllPages().add(webPageProxy.pageID(), this);
+}
+
+ViewGestureController::~ViewGestureController()
+{
+ platformTeardown();
+
+ viewGestureControllersForAllPages().remove(m_webPageProxy.pageID());
+
+ m_webPageProxy.process().removeMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID());
+}
+
+ViewGestureController* ViewGestureController::gestureControllerForPage(uint64_t pageID)
+{
+ auto gestureControllerIter = viewGestureControllersForAllPages().find(pageID);
+ if (gestureControllerIter == viewGestureControllersForAllPages().end())
+ return nullptr;
+ return gestureControllerIter->value;
+}
+
+void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
+{
+ if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::VisuallyNonEmptyLayout))
+ return;
+
+ m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::MainFrameLoad);
+ m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::SubresourceLoads);
+ m_snapshotRemovalTracker.startWatchdog(swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration);
+}
+
+void ViewGestureController::didRepaintAfterNavigation()
+{
+ m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::RepaintAfterNavigation);
+}
+
+void ViewGestureController::didHitRenderTreeSizeThreshold()
+{
+ m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::RenderTreeSizeThreshold);
+}
+
+void ViewGestureController::didRestoreScrollPosition()
+{
+ m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::ScrollPositionRestoration);
+}
+
+void ViewGestureController::didReachMainFrameLoadTerminalState()
+{
+ if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::MainFrameLoad))
+ return;
+
+ // Coming back from the page cache will result in getting a load event, but no first visually non-empty layout.
+ // WebCore considers a loaded document enough to be considered visually non-empty, so that's good
+ // enough for us too.
+ m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::VisuallyNonEmptyLayout);
+
+ // With Web-process scrolling, we check if the scroll position restoration succeeded by comparing the
+ // requested and actual scroll position. It's possible that we will never succeed in restoring
+ // the exact scroll position we wanted, in the case of a dynamic page, but we know that by
+ // main frame load time that we've gotten as close as we're going to get, so stop waiting.
+ // We don't want to do this with UI-side scrolling because scroll position restoration is baked into the transaction.
+ // FIXME: It seems fairly dirty to type-check the DrawingArea like this.
+ if (auto drawingArea = m_webPageProxy.drawingArea()) {
+ if (is<RemoteLayerTreeDrawingAreaProxy>(drawingArea))
+ m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::ScrollPositionRestoration);
+ }
+
+ checkForActiveLoads();
+}
+
+void ViewGestureController::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
+{
+ bool cancelledOutstandingEvent = false;
+
+ // Same-document navigations don't have a main frame load or first visually non-empty layout.
+ cancelledOutstandingEvent |= m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::MainFrameLoad);
+ cancelledOutstandingEvent |= m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::VisuallyNonEmptyLayout);
+
+ if (!cancelledOutstandingEvent)
+ return;
+
+ if (type != SameDocumentNavigationSessionStateReplace && type != SameDocumentNavigationSessionStatePop)
+ return;
+
+ checkForActiveLoads();
+}
+
+void ViewGestureController::checkForActiveLoads()
+{
+ if (m_webPageProxy.pageLoadState().isLoading()) {
+ if (!m_swipeActiveLoadMonitoringTimer.isActive())
+ m_swipeActiveLoadMonitoringTimer.startRepeating(swipeSnapshotRemovalActiveLoadMonitoringInterval);
+ return;
+ }
+
+ m_swipeActiveLoadMonitoringTimer.stop();
+ m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::SubresourceLoads);
+}
+
+ViewGestureController::SnapshotRemovalTracker::SnapshotRemovalTracker()
+ : m_watchdogTimer(RunLoop::main(), this, &SnapshotRemovalTracker::watchdogTimerFired)
+{
+}
+
+String ViewGestureController::SnapshotRemovalTracker::eventsDescription(Events event)
+{
+ StringBuilder description;
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::VisuallyNonEmptyLayout)
+ description.append("VisuallyNonEmptyLayout ");
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::RenderTreeSizeThreshold)
+ description.append("RenderTreeSizeThreshold ");
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::RepaintAfterNavigation)
+ description.append("RepaintAfterNavigation ");
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::MainFrameLoad)
+ description.append("MainFrameLoad ");
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::SubresourceLoads)
+ description.append("SubresourceLoads ");
+
+ if (event & ViewGestureController::SnapshotRemovalTracker::ScrollPositionRestoration)
+ description.append("ScrollPositionRestoration ");
+
+ return description.toString();
+}
+
+
+void ViewGestureController::SnapshotRemovalTracker::log(const String& log) const
+{
+#if !LOG_DISABLED
+ auto now = std::chrono::steady_clock::now();
+ double millisecondsSinceStart = std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(now - m_startTime).count();
+#endif
+ LOG(ViewGestures, "Swipe Snapshot Removal (%0.2f ms) - %s", millisecondsSinceStart, log.utf8().data());
+}
+
+void ViewGestureController::SnapshotRemovalTracker::start(Events desiredEvents, std::function<void()> removalCallback)
+{
+ m_outstandingEvents = desiredEvents;
+ m_removalCallback = WTFMove(removalCallback);
+ m_startTime = std::chrono::steady_clock::now();
+
+ log("start");
+
+ startWatchdog(swipeSnapshotRemovalWatchdogDuration);
+}
+
+void ViewGestureController::SnapshotRemovalTracker::reset()
+{
+ if (m_outstandingEvents)
+ log("reset; had outstanding events: " + eventsDescription(m_outstandingEvents));
+ m_outstandingEvents = 0;
+ m_watchdogTimer.stop();
+ m_removalCallback = nullptr;
+}
+
+bool ViewGestureController::SnapshotRemovalTracker::stopWaitingForEvent(Events event, const String& logReason)
+{
+ ASSERT(hasOneBitSet(event));
+
+ if (!(m_outstandingEvents & event))
+ return false;
+
+#if LOG_DISABLED
+ UNUSED_PARAM(logReason);
+#endif
+ log(logReason + eventsDescription(event));
+
+ m_outstandingEvents &= ~event;
+
+ fireRemovalCallbackIfPossible();
+ return true;
+}
+
+bool ViewGestureController::SnapshotRemovalTracker::eventOccurred(Events event)
+{
+ return stopWaitingForEvent(event, "outstanding event occurred: ");
+}
+
+bool ViewGestureController::SnapshotRemovalTracker::cancelOutstandingEvent(Events event)
+{
+ return stopWaitingForEvent(event, "wait for event cancelled: ");
+}
+
+void ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackIfPossible()
+{
+ if (m_outstandingEvents) {
+ log("deferring removal; had outstanding events: " + eventsDescription(m_outstandingEvents));
+ return;
+ }
+
+ fireRemovalCallbackImmediately();
+}
+
+void ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackImmediately()
+{
+ m_watchdogTimer.stop();
+
+ auto removalCallback = WTFMove(m_removalCallback);
+ if (removalCallback) {
+ log("removing snapshot");
+ reset();
+ removalCallback();
+ }
+}
+
+void ViewGestureController::SnapshotRemovalTracker::watchdogTimerFired()
+{
+ log("watchdog timer fired");
+ fireRemovalCallbackImmediately();
+}
+
+void ViewGestureController::SnapshotRemovalTracker::startWatchdog(std::chrono::seconds duration)
+{
+ log(String::format("(re)started watchdog timer for %lld seconds", duration.count()));
+ m_watchdogTimer.startOneShot(duration.count());
+}
+
+} // namespace WebKit
Copied: trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h (from rev 206935, trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h) (0 => 206936)
--- trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.h 2016-10-07 21:11:59 UTC (rev 206936)
@@ -0,0 +1,290 @@
+/*
+ * Copyright (C) 2013, 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 ViewGestureController_h
+#define ViewGestureController_h
+
+#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>
+
+// 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;
+#else
+OBJC_CLASS CAGradientLayer;
+OBJC_CLASS NSEvent;
+OBJC_CLASS NSView;
+OBJC_CLASS WKSwipeCancellationTracker;
+#endif
+
+namespace WebCore {
+class IOSurface;
+}
+
+namespace WebKit {
+
+class ViewSnapshot;
+class WebBackForwardListItem;
+class WebPageProxy;
+
+class ViewGestureController : private IPC::MessageReceiver {
+ WTF_MAKE_NONCOPYABLE(ViewGestureController);
+public:
+ ViewGestureController(WebPageProxy&);
+ ~ViewGestureController();
+ void platformTeardown();
+
+ enum class ViewGestureType {
+ None,
+#if PLATFORM(MAC)
+ Magnification,
+ SmartMagnification,
+#endif
+ Swipe
+ };
+
+ enum class SwipeDirection {
+ Back,
+ Forward
+ };
+
+#if PLATFORM(MAC)
+ double magnification() const;
+
+ void handleMagnificationGestureEvent(NSEvent *, WebCore::FloatPoint origin);
+
+ bool hasActiveMagnificationGesture() const { return m_activeGestureType == ViewGestureType::Magnification; }
+
+ void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
+
+ bool handleScrollWheelEvent(NSEvent *);
+ void wheelEventWasNotHandledByWebCore(NSEvent *event) { m_pendingSwipeTracker.eventWasNotHandledByWebCore(event); }
+ void gestureEventWasNotHandledByWebCore(NSEvent *, WebCore::FloatPoint origin);
+
+ void setCustomSwipeViews(Vector<RetainPtr<NSView>> views) { m_customSwipeViews = WTFMove(views); }
+ void setCustomSwipeViewsTopContentInset(float topContentInset) { m_customSwipeViewsTopContentInset = topContentInset; }
+ WebCore::FloatRect windowRelativeBoundsForCustomSwipeViews() const;
+ void setDidMoveSwipeSnapshotCallback(BlockPtr<void (CGRect)>&& callback) { m_didMoveSwipeSnapshotCallback = WTFMove(callback); }
+
+ bool shouldIgnorePinnedState() { return m_pendingSwipeTracker.shouldIgnorePinnedState(); }
+ void setShouldIgnorePinnedState(bool ignore) { m_pendingSwipeTracker.setShouldIgnorePinnedState(ignore); }
+
+ 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
+
+ WebCore::Color backgroundColorForCurrentSnapshot() const { return m_backgroundColorForCurrentSnapshot; }
+
+ void didFinishLoadForMainFrame() { didReachMainFrameLoadTerminalState(); }
+ void didFailLoadForMainFrame() { didReachMainFrameLoadTerminalState(); }
+ void didFirstVisuallyNonEmptyLayoutForMainFrame();
+ void didRepaintAfterNavigation();
+ void didHitRenderTreeSizeThreshold();
+ void didRestoreScrollPosition();
+ void didReachMainFrameLoadTerminalState();
+ void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType);
+
+ void checkForActiveLoads();
+
+ void removeSwipeSnapshot();
+
+private:
+ // IPC::MessageReceiver.
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+
+ static ViewGestureController* gestureControllerForPage(uint64_t);
+
+ class SnapshotRemovalTracker {
+ public:
+ enum Event : uint8_t {
+ VisuallyNonEmptyLayout = 1 << 0,
+ RenderTreeSizeThreshold = 1 << 1,
+ RepaintAfterNavigation = 1 << 2,
+ MainFrameLoad = 1 << 3,
+ SubresourceLoads = 1 << 4,
+ ScrollPositionRestoration = 1 << 5
+ };
+ typedef uint8_t Events;
+
+ SnapshotRemovalTracker();
+
+ void start(Events, std::function<void()>);
+ void reset();
+
+ bool eventOccurred(Events);
+ bool cancelOutstandingEvent(Events);
+
+ void startWatchdog(std::chrono::seconds);
+
+ private:
+ static String eventsDescription(Events);
+ void log(const String&) const;
+
+ void fireRemovalCallbackImmediately();
+ void fireRemovalCallbackIfPossible();
+ void watchdogTimerFired();
+
+ bool stopWaitingForEvent(Events, const String& logReason);
+
+ Events m_outstandingEvents { 0 };
+ std::function<void()> m_removalCallback;
+ std::chrono::steady_clock::time_point m_startTime;
+
+ RunLoop::Timer<SnapshotRemovalTracker> m_watchdogTimer;
+ };
+
+#if PLATFORM(MAC)
+ // Message handlers.
+ void didCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture);
+ void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
+
+ void endMagnificationGesture();
+
+ WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
+
+ void trackSwipeGesture(NSEvent *, SwipeDirection);
+ void beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection);
+ void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection);
+ void willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled);
+ void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
+ bool shouldUseSnapshotForSize(ViewSnapshot&, WebCore::FloatSize swipeLayerSize, float topContentInset);
+
+ CALayer *determineSnapshotLayerParent() const;
+ CALayer *determineLayerAdjacentToSnapshotForParent(SwipeDirection, CALayer *snapshotLayerParent) const;
+ void applyDebuggingPropertiesToSwipeViews();
+ void didMoveSwipeSnapshotLayer();
+
+ void forceRepaintIfNeeded();
+
+ class PendingSwipeTracker {
+ public:
+ PendingSwipeTracker(WebPageProxy&, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback);
+ bool handleEvent(NSEvent *);
+ void eventWasNotHandledByWebCore(NSEvent *);
+
+ void reset(const char* resetReasonForLogging);
+
+ bool shouldIgnorePinnedState() { return m_shouldIgnorePinnedState; }
+ void setShouldIgnorePinnedState(bool ignore) { m_shouldIgnorePinnedState = ignore; }
+
+ private:
+ bool tryToStartSwipe(NSEvent *);
+ bool scrollEventCanBecomeSwipe(NSEvent *, SwipeDirection&);
+
+ enum class State {
+ None,
+ WaitingForWebCore,
+ InsufficientMagnitude
+ };
+
+ State m_state { State::None };
+ SwipeDirection m_direction;
+ WebCore::FloatSize m_cumulativeDelta;
+
+ bool m_shouldIgnorePinnedState { false };
+
+ std::function<void(NSEvent *, SwipeDirection)> m_trackSwipeCallback;
+ WebPageProxy& m_webPageProxy;
+ };
+#endif
+
+ WebPageProxy& m_webPageProxy;
+ ViewGestureType m_activeGestureType { ViewGestureType::None };
+
+ RunLoop::Timer<ViewGestureController> m_swipeActiveLoadMonitoringTimer;
+
+ WebCore::Color m_backgroundColorForCurrentSnapshot;
+
+#if PLATFORM(MAC)
+ RefPtr<ViewSnapshot> m_currentSwipeSnapshot;
+
+ double m_magnification;
+ WebCore::FloatPoint m_magnificationOrigin;
+
+ WebCore::FloatRect m_lastSmartMagnificationUnscaledTargetRect;
+ bool m_lastMagnificationGestureWasSmartMagnification { false };
+ WebCore::FloatPoint m_lastSmartMagnificationOrigin;
+
+ WebCore::FloatRect m_visibleContentRect;
+ bool m_visibleContentRectIsValid { false };
+ bool m_frameHandlesMagnificationGesture { false };
+
+ RetainPtr<WKSwipeCancellationTracker> m_swipeCancellationTracker;
+ RetainPtr<CALayer> m_swipeLayer;
+ RetainPtr<CALayer> m_swipeSnapshotLayer;
+ RetainPtr<CAGradientLayer> m_swipeShadowLayer;
+ RetainPtr<CALayer> m_swipeDimmingLayer;
+ Vector<RetainPtr<CALayer>> m_currentSwipeLiveLayers;
+
+ Vector<RetainPtr<NSView>> m_customSwipeViews;
+ float m_customSwipeViewsTopContentInset { 0 };
+ WebCore::FloatRect m_currentSwipeCustomViewBounds;
+
+ PendingSwipeTracker m_pendingSwipeTracker;
+
+ BlockPtr<void (CGRect)> m_didMoveSwipeSnapshotCallback;
+
+ bool m_hasOutstandingRepaintRequest { false };
+#else
+ UIView *m_liveSwipeView { nullptr };
+ RetainPtr<UIView> m_liveSwipeViewClippingView;
+ RetainPtr<UIView> m_snapshotView;
+ RetainPtr<UIView> m_transitionContainerView;
+ 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
+
+ SnapshotRemovalTracker m_snapshotRemovalTracker;
+};
+
+} // namespace WebKit
+
+#endif // ViewGestureController_h
Copied: trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.messages.in (from rev 206935, trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in) (0 => 206936)
--- trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.messages.in (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/ViewGestureController.messages.in 2016-10-07 21:11:59 UTC (rev 206936)
@@ -0,0 +1,29 @@
+# Copyright (C) 2013 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.
+
+messages -> ViewGestureController {
+#if PLATFORM(MAC)
+ DidCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture)
+ DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)
+ DidHitRenderTreeSizeThreshold()
+#endif
+}
Deleted: trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp (206935 => 206936)
--- trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp 2016-10-07 21:11:59 UTC (rev 206936)
@@ -1,287 +0,0 @@
-/*
- * Copyright (C) 2013-2015 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.
- */
-
-#import "config.h"
-#import "ViewGestureController.h"
-
-#import "Logging.h"
-#import "RemoteLayerTreeDrawingAreaProxy.h"
-#import "ViewGestureControllerMessages.h"
-#import "WebPageProxy.h"
-#import "WebProcessProxy.h"
-#import <wtf/MathExtras.h>
-#import <wtf/NeverDestroyed.h>
-#import <wtf/text/StringBuilder.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-static const std::chrono::seconds swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration = 3s;
-static const std::chrono::milliseconds swipeSnapshotRemovalActiveLoadMonitoringInterval = 250ms;
-
-#if PLATFORM(MAC)
-static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 5s;
-#else
-static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 3s;
-#endif
-
-static HashMap<uint64_t, ViewGestureController*>& viewGestureControllersForAllPages()
-{
- // The key in this map is the associated page ID.
- static NeverDestroyed<HashMap<uint64_t, ViewGestureController*>> viewGestureControllers;
- return viewGestureControllers.get();
-}
-
-ViewGestureController::ViewGestureController(WebPageProxy& webPageProxy)
- : m_webPageProxy(webPageProxy)
- , m_swipeActiveLoadMonitoringTimer(RunLoop::main(), this, &ViewGestureController::checkForActiveLoads)
-#if PLATFORM(MAC)
- , 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);
-
- viewGestureControllersForAllPages().add(webPageProxy.pageID(), this);
-}
-
-ViewGestureController::~ViewGestureController()
-{
- platformTeardown();
-
- viewGestureControllersForAllPages().remove(m_webPageProxy.pageID());
-
- m_webPageProxy.process().removeMessageReceiver(Messages::ViewGestureController::messageReceiverName(), m_webPageProxy.pageID());
-}
-
-ViewGestureController* ViewGestureController::gestureControllerForPage(uint64_t pageID)
-{
- auto gestureControllerIter = viewGestureControllersForAllPages().find(pageID);
- if (gestureControllerIter == viewGestureControllersForAllPages().end())
- return nullptr;
- return gestureControllerIter->value;
-}
-
-void ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame()
-{
- if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::VisuallyNonEmptyLayout))
- return;
-
- m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::MainFrameLoad);
- m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::SubresourceLoads);
- m_snapshotRemovalTracker.startWatchdog(swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration);
-}
-
-void ViewGestureController::didRepaintAfterNavigation()
-{
- m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::RepaintAfterNavigation);
-}
-
-void ViewGestureController::didHitRenderTreeSizeThreshold()
-{
- m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::RenderTreeSizeThreshold);
-}
-
-void ViewGestureController::didRestoreScrollPosition()
-{
- m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::ScrollPositionRestoration);
-}
-
-void ViewGestureController::didReachMainFrameLoadTerminalState()
-{
- if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::MainFrameLoad))
- return;
-
- // Coming back from the page cache will result in getting a load event, but no first visually non-empty layout.
- // WebCore considers a loaded document enough to be considered visually non-empty, so that's good
- // enough for us too.
- m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::VisuallyNonEmptyLayout);
-
- // With Web-process scrolling, we check if the scroll position restoration succeeded by comparing the
- // requested and actual scroll position. It's possible that we will never succeed in restoring
- // the exact scroll position we wanted, in the case of a dynamic page, but we know that by
- // main frame load time that we've gotten as close as we're going to get, so stop waiting.
- // We don't want to do this with UI-side scrolling because scroll position restoration is baked into the transaction.
- // FIXME: It seems fairly dirty to type-check the DrawingArea like this.
- if (auto drawingArea = m_webPageProxy.drawingArea()) {
- if (is<RemoteLayerTreeDrawingAreaProxy>(drawingArea))
- m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::ScrollPositionRestoration);
- }
-
- checkForActiveLoads();
-}
-
-void ViewGestureController::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
-{
- bool cancelledOutstandingEvent = false;
-
- // Same-document navigations don't have a main frame load or first visually non-empty layout.
- cancelledOutstandingEvent |= m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::MainFrameLoad);
- cancelledOutstandingEvent |= m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::VisuallyNonEmptyLayout);
-
- if (!cancelledOutstandingEvent)
- return;
-
- if (type != SameDocumentNavigationSessionStateReplace && type != SameDocumentNavigationSessionStatePop)
- return;
-
- checkForActiveLoads();
-}
-
-void ViewGestureController::checkForActiveLoads()
-{
- if (m_webPageProxy.pageLoadState().isLoading()) {
- if (!m_swipeActiveLoadMonitoringTimer.isActive())
- m_swipeActiveLoadMonitoringTimer.startRepeating(swipeSnapshotRemovalActiveLoadMonitoringInterval);
- return;
- }
-
- m_swipeActiveLoadMonitoringTimer.stop();
- m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::SubresourceLoads);
-}
-
-ViewGestureController::SnapshotRemovalTracker::SnapshotRemovalTracker()
- : m_watchdogTimer(RunLoop::main(), this, &SnapshotRemovalTracker::watchdogTimerFired)
-{
-}
-
-String ViewGestureController::SnapshotRemovalTracker::eventsDescription(Events event)
-{
- StringBuilder description;
-
- if (event & ViewGestureController::SnapshotRemovalTracker::VisuallyNonEmptyLayout)
- description.append("VisuallyNonEmptyLayout ");
-
- if (event & ViewGestureController::SnapshotRemovalTracker::RenderTreeSizeThreshold)
- description.append("RenderTreeSizeThreshold ");
-
- if (event & ViewGestureController::SnapshotRemovalTracker::RepaintAfterNavigation)
- description.append("RepaintAfterNavigation ");
-
- if (event & ViewGestureController::SnapshotRemovalTracker::MainFrameLoad)
- description.append("MainFrameLoad ");
-
- if (event & ViewGestureController::SnapshotRemovalTracker::SubresourceLoads)
- description.append("SubresourceLoads ");
-
- if (event & ViewGestureController::SnapshotRemovalTracker::ScrollPositionRestoration)
- description.append("ScrollPositionRestoration ");
-
- return description.toString();
-}
-
-
-void ViewGestureController::SnapshotRemovalTracker::log(const String& log) const
-{
-#if !LOG_DISABLED
- auto now = std::chrono::steady_clock::now();
- double millisecondsSinceStart = std::chrono::duration_cast<std::chrono::duration<double, std::milli>>(now - m_startTime).count();
-#endif
- LOG(ViewGestures, "Swipe Snapshot Removal (%0.2f ms) - %s", millisecondsSinceStart, log.utf8().data());
-}
-
-void ViewGestureController::SnapshotRemovalTracker::start(Events desiredEvents, std::function<void()> removalCallback)
-{
- m_outstandingEvents = desiredEvents;
- m_removalCallback = WTFMove(removalCallback);
- m_startTime = std::chrono::steady_clock::now();
-
- log("start");
-
- startWatchdog(swipeSnapshotRemovalWatchdogDuration);
-}
-
-void ViewGestureController::SnapshotRemovalTracker::reset()
-{
- if (m_outstandingEvents)
- log("reset; had outstanding events: " + eventsDescription(m_outstandingEvents));
- m_outstandingEvents = 0;
- m_watchdogTimer.stop();
- m_removalCallback = nullptr;
-}
-
-bool ViewGestureController::SnapshotRemovalTracker::stopWaitingForEvent(Events event, const String& logReason)
-{
- ASSERT(hasOneBitSet(event));
-
- if (!(m_outstandingEvents & event))
- return false;
-
-#if LOG_DISABLED
- UNUSED_PARAM(logReason);
-#endif
- log(logReason + eventsDescription(event));
-
- m_outstandingEvents &= ~event;
-
- fireRemovalCallbackIfPossible();
- return true;
-}
-
-bool ViewGestureController::SnapshotRemovalTracker::eventOccurred(Events event)
-{
- return stopWaitingForEvent(event, "outstanding event occurred: ");
-}
-
-bool ViewGestureController::SnapshotRemovalTracker::cancelOutstandingEvent(Events event)
-{
- return stopWaitingForEvent(event, "wait for event cancelled: ");
-}
-
-void ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackIfPossible()
-{
- if (m_outstandingEvents) {
- log("deferring removal; had outstanding events: " + eventsDescription(m_outstandingEvents));
- return;
- }
-
- fireRemovalCallbackImmediately();
-}
-
-void ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackImmediately()
-{
- m_watchdogTimer.stop();
-
- auto removalCallback = WTFMove(m_removalCallback);
- if (removalCallback) {
- log("removing snapshot");
- reset();
- removalCallback();
- }
-}
-
-void ViewGestureController::SnapshotRemovalTracker::watchdogTimerFired()
-{
- log("watchdog timer fired");
- fireRemovalCallbackImmediately();
-}
-
-void ViewGestureController::SnapshotRemovalTracker::startWatchdog(std::chrono::seconds duration)
-{
- log(String::format("(re)started watchdog timer for %lld seconds", duration.count()));
- m_watchdogTimer.startOneShot(duration.count());
-}
-
-} // namespace WebKit
Deleted: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (206935 => 206936)
--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2016-10-07 21:11:59 UTC (rev 206936)
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2013, 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 ViewGestureController_h
-#define ViewGestureController_h
-
-#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>
-
-// 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;
-#else
-OBJC_CLASS CAGradientLayer;
-OBJC_CLASS NSEvent;
-OBJC_CLASS NSView;
-OBJC_CLASS WKSwipeCancellationTracker;
-#endif
-
-namespace WebCore {
-class IOSurface;
-}
-
-namespace WebKit {
-
-class ViewSnapshot;
-class WebBackForwardListItem;
-class WebPageProxy;
-
-class ViewGestureController : private IPC::MessageReceiver {
- WTF_MAKE_NONCOPYABLE(ViewGestureController);
-public:
- ViewGestureController(WebPageProxy&);
- ~ViewGestureController();
- void platformTeardown();
-
- enum class ViewGestureType {
- None,
-#if PLATFORM(MAC)
- Magnification,
- SmartMagnification,
-#endif
- Swipe
- };
-
- enum class SwipeDirection {
- Back,
- Forward
- };
-
-#if PLATFORM(MAC)
- double magnification() const;
-
- void handleMagnificationGestureEvent(NSEvent *, WebCore::FloatPoint origin);
-
- bool hasActiveMagnificationGesture() const { return m_activeGestureType == ViewGestureType::Magnification; }
-
- void handleSmartMagnificationGesture(WebCore::FloatPoint origin);
-
- bool handleScrollWheelEvent(NSEvent *);
- void wheelEventWasNotHandledByWebCore(NSEvent *event) { m_pendingSwipeTracker.eventWasNotHandledByWebCore(event); }
- void gestureEventWasNotHandledByWebCore(NSEvent *, WebCore::FloatPoint origin);
-
- void setCustomSwipeViews(Vector<RetainPtr<NSView>> views) { m_customSwipeViews = WTFMove(views); }
- void setCustomSwipeViewsTopContentInset(float topContentInset) { m_customSwipeViewsTopContentInset = topContentInset; }
- WebCore::FloatRect windowRelativeBoundsForCustomSwipeViews() const;
- void setDidMoveSwipeSnapshotCallback(BlockPtr<void (CGRect)>&& callback) { m_didMoveSwipeSnapshotCallback = WTFMove(callback); }
-
- bool shouldIgnorePinnedState() { return m_pendingSwipeTracker.shouldIgnorePinnedState(); }
- void setShouldIgnorePinnedState(bool ignore) { m_pendingSwipeTracker.setShouldIgnorePinnedState(ignore); }
-
- 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
-
- WebCore::Color backgroundColorForCurrentSnapshot() const { return m_backgroundColorForCurrentSnapshot; }
-
- void didFinishLoadForMainFrame() { didReachMainFrameLoadTerminalState(); }
- void didFailLoadForMainFrame() { didReachMainFrameLoadTerminalState(); }
- void didFirstVisuallyNonEmptyLayoutForMainFrame();
- void didRepaintAfterNavigation();
- void didHitRenderTreeSizeThreshold();
- void didRestoreScrollPosition();
- void didReachMainFrameLoadTerminalState();
- void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType);
-
- void checkForActiveLoads();
-
- void removeSwipeSnapshot();
-
-private:
- // IPC::MessageReceiver.
- void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
-
- static ViewGestureController* gestureControllerForPage(uint64_t);
-
- class SnapshotRemovalTracker {
- public:
- enum Event : uint8_t {
- VisuallyNonEmptyLayout = 1 << 0,
- RenderTreeSizeThreshold = 1 << 1,
- RepaintAfterNavigation = 1 << 2,
- MainFrameLoad = 1 << 3,
- SubresourceLoads = 1 << 4,
- ScrollPositionRestoration = 1 << 5
- };
- typedef uint8_t Events;
-
- SnapshotRemovalTracker();
-
- void start(Events, std::function<void()>);
- void reset();
-
- bool eventOccurred(Events);
- bool cancelOutstandingEvent(Events);
-
- void startWatchdog(std::chrono::seconds);
-
- private:
- static String eventsDescription(Events);
- void log(const String&) const;
-
- void fireRemovalCallbackImmediately();
- void fireRemovalCallbackIfPossible();
- void watchdogTimerFired();
-
- bool stopWaitingForEvent(Events, const String& logReason);
-
- Events m_outstandingEvents { 0 };
- std::function<void()> m_removalCallback;
- std::chrono::steady_clock::time_point m_startTime;
-
- RunLoop::Timer<SnapshotRemovalTracker> m_watchdogTimer;
- };
-
-#if PLATFORM(MAC)
- // Message handlers.
- void didCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture);
- void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
-
- void endMagnificationGesture();
-
- WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
-
- void trackSwipeGesture(NSEvent *, SwipeDirection);
- void beginSwipeGesture(WebBackForwardListItem* targetItem, SwipeDirection);
- void handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection);
- void willEndSwipeGesture(WebBackForwardListItem& targetItem, bool cancelled);
- void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
- bool shouldUseSnapshotForSize(ViewSnapshot&, WebCore::FloatSize swipeLayerSize, float topContentInset);
-
- CALayer *determineSnapshotLayerParent() const;
- CALayer *determineLayerAdjacentToSnapshotForParent(SwipeDirection, CALayer *snapshotLayerParent) const;
- void applyDebuggingPropertiesToSwipeViews();
- void didMoveSwipeSnapshotLayer();
-
- void forceRepaintIfNeeded();
-
- class PendingSwipeTracker {
- public:
- PendingSwipeTracker(WebPageProxy&, std::function<void(NSEvent *, SwipeDirection)> trackSwipeCallback);
- bool handleEvent(NSEvent *);
- void eventWasNotHandledByWebCore(NSEvent *);
-
- void reset(const char* resetReasonForLogging);
-
- bool shouldIgnorePinnedState() { return m_shouldIgnorePinnedState; }
- void setShouldIgnorePinnedState(bool ignore) { m_shouldIgnorePinnedState = ignore; }
-
- private:
- bool tryToStartSwipe(NSEvent *);
- bool scrollEventCanBecomeSwipe(NSEvent *, SwipeDirection&);
-
- enum class State {
- None,
- WaitingForWebCore,
- InsufficientMagnitude
- };
-
- State m_state { State::None };
- SwipeDirection m_direction;
- WebCore::FloatSize m_cumulativeDelta;
-
- bool m_shouldIgnorePinnedState { false };
-
- std::function<void(NSEvent *, SwipeDirection)> m_trackSwipeCallback;
- WebPageProxy& m_webPageProxy;
- };
-#endif
-
- WebPageProxy& m_webPageProxy;
- ViewGestureType m_activeGestureType { ViewGestureType::None };
-
- RunLoop::Timer<ViewGestureController> m_swipeActiveLoadMonitoringTimer;
-
- WebCore::Color m_backgroundColorForCurrentSnapshot;
-
-#if PLATFORM(MAC)
- RefPtr<ViewSnapshot> m_currentSwipeSnapshot;
-
- double m_magnification;
- WebCore::FloatPoint m_magnificationOrigin;
-
- WebCore::FloatRect m_lastSmartMagnificationUnscaledTargetRect;
- bool m_lastMagnificationGestureWasSmartMagnification { false };
- WebCore::FloatPoint m_lastSmartMagnificationOrigin;
-
- WebCore::FloatRect m_visibleContentRect;
- bool m_visibleContentRectIsValid { false };
- bool m_frameHandlesMagnificationGesture { false };
-
- RetainPtr<WKSwipeCancellationTracker> m_swipeCancellationTracker;
- RetainPtr<CALayer> m_swipeLayer;
- RetainPtr<CALayer> m_swipeSnapshotLayer;
- RetainPtr<CAGradientLayer> m_swipeShadowLayer;
- RetainPtr<CALayer> m_swipeDimmingLayer;
- Vector<RetainPtr<CALayer>> m_currentSwipeLiveLayers;
-
- Vector<RetainPtr<NSView>> m_customSwipeViews;
- float m_customSwipeViewsTopContentInset { 0 };
- WebCore::FloatRect m_currentSwipeCustomViewBounds;
-
- PendingSwipeTracker m_pendingSwipeTracker;
-
- BlockPtr<void (CGRect)> m_didMoveSwipeSnapshotCallback;
-
- bool m_hasOutstandingRepaintRequest { false };
-#else
- UIView *m_liveSwipeView { nullptr };
- RetainPtr<UIView> m_liveSwipeViewClippingView;
- RetainPtr<UIView> m_snapshotView;
- RetainPtr<UIView> m_transitionContainerView;
- 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
-
- SnapshotRemovalTracker m_snapshotRemovalTracker;
-};
-
-} // namespace WebKit
-
-#endif // ViewGestureController_h
Deleted: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in (206935 => 206936)
--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.messages.in 2016-10-07 21:11:59 UTC (rev 206936)
@@ -1,29 +0,0 @@
-# Copyright (C) 2013 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.
-
-messages -> ViewGestureController {
-#if PLATFORM(MAC)
- DidCollectGeometryForMagnificationGesture(WebCore::FloatRect visibleContentBounds, bool frameHandlesMagnificationGesture)
- DidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale)
- DidHitRenderTreeSizeThreshold()
-#endif
-}
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (206935 => 206936)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-07 21:06:56 UTC (rev 206935)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-07 21:11:59 UTC (rev 206936)
@@ -4807,6 +4807,9 @@
1AFE436318B6C081009C7A48 /* UIDelegate.mm */,
E4E8648E1B1673FB00C82F40 /* VersionChecks.h */,
E4E8648F1B1673FB00C82F40 /* VersionChecks.mm */,
+ 2DAF4FFA1B636181006013D6 /* ViewGestureController.cpp */,
+ 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */,
+ 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */,
9986BDD61CA9A222004800AA /* WebAutomationSessionCocoa.mm */,
1AC0273E196622D600C12B75 /* WebPageProxyCocoa.mm */,
7C4694CB1A4B510A00AD5845 /* WebPasteboardProxyCocoa.mm */,
@@ -6126,7 +6129,6 @@
4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */,
4A410F3B19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.cpp */,
4A410F3C19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.h */,
- 2DAF4FFA1B636181006013D6 /* ViewGestureController.cpp */,
1A0F29E1120B44420053D1B9 /* VisitedLinkStore.cpp */,
1A0F29E2120B44420053D1B9 /* VisitedLinkStore.h */,
1A60224918C16B0800C3E8C9 /* VisitedLinkStore.messages.in */,
@@ -6921,8 +6923,6 @@
1AA417ED12C00D87002BE67B /* TextCheckerMac.mm */,
1AF05D8514688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h */,
1AF05D8414688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.mm */,
- 2D125C5C1857EA05003BA3CB /* ViewGestureController.h */,
- 2D1B5D5A18586599006C6596 /* ViewGestureController.messages.in */,
2D125C5D1857EA05003BA3CB /* ViewGestureControllerMac.mm */,
2D6CD117189058A500E5A4A0 /* ViewSnapshotStore.h */,
2D6CD118189058A500E5A4A0 /* ViewSnapshotStore.mm */,