Title: [170626] trunk/Source/WebKit2
Revision
170626
Author
[email protected]
Date
2014-06-30 18:29:38 -0700 (Mon, 30 Jun 2014)

Log Message

Add a function to restore a WebBackForwardList object from a BackForwardListState object
https://bugs.webkit.org/show_bug.cgi?id=134478

Reviewed by Tim Horton.

* UIProcess/WebBackForwardList.cpp:
(WebKit::generateWebBackForwardItemID):
(WebKit::WebBackForwardList::restoreFromState):
* UIProcess/WebBackForwardList.h:
* UIProcess/cf/WebBackForwardListCF.cpp:
(WebKit::generateWebBackForwardItemID): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (170625 => 170626)


--- trunk/Source/WebKit2/ChangeLog	2014-07-01 01:06:35 UTC (rev 170625)
+++ trunk/Source/WebKit2/ChangeLog	2014-07-01 01:29:38 UTC (rev 170626)
@@ -1,5 +1,19 @@
 2014-06-30  Anders Carlsson  <[email protected]>
 
+        Add a function to restore a WebBackForwardList object from a BackForwardListState object
+        https://bugs.webkit.org/show_bug.cgi?id=134478
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::generateWebBackForwardItemID):
+        (WebKit::WebBackForwardList::restoreFromState):
+        * UIProcess/WebBackForwardList.h:
+        * UIProcess/cf/WebBackForwardListCF.cpp:
+        (WebKit::generateWebBackForwardItemID): Deleted.
+
+2014-06-30  Anders Carlsson  <[email protected]>
+
         Change the AddBackForwardItem message to take a page state object
         https://bugs.webkit.org/show_bug.cgi?id=134475
 

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp (170625 => 170626)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2014-07-01 01:06:35 UTC (rev 170625)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.cpp	2014-07-01 01:29:38 UTC (rev 170626)
@@ -27,10 +27,24 @@
 #include "WebBackForwardList.h"
 
 #include "APIArray.h"
+#include "SessionState.h"
 #include "WebPageProxy.h"
 
 namespace WebKit {
 
+// FIXME: Make this static once WebBackForwardListCF.cpp is no longer using it.
+uint64_t generateWebBackForwardItemID();
+
+uint64_t generateWebBackForwardItemID()
+{
+    // These IDs exist in the UIProcess for items created by the UIProcess.
+    // The IDs generated here need to never collide with the IDs created in WebBackForwardListProxy in the WebProcess.
+    // We accomplish this by starting from 2, and only ever using even ids.
+    static uint64_t uniqueHistoryItemID = 0;
+    uniqueHistoryItemID += 2;
+    return uniqueHistoryItemID;
+}
+
 static const unsigned DefaultCapacity = 100;
 
 WebBackForwardList::WebBackForwardList(WebPageProxy& page)
@@ -366,4 +380,17 @@
     m_page->didChangeBackForwardList(nullptr, std::move(removedItems));
 }
 
+void WebBackForwardList::restoreFromState(BackForwardListState backForwardListState)
+{
+    Vector<RefPtr<WebBackForwardListItem>> items;
+    items.reserveInitialCapacity(backForwardListState.items.size());
+
+    for (auto& pageState : backForwardListState.items)
+        items.uncheckedAppend(WebBackForwardListItem::create(generateWebBackForwardItemID(), std::move(pageState)));
+
+    m_hasCurrentIndex = !!backForwardListState.currentIndex;
+    m_currentIndex = backForwardListState.currentIndex.valueOr(0);
+    m_entries = std::move(items);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebBackForwardList.h (170625 => 170626)


--- trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2014-07-01 01:06:35 UTC (rev 170625)
+++ trunk/Source/WebKit2/UIProcess/WebBackForwardList.h	2014-07-01 01:29:38 UTC (rev 170626)
@@ -38,11 +38,7 @@
 
 namespace WebKit {
 
-/*
- *          Current
- *   |---------*--------------| Entries
- *      Back        Forward
- */
+struct BackForwardListState;
 
 class WebBackForwardList : public API::ObjectImpl<API::Object::Type::BackForwardList> {
 public:
@@ -83,6 +79,8 @@
     bool restoreFromV1CFDictionaryRepresentation(CFDictionaryRef);
 #endif
 
+    void restoreFromState(BackForwardListState);
+
 private:
     explicit WebBackForwardList(WebPageProxy&);
 

Modified: trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp (170625 => 170626)


--- trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp	2014-07-01 01:06:35 UTC (rev 170625)
+++ trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp	2014-07-01 01:29:38 UTC (rev 170626)
@@ -36,15 +36,7 @@
 
 namespace WebKit {
 
-static uint64_t generateWebBackForwardItemID()
-{
-    // These IDs exist in the UIProcess for items created by the UIProcess.
-    // The IDs generated here need to never collide with the IDs created in WebBackForwardListProxy in the WebProcess.
-    // We accomplish this by starting from 2, and only ever using even ids.
-    static uint64_t uniqueHistoryItemID = 0;
-    uniqueHistoryItemID += 2;
-    return uniqueHistoryItemID;
-}
+uint64_t generateWebBackForwardItemID();
 
 static CFNumberRef sessionHistoryCurrentVersion()
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to