⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 169016 in webkit


Ignore:
Timestamp:
May 18, 2014, 12:33:58 PM (12 years ago)
Author:
andersca@apple.com
Message:

Implement Navigations for all methods declared returning one
​https://bugs.webkit.org/show_bug.cgi?id=133048
<rdar://problem/16830064>

Reviewed by Sam Weinig.

Source/WebKit2:

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView goToBackForwardListItem:]):
(-[WKWebView goBack]):
(-[WKWebView goForward]):
(-[WKWebView reload]):
(-[WKWebView reloadFromOrigin]):
Create and return navigations.

(-[WKWebView _reload]):
Call -[WKWebView reload].

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

(WebKit::NavigationState::createBackForwardNavigation):
Create a back/forward navigation.

(WebKit::NavigationState::createReloadNavigation):
Create a reload navigation.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::reattachToWebProcessWithItem):
Generate a navigation ID and send it with the GoToBackForwardItem message.

(WebKit::WebPageProxy::reload):
Return a navigation ID.

(WebKit::WebPageProxy::goForward):
Generate a navigation ID and send it with the GoForward message.

(WebKit::WebPageProxy::goBack):
Generate a navigation ID and send it with the GoBack message.

(WebKit::WebPageProxy::goToBackForwardItem):
Generate a navigation ID and send it with the GoToBackForwardItem message.

  • UIProcess/WebPageProxy.h:

Return navigation IDs where appropriate.

  • UIProcess/cf/WebPageProxyCF.cpp:

(WebKit::WebPageProxy::restoreFromSessionStateData):
Generate a navigation ID and send it with the RestoreSessionAndNavigateToCurrentItem message.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::goForward):
(WebKit::WebPage::goBack):
(WebKit::WebPage::goToBackForwardItem):
Set up the pending navigation ID.

(WebKit::WebPage::restoreSessionAndNavigateToCurrentItem):
Call goToBackForwardItem with a navigation ID.

  • WebProcess/WebPage/WebPage.h:

Add navigation IDs.

  • WebProcess/WebPage/WebPage.messages.in:

Add navigation IDs.

Tools:

  • MiniBrowser/mac/MiniBrowser_Prefix.pch:

Import WebKit.h.

  • MiniBrowser/mac/WK2BrowserWindowController.m:

(-[WK2BrowserWindowController webView:didStartProvisionalNavigation:]):
(-[WK2BrowserWindowController webView:didReceiveServerRedirectForProvisionalNavigation:]):
(-[WK2BrowserWindowController webView:didFailProvisionalNavigation:withError:]):
(-[WK2BrowserWindowController webView:didCommitNavigation:]):
(-[WK2BrowserWindowController webView:didFinishLoadingNavigation:]):
(-[WK2BrowserWindowController webView:didFailNavigation:withError:]):
Print out the navigations.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r169012 r169016  
     12014-05-18  Anders Carlsson  <andersca@apple.com>
     2
     3        Implement Navigations for all methods declared returning one
     4        https://bugs.webkit.org/show_bug.cgi?id=133048
     5        <rdar://problem/16830064>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * UIProcess/API/Cocoa/WKWebView.mm:
     10        (-[WKWebView goToBackForwardListItem:]):
     11        (-[WKWebView goBack]):
     12        (-[WKWebView goForward]):
     13        (-[WKWebView reload]):
     14        (-[WKWebView reloadFromOrigin]):
     15        Create and return navigations.
     16
     17        (-[WKWebView _reload]):
     18        Call -[WKWebView reload].
     19
     20        * UIProcess/Cocoa/NavigationState.h:
     21        * UIProcess/Cocoa/NavigationState.mm:
     22        (WebKit::NavigationState::createBackForwardNavigation):
     23        Create a back/forward navigation.
     24
     25        (WebKit::NavigationState::createReloadNavigation):
     26        Create a reload navigation.
     27
     28        * UIProcess/WebPageProxy.cpp:
     29        (WebKit::WebPageProxy::reattachToWebProcessWithItem):
     30        Generate a navigation ID and send it with the GoToBackForwardItem message.
     31
     32        (WebKit::WebPageProxy::reload):
     33        Return a navigation ID.
     34
     35        (WebKit::WebPageProxy::goForward):
     36        Generate a navigation ID and send it with the GoForward message.
     37       
     38        (WebKit::WebPageProxy::goBack):
     39        Generate a navigation ID and send it with the GoBack message.
     40
     41        (WebKit::WebPageProxy::goToBackForwardItem):
     42        Generate a navigation ID and send it with the GoToBackForwardItem message.
     43
     44        * UIProcess/WebPageProxy.h:
     45        Return navigation IDs where appropriate.
     46
     47        * UIProcess/cf/WebPageProxyCF.cpp:
     48        (WebKit::WebPageProxy::restoreFromSessionStateData):
     49        Generate a navigation ID and send it with the RestoreSessionAndNavigateToCurrentItem message.
     50       
     51        * WebProcess/WebPage/WebPage.cpp:
     52        (WebKit::WebPage::goForward):
     53        (WebKit::WebPage::goBack):
     54        (WebKit::WebPage::goToBackForwardItem):
     55        Set up the pending navigation ID.
     56
     57        (WebKit::WebPage::restoreSessionAndNavigateToCurrentItem):
     58        Call goToBackForwardItem with a navigation ID.
     59
     60        * WebProcess/WebPage/WebPage.h:
     61        Add navigation IDs.
     62
     63        * WebProcess/WebPage/WebPage.messages.in:
     64        Add navigation IDs.
     65
    1662014-05-18  Commit Queue  <commit-queue@webkit.org>
    267
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r169012 r169016  
    289289- (WKNavigation *)goToBackForwardListItem:(WKBackForwardListItem *)item
    290290{
    291     _page->goToBackForwardItem(&item._item);
    292 
    293     // FIXME: return a WKNavigation object.
    294     return nil;
     291    uint64_t navigationID = _page->goToBackForwardItem(&item._item);
     292
     293    auto navigation = _navigationState->createBackForwardNavigation(navigationID, item._item);
     294
     295    return [navigation.leakRef() autorelease];
    295296}
    296297
    … …  
    334335- (WKNavigation *)goBack
    335336{
    336     _page->goBack();
    337 
    338     // FIXME: Return a navigation object.
    339     return nil;
     337    uint64_t navigationID = _page->goBack();
     338    if (!navigationID)
     339        return nil;
     340
     341    ASSERT(_page->backForwardList().currentItem());
     342    auto navigation = _navigationState->createBackForwardNavigation(navigationID, *_page->backForwardList().currentItem());
     343
     344    return [navigation.leakRef() autorelease];
    340345}
    341346
    342347- (WKNavigation *)goForward
    343348{
    344     _page->goForward();
    345 
    346     // FIXME: Return a navigation object.
    347     return nil;
     349    uint64_t navigationID = _page->goForward();
     350    if (!navigationID)
     351        return nil;
     352
     353    ASSERT(_page->backForwardList().currentItem());
     354    auto navigation = _navigationState->createBackForwardNavigation(navigationID, *_page->backForwardList().currentItem());
     355
     356    return [navigation.leakRef() autorelease];
    348357}
    349358
    350359- (WKNavigation *)reload
    351360{
    352     _page->reload(false);
    353 
    354     // FIXME: Return a navigation object.
    355     return nil;
     361    uint64_t navigationID = _page->reload(false);
     362    ASSERT(navigationID);
     363
     364    auto navigation = _navigationState->createReloadNavigation(navigationID);
     365    return [navigation.leakRef() autorelease];
    356366}
    357367
    358368- (WKNavigation *)reloadFromOrigin
    359369{
    360     _page->reload(true);
    361 
    362     // FIXME: Return a navigation object.
    363     return nil;
     370    uint64_t navigationID = _page->reload(true);
     371    ASSERT(navigationID);
     372
     373    auto navigation = _navigationState->createReloadNavigation(navigationID);
     374    return [navigation.leakRef() autorelease];
    364375}
    365376
    … …  
    11011112- (WKNavigation *)_reload
    11021113{
    1103     _page->reload(false);
    1104 
    1105     // FIXME: return a WKNavigation object.
    1106     return nil;
     1114    return [self reload];
    11071115}
    11081116
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.h

    r168441 r169016  
    6464    void setHistoryDelegate(id <WKHistoryDelegatePrivate>);
    6565
     66    RetainPtr<WKNavigation> createBackForwardNavigation(uint64_t navigationID, const WebBackForwardListItem&);
    6667    RetainPtr<WKNavigation> createLoadRequestNavigation(uint64_t navigationID, NSURLRequest *);
     68    RetainPtr<WKNavigation> createReloadNavigation(uint64_t navigationID);
    6769
    6870    // Called by the history client.
  • trunk/Source/WebKit2/UIProcess/Cocoa/NavigationState.mm

    r168690 r169016  
    164164}
    165165
     166RetainPtr<WKNavigation> NavigationState::createBackForwardNavigation(uint64_t navigationID, const WebBackForwardListItem& item)
     167{
     168    ASSERT(!m_navigations.contains(navigationID));
     169
     170    auto navigation = adoptNS([[WKNavigation alloc] init]);
     171
     172    // FIXME: We need to remove the navigation when we're done with it!
     173    m_navigations.set(navigationID, navigation);
     174
     175    return navigation;
     176}
     177
     178RetainPtr<WKNavigation> NavigationState::createReloadNavigation(uint64_t navigationID)
     179{
     180    ASSERT(!m_navigations.contains(navigationID));
     181
     182    auto navigation = adoptNS([[WKNavigation alloc] init]);
     183
     184    // FIXME: We need to remove the navigation when we're done with it!
     185    m_navigations.set(navigationID, navigation);
     186
     187    return navigation;
     188}
     189
    166190void NavigationState::didNavigateWithNavigationData(const WebKit::WebNavigationDataStore& navigationDataStore)
    167191{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r168994 r169016  
    554554}
    555555
    556 void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
     556uint64_t WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
    557557{
    558558    if (item && item != m_backForwardList->currentItem())
    … …  
    562562
    563563    if (!item)
    564         return;
    565 
    566     m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
     564        return 0;
     565
     566    uint64_t navigationID = generateNavigationID();
     567
     568    m_process->send(Messages::WebPage::GoToBackForwardItem(navigationID, item->itemID()), m_pageID);
    567569    m_process->responsivenessTimer()->start();
     570
     571    return navigationID;
    568572}
    569573
    … …  
    796800}
    797801
    798 void WebPageProxy::reload(bool reloadFromOrigin)
     802uint64_t WebPageProxy::reload(bool reloadFromOrigin)
    799803{
    800804    SandboxExtension::Handle sandboxExtensionHandle;
    … …  
    811815    }
    812816
    813     if (!isValid()) {
    814         reattachToWebProcessWithItem(m_backForwardList->currentItem());
    815         return;
    816     }
    817 
    818     m_process->send(Messages::WebPage::Reload(generateNavigationID(), reloadFromOrigin, sandboxExtensionHandle), m_pageID);
     817    if (!isValid())
     818        return reattachToWebProcessWithItem(m_backForwardList->currentItem());
     819
     820    uint64_t navigationID = generateNavigationID();
     821
     822    m_process->send(Messages::WebPage::Reload(navigationID, reloadFromOrigin, sandboxExtensionHandle), m_pageID);
    819823    m_process->responsivenessTimer()->start();
     824
     825    return navigationID;
    820826}
    821827
    … …  
    830836}
    831837
    832 void WebPageProxy::goForward()
     838uint64_t WebPageProxy::goForward()
    833839{
    834840    WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
    835841    if (!forwardItem)
    836         return;
     842        return 0;
    837843
    838844    recordNavigationSnapshot();
    … …  
    842848    m_pageLoadState.setPendingAPIRequestURL(transaction, forwardItem->url());
    843849
    844     if (!isValid()) {
    845         reattachToWebProcessWithItem(forwardItem);
    846         return;
    847     }
    848 
    849     m_process->send(Messages::WebPage::GoForward(forwardItem->itemID()), m_pageID);
     850    if (!isValid())
     851        return reattachToWebProcessWithItem(forwardItem);
     852
     853    uint64_t navigationID = generateNavigationID();
     854
     855    m_process->send(Messages::WebPage::GoForward(navigationID, forwardItem->itemID()), m_pageID);
    850856    m_process->responsivenessTimer()->start();
    851 }
    852 
    853 void WebPageProxy::goBack()
     857
     858    return navigationID;
     859}
     860
     861uint64_t WebPageProxy::goBack()
    854862{
    855863    WebBackForwardListItem* backItem = m_backForwardList->backItem();
    856864    if (!backItem)
    857         return;
     865        return 0;
    858866
    859867    recordNavigationSnapshot();
    … …  
    863871    m_pageLoadState.setPendingAPIRequestURL(transaction, backItem->url());
    864872
    865     if (!isValid()) {
    866         reattachToWebProcessWithItem(backItem);
    867         return;
    868     }
    869 
    870     m_process->send(Messages::WebPage::GoBack(backItem->itemID()), m_pageID);
     873    if (!isValid())
     874        return reattachToWebProcessWithItem(backItem);
     875
     876    uint64_t navigationID = generateNavigationID();
     877
     878    m_process->send(Messages::WebPage::GoBack(navigationID, backItem->itemID()), m_pageID);
    871879    m_process->responsivenessTimer()->start();
    872 }
    873 
    874 void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
    875 {
    876     if (!isValid()) {
    877         reattachToWebProcessWithItem(item);
    878         return;
    879     }
     880
     881    return navigationID;
     882}
     883
     884uint64_t WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
     885{
     886    if (!isValid())
     887        return reattachToWebProcessWithItem(item);
    880888
    881889    recordNavigationSnapshot();
    … …  
    885893    m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
    886894
    887     m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
     895    uint64_t navigationID = generateNavigationID();
     896
     897    m_process->send(Messages::WebPage::GoToBackForwardItem(navigationID, item->itemID()), m_pageID);
    888898    m_process->responsivenessTimer()->start();
     899
     900    return navigationID;
    889901}
    890902
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r168994 r169016  
    518518
    519519    void stopLoading();
    520     void reload(bool reloadFromOrigin);
    521 
    522     void goForward();
    523     void goBack();
    524 
    525     void goToBackForwardItem(WebBackForwardListItem*);
     520    uint64_t reload(bool reloadFromOrigin);
     521
     522    uint64_t goForward();
     523    uint64_t goBack();
     524
     525    uint64_t goToBackForwardItem(WebBackForwardListItem*);
    526526    void tryRestoreScrollPosition();
    527527    void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<RefPtr<WebBackForwardListItem>> removed);
    … …  
    12071207
    12081208    void reattachToWebProcess();
    1209     void reattachToWebProcessWithItem(WebBackForwardListItem*);
     1209    uint64_t reattachToWebProcessWithItem(WebBackForwardListItem*);
    12101210
    12111211    void requestNotificationPermission(uint64_t notificationID, const String& originString);
  • trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp

    r164381 r169016  
    170170                        m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
    171171
    172                     process().send(Messages::WebPage::RestoreSessionAndNavigateToCurrentItem(state), m_pageID);
     172                    process().send(Messages::WebPage::RestoreSessionAndNavigateToCurrentItem(generateNavigationID(), state), m_pageID);
    173173                }
    174174            }
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r168994 r169016  
    10791079}
    10801080
    1081 void WebPage::goForward(uint64_t backForwardItemID)
     1081void WebPage::goForward(uint64_t navigationID, uint64_t backForwardItemID)
    10821082{
    10831083    SendStopResponsivenessTimer stopper(this);
    … …  
    10881088        return;
    10891089
     1090    ASSERT(!m_pendingNavigationID);
     1091    if (!item->isInPageCache())
     1092        m_pendingNavigationID = navigationID;
     1093
    10901094    m_page->goToItem(item, FrameLoadTypeForward);
    10911095}
    10921096
    1093 void WebPage::goBack(uint64_t backForwardItemID)
     1097void WebPage::goBack(uint64_t navigationID, uint64_t backForwardItemID)
    10941098{
    10951099    SendStopResponsivenessTimer stopper(this);
    … …  
    11001104        return;
    11011105
     1106    ASSERT(!m_pendingNavigationID);
     1107    if (!item->isInPageCache())
     1108        m_pendingNavigationID = navigationID;
     1109
    11021110    m_page->goToItem(item, FrameLoadTypeBack);
    11031111}
    11041112
    1105 void WebPage::goToBackForwardItem(uint64_t backForwardItemID)
     1113void WebPage::goToBackForwardItem(uint64_t navigationID, uint64_t backForwardItemID)
    11061114{
    11071115    SendStopResponsivenessTimer stopper(this);
    … …  
    11111119    if (!item)
    11121120        return;
     1121
     1122    ASSERT(!m_pendingNavigationID);
     1123    if (!item->isInPageCache())
     1124        m_pendingNavigationID = navigationID;
    11131125
    11141126    m_page->goToItem(item, FrameLoadTypeIndexedBackForward);
    … …  
    19551967}
    19561968
    1957 void WebPage::restoreSessionAndNavigateToCurrentItem(const SessionState& sessionState)
     1969void WebPage::restoreSessionAndNavigateToCurrentItem(uint64_t navigationID, const SessionState& sessionState)
    19581970{
    19591971    if (uint64_t currentItemID = restoreSession(sessionState))
    1960         goToBackForwardItem(currentItemID);
     1972        goToBackForwardItem(navigationID, currentItemID);
    19611973}
    19621974
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r168994 r169016  
    856856    void loadWebArchiveData(const IPC::DataReference&, IPC::MessageDecoder&);
    857857    void reload(uint64_t navigationID, bool reloadFromOrigin, const SandboxExtension::Handle&);
    858     void goForward(uint64_t);
    859     void goBack(uint64_t);
    860     void goToBackForwardItem(uint64_t);
     858    void goForward(uint64_t navigationID, uint64_t);
     859    void goBack(uint64_t navigationID, uint64_t);
     860    void goToBackForwardItem(uint64_t navigationID, uint64_t);
    861861    void tryRestoreScrollPosition();
    862862    void setActive(bool);
    … …  
    891891
    892892    uint64_t restoreSession(const SessionState&);
    893     void restoreSessionAndNavigateToCurrentItem(const SessionState&);
     893    void restoreSessionAndNavigateToCurrentItem(uint64_t navigationID, const SessionState&);
    894894
    895895    void didRemoveBackForwardItem(uint64_t);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r168984 r169016  
    105105    CenterSelectionInVisibleArea()
    106106
    107     GoBack(uint64_t backForwardItemID)
    108     GoForward(uint64_t backForwardItemID)
    109     GoToBackForwardItem(uint64_t backForwardItemID)
     107    GoBack(uint64_t navigationID, uint64_t backForwardItemID)
     108    GoForward(uint64_t navigationID, uint64_t backForwardItemID)
     109    GoToBackForwardItem(uint64_t navigationID, uint64_t backForwardItemID)
    110110    TryRestoreScrollPosition()
    111111
    … …  
    124124   
    125125    RestoreSession(WebKit::SessionState state)
    126     RestoreSessionAndNavigateToCurrentItem(WebKit::SessionState state)
     126    RestoreSessionAndNavigateToCurrentItem(uint64_t navigationID, WebKit::SessionState state)
    127127
    128128    DidRemoveBackForwardItem(uint64_t backForwardItemID)
  • trunk/Tools/ChangeLog

    r169002 r169016  
     12014-05-18  Anders Carlsson  <andersca@apple.com>
     2
     3        Implement Navigations for all methods declared returning one
     4        https://bugs.webkit.org/show_bug.cgi?id=133048
     5        <rdar://problem/16830064>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * MiniBrowser/mac/MiniBrowser_Prefix.pch:
     10        Import WebKit.h.
     11       
     12        * MiniBrowser/mac/WK2BrowserWindowController.m:
     13        (-[WK2BrowserWindowController webView:didStartProvisionalNavigation:]):
     14        (-[WK2BrowserWindowController webView:didReceiveServerRedirectForProvisionalNavigation:]):
     15        (-[WK2BrowserWindowController webView:didFailProvisionalNavigation:withError:]):
     16        (-[WK2BrowserWindowController webView:didCommitNavigation:]):
     17        (-[WK2BrowserWindowController webView:didFinishLoadingNavigation:]):
     18        (-[WK2BrowserWindowController webView:didFailNavigation:withError:]):
     19        Print out the navigations.
     20
    1212014-05-17  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/Tools/MiniBrowser/mac/MiniBrowser_Prefix.pch

    r124163 r169016  
    2626#ifdef __OBJC__
    2727    #import <Cocoa/Cocoa.h>
     28    #import <WebKit/WebKit.h>
    2829#endif
    29 
    30 #import <WebKit2/WebKit2_C.h>
    3130
    3231#define ENABLE_LOGGING 0
  • trunk/Tools/MiniBrowser/mac/WK2BrowserWindowController.m

    r169002 r169016  
    425425- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
    426426{
    427     LOG(@"didStartProvisionalNavigation");
     427    LOG(@"didStartProvisionalNavigation: %@", navigation);
    428428}
    429429
    430430- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
    431431{
    432     LOG(@"didReceiveServerRedirectForProvisionalNavigation");
     432    LOG(@"didReceiveServerRedirectForProvisionalNavigation: %@", navigation);
    433433}
    434434
    435435- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
    436436{
    437     LOG(@"didFailProvisionalNavigation: %@", error);
     437    LOG(@"didFailProvisionalNavigation: %@navigation, error: %@", navigation, error);
    438438}
    439439
    440440- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
    441441{
    442     LOG(@"didCommitNavigation: %@", error);
     442    LOG(@"didCommitNavigation: %@", navigation);
    443443}
    444444
    445445- (void)webView:(WKWebView *)webView didFinishLoadingNavigation:(WKNavigation *)navigation
    446446{
    447     LOG(@"didFinishLoadingNavigation");
     447    LOG(@"didFinishLoadingNavigation: %@", navigation);
    448448}
    449449
    450450- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
    451451{
    452     LOG(@"didFailNavigation: %@", error);
     452    LOG(@"didFailNavigation: %@, error %@", navigation, error);
    453453}
    454454
Note: See TracChangeset for help on using the changeset viewer.