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

Changeset 170664 in webkit


Ignore:
Timestamp:
Jul 1, 2014, 2:07:40 PM (12 years ago)
Author:
andersca@apple.com
Message:

Add a function for restoring page state given a SessionState object
​https://bugs.webkit.org/show_bug.cgi?id=134509

Reviewed by Tim Horton.

  • Shared/WebBackForwardListItem.h:

(WebKit::WebBackForwardListItem::itemState):

  • UIProcess/WebBackForwardList.cpp:

(WebKit::WebBackForwardList::saveState):

  • UIProcess/WebBackForwardList.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::saveState):

  • UIProcess/WebPageProxy.h:
Location:
trunk/Source/WebKit2
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r170662 r170664  
     12014-07-01  Anders Carlsson  <andersca@apple.com>
     2
     3        Add a function for restoring page state given a SessionState object
     4        https://bugs.webkit.org/show_bug.cgi?id=134509
     5
     6        Reviewed by Tim Horton.
     7
     8        * Shared/WebBackForwardListItem.h:
     9        (WebKit::WebBackForwardListItem::itemState):
     10        * UIProcess/WebBackForwardList.cpp:
     11        (WebKit::WebBackForwardList::saveState):
     12        * UIProcess/WebBackForwardList.h:
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::saveState):
     15        * UIProcess/WebPageProxy.h:
     16
    1172014-07-01  Dan Bernstein  <mitz@apple.com>
    218
  • trunk/Source/WebKit2/Shared/WebBackForwardListItem.h

    r170649 r170664  
    5555
    5656    uint64_t itemID() const { return m_itemID; }
     57    const BackForwardListItemState& itemState() { return m_itemState; }
    5758
    5859    void setPageState(PageState pageState) { m_itemState.pageState = std::move(pageState); }
  • trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp

    r170649 r170664  
    381381}
    382382
     383BackForwardListState WebBackForwardList::backForwardListState(const std::function<bool (WebBackForwardListItem&)>& filter) const
     384{
     385    ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
     386
     387    BackForwardListState backForwardListState;
     388    if (m_hasCurrentIndex)
     389        backForwardListState.currentIndex = m_currentIndex;
     390
     391    for (size_t i = 0; i < m_entries.size(); ++i) {
     392        auto& entry = *m_entries[i];
     393
     394        if (filter && !filter(entry)) {
     395            if (backForwardListState.currentIndex && i <= backForwardListState.currentIndex.value())
     396                --backForwardListState.currentIndex.value();
     397
     398            continue;
     399        }
     400
     401        backForwardListState.items.append(entry.itemState());
     402    }
     403
     404    return backForwardListState;
     405}
     406
    383407void WebBackForwardList::restoreFromState(BackForwardListState backForwardListState)
    384408{
  • trunk/Source/WebKit2/UIProcess/WebBackForwardList.h

    r170644 r170664  
    8080#endif
    8181
     82    BackForwardListState backForwardListState(const std::function<bool (WebBackForwardListItem&)>&) const;
    8283    void restoreFromState(BackForwardListState);
    8384
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r170660 r170664  
    18481848#endif
    18491849
     1850SessionState WebPageProxy::sessionState(const std::function<bool (WebBackForwardListItem&)>& filter) const
     1851{
     1852    SessionState sessionState;
     1853
     1854    sessionState.backForwardListState = m_backForwardList->backForwardListState(filter);
     1855
     1856    String provisionalURLString = m_pageLoadState.pendingAPIRequestURL();
     1857    if (provisionalURLString.isEmpty())
     1858        provisionalURLString = m_pageLoadState.provisionalURL();
     1859
     1860    if (!provisionalURLString.isEmpty())
     1861        sessionState.provisionalURL = URL(URL(), provisionalURLString);
     1862
     1863    return sessionState;
     1864}
     1865
    18501866uint64_t WebPageProxy::restoreFromState(SessionState sessionState)
    18511867{
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r170660 r170664  
    551551    void terminateProcess();
    552552
     553    SessionState sessionState(const std::function<bool (WebBackForwardListItem&)>&) const;
    553554    PassRefPtr<API::Data> sessionStateData(std::function<bool (WebBackForwardListItem&)>) const;
    554555    uint64_t restoreFromSessionStateData(API::Data*);
Note: See TracChangeset for help on using the changeset viewer.