Store the back forward list item id inside BackForwardListItemState
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jul 2014 21:13:23 +0000 (21:13 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jul 2014 21:13:23 +0000 (21:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134557

Reviewed by Tim Horton.

* Shared/SessionState.cpp:
(WebKit::BackForwardListItemState::encode):
(WebKit::BackForwardListItemState::decode):
* Shared/SessionState.h:
* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::create):
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
(WebKit::WebBackForwardListItem::encode):
* Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::itemID):
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::restoreFromState):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addBackForwardItem):

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/SessionState.cpp
Source/WebKit2/Shared/SessionState.h
Source/WebKit2/Shared/WebBackForwardListItem.cpp
Source/WebKit2/Shared/WebBackForwardListItem.h
Source/WebKit2/UIProcess/WebBackForwardList.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp

index 349ecc5..c93411c 100644 (file)
@@ -1,3 +1,25 @@
+2014-07-02  Anders Carlsson  <andersca@apple.com>
+
+        Store the back forward list item id inside BackForwardListItemState
+        https://bugs.webkit.org/show_bug.cgi?id=134557
+
+        Reviewed by Tim Horton.
+
+        * Shared/SessionState.cpp:
+        (WebKit::BackForwardListItemState::encode):
+        (WebKit::BackForwardListItemState::decode):
+        * Shared/SessionState.h:
+        * Shared/WebBackForwardListItem.cpp:
+        (WebKit::WebBackForwardListItem::create):
+        (WebKit::WebBackForwardListItem::WebBackForwardListItem):
+        (WebKit::WebBackForwardListItem::encode):
+        * Shared/WebBackForwardListItem.h:
+        (WebKit::WebBackForwardListItem::itemID):
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::restoreFromState):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::addBackForwardItem):
+
 2014-07-02  Manuel Rego Casasnovas  <rego@igalia.com>
 
         Unreviewed. EFL and GTK build fix after r170716.
index 2b0f0c4..168abf7 100644 (file)
@@ -184,11 +184,15 @@ bool PageState::decode(IPC::ArgumentDecoder& decoder, PageState& result)
 
 void BackForwardListItemState::encode(IPC::ArgumentEncoder& encoder) const
 {
+    encoder << identifier;
     encoder << pageState;
 }
 
 bool BackForwardListItemState::decode(IPC::ArgumentDecoder& decoder, BackForwardListItemState& result)
 {
+    if (!decoder.decode(result.identifier))
+        return false;
+
     if (!decoder.decode(result.pageState))
         return false;
 
index d205620..76e41c2 100644 (file)
@@ -117,6 +117,8 @@ struct BackForwardListItemState {
     void encode(IPC::ArgumentEncoder&) const;
     static bool decode(IPC::ArgumentDecoder&, BackForwardListItemState&);
 
+    uint64_t identifier;
+
     PageState pageState;
     // FIXME: This should hold the snapshot itself, not its UUID.
     String snapshotUUID;
index 8ccd4a7..b02d778 100644 (file)
@@ -35,28 +35,27 @@ namespace WebKit {
 
 static uint64_t highestUsedItemID = 0;
 
-PassRefPtr<WebBackForwardListItem> WebBackForwardListItem::create(uint64_t itemID, BackForwardListItemState backForwardListItemState)
+PassRefPtr<WebBackForwardListItem> WebBackForwardListItem::create(BackForwardListItemState backForwardListItemState)
 {
-    return adoptRef(new WebBackForwardListItem(itemID, std::move(backForwardListItemState)));
+    return adoptRef(new WebBackForwardListItem(std::move(backForwardListItemState)));
 }
 
-WebBackForwardListItem::WebBackForwardListItem(uint64_t itemID, BackForwardListItemState backForwardListItemState)
-    : m_itemID(itemID)
-    , m_itemState(std::move(backForwardListItemState))
+WebBackForwardListItem::WebBackForwardListItem(BackForwardListItemState backForwardListItemState)
+    : m_itemState(std::move(backForwardListItemState))
 {
-    if (m_itemID > highestUsedItemID)
-        highestUsedItemID = m_itemID;
+    if (m_itemState.identifier > highestUsedItemID)
+        highestUsedItemID = m_itemState.identifier;
 }
 
 WebBackForwardListItem::WebBackForwardListItem(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID)
-    : m_itemID(itemID)
 {
     m_itemState.pageState.mainFrameState.originalURLString = originalURL;
     m_itemState.pageState.mainFrameState.urlString = url;
     m_itemState.pageState.title = title;
+    m_itemState.identifier = itemID;
 
-    if (m_itemID > highestUsedItemID)
-        highestUsedItemID = m_itemID;
+    if (m_itemState.identifier > highestUsedItemID)
+        highestUsedItemID = m_itemState.identifier;
 
     setBackForwardData(backForwardData, backForwardDataSize);
 }
@@ -85,7 +84,7 @@ void WebBackForwardListItem::encode(IPC::ArgumentEncoder& encoder) const
     encoder << m_itemState.pageState.mainFrameState.originalURLString;
     encoder << m_itemState.pageState.mainFrameState.urlString;
     encoder << m_itemState.pageState.title;
-    encoder << m_itemID;
+    encoder << m_itemState.identifier;
 
     RefPtr<API::Data> backForwardData = this->backForwardData();
     encoder << IPC::DataReference(backForwardData->bytes(), backForwardData->size());
index f0d3fff..d0140a9 100644 (file)
@@ -44,7 +44,7 @@ namespace WebKit {
 
 class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackForwardListItem> {
 public:
-    static PassRefPtr<WebBackForwardListItem> create(uint64_t itemID, BackForwardListItemState);
+    static PassRefPtr<WebBackForwardListItem> create(BackForwardListItemState);
 
     static PassRefPtr<WebBackForwardListItem> create(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID)
     {
@@ -53,7 +53,7 @@ public:
 
     virtual ~WebBackForwardListItem();
 
-    uint64_t itemID() const { return m_itemID; }
+    uint64_t itemID() const { return m_itemState.identifier; }
     const BackForwardListItemState& itemState() { return m_itemState; }
 
     void setPageState(PageState pageState) { m_itemState.pageState = std::move(pageState); }
@@ -79,11 +79,10 @@ public:
     static uint64_t highedUsedItemID();
 
 private:
-    WebBackForwardListItem(uint64_t itemID, BackForwardListItemState);
+    explicit WebBackForwardListItem(BackForwardListItemState);
 
     WebBackForwardListItem(const String& originalURL, const String& url, const String& title, const uint8_t* backForwardData, size_t backForwardDataSize, uint64_t itemID);
 
-    uint64_t m_itemID;
     BackForwardListItemState m_itemState;
 };
 
index 90195a3..e8c0e13 100644 (file)
@@ -409,9 +409,10 @@ void WebBackForwardList::restoreFromState(BackForwardListState backForwardListSt
     Vector<RefPtr<WebBackForwardListItem>> items;
     items.reserveInitialCapacity(backForwardListState.items.size());
 
-    for (auto& backForwardListItemState : backForwardListState.items)
-        items.uncheckedAppend(WebBackForwardListItem::create(generateWebBackForwardItemID(), std::move(backForwardListItemState)));
-
+    for (auto& backForwardListItemState : backForwardListState.items) {
+        backForwardListItemState.identifier = generateWebBackForwardItemID();
+        items.uncheckedAppend(WebBackForwardListItem::create(std::move(backForwardListItemState)));
+    }
     m_hasCurrentIndex = !!backForwardListState.currentIndex;
     m_currentIndex = backForwardListState.currentIndex.valueOr(0);
     m_entries = std::move(items);
index 4153070..79912dd 100644 (file)
@@ -318,8 +318,9 @@ void WebProcessProxy::addBackForwardItem(uint64_t itemID, const PageState& pageS
     auto& backForwardListItem = m_backForwardListItemMap.add(itemID, nullptr).iterator->value;
     if (!backForwardListItem) {
         BackForwardListItemState backForwardListItemState;
+        backForwardListItemState.identifier = itemID;
         backForwardListItemState.pageState = pageState;
-        backForwardListItem = WebBackForwardListItem::create(itemID, std::move(backForwardListItemState));
+        backForwardListItem = WebBackForwardListItem::create(std::move(backForwardListItemState));
         return;
     }