Title: [237233] trunk/Source
Revision
237233
Author
achristen...@apple.com
Date
2018-10-17 13:37:36 -0700 (Wed, 17 Oct 2018)

Log Message

BackForwardClient needs to be able to support UIProcess-only back/forward lists
https://bugs.webkit.org/show_bug.cgi?id=190675

Reviewed by Chris Dumez.

Source/WebCore:

Return a RefPtr<HistoryItem> instead of a HistoryItem so that we will be able to return a
HistoryItem that has been created instead of a pointer to a HistoryItem that is owned by something else.
Also use unsigned for the back and forward list counts because they can never be negative.

* history/BackForwardClient.h:
* history/BackForwardController.cpp:
(WebCore::BackForwardController::backItem):
(WebCore::BackForwardController::currentItem):
(WebCore::BackForwardController::forwardItem):
(WebCore::BackForwardController::canGoBackOrForward const):
(WebCore::BackForwardController::goBackOrForward):
(WebCore::BackForwardController::goBack):
(WebCore::BackForwardController::goForward):
(WebCore::BackForwardController::count const):
(WebCore::BackForwardController::backCount const):
(WebCore::BackForwardController::forwardCount const):
(WebCore::BackForwardController::itemAtIndex):
* history/BackForwardController.h:
(WebCore::BackForwardController::backItem): Deleted.
(WebCore::BackForwardController::currentItem): Deleted.
(WebCore::BackForwardController::forwardItem): Deleted.
* loader/EmptyClients.cpp:
* loader/NavigationScheduler.cpp:
(WebCore::NavigationScheduler::scheduleHistoryNavigation):

Source/WebKit:

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::itemAtIndex const):
(WebKit::WebBackForwardList::backListCount const):
(WebKit::WebBackForwardList::forwardListCount const):
* UIProcess/WebBackForwardList.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::backForwardBackListCount):
(WebKit::WebPageProxy::backForwardForwardListCount):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::backListCount const):
(WebKit::WebBackForwardListProxy::forwardListCount const):
* WebProcess/WebPage/WebBackForwardListProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dumpHistoryForTesting):

Source/WebKitLegacy/mac:

* History/BackForwardList.h:
* History/BackForwardList.mm:
(BackForwardList::backItem):
(BackForwardList::currentItem):
(BackForwardList::forwardItem):
(BackForwardList::backListCount const):
(BackForwardList::forwardListCount const):
(BackForwardList::itemAtIndex):
* History/WebBackForwardList.mm:
(-[WebBackForwardList backItem]):
(-[WebBackForwardList currentItem]):
(-[WebBackForwardList forwardItem]):
(-[WebBackForwardList itemAtIndex:]):

Source/WebKitLegacy/win:

* BackForwardList.cpp:
(BackForwardList::backItem):
(BackForwardList::currentItem):
(BackForwardList::forwardItem):
(BackForwardList::backListCount const):
(BackForwardList::forwardListCount const):
(BackForwardList::itemAtIndex):
* BackForwardList.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (237232 => 237233)


--- trunk/Source/WebCore/ChangeLog	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/ChangeLog	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1,3 +1,35 @@
+2018-10-17  Alex Christensen  <achristen...@webkit.org>
+
+        BackForwardClient needs to be able to support UIProcess-only back/forward lists
+        https://bugs.webkit.org/show_bug.cgi?id=190675
+
+        Reviewed by Chris Dumez.
+
+        Return a RefPtr<HistoryItem> instead of a HistoryItem so that we will be able to return a
+        HistoryItem that has been created instead of a pointer to a HistoryItem that is owned by something else.
+        Also use unsigned for the back and forward list counts because they can never be negative.
+
+        * history/BackForwardClient.h:
+        * history/BackForwardController.cpp:
+        (WebCore::BackForwardController::backItem):
+        (WebCore::BackForwardController::currentItem):
+        (WebCore::BackForwardController::forwardItem):
+        (WebCore::BackForwardController::canGoBackOrForward const):
+        (WebCore::BackForwardController::goBackOrForward):
+        (WebCore::BackForwardController::goBack):
+        (WebCore::BackForwardController::goForward):
+        (WebCore::BackForwardController::count const):
+        (WebCore::BackForwardController::backCount const):
+        (WebCore::BackForwardController::forwardCount const):
+        (WebCore::BackForwardController::itemAtIndex):
+        * history/BackForwardController.h:
+        (WebCore::BackForwardController::backItem): Deleted.
+        (WebCore::BackForwardController::currentItem): Deleted.
+        (WebCore::BackForwardController::forwardItem): Deleted.
+        * loader/EmptyClients.cpp:
+        * loader/NavigationScheduler.cpp:
+        (WebCore::NavigationScheduler::scheduleHistoryNavigation):
+
 2018-10-17  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Do not create a DocumentTimeline to suspend or resume animations

Modified: trunk/Source/WebCore/history/BackForwardClient.h (237232 => 237233)


--- trunk/Source/WebCore/history/BackForwardClient.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/history/BackForwardClient.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -44,9 +44,9 @@
 
     virtual void goToItem(HistoryItem&) = 0;
         
-    virtual HistoryItem* itemAtIndex(int) = 0;
-    virtual int backListCount() const = 0;
-    virtual int forwardListCount() const = 0;
+    virtual RefPtr<HistoryItem> itemAtIndex(int) = 0;
+    virtual unsigned backListCount() const = 0;
+    virtual unsigned forwardListCount() const = 0;
 
     virtual void close() = 0;
 };

Modified: trunk/Source/WebCore/history/BackForwardController.cpp (237232 => 237233)


--- trunk/Source/WebCore/history/BackForwardController.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/history/BackForwardController.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -27,6 +27,7 @@
 #include "BackForwardController.h"
 
 #include "BackForwardClient.h"
+#include "HistoryItem.h"
 #include "Page.h"
 #include "ShouldTreatAsContinuingLoad.h"
 
@@ -40,13 +41,28 @@
 
 BackForwardController::~BackForwardController() = default;
 
+RefPtr<HistoryItem> BackForwardController::backItem()
+{
+    return itemAtIndex(-1);
+}
+
+RefPtr<HistoryItem> BackForwardController::currentItem()
+{
+    return itemAtIndex(0);
+}
+
+RefPtr<HistoryItem> BackForwardController::forwardItem()
+{
+    return itemAtIndex(1);
+}
+
 bool BackForwardController::canGoBackOrForward(int distance) const
 {
     if (!distance)
         return true;
-    if (distance > 0 && distance <= forwardCount())
+    if (distance > 0 && static_cast<unsigned>(distance) <= forwardCount())
         return true;
-    if (distance < 0 && -distance <= backCount())
+    if (distance < 0 && static_cast<unsigned>(-distance) <= backCount())
         return true;
     return false;
 }
@@ -56,40 +72,40 @@
     if (!distance)
         return;
 
-    HistoryItem* item = itemAtIndex(distance);
-    if (!item) {
+    auto historyItem = itemAtIndex(distance);
+    if (!historyItem) {
         if (distance > 0) {
             if (int forwardCount = this->forwardCount())
-                item = itemAtIndex(forwardCount);
+                historyItem = itemAtIndex(forwardCount);
         } else {
             if (int backCount = this->backCount())
-                item = itemAtIndex(-backCount);
+                historyItem = itemAtIndex(-backCount);
         }
     }
 
-    if (!item)
+    if (!historyItem)
         return;
 
-    m_page.goToItem(*item, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
+    m_page.goToItem(*historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
 }
 
 bool BackForwardController::goBack()
 {
-    HistoryItem* item = backItem();
-    if (!item)
+    auto historyItem = backItem();
+    if (!historyItem)
         return false;
 
-    m_page.goToItem(*item, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
+    m_page.goToItem(*historyItem, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
     return true;
 }
 
 bool BackForwardController::goForward()
 {
-    HistoryItem* item = forwardItem();
-    if (!item)
+    auto historyItem = forwardItem();
+    if (!historyItem)
         return false;
 
-    m_page.goToItem(*item, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
+    m_page.goToItem(*historyItem, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
     return true;
 }
 
@@ -103,22 +119,22 @@
     m_client->goToItem(item);
 }
 
-int BackForwardController::count() const
+unsigned BackForwardController::count() const
 {
     return m_client->backListCount() + 1 + m_client->forwardListCount();
 }
 
-int BackForwardController::backCount() const
+unsigned BackForwardController::backCount() const
 {
     return m_client->backListCount();
 }
 
-int BackForwardController::forwardCount() const
+unsigned BackForwardController::forwardCount() const
 {
     return m_client->forwardListCount();
 }
 
-HistoryItem* BackForwardController::itemAtIndex(int i)
+RefPtr<HistoryItem> BackForwardController::itemAtIndex(int i)
 {
     return m_client->itemAtIndex(i);
 }

Modified: trunk/Source/WebCore/history/BackForwardController.h (237232 => 237233)


--- trunk/Source/WebCore/history/BackForwardController.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/history/BackForwardController.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -53,17 +53,17 @@
     void addItem(Ref<HistoryItem>&&);
     void setCurrentItem(HistoryItem&);
         
-    int count() const;
-    WEBCORE_EXPORT int backCount() const;
-    WEBCORE_EXPORT int forwardCount() const;
+    unsigned count() const;
+    WEBCORE_EXPORT unsigned backCount() const;
+    WEBCORE_EXPORT unsigned forwardCount() const;
 
-    WEBCORE_EXPORT HistoryItem* itemAtIndex(int);
+    WEBCORE_EXPORT RefPtr<HistoryItem> itemAtIndex(int);
 
     void close();
 
-    HistoryItem* backItem() { return itemAtIndex(-1); }
-    HistoryItem* currentItem() { return itemAtIndex(0); }
-    HistoryItem* forwardItem() { return itemAtIndex(1); }
+    WEBCORE_EXPORT RefPtr<HistoryItem> backItem();
+    WEBCORE_EXPORT RefPtr<HistoryItem> currentItem();
+    WEBCORE_EXPORT RefPtr<HistoryItem> forwardItem();
 
 private:
     Page& m_page;

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (237232 => 237233)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -47,6 +47,7 @@
 #include "FrameLoaderClient.h"
 #include "FrameNetworkingContext.h"
 #include "HTMLFormElement.h"
+#include "HistoryItem.h"
 #include "InProcessIDBServer.h"
 #include "InspectorClient.h"
 #include "LibWebRTCProvider.h"
@@ -84,9 +85,9 @@
 class EmptyBackForwardClient final : public BackForwardClient {
     void addItem(Ref<HistoryItem>&&) final { }
     void goToItem(HistoryItem&) final { }
-    HistoryItem* itemAtIndex(int) final { return nullptr; }
-    int backListCount() const final { return 0; }
-    int forwardListCount() const final { return 0; }
+    RefPtr<HistoryItem> itemAtIndex(int) final { return nullptr; }
+    unsigned backListCount() const final { return 0; }
+    unsigned forwardListCount() const final { return 0; }
     void close() final { }
 };
 

Modified: trunk/Source/WebCore/loader/NavigationScheduler.cpp (237232 => 237233)


--- trunk/Source/WebCore/loader/NavigationScheduler.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebCore/loader/NavigationScheduler.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -477,7 +477,8 @@
     // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled
     // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether.
     BackForwardController& backForward = m_frame.page()->backForward();
-    if (steps > backForward.forwardCount() || -steps > backForward.backCount()) {
+    if ((steps > 0 && static_cast<unsigned>(steps) > backForward.forwardCount())
+        || (steps < 0 && static_cast<unsigned>(-steps) > backForward.backCount())) {
         cancel();
         return;
     }

Modified: trunk/Source/WebKit/ChangeLog (237232 => 237233)


--- trunk/Source/WebKit/ChangeLog	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/ChangeLog	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1,3 +1,28 @@
+2018-10-17  Alex Christensen  <achristen...@webkit.org>
+
+        BackForwardClient needs to be able to support UIProcess-only back/forward lists
+        https://bugs.webkit.org/show_bug.cgi?id=190675
+
+        Reviewed by Chris Dumez.
+
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::itemAtIndex const):
+        (WebKit::WebBackForwardList::backListCount const):
+        (WebKit::WebBackForwardList::forwardListCount const):
+        * UIProcess/WebBackForwardList.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::backForwardBackListCount):
+        (WebKit::WebPageProxy::backForwardForwardListCount):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
+        (WebKit::WebBackForwardListProxy::itemAtIndex):
+        (WebKit::WebBackForwardListProxy::backListCount const):
+        (WebKit::WebBackForwardListProxy::forwardListCount const):
+        * WebProcess/WebPage/WebBackForwardListProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::dumpHistoryForTesting):
+
 2018-10-17  Ali Juma  <aj...@chromium.org>
 
         Flaky IntersectionObserver web platform tests involving style updates

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp (237232 => 237233)


--- trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -249,16 +249,16 @@
         return nullptr;
     
     // Do range checks without doing math on index to avoid overflow.
-    if (index < -backListCount())
+    if (index < 0 && static_cast<unsigned>(-index) > backListCount())
         return nullptr;
     
-    if (index > forwardListCount())
+    if (index > 0 && static_cast<unsigned>(index) > forwardListCount())
         return nullptr;
-        
+
     return m_entries[index + *m_currentIndex].ptr();
 }
 
-int WebBackForwardList::backListCount() const
+unsigned WebBackForwardList::backListCount() const
 {
     ASSERT(!m_currentIndex || *m_currentIndex < m_entries.size());
 
@@ -265,7 +265,7 @@
     return m_page && m_currentIndex ? *m_currentIndex : 0;
 }
 
-int WebBackForwardList::forwardListCount() const
+unsigned WebBackForwardList::forwardListCount() const
 {
     ASSERT(!m_currentIndex || *m_currentIndex < m_entries.size());
 

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardList.h (237232 => 237233)


--- trunk/Source/WebKit/UIProcess/WebBackForwardList.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardList.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -60,8 +60,8 @@
 
     const BackForwardListItemVector& entries() const { return m_entries; }
 
-    int backListCount() const;
-    int forwardListCount() const;
+    unsigned backListCount() const;
+    unsigned forwardListCount() const;
 
     Ref<API::Array> backList() const;
     Ref<API::Array> forwardList() const;

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (237232 => 237233)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -4986,12 +4986,12 @@
         itemID = std::nullopt;
 }
 
-void WebPageProxy::backForwardBackListCount(int32_t& count)
+void WebPageProxy::backForwardBackListCount(uint32_t& count)
 {
     count = m_backForwardList->backListCount();
 }
 
-void WebPageProxy::backForwardForwardListCount(int32_t& count)
+void WebPageProxy::backForwardForwardListCount(uint32_t& count)
 {
     count = m_backForwardList->forwardListCount();
 }

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (237232 => 237233)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1567,8 +1567,8 @@
     void backForwardAddItem(BackForwardListItemState&&);
     void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, SandboxExtension::Handle&);
     void backForwardItemAtIndex(int32_t index, std::optional<WebCore::BackForwardItemIdentifier>&);
-    void backForwardBackListCount(int32_t& count);
-    void backForwardForwardListCount(int32_t& count);
+    void backForwardBackListCount(uint32_t& count);
+    void backForwardForwardListCount(uint32_t& count);
     void backForwardClear();
 
     // Undo management

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (237232 => 237233)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2018-10-17 20:37:36 UTC (rev 237233)
@@ -230,8 +230,8 @@
     BackForwardAddItem(struct WebKit::BackForwardListItemState itemState)
     BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle)
     BackForwardItemAtIndex(int32_t itemIndex) -> (std::optional<WebCore::BackForwardItemIdentifier> itemID)
-    BackForwardBackListCount() -> (int32_t count)
-    BackForwardForwardListCount() -> (int32_t count)
+    BackForwardBackListCount() -> (uint32_t count)
+    BackForwardForwardListCount() -> (uint32_t count)
     BackForwardClear()
     WillGoToBackForwardListItem(struct WebCore::BackForwardItemIdentifier itemID, bool inPageCache)
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp (237232 => 237233)


--- trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -110,7 +110,7 @@
     m_page->sandboxExtensionTracker().beginLoad(m_page->mainWebFrame(), WTFMove(sandboxExtensionHandle));
 }
 
-HistoryItem* WebBackForwardListProxy::itemAtIndex(int itemIndex)
+RefPtr<HistoryItem> WebBackForwardListProxy::itemAtIndex(int itemIndex)
 {
     if (!m_page)
         return nullptr;
@@ -125,12 +125,12 @@
     return idToHistoryItemMap().get(*itemID);
 }
 
-int WebBackForwardListProxy::backListCount() const
+unsigned WebBackForwardListProxy::backListCount() const
 {
     if (!m_page)
         return 0;
 
-    int backListCount = 0;
+    unsigned backListCount = 0;
     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardBackListCount(), Messages::WebPageProxy::BackForwardBackListCount::Reply(backListCount), m_page->pageID()))
         return 0;
 
@@ -137,12 +137,12 @@
     return backListCount;
 }
 
-int WebBackForwardListProxy::forwardListCount() const
+unsigned WebBackForwardListProxy::forwardListCount() const
 {
     if (!m_page)
         return 0;
 
-    int forwardListCount = 0;
+    unsigned forwardListCount = 0;
     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardForwardListCount(), Messages::WebPageProxy::BackForwardForwardListCount::Reply(forwardListCount), m_page->pageID()))
         return 0;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h (237232 => 237233)


--- trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -58,9 +58,9 @@
 
     void goToItem(WebCore::HistoryItem&) override;
         
-    WebCore::HistoryItem* itemAtIndex(int) override;
-    int backListCount() const override;
-    int forwardListCount() const override;
+    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
+    unsigned backListCount() const override;
+    unsigned forwardListCount() const override;
 
     void close() override;
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (237232 => 237233)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1666,7 +1666,7 @@
     int begin = -list.backCount();
     if (list.itemAtIndex(begin)->url() == blankURL())
         ++begin;
-    for (int i = begin; i <= list.forwardCount(); ++i)
+    for (int i = begin; i <= static_cast<int>(list.forwardCount()); ++i)
         dumpHistoryItem(*list.itemAtIndex(i), 8, !i, builder, directory);
     return builder.toString();
 }

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (237232 => 237233)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1,3 +1,24 @@
+2018-10-17  Alex Christensen  <achristen...@webkit.org>
+
+        BackForwardClient needs to be able to support UIProcess-only back/forward lists
+        https://bugs.webkit.org/show_bug.cgi?id=190675
+
+        Reviewed by Chris Dumez.
+
+        * History/BackForwardList.h:
+        * History/BackForwardList.mm:
+        (BackForwardList::backItem):
+        (BackForwardList::currentItem):
+        (BackForwardList::forwardItem):
+        (BackForwardList::backListCount const):
+        (BackForwardList::forwardListCount const):
+        (BackForwardList::itemAtIndex):
+        * History/WebBackForwardList.mm:
+        (-[WebBackForwardList backItem]):
+        (-[WebBackForwardList currentItem]):
+        (-[WebBackForwardList forwardItem]):
+        (-[WebBackForwardList itemAtIndex:]):
+
 2018-10-16  Timothy Hatcher  <timo...@apple.com>
 
         Add <meta name="supported-color-schemes"> to control what color schemes the page supports

Modified: trunk/Source/WebKitLegacy/mac/History/BackForwardList.h (237232 => 237233)


--- trunk/Source/WebKitLegacy/mac/History/BackForwardList.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/mac/History/BackForwardList.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -47,10 +47,10 @@
     void goForward();
     void goToItem(WebCore::HistoryItem&) override;
         
-    WebCore::HistoryItem* backItem();
-    WebCore::HistoryItem* currentItem();
-    WebCore::HistoryItem* forwardItem();
-    WebCore::HistoryItem* itemAtIndex(int) override;
+    RefPtr<WebCore::HistoryItem> backItem();
+    RefPtr<WebCore::HistoryItem> currentItem();
+    RefPtr<WebCore::HistoryItem> forwardItem();
+    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
 
     void backListWithLimit(int, Vector<Ref<WebCore::HistoryItem>>&);
     void forwardListWithLimit(int, Vector<Ref<WebCore::HistoryItem>>&);
@@ -59,8 +59,8 @@
     void setCapacity(int);
     bool enabled();
     void setEnabled(bool);
-    int backListCount() const override;
-    int forwardListCount() const override;
+    unsigned backListCount() const override;
+    unsigned forwardListCount() const override;
     bool containsItem(WebCore::HistoryItem&);
 
     void close() override;

Modified: trunk/Source/WebKitLegacy/mac/History/BackForwardList.mm (237232 => 237233)


--- trunk/Source/WebKitLegacy/mac/History/BackForwardList.mm	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/mac/History/BackForwardList.mm	2018-10-17 20:37:36 UTC (rev 237233)
@@ -106,24 +106,24 @@
         m_current = index;
 }
 
-HistoryItem* BackForwardList::backItem()
+RefPtr<HistoryItem> BackForwardList::backItem()
 {
     if (m_current && m_current != NoCurrentItemIndex)
-        return m_entries[m_current - 1].ptr();
+        return m_entries[m_current - 1].copyRef();
     return nullptr;
 }
 
-HistoryItem* BackForwardList::currentItem()
+RefPtr<HistoryItem> BackForwardList::currentItem()
 {
     if (m_current != NoCurrentItemIndex)
-        return m_entries[m_current].ptr();
+        return m_entries[m_current].copyRef();
     return nullptr;
 }
 
-HistoryItem* BackForwardList::forwardItem()
+RefPtr<HistoryItem> BackForwardList::forwardItem()
 {
     if (m_entries.size() && m_current < m_entries.size() - 1)
-        return m_entries[m_current + 1].ptr();
+        return m_entries[m_current + 1].copyRef();
     return nullptr;
 }
 
@@ -189,26 +189,26 @@
     }
 }
 
-int BackForwardList::backListCount() const
+unsigned BackForwardList::backListCount() const
 {
     return m_current == NoCurrentItemIndex ? 0 : m_current;
 }
 
-int BackForwardList::forwardListCount() const
+unsigned BackForwardList::forwardListCount() const
 {
-    return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
+    return m_current == NoCurrentItemIndex ? 0 : m_entries.size() - m_current - 1;
 }
 
-HistoryItem* BackForwardList::itemAtIndex(int index)
+RefPtr<HistoryItem> BackForwardList::itemAtIndex(int index)
 {
     // Do range checks without doing math on index to avoid overflow.
     if (index < -static_cast<int>(m_current))
         return nullptr;
     
-    if (index > forwardListCount())
+    if (index > static_cast<int>(forwardListCount()))
         return nullptr;
-        
-    return m_entries[index + m_current].ptr();
+
+    return m_entries[index + m_current].copyRef();
 }
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKitLegacy/mac/History/WebBackForwardList.mm (237232 => 237233)


--- trunk/Source/WebKitLegacy/mac/History/WebBackForwardList.mm	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/mac/History/WebBackForwardList.mm	2018-10-17 20:37:36 UTC (rev 237233)
@@ -225,17 +225,17 @@
 
 - (WebHistoryItem *)backItem
 {
-    return [[kit(core(self)->backItem()) retain] autorelease];
+    return [[kit(core(self)->backItem().get()) retain] autorelease];
 }
 
 - (WebHistoryItem *)currentItem
 {
-    return [[kit(core(self)->currentItem()) retain] autorelease];
+    return [[kit(core(self)->currentItem().get()) retain] autorelease];
 }
 
 - (WebHistoryItem *)forwardItem
 {
-    return [[kit(core(self)->forwardItem()) retain] autorelease];
+    return [[kit(core(self)->forwardItem().get()) retain] autorelease];
 }
 
 static NSArray* vectorToNSArray(Vector<Ref<HistoryItem>>& list)
@@ -357,7 +357,7 @@
 
 - (WebHistoryItem *)itemAtIndex:(int)index
 {
-    return [[kit(core(self)->itemAtIndex(index)) retain] autorelease];
+    return [[kit(core(self)->itemAtIndex(index).get()) retain] autorelease];
 }
 
 @end

Modified: trunk/Source/WebKitLegacy/win/BackForwardList.cpp (237232 => 237233)


--- trunk/Source/WebKitLegacy/win/BackForwardList.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/win/BackForwardList.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -113,24 +113,24 @@
     }
 }
 
-HistoryItem* BackForwardList::backItem()
+RefPtr<HistoryItem> BackForwardList::backItem()
 {
     if (m_current && m_current != NoCurrentItemIndex)
-        return m_entries[m_current - 1].ptr();
+        return m_entries[m_current - 1].copyRef();
     return nullptr;
 }
 
-HistoryItem* BackForwardList::currentItem()
+RefPtr<HistoryItem> BackForwardList::currentItem()
 {
     if (m_current != NoCurrentItemIndex)
-        return m_entries[m_current].ptr();
+        return m_entries[m_current].copyRef();
     return nullptr;
 }
 
-HistoryItem* BackForwardList::forwardItem()
+RefPtr<HistoryItem> BackForwardList::forwardItem()
 {
     if (m_entries.size() && m_current < m_entries.size() - 1)
-        return m_entries[m_current + 1].ptr();
+        return m_entries[m_current + 1].copyRef();
     return nullptr;
 }
 
@@ -196,26 +196,26 @@
     }
 }
 
-int BackForwardList::backListCount() const
+unsigned BackForwardList::backListCount() const
 {
     return m_current == NoCurrentItemIndex ? 0 : m_current;
 }
 
-int BackForwardList::forwardListCount() const
+unsigned BackForwardList::forwardListCount() const
 {
-    return m_current == NoCurrentItemIndex ? 0 : (int)m_entries.size() - (m_current + 1);
+    return m_current == NoCurrentItemIndex ? 0 : m_entries.size() - m_current - 1;
 }
 
-HistoryItem* BackForwardList::itemAtIndex(int index)
+RefPtr<HistoryItem> BackForwardList::itemAtIndex(int index)
 {
     // Do range checks without doing math on index to avoid overflow.
     if (index < -static_cast<int>(m_current))
         return nullptr;
     
-    if (index > forwardListCount())
+    if (index > static_cast<int>(forwardListCount()))
         return nullptr;
-        
-    return m_entries[index + m_current].ptr();
+
+    return m_entries[index + m_current].copyRef();
 }
 
 Vector<Ref<HistoryItem>>& BackForwardList::entries()

Modified: trunk/Source/WebKitLegacy/win/BackForwardList.h (237232 => 237233)


--- trunk/Source/WebKitLegacy/win/BackForwardList.h	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/win/BackForwardList.h	2018-10-17 20:37:36 UTC (rev 237233)
@@ -44,10 +44,10 @@
     void goForward();
     void goToItem(WebCore::HistoryItem&) override;
         
-    WebCore::HistoryItem* backItem();
-    WebCore::HistoryItem* currentItem();
-    WebCore::HistoryItem* forwardItem();
-    WebCore::HistoryItem* itemAtIndex(int) override;
+    RefPtr<WebCore::HistoryItem> backItem();
+    RefPtr<WebCore::HistoryItem> currentItem();
+    RefPtr<WebCore::HistoryItem> forwardItem();
+    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
 
     void backListWithLimit(int, HistoryItemVector&);
     void forwardListWithLimit(int, HistoryItemVector&);
@@ -56,8 +56,8 @@
     void setCapacity(int);
     bool enabled();
     void setEnabled(bool);
-    int backListCount() const final;
-    int forwardListCount() const final;
+    unsigned backListCount() const final;
+    unsigned forwardListCount() const final;
     bool containsItem(WebCore::HistoryItem*);
 
     void close() override;

Modified: trunk/Source/WebKitLegacy/win/ChangeLog (237232 => 237233)


--- trunk/Source/WebKitLegacy/win/ChangeLog	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/win/ChangeLog	2018-10-17 20:37:36 UTC (rev 237233)
@@ -1,3 +1,19 @@
+2018-10-17  Alex Christensen  <achristen...@webkit.org>
+
+        BackForwardClient needs to be able to support UIProcess-only back/forward lists
+        https://bugs.webkit.org/show_bug.cgi?id=190675
+
+        Reviewed by Chris Dumez.
+
+        * BackForwardList.cpp:
+        (BackForwardList::backItem):
+        (BackForwardList::currentItem):
+        (BackForwardList::forwardItem):
+        (BackForwardList::backListCount const):
+        (BackForwardList::forwardListCount const):
+        (BackForwardList::itemAtIndex):
+        * BackForwardList.h:
+
 2018-10-16  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed attempt to fix the Windows build after r237112.

Modified: trunk/Source/WebKitLegacy/win/WebBackForwardList.cpp (237232 => 237233)


--- trunk/Source/WebKitLegacy/win/WebBackForwardList.cpp	2018-10-17 19:46:54 UTC (rev 237232)
+++ trunk/Source/WebKitLegacy/win/WebBackForwardList.cpp	2018-10-17 20:37:36 UTC (rev 237233)
@@ -156,12 +156,12 @@
     if (!item)
         return E_POINTER;
     *item = nullptr;
-    HistoryItem* historyItem = m_backForwardList->backItem();
+    auto historyItem = m_backForwardList->backItem();
 
     if (!historyItem)
         return E_FAIL;
 
-    *item = WebHistoryItem::createInstance(historyItem);
+    *item = WebHistoryItem::createInstance(historyItem.get());
     return S_OK;
 }
 
@@ -171,11 +171,11 @@
         return E_POINTER;
     *item = nullptr;
 
-    HistoryItem* historyItem = m_backForwardList->currentItem();
+    auto historyItem = m_backForwardList->currentItem();
     if (!historyItem)
         return E_FAIL;
 
-    *item = WebHistoryItem::createInstance(historyItem);
+    *item = WebHistoryItem::createInstance(historyItem.get());
     return S_OK;
 }
 
@@ -185,11 +185,11 @@
         return E_POINTER;
     *item = nullptr;
 
-    HistoryItem* historyItem = m_backForwardList->forwardItem();
+    auto historyItem = m_backForwardList->forwardItem();
     if (!historyItem)
         return E_FAIL;
 
-    *item = WebHistoryItem::createInstance(historyItem);
+    *item = WebHistoryItem::createInstance(historyItem.get());
     return S_OK;
 }
 
@@ -283,11 +283,11 @@
         return E_POINTER;
     *item = nullptr;
 
-    HistoryItem* historyItem = m_backForwardList->itemAtIndex(index);
+    auto historyItem = m_backForwardList->itemAtIndex(index);
     if (!historyItem)
         return E_FAIL;
  
-    *item = WebHistoryItem::createInstance(historyItem);
+    *item = WebHistoryItem::createInstance(historyItem.get());
     return S_OK;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to