Changeset 171034 in webkit


Ignore:
Timestamp:
Jul 12, 2014 4:32:39 PM (10 years ago)
Author:
mitz@apple.com
Message:

<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.

Location:
trunk/Source/WebKit2
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r171030 r171034  
     12014-07-12  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/16020380> [Cocoa] Inform the client when back-forward navigation gestures begin and end
     4        https://bugs.webkit.org/show_bug.cgi?id=134853
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h: Declared new WKNavigationDelegate
     9        methods.
     10
     11        * UIProcess/API/Cocoa/WKWebView.mm:
     12        (-[WKWebView _isShowingNavigationGestureSnapshot]): Added this getter.
     13
     14        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new property
     15        _isShowingNavigationGestureSnapshot.
     16
     17        * UIProcess/Cocoa/NavigationState.h:
     18        * UIProcess/Cocoa/NavigationState.mm:
     19        (WebKit::NavigationState::setNavigationDelegate): Initialize new flags in
     20        m_navigationDelegateMethods.
     21        (WebKit::NavigationState::navigationGestureDidBegin): Added. Calls the new
     22        WKNavigationDelegate method.
     23        (WebKit::NavigationState::navigationGestureWillEnd): Ditto.
     24        (WebKit::NavigationState::navigationGestureDidEnd): Ditto.
     25
     26        * UIProcess/PageClient.h: Declared new client functions.
     27
     28        * UIProcess/WebPageProxy.cpp:
     29        (WebKit::WebPageProxy::WebPageProxy): Initialize new member variable.
     30        (WebKit::WebPageProxy::navigationGestureDidBegin): Set m_isShowingNavigationGestureSnapshot
     31        and call the new client function.
     32        (WebKit::WebPageProxy::navigationGestureWillEnd): Call the new client function.
     33        (WebKit::WebPageProxy::navigationGestureDidEnd): Ditto.
     34        (WebKit::WebPageProxy::navigationGestureSnapshotWasRemoved): Clear
     35        m_isShowingNavigationGestureSnapshot.
     36        * UIProcess/WebPageProxy.h:
     37        (WebKit::WebPageProxy::isShowingNavigationGestureSnapshot): Added this getter.
     38
     39        * UIProcess/ios/PageClientImplIOS.h: Declared overrides of new client functions.
     40        * UIProcess/ios/PageClientImplIOS.mm:
     41        (WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
     42        NavigationState function.
     43        (WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
     44        (WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.
     45
     46        * UIProcess/ios/ViewGestureControllerIOS.mm:
     47        (WebKit::ViewGestureController::beginSwipeGesture): Added calls to
     48        WebPageProxy::navigationGestureDidBegin and WebPageProxy::navigationGestureWillEnd.
     49        (WebKit::ViewGestureController::endSwipeGesture): Added calls to
     50        WebPageProxy::navigationGestureDidEnd.
     51        (WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
     52        WebPageProxy::navigationGestureSnapshotWasRemoved.
     53
     54        * UIProcess/mac/PageClientImpl.h: Declared overrides of new client functions.
     55        * UIProcess/mac/PageClientImpl.mm:
     56        (WebKit::PageClientImpl::navigationGestureDidBegin): Override that calls the new
     57        NavigationState function.
     58        (WebKit::PageClientImpl::navigationGestureWillEnd): Ditto.
     59        (WebKit::PageClientImpl::navigationGestureDidEnd): Ditto.
     60
     61        * UIProcess/mac/ViewGestureControllerMac.mm:
     62        (WebKit::ViewGestureController::beginSwipeGesture): Added call to
     63        WebPageProxy::navigationGestureDidBegin.
     64        (WebKit::ViewGestureController::endSwipeGesture): Added calls to
     65        WebPageProxy::navigationGestureDidEnd.
     66        (WebKit::ViewGestureController::removeSwipeSnapshot): Added call to
     67        WebPageProxy::navigationGestureSnapshotWasRemoved.
     68
    1692014-07-12  Oliver Hunt  <oliver@apple.com>
    270
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h

    r171027 r171034  
    6060- (NSData *)_webCryptoMasterKeyForWebView:(WKWebView *)webView;
    6161
     62- (void)_webViewDidBeginNavigationGesture:(WKWebView *)webView;
     63// Item is nil if the gesture ended without navigation.
     64- (void)_webViewDidEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
     65// Only called if how the gesture will end (with or without navigation) is known before it ends.
     66- (void)_webViewWillEndNavigationGesture:(WKWebView *)webView withNavigationToBackForwardListItem:(WKBackForwardListItem *)item;
     67
     68
    6269#if TARGET_OS_IPHONE
    6370- (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti;
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r170982 r171034  
    19811981}
    19821982
     1983- (BOOL)_isShowingNavigationGestureSnapshot
     1984{
     1985    return _page->isShowingNavigationGestureSnapshot();
     1986}
     1987
    19831988#pragma mark iOS-specific methods
    19841989
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r170856 r171034  
    102102@property (nonatomic, readonly) BOOL _networkRequestsInProgress;
    103103
     104@property (nonatomic, readonly, getter=_isShowingNavigationGestureSnapshot) BOOL _showingNavigationGestureSnapshot;
     105
    104106- (void)_close;
    105107
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h

    r171027 r171034  
    7474    void didPerformServerRedirect(const WTF::String& sourceURL, const WTF::String& destinationURL);
    7575    void didUpdateHistoryTitle(const WTF::String& title, const WTF::String& url);
     76
     77    // Called by the page client.
     78    void navigationGestureDidBegin();
     79    void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
     80    void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
    7681
    7782private:
     
    159164        bool webViewWebProcessDidCrash : 1;
    160165        bool webCryptoMasterKeyForWebView : 1;
     166        bool webViewDidBeginNavigationGesture : 1;
     167        bool webViewWillEndNavigationGestureWithNavigationToBackForwardListItem : 1;
     168        bool webViewDidEndNavigationGestureWithNavigationToBackForwardListItem : 1;
    161169#if USE(QUICK_LOOK)
    162170        bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

    r171027 r171034  
    138138    m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
    139139    m_navigationDelegateMethods.webCryptoMasterKeyForWebView = [delegate respondsToSelector:@selector(_webCryptoMasterKeyForWebView:)];
     140    m_navigationDelegateMethods.webViewDidBeginNavigationGesture = [delegate respondsToSelector:@selector(_webViewDidBeginNavigationGesture:)];
     141    m_navigationDelegateMethods.webViewWillEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewWillEndNavigationGesture:withNavigationToBackForwardListItem:)];
     142    m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem = [delegate respondsToSelector:@selector(_webViewDidEndNavigationGesture:withNavigationToBackForwardListItem:)];
    140143#if USE(QUICK_LOOK)
    141144    m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:)];
     
    250253
    251254    [historyDelegate _webView:m_webView didUpdateHistoryTitle:title forURL:[NSURL _web_URLWithWTFString:url]];
     255}
     256
     257void NavigationState::navigationGestureDidBegin()
     258{
     259    if (!m_navigationDelegateMethods.webViewDidBeginNavigationGesture)
     260        return;
     261
     262    auto navigationDelegate = m_navigationDelegate.get();
     263    if (!navigationDelegate)
     264        return;
     265
     266    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidBeginNavigationGesture:m_webView];
     267}
     268
     269void NavigationState::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
     270{
     271    if (!m_navigationDelegateMethods.webViewWillEndNavigationGestureWithNavigationToBackForwardListItem)
     272        return;
     273
     274    auto navigationDelegate = m_navigationDelegate.get();
     275    if (!navigationDelegate)
     276        return;
     277
     278    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewWillEndNavigationGesture:m_webView withNavigationToBackForwardListItem:willNavigate ? wrapper(item) : nil];
     279}
     280
     281void NavigationState::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
     282{
     283    if (!m_navigationDelegateMethods.webViewDidEndNavigationGestureWithNavigationToBackForwardListItem)
     284        return;
     285
     286    auto navigationDelegate = m_navigationDelegate.get();
     287    if (!navigationDelegate)
     288        return;
     289
     290    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate) _webViewDidEndNavigationGesture:m_webView withNavigationToBackForwardListItem:willNavigate ? wrapper(item) : nil];
    252291}
    253292
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r170981 r171034  
    295295    // Custom representations.
    296296    virtual void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) = 0;
     297
     298    virtual void navigationGestureDidBegin() = 0;
     299    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) = 0;
     300    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) = 0;
    297301};
    298302
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r171027 r171034  
    356356    , m_backgroundExtendsBeyondPage(false)
    357357    , m_shouldRecordNavigationSnapshots(false)
     358    , m_isShowingNavigationGestureSnapshot(false)
    358359    , m_pageCount(0)
    359360    , m_renderTreeSize(0)
     
    51275128}
    51285129
     5130void WebPageProxy::navigationGestureDidBegin()
     5131{
     5132    m_isShowingNavigationGestureSnapshot = true;
     5133    m_pageClient.navigationGestureDidBegin();
     5134}
     5135
     5136void WebPageProxy::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
     5137{
     5138    m_pageClient.navigationGestureWillEnd(willNavigate, item);
     5139}
     5140
     5141void WebPageProxy::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
     5142{
     5143    m_pageClient.navigationGestureDidEnd(willNavigate, item);
     5144}
     5145
     5146void WebPageProxy::navigationGestureSnapshotWasRemoved()
     5147{
     5148    m_isShowingNavigationGestureSnapshot = false;
     5149}
     5150
    51295151} // namespace WebKit
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r171027 r171034  
    898898    void takeSnapshot(WebCore::IntRect, WebCore::IntSize bitmapSize, SnapshotOptions, std::function<void (const ShareableBitmap::Handle&, CallbackBase::Error)>);
    899899
     900    void navigationGestureDidBegin();
     901    void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
     902    void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&);
     903    void navigationGestureSnapshotWasRemoved();
     904
     905    bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
     906
    900907private:
    901908    WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     
    14861493
    14871494    bool m_shouldRecordNavigationSnapshots;
     1495    bool m_isShowingNavigationGestureSnapshot;
    14881496
    14891497    unsigned m_pageCount;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r170981 r171034  
    168168    virtual Vector<String> mimeTypesWithCustomContentProviders() override;
    169169
     170    virtual void navigationGestureDidBegin() override;
     171    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
     172    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
     173
    170174    WKContentView *m_contentView;
    171175    WKWebView *m_webView;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r170981 r171034  
    3333#import "DownloadProxy.h"
    3434#import "FindIndicator.h"
     35#import "InteractionInformationAtPosition.h"
    3536#import "NativeWebKeyboardEvent.h"
    36 #import "InteractionInformationAtPosition.h"
     37#import "NavigationState.h"
    3738#import "ViewSnapshotStore.h"
    3839#import "WKContentView.h"
     
    652653}
    653654
     655void PageClientImpl::navigationGestureDidBegin()
     656{
     657    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
     658}
     659
     660void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
     661{
     662    NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
     663}
     664
     665void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
     666{
     667    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
     668}
     669
    654670} // namespace WebKit
    655671
  • trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm

    r170974 r171034  
    158158    if (m_activeGestureType != ViewGestureType::None)
    159159        return;
    160    
     160
     161    m_webPageProxy.navigationGestureDidBegin();
     162
    161163    ViewSnapshotStore::shared().recordSnapshot(m_webPageProxy);
    162164
     
    210212    [transitionContext _setInteractor:transition];
    211213    [transitionContext _setTransitionIsInFlight:YES];
     214    [transitionContext _setInteractiveUpdateHandler:^(BOOL finish, CGFloat percent, BOOL transitionCompleted, _UIViewControllerTransitionContext *) {
     215        if (finish)
     216            m_webPageProxy.navigationGestureWillEnd(transitionCompleted, *targetItem);
     217    }];
    212218    [transitionContext _setCompletionHandler:^(_UIViewControllerTransitionContext *context, BOOL didComplete) { endSwipeGesture(targetItem, context, !didComplete); }];
    213219    [transitionContext _setInteractiveUpdateHandler:^(BOOL, CGFloat, BOOL, _UIViewControllerTransitionContext *) { }];
     
    241247    if (cancelled) {
    242248        removeSwipeSnapshot();
     249        m_webPageProxy.navigationGestureDidEnd(false, *targetItem);
    243250        return;
    244251    }
     
    252259    // displaying the destination item's snapshot.
    253260    ViewSnapshotStore::shared().disableSnapshotting();
     261
     262    m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
    254263    m_webPageProxy.goToBackForwardItem(targetItem);
    255264    ViewSnapshotStore::shared().enableSnapshotting();
     
    315324    m_snapshotRemovalTargetRenderTreeSize = 0;
    316325    m_activeGestureType = ViewGestureType::None;
     326
     327    m_webPageProxy.navigationGestureSnapshotWasRemoved();
    317328}
    318329
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r170974 r171034  
    174174#endif
    175175
     176    virtual void navigationGestureDidBegin() override;
     177    virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
     178    virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
     179
    176180    NSView *activeView() const;
    177181
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r170974 r171034  
    2929#if PLATFORM(MAC)
    3030
    31 #import "_WKDownloadInternal.h"
    3231#import "AttributedString.h"
    3332#import "ColorSpaceData.h"
     
    3837#import "NativeWebKeyboardEvent.h"
    3938#import "NativeWebWheelEvent.h"
     39#import "NavigationState.h"
    4040#import "StringUtilities.h"
    4141#import "ViewSnapshotStore.h"
     
    4444#import "WKStringCF.h"
    4545#import "WKViewInternal.h"
     46#import "WKWebViewInternal.h"
    4647#import "WebColorPickerMac.h"
    4748#import "WebContextMenuProxyMac.h"
     
    4950#import "WebPopupMenuProxyMac.h"
    5051#import "WindowServerConnection.h"
     52#import "_WKDownloadInternal.h"
    5153#import "_WKThumbnailView.h"
    5254#import <WebCore/AlternativeTextUIController.h>
     
    686688#endif // ENABLE(FULLSCREEN_API)
    687689
     690void PageClientImpl::navigationGestureDidBegin()
     691{
     692    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
     693}
     694
     695void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
     696{
     697    NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
     698}
     699
     700void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
     701{
     702    NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
     703}
     704
    688705} // namespace WebKit
    689706
  • trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm

    r170974 r171034  
    497497    ASSERT(m_currentSwipeLiveLayers.isEmpty());
    498498
     499    m_webPageProxy.navigationGestureDidBegin();
     500
    499501    m_activeGestureType = ViewGestureType::Swipe;
    500502
     
    627629    if (cancelled) {
    628630        removeSwipeSnapshot();
     631        m_webPageProxy.navigationGestureDidEnd(false, *targetItem);
    629632        return;
    630633    }
     
    640643    // displaying the destination item's snapshot.
    641644    ViewSnapshotStore::shared().disableSnapshotting();
     645    m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
    642646    m_webPageProxy.goToBackForwardItem(targetItem);
    643647    ViewSnapshotStore::shared().enableSnapshotting();
     
    686690
    687691    m_activeGestureType = ViewGestureType::None;
     692
     693    m_webPageProxy.navigationGestureSnapshotWasRemoved();
    688694}
    689695
Note: See TracChangeset for help on using the changeset viewer.