Changeset 237233 in webkit


Ignore:
Timestamp:
Oct 17, 2018, 1:37:36 PM (6 years ago)
Author:
achristensen@apple.com
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:
Location:
trunk/Source
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r237231 r237233  
     12018-10-17  Alex Christensen  <achristensen@webkit.org>
     2
     3        BackForwardClient needs to be able to support UIProcess-only back/forward lists
     4        https://bugs.webkit.org/show_bug.cgi?id=190675
     5
     6        Reviewed by Chris Dumez.
     7
     8        Return a RefPtr<HistoryItem> instead of a HistoryItem so that we will be able to return a
     9        HistoryItem that has been created instead of a pointer to a HistoryItem that is owned by something else.
     10        Also use unsigned for the back and forward list counts because they can never be negative.
     11
     12        * history/BackForwardClient.h:
     13        * history/BackForwardController.cpp:
     14        (WebCore::BackForwardController::backItem):
     15        (WebCore::BackForwardController::currentItem):
     16        (WebCore::BackForwardController::forwardItem):
     17        (WebCore::BackForwardController::canGoBackOrForward const):
     18        (WebCore::BackForwardController::goBackOrForward):
     19        (WebCore::BackForwardController::goBack):
     20        (WebCore::BackForwardController::goForward):
     21        (WebCore::BackForwardController::count const):
     22        (WebCore::BackForwardController::backCount const):
     23        (WebCore::BackForwardController::forwardCount const):
     24        (WebCore::BackForwardController::itemAtIndex):
     25        * history/BackForwardController.h:
     26        (WebCore::BackForwardController::backItem): Deleted.
     27        (WebCore::BackForwardController::currentItem): Deleted.
     28        (WebCore::BackForwardController::forwardItem): Deleted.
     29        * loader/EmptyClients.cpp:
     30        * loader/NavigationScheduler.cpp:
     31        (WebCore::NavigationScheduler::scheduleHistoryNavigation):
     32
    1332018-10-17  Antoine Quint  <graouts@apple.com>
    234
  • trunk/Source/WebCore/history/BackForwardClient.h

    r237184 r237233  
    4545    virtual void goToItem(HistoryItem&) = 0;
    4646       
    47     virtual HistoryItem* itemAtIndex(int) = 0;
    48     virtual int backListCount() const = 0;
    49     virtual int forwardListCount() const = 0;
     47    virtual RefPtr<HistoryItem> itemAtIndex(int) = 0;
     48    virtual unsigned backListCount() const = 0;
     49    virtual unsigned forwardListCount() const = 0;
    5050
    5151    virtual void close() = 0;
  • trunk/Source/WebCore/history/BackForwardController.cpp

    r237184 r237233  
    2828
    2929#include "BackForwardClient.h"
     30#include "HistoryItem.h"
    3031#include "Page.h"
    3132#include "ShouldTreatAsContinuingLoad.h"
     
    4142BackForwardController::~BackForwardController() = default;
    4243
     44RefPtr<HistoryItem> BackForwardController::backItem()
     45{
     46    return itemAtIndex(-1);
     47}
     48
     49RefPtr<HistoryItem> BackForwardController::currentItem()
     50{
     51    return itemAtIndex(0);
     52}
     53
     54RefPtr<HistoryItem> BackForwardController::forwardItem()
     55{
     56    return itemAtIndex(1);
     57}
     58
    4359bool BackForwardController::canGoBackOrForward(int distance) const
    4460{
    4561    if (!distance)
    4662        return true;
    47     if (distance > 0 && distance <= forwardCount())
     63    if (distance > 0 && static_cast<unsigned>(distance) <= forwardCount())
    4864        return true;
    49     if (distance < 0 && -distance <= backCount())
     65    if (distance < 0 && static_cast<unsigned>(-distance) <= backCount())
    5066        return true;
    5167    return false;
     
    5773        return;
    5874
    59     HistoryItem* item = itemAtIndex(distance);
    60     if (!item) {
     75    auto historyItem = itemAtIndex(distance);
     76    if (!historyItem) {
    6177        if (distance > 0) {
    6278            if (int forwardCount = this->forwardCount())
    63                 item = itemAtIndex(forwardCount);
     79                historyItem = itemAtIndex(forwardCount);
    6480        } else {
    6581            if (int backCount = this->backCount())
    66                 item = itemAtIndex(-backCount);
     82                historyItem = itemAtIndex(-backCount);
    6783        }
    6884    }
    6985
    70     if (!item)
     86    if (!historyItem)
    7187        return;
    7288
    73     m_page.goToItem(*item, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
     89    m_page.goToItem(*historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
    7490}
    7591
    7692bool BackForwardController::goBack()
    7793{
    78     HistoryItem* item = backItem();
    79     if (!item)
     94    auto historyItem = backItem();
     95    if (!historyItem)
    8096        return false;
    8197
    82     m_page.goToItem(*item, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
     98    m_page.goToItem(*historyItem, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
    8399    return true;
    84100}
     
    86102bool BackForwardController::goForward()
    87103{
    88     HistoryItem* item = forwardItem();
    89     if (!item)
     104    auto historyItem = forwardItem();
     105    if (!historyItem)
    90106        return false;
    91107
    92     m_page.goToItem(*item, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
     108    m_page.goToItem(*historyItem, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
    93109    return true;
    94110}
     
    104120}
    105121
    106 int BackForwardController::count() const
     122unsigned BackForwardController::count() const
    107123{
    108124    return m_client->backListCount() + 1 + m_client->forwardListCount();
    109125}
    110126
    111 int BackForwardController::backCount() const
     127unsigned BackForwardController::backCount() const
    112128{
    113129    return m_client->backListCount();
    114130}
    115131
    116 int BackForwardController::forwardCount() const
     132unsigned BackForwardController::forwardCount() const
    117133{
    118134    return m_client->forwardListCount();
    119135}
    120136
    121 HistoryItem* BackForwardController::itemAtIndex(int i)
     137RefPtr<HistoryItem> BackForwardController::itemAtIndex(int i)
    122138{
    123139    return m_client->itemAtIndex(i);
  • trunk/Source/WebCore/history/BackForwardController.h

    r237184 r237233  
    5454    void setCurrentItem(HistoryItem&);
    5555       
    56     int count() const;
    57     WEBCORE_EXPORT int backCount() const;
    58     WEBCORE_EXPORT int forwardCount() const;
     56    unsigned count() const;
     57    WEBCORE_EXPORT unsigned backCount() const;
     58    WEBCORE_EXPORT unsigned forwardCount() const;
    5959
    60     WEBCORE_EXPORT HistoryItem* itemAtIndex(int);
     60    WEBCORE_EXPORT RefPtr<HistoryItem> itemAtIndex(int);
    6161
    6262    void close();
    6363
    64     HistoryItem* backItem() { return itemAtIndex(-1); }
    65     HistoryItem* currentItem() { return itemAtIndex(0); }
    66     HistoryItem* forwardItem() { return itemAtIndex(1); }
     64    WEBCORE_EXPORT RefPtr<HistoryItem> backItem();
     65    WEBCORE_EXPORT RefPtr<HistoryItem> currentItem();
     66    WEBCORE_EXPORT RefPtr<HistoryItem> forwardItem();
    6767
    6868private:
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r237184 r237233  
    4848#include "FrameNetworkingContext.h"
    4949#include "HTMLFormElement.h"
     50#include "HistoryItem.h"
    5051#include "InProcessIDBServer.h"
    5152#include "InspectorClient.h"
     
    8586    void addItem(Ref<HistoryItem>&&) final { }
    8687    void goToItem(HistoryItem&) final { }
    87     HistoryItem* itemAtIndex(int) final { return nullptr; }
    88     int backListCount() const final { return 0; }
    89     int forwardListCount() const final { return 0; }
     88    RefPtr<HistoryItem> itemAtIndex(int) final { return nullptr; }
     89    unsigned backListCount() const final { return 0; }
     90    unsigned forwardListCount() const final { return 0; }
    9091    void close() final { }
    9192};
  • trunk/Source/WebCore/loader/NavigationScheduler.cpp

    r233668 r237233  
    478478    // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether.
    479479    BackForwardController& backForward = m_frame.page()->backForward();
    480     if (steps > backForward.forwardCount() || -steps > backForward.backCount()) {
     480    if ((steps > 0 && static_cast<unsigned>(steps) > backForward.forwardCount())
     481        || (steps < 0 && static_cast<unsigned>(-steps) > backForward.backCount())) {
    481482        cancel();
    482483        return;
  • trunk/Source/WebKit/ChangeLog

    r237218 r237233  
     12018-10-17  Alex Christensen  <achristensen@webkit.org>
     2
     3        BackForwardClient needs to be able to support UIProcess-only back/forward lists
     4        https://bugs.webkit.org/show_bug.cgi?id=190675
     5
     6        Reviewed by Chris Dumez.
     7
     8        * UIProcess/WebBackForwardList.cpp:
     9        (WebKit::WebBackForwardList::itemAtIndex const):
     10        (WebKit::WebBackForwardList::backListCount const):
     11        (WebKit::WebBackForwardList::forwardListCount const):
     12        * UIProcess/WebBackForwardList.h:
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::backForwardBackListCount):
     15        (WebKit::WebPageProxy::backForwardForwardListCount):
     16        * UIProcess/WebPageProxy.h:
     17        * UIProcess/WebPageProxy.messages.in:
     18        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
     19        (WebKit::WebBackForwardListProxy::itemAtIndex):
     20        (WebKit::WebBackForwardListProxy::backListCount const):
     21        (WebKit::WebBackForwardListProxy::forwardListCount const):
     22        * WebProcess/WebPage/WebBackForwardListProxy.h:
     23        * WebProcess/WebPage/WebPage.cpp:
     24        (WebKit::WebPage::dumpHistoryForTesting):
     25
    1262018-10-17  Ali Juma  <ajuma@chromium.org>
    227
  • trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp

    r237100 r237233  
    250250   
    251251    // Do range checks without doing math on index to avoid overflow.
    252     if (index < -backListCount())
     252    if (index < 0 && static_cast<unsigned>(-index) > backListCount())
    253253        return nullptr;
    254254   
    255     if (index > forwardListCount())
     255    if (index > 0 && static_cast<unsigned>(index) > forwardListCount())
    256256        return nullptr;
    257        
     257
    258258    return m_entries[index + *m_currentIndex].ptr();
    259259}
    260260
    261 int WebBackForwardList::backListCount() const
     261unsigned WebBackForwardList::backListCount() const
    262262{
    263263    ASSERT(!m_currentIndex || *m_currentIndex < m_entries.size());
     
    266266}
    267267
    268 int WebBackForwardList::forwardListCount() const
     268unsigned WebBackForwardList::forwardListCount() const
    269269{
    270270    ASSERT(!m_currentIndex || *m_currentIndex < m_entries.size());
  • trunk/Source/WebKit/UIProcess/WebBackForwardList.h

    r237100 r237233  
    6161    const BackForwardListItemVector& entries() const { return m_entries; }
    6262
    63     int backListCount() const;
    64     int forwardListCount() const;
     63    unsigned backListCount() const;
     64    unsigned forwardListCount() const;
    6565
    6666    Ref<API::Array> backList() const;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r237104 r237233  
    49874987}
    49884988
    4989 void WebPageProxy::backForwardBackListCount(int32_t& count)
     4989void WebPageProxy::backForwardBackListCount(uint32_t& count)
    49904990{
    49914991    count = m_backForwardList->backListCount();
    49924992}
    49934993
    4994 void WebPageProxy::backForwardForwardListCount(int32_t& count)
     4994void WebPageProxy::backForwardForwardListCount(uint32_t& count)
    49954995{
    49964996    count = m_backForwardList->forwardListCount();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r237110 r237233  
    15681568    void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, SandboxExtension::Handle&);
    15691569    void backForwardItemAtIndex(int32_t index, std::optional<WebCore::BackForwardItemIdentifier>&);
    1570     void backForwardBackListCount(int32_t& count);
    1571     void backForwardForwardListCount(int32_t& count);
     1570    void backForwardBackListCount(uint32_t& count);
     1571    void backForwardForwardListCount(uint32_t& count);
    15721572    void backForwardClear();
    15731573
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r237110 r237233  
    231231    BackForwardGoToItem(struct WebCore::BackForwardItemIdentifier itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle)
    232232    BackForwardItemAtIndex(int32_t itemIndex) -> (std::optional<WebCore::BackForwardItemIdentifier> itemID)
    233     BackForwardBackListCount() -> (int32_t count)
    234     BackForwardForwardListCount() -> (int32_t count)
     233    BackForwardBackListCount() -> (uint32_t count)
     234    BackForwardForwardListCount() -> (uint32_t count)
    235235    BackForwardClear()
    236236    WillGoToBackForwardListItem(struct WebCore::BackForwardItemIdentifier itemID, bool inPageCache)
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp

    r237184 r237233  
    111111}
    112112
    113 HistoryItem* WebBackForwardListProxy::itemAtIndex(int itemIndex)
     113RefPtr<HistoryItem> WebBackForwardListProxy::itemAtIndex(int itemIndex)
    114114{
    115115    if (!m_page)
     
    126126}
    127127
    128 int WebBackForwardListProxy::backListCount() const
     128unsigned WebBackForwardListProxy::backListCount() const
    129129{
    130130    if (!m_page)
    131131        return 0;
    132132
    133     int backListCount = 0;
     133    unsigned backListCount = 0;
    134134    if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardBackListCount(), Messages::WebPageProxy::BackForwardBackListCount::Reply(backListCount), m_page->pageID()))
    135135        return 0;
     
    138138}
    139139
    140 int WebBackForwardListProxy::forwardListCount() const
     140unsigned WebBackForwardListProxy::forwardListCount() const
    141141{
    142142    if (!m_page)
    143143        return 0;
    144144
    145     int forwardListCount = 0;
     145    unsigned forwardListCount = 0;
    146146    if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardForwardListCount(), Messages::WebPageProxy::BackForwardForwardListCount::Reply(forwardListCount), m_page->pageID()))
    147147        return 0;
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h

    r237184 r237233  
    5959    void goToItem(WebCore::HistoryItem&) override;
    6060       
    61     WebCore::HistoryItem* itemAtIndex(int) override;
    62     int backListCount() const override;
    63     int forwardListCount() const override;
     61    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
     62    unsigned backListCount() const override;
     63    unsigned forwardListCount() const override;
    6464
    6565    void close() override;
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r237218 r237233  
    16671667    if (list.itemAtIndex(begin)->url() == blankURL())
    16681668        ++begin;
    1669     for (int i = begin; i <= list.forwardCount(); ++i)
     1669    for (int i = begin; i <= static_cast<int>(list.forwardCount()); ++i)
    16701670        dumpHistoryItem(*list.itemAtIndex(i), 8, !i, builder, directory);
    16711671    return builder.toString();
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r237204 r237233  
     12018-10-17  Alex Christensen  <achristensen@webkit.org>
     2
     3        BackForwardClient needs to be able to support UIProcess-only back/forward lists
     4        https://bugs.webkit.org/show_bug.cgi?id=190675
     5
     6        Reviewed by Chris Dumez.
     7
     8        * History/BackForwardList.h:
     9        * History/BackForwardList.mm:
     10        (BackForwardList::backItem):
     11        (BackForwardList::currentItem):
     12        (BackForwardList::forwardItem):
     13        (BackForwardList::backListCount const):
     14        (BackForwardList::forwardListCount const):
     15        (BackForwardList::itemAtIndex):
     16        * History/WebBackForwardList.mm:
     17        (-[WebBackForwardList backItem]):
     18        (-[WebBackForwardList currentItem]):
     19        (-[WebBackForwardList forwardItem]):
     20        (-[WebBackForwardList itemAtIndex:]):
     21
    1222018-10-16  Timothy Hatcher  <timothy@apple.com>
    223
  • trunk/Source/WebKitLegacy/mac/History/BackForwardList.h

    r237184 r237233  
    4848    void goToItem(WebCore::HistoryItem&) override;
    4949       
    50     WebCore::HistoryItem* backItem();
    51     WebCore::HistoryItem* currentItem();
    52     WebCore::HistoryItem* forwardItem();
    53     WebCore::HistoryItem* itemAtIndex(int) override;
     50    RefPtr<WebCore::HistoryItem> backItem();
     51    RefPtr<WebCore::HistoryItem> currentItem();
     52    RefPtr<WebCore::HistoryItem> forwardItem();
     53    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
    5454
    5555    void backListWithLimit(int, Vector<Ref<WebCore::HistoryItem>>&);
     
    6060    bool enabled();
    6161    void setEnabled(bool);
    62     int backListCount() const override;
    63     int forwardListCount() const override;
     62    unsigned backListCount() const override;
     63    unsigned forwardListCount() const override;
    6464    bool containsItem(WebCore::HistoryItem&);
    6565
  • trunk/Source/WebKitLegacy/mac/History/BackForwardList.mm

    r237184 r237233  
    107107}
    108108
    109 HistoryItem* BackForwardList::backItem()
     109RefPtr<HistoryItem> BackForwardList::backItem()
    110110{
    111111    if (m_current && m_current != NoCurrentItemIndex)
    112         return m_entries[m_current - 1].ptr();
     112        return m_entries[m_current - 1].copyRef();
    113113    return nullptr;
    114114}
    115115
    116 HistoryItem* BackForwardList::currentItem()
     116RefPtr<HistoryItem> BackForwardList::currentItem()
    117117{
    118118    if (m_current != NoCurrentItemIndex)
    119         return m_entries[m_current].ptr();
     119        return m_entries[m_current].copyRef();
    120120    return nullptr;
    121121}
    122122
    123 HistoryItem* BackForwardList::forwardItem()
     123RefPtr<HistoryItem> BackForwardList::forwardItem()
    124124{
    125125    if (m_entries.size() && m_current < m_entries.size() - 1)
    126         return m_entries[m_current + 1].ptr();
     126        return m_entries[m_current + 1].copyRef();
    127127    return nullptr;
    128128}
     
    190190}
    191191
    192 int BackForwardList::backListCount() const
     192unsigned BackForwardList::backListCount() const
    193193{
    194194    return m_current == NoCurrentItemIndex ? 0 : m_current;
    195195}
    196196
    197 int BackForwardList::forwardListCount() const
    198 {
    199     return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
    200 }
    201 
    202 HistoryItem* BackForwardList::itemAtIndex(int index)
     197unsigned BackForwardList::forwardListCount() const
     198{
     199    return m_current == NoCurrentItemIndex ? 0 : m_entries.size() - m_current - 1;
     200}
     201
     202RefPtr<HistoryItem> BackForwardList::itemAtIndex(int index)
    203203{
    204204    // Do range checks without doing math on index to avoid overflow.
     
    206206        return nullptr;
    207207   
    208     if (index > forwardListCount())
     208    if (index > static_cast<int>(forwardListCount()))
    209209        return nullptr;
    210        
    211     return m_entries[index + m_current].ptr();
     210
     211    return m_entries[index + m_current].copyRef();
    212212}
    213213
  • trunk/Source/WebKitLegacy/mac/History/WebBackForwardList.mm

    r237184 r237233  
    226226- (WebHistoryItem *)backItem
    227227{
    228     return [[kit(core(self)->backItem()) retain] autorelease];
     228    return [[kit(core(self)->backItem().get()) retain] autorelease];
    229229}
    230230
    231231- (WebHistoryItem *)currentItem
    232232{
    233     return [[kit(core(self)->currentItem()) retain] autorelease];
     233    return [[kit(core(self)->currentItem().get()) retain] autorelease];
    234234}
    235235
    236236- (WebHistoryItem *)forwardItem
    237237{
    238     return [[kit(core(self)->forwardItem()) retain] autorelease];
     238    return [[kit(core(self)->forwardItem().get()) retain] autorelease];
    239239}
    240240
     
    358358- (WebHistoryItem *)itemAtIndex:(int)index
    359359{
    360     return [[kit(core(self)->itemAtIndex(index)) retain] autorelease];
     360    return [[kit(core(self)->itemAtIndex(index).get()) retain] autorelease];
    361361}
    362362
  • trunk/Source/WebKitLegacy/win/BackForwardList.cpp

    r237184 r237233  
    114114}
    115115
    116 HistoryItem* BackForwardList::backItem()
     116RefPtr<HistoryItem> BackForwardList::backItem()
    117117{
    118118    if (m_current && m_current != NoCurrentItemIndex)
    119         return m_entries[m_current - 1].ptr();
     119        return m_entries[m_current - 1].copyRef();
    120120    return nullptr;
    121121}
    122122
    123 HistoryItem* BackForwardList::currentItem()
     123RefPtr<HistoryItem> BackForwardList::currentItem()
    124124{
    125125    if (m_current != NoCurrentItemIndex)
    126         return m_entries[m_current].ptr();
     126        return m_entries[m_current].copyRef();
    127127    return nullptr;
    128128}
    129129
    130 HistoryItem* BackForwardList::forwardItem()
     130RefPtr<HistoryItem> BackForwardList::forwardItem()
    131131{
    132132    if (m_entries.size() && m_current < m_entries.size() - 1)
    133         return m_entries[m_current + 1].ptr();
     133        return m_entries[m_current + 1].copyRef();
    134134    return nullptr;
    135135}
     
    197197}
    198198
    199 int BackForwardList::backListCount() const
     199unsigned BackForwardList::backListCount() const
    200200{
    201201    return m_current == NoCurrentItemIndex ? 0 : m_current;
    202202}
    203203
    204 int BackForwardList::forwardListCount() const
    205 {
    206     return m_current == NoCurrentItemIndex ? 0 : (int)m_entries.size() - (m_current + 1);
    207 }
    208 
    209 HistoryItem* BackForwardList::itemAtIndex(int index)
     204unsigned BackForwardList::forwardListCount() const
     205{
     206    return m_current == NoCurrentItemIndex ? 0 : m_entries.size() - m_current - 1;
     207}
     208
     209RefPtr<HistoryItem> BackForwardList::itemAtIndex(int index)
    210210{
    211211    // Do range checks without doing math on index to avoid overflow.
     
    213213        return nullptr;
    214214   
    215     if (index > forwardListCount())
     215    if (index > static_cast<int>(forwardListCount()))
    216216        return nullptr;
    217        
    218     return m_entries[index + m_current].ptr();
     217
     218    return m_entries[index + m_current].copyRef();
    219219}
    220220
  • trunk/Source/WebKitLegacy/win/BackForwardList.h

    r237184 r237233  
    4545    void goToItem(WebCore::HistoryItem&) override;
    4646       
    47     WebCore::HistoryItem* backItem();
    48     WebCore::HistoryItem* currentItem();
    49     WebCore::HistoryItem* forwardItem();
    50     WebCore::HistoryItem* itemAtIndex(int) override;
     47    RefPtr<WebCore::HistoryItem> backItem();
     48    RefPtr<WebCore::HistoryItem> currentItem();
     49    RefPtr<WebCore::HistoryItem> forwardItem();
     50    RefPtr<WebCore::HistoryItem> itemAtIndex(int) override;
    5151
    5252    void backListWithLimit(int, HistoryItemVector&);
     
    5757    bool enabled();
    5858    void setEnabled(bool);
    59     int backListCount() const final;
    60     int forwardListCount() const final;
     59    unsigned backListCount() const final;
     60    unsigned forwardListCount() const final;
    6161    bool containsItem(WebCore::HistoryItem*);
    6262
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r237194 r237233  
     12018-10-17  Alex Christensen  <achristensen@webkit.org>
     2
     3        BackForwardClient needs to be able to support UIProcess-only back/forward lists
     4        https://bugs.webkit.org/show_bug.cgi?id=190675
     5
     6        Reviewed by Chris Dumez.
     7
     8        * BackForwardList.cpp:
     9        (BackForwardList::backItem):
     10        (BackForwardList::currentItem):
     11        (BackForwardList::forwardItem):
     12        (BackForwardList::backListCount const):
     13        (BackForwardList::forwardListCount const):
     14        (BackForwardList::itemAtIndex):
     15        * BackForwardList.h:
     16
    1172018-10-16  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/Source/WebKitLegacy/win/WebBackForwardList.cpp

    r237184 r237233  
    157157        return E_POINTER;
    158158    *item = nullptr;
    159     HistoryItem* historyItem = m_backForwardList->backItem();
     159    auto historyItem = m_backForwardList->backItem();
    160160
    161161    if (!historyItem)
    162162        return E_FAIL;
    163163
    164     *item = WebHistoryItem::createInstance(historyItem);
     164    *item = WebHistoryItem::createInstance(historyItem.get());
    165165    return S_OK;
    166166}
     
    172172    *item = nullptr;
    173173
    174     HistoryItem* historyItem = m_backForwardList->currentItem();
     174    auto historyItem = m_backForwardList->currentItem();
    175175    if (!historyItem)
    176176        return E_FAIL;
    177177
    178     *item = WebHistoryItem::createInstance(historyItem);
     178    *item = WebHistoryItem::createInstance(historyItem.get());
    179179    return S_OK;
    180180}
     
    186186    *item = nullptr;
    187187
    188     HistoryItem* historyItem = m_backForwardList->forwardItem();
     188    auto historyItem = m_backForwardList->forwardItem();
    189189    if (!historyItem)
    190190        return E_FAIL;
    191191
    192     *item = WebHistoryItem::createInstance(historyItem);
     192    *item = WebHistoryItem::createInstance(historyItem.get());
    193193    return S_OK;
    194194}
     
    284284    *item = nullptr;
    285285
    286     HistoryItem* historyItem = m_backForwardList->itemAtIndex(index);
     286    auto historyItem = m_backForwardList->itemAtIndex(index);
    287287    if (!historyItem)
    288288        return E_FAIL;
    289289 
    290     *item = WebHistoryItem::createInstance(historyItem);
     290    *item = WebHistoryItem::createInstance(historyItem.get());
    291291    return S_OK;
    292292}
Note: See TracChangeset for help on using the changeset viewer.