<rdar://problem/16020380> [Cocoa] Inform the client when back-forward navigation...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jul 2014 23:32:39 +0000 (23:32 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Jul 2014 23:32:39 +0000 (23:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134853

Reviewed by Sam Weinig.

* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Declared new WKNavigationDelegate
methods.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _isShowingNavigationGestureSnapshot]): Added this getter.

* UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new property
_isShowingNavigationGestureSnapshot.

* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate): Initialize new flags in
m_navigationDelegateMethods.
(WebKit::NavigationState::navigationGestureDidBegin): Added. Calls the new
WKNavigationDelegate method.
(WebKit::NavigationState::navigationGestureWillEnd): Ditto.
(WebKit::NavigationState::navigationGestureDidEnd): Ditto.

* UIProcess/PageClient.h: Declared new client functions.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Initialize new member variable.
(WebKit::WebPageProxy::navigationGestureDidBegin): Set m_isShowingNavigationGestureSnapshot
and call the new client function.
(WebKit::WebPageProxy::navigationGestureWillEnd): Call the new client function.
(WebKit::WebPageProxy::navigationGestureDidEnd): Ditto.
(WebKit::WebPageProxy::navigationGestureSnapshotWasRemoved): Clear
m_isShowingNavigationGestureSnapshot.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::isShowingNavigationGestureSnapshot): Added this getter.

* UIProcess/ios/PageClientImplIOS.h: Declared overrides of new client functions.
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
NavigationState function.
(WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
(WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.

* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture): Added calls to
WebPageProxy::navigationGestureDidBegin and WebPageProxy::navigationGestureWillEnd.
(WebKit::ViewGestureController::endSwipeGesture): Added calls to
WebPageProxy::navigationGestureDidEnd.
(WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
WebPageProxy::navigationGestureSnapshotWasRemoved.

* UIProcess/mac/PageClientImpl.h: Declared overrides of new client functions.
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
NavigationState function.
(WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
(WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.

* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::beginSwipeGesture): Added call to
WebPageProxy::navigationGestureDidBegin.
(WebKit::ViewGestureController::endSwipeGesture): Added calls to
WebPageProxy::navigationGestureDidEnd.
(WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
WebPageProxy::navigationGestureSnapshotWasRemoved.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.mm
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm

index ceabb29..ac62553 100644 (file)
@@ -1,3 +1,71 @@
+2014-07-12  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/16020380> [Cocoa] Inform the client when back-forward navigation gestures begin and end
+        https://bugs.webkit.org/show_bug.cgi?id=134853
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Declared new WKNavigationDelegate
+        methods.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _isShowingNavigationGestureSnapshot]): Added this getter.
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new property
+        _isShowingNavigationGestureSnapshot.
+
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate): Initialize new flags in
+        m_navigationDelegateMethods.
+        (WebKit::NavigationState::navigationGestureDidBegin): Added. Calls the new
+        WKNavigationDelegate method.
+        (WebKit::NavigationState::navigationGestureWillEnd): Ditto.
+        (WebKit::NavigationState::navigationGestureDidEnd): Ditto.
+
+        * UIProcess/PageClient.h: Declared new client functions.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy): Initialize new member variable.
+        (WebKit::WebPageProxy::navigationGestureDidBegin): Set m_isShowingNavigationGestureSnapshot
+        and call the new client function.
+        (WebKit::WebPageProxy::navigationGestureWillEnd): Call the new client function.
+        (WebKit::WebPageProxy::navigationGestureDidEnd): Ditto.
+        (WebKit::WebPageProxy::navigationGestureSnapshotWasRemoved): Clear
+        m_isShowingNavigationGestureSnapshot.
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::isShowingNavigationGestureSnapshot): Added this getter.
+
+        * UIProcess/ios/PageClientImplIOS.h: Declared overrides of new client functions.
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
+        NavigationState function.
+        (WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
+        (WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.
+
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::beginSwipeGesture): Added calls to
+        WebPageProxy::navigationGestureDidBegin and WebPageProxy::navigationGestureWillEnd.
+        (WebKit::ViewGestureController::endSwipeGesture): Added calls to
+        WebPageProxy::navigationGestureDidEnd.
+        (WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
+        WebPageProxy::navigationGestureSnapshotWasRemoved.
+
+        * UIProcess/mac/PageClientImpl.h: Declared overrides of new client functions.
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
+        NavigationState function.
+        (WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
+        (WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.
+
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::beginSwipeGesture): Added call to
+        WebPageProxy::navigationGestureDidBegin.
+        (WebKit::ViewGestureController::endSwipeGesture): Added calls to
+        WebPageProxy::navigationGestureDidEnd.
+        (WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
+        WebPageProxy::navigationGestureSnapshotWasRemoved.
+
 2014-07-12  Oliver Hunt  <oliver@apple.com>
 
         Fix typo in prior patch
index c51ba9e..641ce83 100644 (file)
@@ -59,6 +59,13 @@ typedef NS_ENUM(NSInteger, _WKSameDocumentNavigationType) {
 
 - (NSData *)_webCryptoMasterKeyForWebView:(WKWebView *)webView;
 
+- (void)_webViewDidBeginNavigationGesture:(WKWebView *)webView;
+// Item is nil if the gesture ended without navigation.
+- (void)_webViewDidEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
+// Only called if how the gesture will end (with or without navigation) is known before it ends.
+- (void)_webViewWillEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
+
+
 #if TARGET_OS_IPHONE
 - (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti;
 - (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData;
index e56c0b0..7718de7 100644 (file)
@@ -1980,6 +1980,11 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     return NO;
 }
 
+- (BOOL)_isShowingNavigationGestureSnapshot
+{
+    return _page->isShowingNavigationGestureSnapshot();
+}
+
 #pragma mark iOS-specific methods
 
 #if PLATFORM(IOS)
index 23e80e7..c7c7e7d 100644 (file)
@@ -101,6 +101,8 @@ typedef NS_OPTIONS(NSUInteger, _WKFindOptions) {
 
 @property (nonatomic, readonly) BOOL _networkRequestsInProgress;
 
+@property (nonatomic, readonly, getter=_isShowingNavigationGestureSnapshot) BOOL _showingNavigationGestureSnapshot;
+
 - (void)_close;
 
 #if TARGET_OS_IPHONE
index a22b8d2..9fe2ba8 100644 (file)
@@ -74,6 +74,11 @@ public:
     void didPerformServerRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL);
     void didUpdateHistoryTitle(const WTF::String& title, const WTF::String& url);
 
+    // Called by the page client.
+    void navigationGestureDidBegin();
+    void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
+    void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
+
 private:
     class PolicyClient : public API::PolicyClient {
     public:
@@ -158,6 +163,9 @@ private:
         bool webViewDidReceiveAuthenticationChallenge : 1;
         bool webViewWebProcessDidCrash : 1;
         bool webCryptoMasterKeyForWebView : 1;
+        bool webViewDidBeginNavigationGesture : 1;
+        bool webViewWillEndNavigationGestureWithNavigationToBackForwardListItem : 1;
+        bool webViewDidEndNavigationGestureWithNavigationToBackForwardListItem : 1;
 #if USE(QUICK_LOOK)
         bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
         bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;
index 45e7353..44fc16b 100644 (file)
@@ -137,6 +137,9 @@ void NavigationState::setNavigationDelegate(id <WKNavigationDelegate> delegate)
     m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge = [delegate respondsToSelector:@selector(_webView:didReceiveAuthenticationChallenge:)];
     m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
     m_navigationDelegateMethods.webCryptoMasterKeyForWebView = [delegate respondsToSelector:@selector(_webCryptoMasterKeyForWebView:)];
+    m_navigationDelegateMethods.webViewDidBeginNavigationGesture = [delegate respondsToSelector:@selector(_webViewDidBeginNavigationGesture:)];
+    m_navigationDelegateMethods.webViewWillEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewWillEndNavigationGesture:withNavigationToBackForwardListItem:)];
+    m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewDidEndNavigationGesture:withNavigationToBackForwardListItem:)];
 #if USE(QUICK_LOOK)
     m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:)];
     m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didFinishLoadForQuickLookDocumentInMainFrame:)];
@@ -251,6 +254,42 @@ void NavigationState::didUpdateHistoryTitle(const WTF::String& title, const WTF:
     [historyDelegate _webView:m_webView didUpdateHistoryTitle:title forURL:[NSURL _web_URLWithWTFString:url]];
 }
 
+void NavigationState::navigationGestureDidBegin()
+{
+    if (!m_navigationDelegateMethods.webViewDidBeginNavigationGesture)
+        return;
+
+    auto navigationDelegate = m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidBeginNavigationGesture:m_webView];
+}
+
+void NavigationState::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    if (!m_navigationDelegateMethods.webViewWillEndNavigationGestureWithNavigationToBackForwardListItem)
+        return;
+
+    auto navigationDelegate = m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewWillEndNavigationGesture:m_webView withNavigationToBackForwardListItem:willNavigate ? wrapper(item) : nil];
+}
+
+void NavigationState::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    if (!m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem)
+        return;
+
+    auto navigationDelegate = m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidEndNavigationGesture:m_webView withNavigationToBackForwardListItem:willNavigate ? wrapper(item) : nil];
+}
+
 NavigationState::PolicyClient::PolicyClient(NavigationState& navigationState)
     : m_navigationState(navigationState)
 {
index b08f690..9cfa5fa 100644 (file)
@@ -294,6 +294,10 @@ public:
 
     // Custom representations.
     virtual void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) = 0;
+
+    virtual void navigationGestureDidBegin() = 0;
+    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) = 0;
+    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) = 0;
 };
 
 } // namespace WebKit
index bb60f32..a69be6e 100644 (file)
@@ -355,6 +355,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_enableHorizontalRubberBanding(true)
     , m_backgroundExtendsBeyondPage(false)
     , m_shouldRecordNavigationSnapshots(false)
+    , m_isShowingNavigationGestureSnapshot(false)
     , m_pageCount(0)
     , m_renderTreeSize(0)
     , m_shouldSendEventsSynchronously(false)
@@ -5126,4 +5127,25 @@ void WebPageProxy::takeSnapshot(IntRect rect, IntSize bitmapSize, SnapshotOption
     m_process->send(Messages::WebPage::TakeSnapshot(rect, bitmapSize, options, callbackID), m_pageID);
 }
 
+void WebPageProxy::navigationGestureDidBegin()
+{
+    m_isShowingNavigationGestureSnapshot = true;
+    m_pageClient.navigationGestureDidBegin();
+}
+
+void WebPageProxy::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    m_pageClient.navigationGestureWillEnd(willNavigate, item);
+}
+
+void WebPageProxy::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    m_pageClient.navigationGestureDidEnd(willNavigate, item);
+}
+
+void WebPageProxy::navigationGestureSnapshotWasRemoved()
+{
+    m_isShowingNavigationGestureSnapshot = false;
+}
+
 } // namespace WebKit
index 9393bc7..c005688 100644 (file)
@@ -897,6 +897,13 @@ public:
 
     void takeSnapshot(WebCore::IntRect, WebCore::IntSize bitmapSize, SnapshotOptions, std::function<void (const ShareableBitmap::Handle&, CallbackBase::Error)>);
 
+    void navigationGestureDidBegin();
+    void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
+    void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
+    void navigationGestureSnapshotWasRemoved();
+
+    bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     void platformInitialize();
@@ -1485,6 +1492,7 @@ private:
     bool m_backgroundExtendsBeyondPage;
 
     bool m_shouldRecordNavigationSnapshots;
+    bool m_isShowingNavigationGestureSnapshot;
 
     unsigned m_pageCount;
 
index cacff2c..f79eea6 100644 (file)
@@ -167,6 +167,10 @@ private:
 
     virtual Vector<String> mimeTypesWithCustomContentProviders() override;
 
+    virtual void navigationGestureDidBegin() override;
+    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
+    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
+
     WKContentView *m_contentView;
     WKWebView *m_webView;
     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
index e89752b..5ba4deb 100644 (file)
@@ -32,8 +32,9 @@
 #import "DataReference.h"
 #import "DownloadProxy.h"
 #import "FindIndicator.h"
-#import "NativeWebKeyboardEvent.h"
 #import "InteractionInformationAtPosition.h"
+#import "NativeWebKeyboardEvent.h"
+#import "NavigationState.h"
 #import "ViewSnapshotStore.h"
 #import "WKContentView.h"
 #import "WKContentViewInteraction.h"
@@ -651,6 +652,21 @@ Vector<String> PageClientImpl::mimeTypesWithCustomContentProviders()
     return m_webView.configuration._contentProviderRegistry._mimeTypesWithCustomContentProviders;
 }
 
+void PageClientImpl::navigationGestureDidBegin()
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
+}
+
+void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
+}
+
+void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
index 914a847..f570c72 100644 (file)
@@ -157,7 +157,9 @@ void ViewGestureController::beginSwipeGesture(_UINavigationInteractiveTransition
 {
     if (m_activeGestureType != ViewGestureType::None)
         return;
-    
+
+    m_webPageProxy.navigationGestureDidBegin();
+
     ViewSnapshotStore::shared().recordSnapshot(m_webPageProxy);
 
     WebKit::WebBackForwardListItem* targetItem = direction == SwipeDirection::Left ? m_webPageProxy.backForwardList().backItem() : m_webPageProxy.backForwardList().forwardItem();
@@ -209,6 +211,10 @@ void ViewGestureController::beginSwipeGesture(_UINavigationInteractiveTransition
     [transitionContext _setAnimator:animationController.get()];
     [transitionContext _setInteractor:transition];
     [transitionContext _setTransitionIsInFlight:YES];
+    [transitionContext _setInteractiveUpdateHandler:^(BOOL finish, CGFloat percent, BOOL transitionCompleted, _UIViewControllerTransitionContext *) {
+        if (finish)
+            m_webPageProxy.navigationGestureWillEnd(transitionCompleted, *targetItem);
+    }];
     [transitionContext _setCompletionHandler:^(_UIViewControllerTransitionContext *context, BOOL didComplete) { endSwipeGesture(targetItem, context, !didComplete); }];
     [transitionContext _setInteractiveUpdateHandler:^(BOOL, CGFloat, BOOL, _UIViewControllerTransitionContext *) { }];
 
@@ -240,6 +246,7 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
     
     if (cancelled) {
         removeSwipeSnapshot();
+        m_webPageProxy.navigationGestureDidEnd(false, *targetItem);
         return;
     }
 
@@ -251,6 +258,8 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
     // like we normally would when going back or forward, because we are
     // displaying the destination item's snapshot.
     ViewSnapshotStore::shared().disableSnapshotting();
+
+    m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
     m_webPageProxy.goToBackForwardItem(targetItem);
     ViewSnapshotStore::shared().enableSnapshotting();
 
@@ -314,6 +323,8 @@ void ViewGestureController::removeSwipeSnapshot()
     
     m_snapshotRemovalTargetRenderTreeSize = 0;
     m_activeGestureType = ViewGestureType::None;
+
+    m_webPageProxy.navigationGestureSnapshotWasRemoved();
 }
 
 } // namespace WebKit
index f57c816..5e220ed 100644 (file)
@@ -173,6 +173,10 @@ private:
     virtual void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
 #endif
 
+    virtual void navigationGestureDidBegin() override;
+    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
+    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
+
     NSView *activeView() const;
 
     WKView *m_wkView;
index e1b5a02..eed3ec6 100644 (file)
@@ -28,7 +28,6 @@
 
 #if PLATFORM(MAC)
 
-#import "_WKDownloadInternal.h"
 #import "AttributedString.h"
 #import "ColorSpaceData.h"
 #import "DataReference.h"
 #import "FindIndicator.h"
 #import "NativeWebKeyboardEvent.h"
 #import "NativeWebWheelEvent.h"
+#import "NavigationState.h"
 #import "StringUtilities.h"
 #import "ViewSnapshotStore.h"
 #import "WKAPICast.h"
 #import "WKFullScreenWindowController.h"
 #import "WKStringCF.h"
 #import "WKViewInternal.h"
+#import "WKWebViewInternal.h"
 #import "WebColorPickerMac.h"
 #import "WebContextMenuProxyMac.h"
 #import "WebEditCommandProxy.h"
 #import "WebPopupMenuProxyMac.h"
 #import "WindowServerConnection.h"
+#import "_WKDownloadInternal.h"
 #import "_WKThumbnailView.h"
 #import <WebCore/AlternativeTextUIController.h>
 #import <WebCore/BitmapImage.h>
@@ -685,6 +687,21 @@ void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntR
 
 #endif // ENABLE(FULLSCREEN_API)
 
+void PageClientImpl::navigationGestureDidBegin()
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
+}
+
+void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
+}
+
+void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
index b96a59d..9b9b197 100644 (file)
@@ -496,6 +496,8 @@ void ViewGestureController::beginSwipeGesture(WebBackForwardListItem* targetItem
 {
     ASSERT(m_currentSwipeLiveLayers.isEmpty());
 
+    m_webPageProxy.navigationGestureDidBegin();
+
     m_activeGestureType = ViewGestureType::Swipe;
 
     CALayer *rootContentLayer = m_webPageProxy.acceleratedCompositingRootLayer();
@@ -626,6 +628,7 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
 
     if (cancelled) {
         removeSwipeSnapshot();
+        m_webPageProxy.navigationGestureDidEnd(false, *targetItem);
         return;
     }
 
@@ -639,6 +642,7 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
     // like we normally would when going back or forward, because we are
     // displaying the destination item's snapshot.
     ViewSnapshotStore::shared().disableSnapshotting();
+    m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
     m_webPageProxy.goToBackForwardItem(targetItem);
     ViewSnapshotStore::shared().enableSnapshotting();
 
@@ -685,6 +689,8 @@ void ViewGestureController::removeSwipeSnapshot()
     m_currentSwipeLiveLayers.clear();
 
     m_activeGestureType = ViewGestureType::None;
+
+    m_webPageProxy.navigationGestureSnapshotWasRemoved();
 }
 
 void ViewGestureController::endActiveGesture()