Changeset 222794 in webkit


Ignore:
Timestamp:
Oct 3, 2017 11:54:11 AM (6 years ago)
Author:
achristensen@apple.com
Message:

Add ObjC SPI equivalent to WKPageLoaderClient.willGoToBackForwardListItem
https://bugs.webkit.org/show_bug.cgi?id=177825
<rdar://problem/22387505>

Reviewed by Tim Horton.

Source/WebKit:

  • UIProcess/API/APILoaderClient.h:

(API::LoaderClient::willGoToBackForwardListItem):

  • UIProcess/API/APINavigationClient.h:

(API::NavigationClient::canHandleWillGoToBackForwardListItem const):
(API::NavigationClient::willGoToBackForwardListItem):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageLoaderClient):

  • UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
  • UIProcess/Cocoa/NavigationState.h:
  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::NavigationClient::canHandleWillGoToBackForwardListItem const):
(WebKit::NavigationState::NavigationClient::willGoToBackForwardListItem):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::willGoToBackForwardListItem):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::shouldGoToHistoryItem const):

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:

(-[BackForwardDelegate _webView:willGoToBackForwardListItem:inPageCache:]):
(-[BackForwardDelegate webView:didFinishNavigation:]):
(TEST):

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r222776 r222794  
     12017-10-03  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add ObjC SPI equivalent to WKPageLoaderClient.willGoToBackForwardListItem
     4        https://bugs.webkit.org/show_bug.cgi?id=177825
     5        <rdar://problem/22387505>
     6
     7        Reviewed by Tim Horton.
     8
     9        * UIProcess/API/APILoaderClient.h:
     10        (API::LoaderClient::willGoToBackForwardListItem):
     11        * UIProcess/API/APINavigationClient.h:
     12        (API::NavigationClient::canHandleWillGoToBackForwardListItem const):
     13        (API::NavigationClient::willGoToBackForwardListItem):
     14        * UIProcess/API/C/WKPage.cpp:
     15        (WKPageSetPageLoaderClient):
     16        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
     17        * UIProcess/Cocoa/NavigationState.h:
     18        * UIProcess/Cocoa/NavigationState.mm:
     19        (WebKit::NavigationState::setNavigationDelegate):
     20        (WebKit::NavigationState::NavigationClient::canHandleWillGoToBackForwardListItem const):
     21        (WebKit::NavigationState::NavigationClient::willGoToBackForwardListItem):
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::willGoToBackForwardListItem):
     24        * UIProcess/WebPageProxy.h:
     25        * UIProcess/WebPageProxy.messages.in:
     26        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     27        (WebKit::WebFrameLoaderClient::shouldGoToHistoryItem const):
     28
    1292017-10-03  Michael Catanzaro  <mcatanzaro@igalia.com>
    230
  • trunk/Source/WebKit/UIProcess/API/APILoaderClient.h

    r206684 r222794  
    9292    virtual void didChangeBackForwardList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*, Vector<RefPtr<WebKit::WebBackForwardListItem>>) { }
    9393    virtual bool shouldKeepCurrentBackForwardListItemInList(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*) { return true; }
    94     virtual void willGoToBackForwardListItem(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem*, API::Object*) { }
     94    virtual void willGoToBackForwardListItem(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem&, API::Object*) { }
    9595
    9696    virtual void didNavigateWithNavigationData(WebKit::WebPageProxy&, const WebKit::WebNavigationDataStore&, WebKit::WebFrameProxy&) { }
  • trunk/Source/WebKit/UIProcess/API/APINavigationClient.h

    r222602 r222794  
    120120    virtual void resolveWebGLLoadPolicy(WebKit::WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const { completionHandler(WebCore::WebGLLoadPolicy::WebGLAllowCreation); }
    121121#endif
     122   
     123    virtual bool willGoToBackForwardListItem(WebKit::WebPageProxy&, WebKit::WebBackForwardListItem&, bool inPageCache, Object*) { return false; }
    122124
    123125    virtual void didBeginNavigationGesture(WebKit::WebPageProxy&) { }
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r222736 r222794  
    12311231        }
    12321232
    1233         void willGoToBackForwardListItem(WebPageProxy& page, WebBackForwardListItem* item, API::Object* userData) override
     1233        void willGoToBackForwardListItem(WebPageProxy& page, WebBackForwardListItem& item, API::Object* userData) override
    12341234        {
    12351235            if (m_client.willGoToBackForwardListItem)
    1236                 m_client.willGoToBackForwardListItem(toAPI(&page), toAPI(item), toAPI(userData), m_client.base.clientInfo);
     1236                m_client.willGoToBackForwardListItem(toAPI(&page), toAPI(&item), toAPI(userData), m_client.base.clientInfo);
    12371237        }
    12381238
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h

    r222602 r222794  
    8888- (void)_webView:(WKWebView *)webView webGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    8989- (void)_webView:(WKWebView *)webView resolveWebGLLoadPolicyForURL:(NSURL *)url decisionHandler:(void (^)(_WKWebGLLoadPolicy))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA));
     90- (void)_webView:(WKWebView *)webView willGoToBackForwardListItem:(WKBackForwardListItem *)item inPageCache:(BOOL)inPageCache WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    9091#endif
    9192
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h

    r222602 r222794  
    9292        void didStartProvisionalNavigation(WebPageProxy&, API::Navigation*, API::Object*) override;
    9393        void didReceiveServerRedirectForProvisionalNavigation(WebPageProxy&, API::Navigation*, API::Object*) override;
    94         void willPerformClientRedirect(WebKit::WebPageProxy&, const WTF::String&, double) override;
    95         void didCancelClientRedirect(WebKit::WebPageProxy&) override;
     94        void willPerformClientRedirect(WebPageProxy&, const WTF::String&, double) override;
     95        void didCancelClientRedirect(WebPageProxy&) override;
    9696        void didFailProvisionalNavigationWithError(WebPageProxy&, WebFrameProxy&, API::Navigation*, const WebCore::ResourceError&, API::Object*) override;
    9797        void didFailProvisionalLoadInSubframeWithError(WebPageProxy&, WebFrameProxy&, const WebCore::SecurityOriginData&, API::Navigation*, const WebCore::ResourceError&, API::Object*) override;
     
    117117#endif
    118118
    119 #if ENABLE(WEBGL) && PLATFORM(MAC)
     119#if PLATFORM(MAC)
    120120        void webGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
    121121        void resolveWebGLLoadPolicy(WebPageProxy&, const WebCore::URL&, WTF::Function<void(WebCore::WebGLLoadPolicy)>&& completionHandler) const final;
     122        bool willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem&, bool inPageCache, API::Object*) final;
    122123#endif
    123124
     
    210211#endif
    211212
    212 #if ENABLE(WEBGL) && PLATFORM(MAC)
     213#if PLATFORM(MAC)
    213214        bool webViewWebGLLoadPolicyForURL : 1;
    214215        bool webViewResolveWebGLLoadPolicyForURL : 1;
     216        bool webViewWillGoToBackForwardListItemInPageCache : 1;
    215217#endif
    216218    } m_navigationDelegateMethods;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r222602 r222794  
    175175    m_navigationDelegateMethods.webViewDidRequestPasswordForQuickLookDocument = [delegate respondsToSelector:@selector(_webViewDidRequestPasswordForQuickLookDocument:)];
    176176#endif
    177 #if ENABLE(WEBGL) && PLATFORM(MAC)
     177#if PLATFORM(MAC)
    178178    m_navigationDelegateMethods.webViewWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:webGLLoadPolicyForURL:decisionHandler:)];
    179179    m_navigationDelegateMethods.webViewResolveWebGLLoadPolicyForURL = [delegate respondsToSelector:@selector(_webView:resolveWebGLLoadPolicyForURL:decisionHandler:)];
     180    m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache = [delegate respondsToSelector:@selector(_webView:willGoToBackForwardListItem:inPageCache:)];
    180181#endif
    181182}
     
    339340        completionHandler(toWebCoreWebGLLoadPolicy(policy));
    340341    }).get()];
     342}
     343
     344bool NavigationState::NavigationClient::willGoToBackForwardListItem(WebPageProxy&, WebBackForwardListItem& item, bool inPageCache, API::Object*)
     345{
     346    if (!m_navigationState.m_navigationDelegateMethods.webViewWillGoToBackForwardListItemInPageCache)
     347        return false;
     348
     349    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
     350    if (!navigationDelegate)
     351        return false;
     352
     353    [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState.m_webView willGoToBackForwardListItem:wrapper(item) inPageCache:inPageCache];
     354    return true;
    341355}
    342356#endif
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r222714 r222794  
    12051205}
    12061206
    1207 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, const UserData& userData)
     1207void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, bool inPageCache, const UserData& userData)
    12081208{
    12091209    PageClientProtector protector(m_pageClient);
    12101210
    1211     if (WebBackForwardListItem* item = m_process->webBackForwardItem(itemID))
    1212         m_loaderClient->willGoToBackForwardListItem(*this, item, m_process->transformHandlesToObjects(userData.object()).get());
     1211    if (auto* item = m_process->webBackForwardItem(itemID)) {
     1212        if (m_navigationClient->willGoToBackForwardListItem(*this, *item, inPageCache, m_process->transformHandlesToObjects(userData.object()).get()))
     1213            return;
     1214        m_loaderClient->willGoToBackForwardListItem(*this, *item, m_process->transformHandlesToObjects(userData.object()).get());
     1215    }
    12131216}
    12141217
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r222714 r222794  
    411411    void tryRestoreScrollPosition();
    412412    void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<RefPtr<WebBackForwardListItem>> removed);
    413     void willGoToBackForwardListItem(uint64_t itemID, const UserData&);
     413    void willGoToBackForwardListItem(uint64_t itemID, bool inPageCache, const UserData&);
    414414
    415415    bool shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem*);
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r222714 r222794  
    217217    BackForwardForwardListCount() -> (int32_t count)
    218218    BackForwardClear()
    219     WillGoToBackForwardListItem(uint64_t itemID, WebKit::UserData userData)
     219    WillGoToBackForwardListItem(uint64_t itemID, bool inPageCache, WebKit::UserData userData)
    220220
    221221    # Undo/Redo messages
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r222714 r222794  
    11081108        return false;
    11091109
    1110     webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     1110    webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, bundleItem->isInPageCache(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
    11111111    return true;
    11121112}
  • trunk/Tools/ChangeLog

    r222793 r222794  
     12017-10-03  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add ObjC SPI equivalent to WKPageLoaderClient.willGoToBackForwardListItem
     4        https://bugs.webkit.org/show_bug.cgi?id=177825
     5        <rdar://problem/22387505>
     6
     7        Reviewed by Tim Horton.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm:
     10        (-[BackForwardDelegate _webView:willGoToBackForwardListItem:inPageCache:]):
     11        (-[BackForwardDelegate webView:didFinishNavigation:]):
     12        (TEST):
     13
    1142017-10-03  Antti Koivisto  <antti@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Navigation.mm

    r221444 r222794  
    293293}
    294294
    295 #endif
     295#if PLATFORM(MAC)
     296
     297static bool navigationComplete;
     298
     299@interface BackForwardDelegate : NSObject<WKNavigationDelegatePrivate>
     300@end
     301@implementation BackForwardDelegate
     302- (void)_webView:(WKWebView *)webView willGoToBackForwardListItem:(WKBackForwardListItem *)item inPageCache:(BOOL)inPageCache
     303{
     304    const char* expectedURL = [[[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"] absoluteString] UTF8String];
     305    EXPECT_STREQ(item.URL.absoluteString.UTF8String, expectedURL);
     306    EXPECT_TRUE(item.title == nil);
     307    EXPECT_STREQ(item.initialURL.absoluteString.UTF8String, expectedURL);
     308    EXPECT_TRUE(inPageCache);
     309    isDone = true;
     310}
     311- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
     312{
     313    navigationComplete = true;
     314}
     315@end
     316
     317TEST(WKNavigation, WillGoToBackForwardListItem)
     318{
     319    auto webView = adoptNS([[WKWebView alloc] init]);
     320    auto delegate = adoptNS([[BackForwardDelegate alloc] init]);
     321    [webView setNavigationDelegate:delegate.get()];
     322    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
     323    TestWebKitAPI::Util::run(&navigationComplete);
     324    navigationComplete = false;
     325    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
     326    TestWebKitAPI::Util::run(&navigationComplete);
     327    [webView goBack];
     328    TestWebKitAPI::Util::run(&isDone);
     329}
     330
     331#endif // PLATFORM(MAC)
     332
     333#endif // WK_API_ENABLED
Note: See TracChangeset for help on using the changeset viewer.