Changeset 237184 in webkit


Ignore:
Timestamp:
Oct 16, 2018, 8:58:10 AM (7 years ago)
Author:
achristensen@apple.com
Message:

Replace HistoryItem* with HistoryItem& where possible
https://bugs.webkit.org/show_bug.cgi?id=190617

Reviewed by Chris Dumez.

Source/WebCore:

  • history/BackForwardClient.h:
  • history/BackForwardController.cpp:

(WebCore::BackForwardController::setCurrentItem):

  • history/BackForwardController.h:
  • history/HistoryItem.cpp:

(WebCore::defaultNotifyHistoryItemChanged):
(WebCore::HistoryItem::setAlternateTitle):
(WebCore::HistoryItem::setURLString):
(WebCore::HistoryItem::setOriginalURLString):
(WebCore::HistoryItem::setReferrer):
(WebCore::HistoryItem::setTitle):
(WebCore::HistoryItem::setTarget):
(WebCore::HistoryItem::setShouldRestoreScrollPosition):
(WebCore::HistoryItem::setStateObject):
(WebCore::HistoryItem::notifyChanged):

  • history/HistoryItem.h:
  • loader/EmptyClients.cpp:
  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::loadSameDocumentItem):

  • loader/HistoryController.cpp:

(WebCore::HistoryController::goToItem):
(WebCore::HistoryController::updateForCommit):
(WebCore::HistoryController::recursiveUpdateForCommit):
(WebCore::HistoryController::recursiveUpdateForSameDocumentNavigation):
(WebCore::HistoryController::setCurrentItem):
(WebCore::HistoryController::createItem):
(WebCore::HistoryController::itemsAreClones const):
(WebCore::HistoryController::currentFramesMatchItem const):

  • loader/HistoryController.h:

Source/WebKit:

  • WebProcess/WebCoreSupport/SessionStateConversion.h:
  • WebProcess/WebPage/WebBackForwardListProxy.cpp:

(WebKit::WK2NotifyHistoryItemChanged):
(WebKit::WebBackForwardListProxy::goToItem):

  • WebProcess/WebPage/WebBackForwardListProxy.h:

Source/WebKitLegacy/mac:

  • History/BackForwardList.h:
  • History/BackForwardList.mm:

(BackForwardList::goToItem):

  • History/WebBackForwardList.mm:

(-[WebBackForwardList goToItem:]):

  • History/WebHistoryItem.mm:

(WKNotifyHistoryItemChanged):

  • History/WebHistoryItemInternal.h:

Source/WebKitLegacy/win:

  • BackForwardList.cpp:

(BackForwardList::goToItem):

  • BackForwardList.h:
  • WebBackForwardList.cpp:

(WebBackForwardList::goToItem):

Location:
trunk/Source
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r237182 r237184  
     12018-10-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Replace HistoryItem* with HistoryItem& where possible
     4        https://bugs.webkit.org/show_bug.cgi?id=190617
     5
     6        Reviewed by Chris Dumez.
     7
     8        * history/BackForwardClient.h:
     9        * history/BackForwardController.cpp:
     10        (WebCore::BackForwardController::setCurrentItem):
     11        * history/BackForwardController.h:
     12        * history/HistoryItem.cpp:
     13        (WebCore::defaultNotifyHistoryItemChanged):
     14        (WebCore::HistoryItem::setAlternateTitle):
     15        (WebCore::HistoryItem::setURLString):
     16        (WebCore::HistoryItem::setOriginalURLString):
     17        (WebCore::HistoryItem::setReferrer):
     18        (WebCore::HistoryItem::setTitle):
     19        (WebCore::HistoryItem::setTarget):
     20        (WebCore::HistoryItem::setShouldRestoreScrollPosition):
     21        (WebCore::HistoryItem::setStateObject):
     22        (WebCore::HistoryItem::notifyChanged):
     23        * history/HistoryItem.h:
     24        * loader/EmptyClients.cpp:
     25        * loader/FrameLoader.cpp:
     26        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
     27        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
     28        (WebCore::FrameLoader::loadSameDocumentItem):
     29        * loader/HistoryController.cpp:
     30        (WebCore::HistoryController::goToItem):
     31        (WebCore::HistoryController::updateForCommit):
     32        (WebCore::HistoryController::recursiveUpdateForCommit):
     33        (WebCore::HistoryController::recursiveUpdateForSameDocumentNavigation):
     34        (WebCore::HistoryController::setCurrentItem):
     35        (WebCore::HistoryController::createItem):
     36        (WebCore::HistoryController::itemsAreClones const):
     37        (WebCore::HistoryController::currentFramesMatchItem const):
     38        * loader/HistoryController.h:
     39
    1402018-10-16  Alex Christensen  <achristensen@webkit.org>
    241
  • trunk/Source/WebCore/history/BackForwardClient.h

    r237157 r237184  
    4343    virtual void addItem(Ref<HistoryItem>&&) = 0;
    4444
    45     virtual void goToItem(HistoryItem*) = 0;
     45    virtual void goToItem(HistoryItem&) = 0;
    4646       
    4747    virtual HistoryItem* itemAtIndex(int) = 0;
  • trunk/Source/WebCore/history/BackForwardController.cpp

    r232730 r237184  
    9999}
    100100
    101 void BackForwardController::setCurrentItem(HistoryItem* item)
     101void BackForwardController::setCurrentItem(HistoryItem& item)
    102102{
    103103    m_client->goToItem(item);
  • trunk/Source/WebCore/history/BackForwardController.h

    r237157 r237184  
    5252
    5353    void addItem(Ref<HistoryItem>&&);
    54     void setCurrentItem(HistoryItem*);
     54    void setCurrentItem(HistoryItem&);
    5555       
    5656    int count() const;
  • trunk/Source/WebCore/history/HistoryItem.cpp

    r236762 r237184  
    5050}
    5151
    52 static void defaultNotifyHistoryItemChanged(HistoryItem*)
    53 {
    54 }
    55 
    56 WEBCORE_EXPORT void (*notifyHistoryItemChanged)(HistoryItem*) = defaultNotifyHistoryItemChanged;
     52static void defaultNotifyHistoryItemChanged(HistoryItem&)
     53{
     54}
     55
     56void (*notifyHistoryItemChanged)(HistoryItem&) = defaultNotifyHistoryItemChanged;
    5757
    5858HistoryItem::HistoryItem()
     
    196196{
    197197    m_displayTitle = alternateTitle;
    198     notifyHistoryItemChanged(this);
     198    notifyChanged();
    199199}
    200200
     
    202202{
    203203    m_urlString = urlString;
    204     notifyHistoryItemChanged(this);
     204    notifyChanged();
    205205}
    206206
     
    215215{
    216216    m_originalURLString = urlString;
    217     notifyHistoryItemChanged(this);
     217    notifyChanged();
    218218}
    219219
     
    221221{
    222222    m_referrer = referrer;
    223     notifyHistoryItemChanged(this);
     223    notifyChanged();
    224224}
    225225
     
    227227{
    228228    m_title = title;
    229     notifyHistoryItemChanged(this);
     229    notifyChanged();
    230230}
    231231
     
    233233{
    234234    m_target = target;
    235     notifyHistoryItemChanged(this);
     235    notifyChanged();
    236236}
    237237
     
    259259{
    260260    m_shouldRestoreScrollPosition = shouldRestore;
    261     notifyHistoryItemChanged(this);
     261    notifyChanged();
    262262}
    263263
     
    310310{
    311311    m_stateObject = WTFMove(object);
    312     notifyHistoryItemChanged(this);
     312    notifyChanged();
    313313}
    314314
     
    466466void HistoryItem::notifyChanged()
    467467{
    468     notifyHistoryItemChanged(this);
     468    notifyHistoryItemChanged(*this);
    469469}
    470470
  • trunk/Source/WebCore/history/HistoryItem.h

    r237182 r237184  
    5858enum class PruningReason;
    5959
    60 WEBCORE_EXPORT extern void (*notifyHistoryItemChanged)(HistoryItem*);
     60WEBCORE_EXPORT extern void (*notifyHistoryItemChanged)(HistoryItem&);
    6161
    6262class HistoryItem : public RefCounted<HistoryItem> {
  • trunk/Source/WebCore/loader/EmptyClients.cpp

    r237157 r237184  
    8484class EmptyBackForwardClient final : public BackForwardClient {
    8585    void addItem(Ref<HistoryItem>&&) final { }
    86     void goToItem(HistoryItem*) final { }
     86    void goToItem(HistoryItem&) final { }
    8787    HistoryItem* itemAtIndex(int) final { return nullptr; }
    8888    int backListCount() const final { return 0; }
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r237148 r237184  
    24372437            if (shouldReset && item)
    24382438                if (Page* page = m_frame.page()) {
    2439                     page->backForward().setCurrentItem(item.get());
     2439                    page->backForward().setCurrentItem(*item);
    24402440                }
    24412441            return;
     
    33023302            if (Page* page = m_frame.page()) {
    33033303                if (HistoryItem* resetItem = m_frame.mainFrame().loader().history().currentItem())
    3304                     page->backForward().setCurrentItem(resetItem);
     3304                    page->backForward().setCurrentItem(*resetItem);
    33053305            }
    33063306        }
     
    35623562        view->setWasScrolledByUser(false);
    35633563
    3564     history().setCurrentItem(&item);
     3564    history().setCurrentItem(item);
    35653565       
    35663566    // loadInSameDocument() actually changes the URL and notifies load delegates of a "fake" load
  • trunk/Source/WebCore/loader/HistoryController.cpp

    r237148 r237184  
    317317    // as opposed to happening for some/one of the page commits that might happen soon
    318318    RefPtr<HistoryItem> currentItem = page->backForward().currentItem();
    319     page->backForward().setCurrentItem(&targetItem);
     319    page->backForward().setCurrentItem(targetItem);
    320320
    321321    // First set the provisional item of any frames that are not actually navigating.
     
    485485        // We should get to the bottom of this.
    486486        ASSERT(m_provisionalItem);
    487         setCurrentItem(m_provisionalItem.get());
     487        if (m_provisionalItem)
     488            setCurrentItem(*m_provisionalItem.get());
    488489        m_provisionalItem = nullptr;
    489490
     
    526527
    527528        // Now commit the provisional item
    528         setCurrentItem(m_provisionalItem.get());
     529        if (m_provisionalItem)
     530            setCurrentItem(*m_provisionalItem.get());
    529531        m_provisionalItem = nullptr;
    530532
     
    575577
    576578    // Commit the provisional item.
    577     setCurrentItem(m_provisionalItem.get());
     579    if (m_provisionalItem)
     580        setCurrentItem(*m_provisionalItem.get());
    578581    m_provisionalItem = nullptr;
    579582
     
    591594}
    592595
    593 void HistoryController::setCurrentItem(HistoryItem* item)
     596void HistoryController::setCurrentItem(HistoryItem& item)
    594597{
    595598    m_frameLoadComplete = false;
    596599    m_previousItem = m_currentItem;
    597     m_currentItem = item;
     600    m_currentItem = &item;
    598601}
    599602
     
    677680   
    678681    // Set the item for which we will save document state
    679     setCurrentItem(item.ptr());
     682    setCurrentItem(item);
    680683   
    681684    return item;
     
    776779        && &item1 != item2
    777780        && item1.itemSequenceNumber() == item2->itemSequenceNumber()
    778         && currentFramesMatchItem(&item1)
     781        && currentFramesMatchItem(item1)
    779782        && item2->hasSameFrames(item1);
    780783}
    781784
    782785// Helper method that determines whether the current frame tree matches given history item's.
    783 bool HistoryController::currentFramesMatchItem(HistoryItem* item) const
    784 {
    785     if ((!m_frame.tree().uniqueName().isEmpty() || !item->target().isEmpty()) && m_frame.tree().uniqueName() != item->target())
     786bool HistoryController::currentFramesMatchItem(HistoryItem& item) const
     787{
     788    if ((!m_frame.tree().uniqueName().isEmpty() || !item.target().isEmpty()) && m_frame.tree().uniqueName() != item.target())
    786789        return false;
    787        
    788     const auto& childItems = item->children();
     790
     791    const auto& childItems = item.children();
    789792    if (childItems.size() != m_frame.tree().childCount())
    790793        return false;
  • trunk/Source/WebCore/loader/HistoryController.h

    r237110 r237184  
    7676
    7777    HistoryItem* currentItem() const { return m_currentItem.get(); }
    78     void setCurrentItem(HistoryItem*);
     78    void setCurrentItem(HistoryItem&);
    7979    void setCurrentItemTitle(const StringWithDirection&);
    8080    bool currentItemShouldBeReplaced() const;
     
    108108    void recursiveUpdateForSameDocumentNavigation();
    109109    bool itemsAreClones(HistoryItem&, HistoryItem*) const;
    110     bool currentFramesMatchItem(HistoryItem*) const;
     110    bool currentFramesMatchItem(HistoryItem&) const;
    111111    void updateBackForwardListClippedAtTarget(bool doClip);
    112112    void updateCurrentItem();
  • trunk/Source/WebKit/ChangeLog

    r237177 r237184  
     12018-10-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Replace HistoryItem* with HistoryItem& where possible
     4        https://bugs.webkit.org/show_bug.cgi?id=190617
     5
     6        Reviewed by Chris Dumez.
     7
     8        * WebProcess/WebCoreSupport/SessionStateConversion.h:
     9        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
     10        (WebKit::WK2NotifyHistoryItemChanged):
     11        (WebKit::WebBackForwardListProxy::goToItem):
     12        * WebProcess/WebPage/WebBackForwardListProxy.h:
     13
    1142018-10-16  Philippe Normand  <pnormand@igalia.com>
    215
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/SessionStateConversion.h

    r230812 r237184  
    2424 */
    2525
    26 #ifndef SessionStateConversion_h
    27 #define SessionStateConversion_h
     26#pragma once
    2827
    2928#include <wtf/Forward.h>
     
    3635
    3736struct BackForwardListItemState;
    38 struct PageState;
    3937
    4038BackForwardListItemState toBackForwardListItemState(const WebCore::HistoryItem&);
     
    4240
    4341} // namespace WebKit
    44 
    45 #endif // SessionStateConversion_h
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp

    r237157 r237184  
    6363}
    6464
    65 static void WK2NotifyHistoryItemChanged(HistoryItem* item)
     65static void WK2NotifyHistoryItemChanged(HistoryItem& item)
    6666{
    67     WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::UpdateBackForwardItem(toBackForwardListItemState(*item)), 0);
     67    WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::UpdateBackForwardItem(toBackForwardListItemState(item)), 0);
    6868}
    6969
     
    101101}
    102102
    103 void WebBackForwardListProxy::goToItem(HistoryItem* item)
     103void WebBackForwardListProxy::goToItem(HistoryItem& item)
    104104{
    105105    if (!m_page)
     
    107107
    108108    SandboxExtension::Handle sandboxExtensionHandle;
    109     m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item->identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
     109    m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(item.identifier()), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
    110110    m_page->sandboxExtensionTracker().beginLoad(m_page->mainWebFrame(), WTFMove(sandboxExtensionHandle));
    111111}
  • trunk/Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h

    r237157 r237184  
    5757    void addItem(Ref<WebCore::HistoryItem>&&) override;
    5858
    59     void goToItem(WebCore::HistoryItem*) override;
     59    void goToItem(WebCore::HistoryItem&) override;
    6060       
    6161    WebCore::HistoryItem* itemAtIndex(int) override;
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r237182 r237184  
     12018-10-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Replace HistoryItem* with HistoryItem& where possible
     4        https://bugs.webkit.org/show_bug.cgi?id=190617
     5
     6        Reviewed by Chris Dumez.
     7
     8        * History/BackForwardList.h:
     9        * History/BackForwardList.mm:
     10        (BackForwardList::goToItem):
     11        * History/WebBackForwardList.mm:
     12        (-[WebBackForwardList goToItem:]):
     13        * History/WebHistoryItem.mm:
     14        (WKNotifyHistoryItemChanged):
     15        * History/WebHistoryItemInternal.h:
     16
    1172018-10-16  Alex Christensen  <achristensen@webkit.org>
    218
  • trunk/Source/WebKitLegacy/mac/History/BackForwardList.h

    r237157 r237184  
    4646    void goBack();
    4747    void goForward();
    48     void goToItem(WebCore::HistoryItem*) override;
     48    void goToItem(WebCore::HistoryItem&) override;
    4949       
    5050    WebCore::HistoryItem* backItem();
  • trunk/Source/WebKitLegacy/mac/History/BackForwardList.mm

    r237157 r237184  
    9292}
    9393
    94 void BackForwardList::goToItem(HistoryItem* item)
    95 {
    96     if (!m_entries.size() || !item)
     94void BackForwardList::goToItem(HistoryItem& item)
     95{
     96    if (!m_entries.size())
    9797        return;
    98        
     98
    9999    unsigned index = 0;
    100100    for (; index < m_entries.size(); ++index) {
    101         if (m_entries[index].ptr() == item)
     101        if (m_entries[index].ptr() == &item)
    102102            break;
    103103    }
  • trunk/Source/WebKitLegacy/mac/History/WebBackForwardList.mm

    r237157 r237184  
    220220- (void)goToItem:(WebHistoryItem *)item
    221221{
    222     core(self)->goToItem(core(item));
     222    if (item)
     223        core(self)->goToItem(*core(item));
    223224}
    224225
  • trunk/Source/WebKitLegacy/mac/History/WebHistoryItem.mm

    r237182 r237184  
    110110}
    111111
    112 void WKNotifyHistoryItemChanged(HistoryItem*)
     112void WKNotifyHistoryItemChanged(HistoryItem&)
    113113{
    114114#if !PLATFORM(IOS)
  • trunk/Source/WebKitLegacy/mac/History/WebHistoryItemInternal.h

    r216816 r237184  
    3434
    3535namespace WebCore {
    36     class HistoryItem;
     36class HistoryItem;
    3737}
    3838
     
    4040WebHistoryItem *kit(WebCore::HistoryItem* item);
    4141
    42 extern void WKNotifyHistoryItemChanged(WebCore::HistoryItem*);
     42extern void WKNotifyHistoryItemChanged(WebCore::HistoryItem&);
    4343
    4444@interface WebHistoryItem ()
  • trunk/Source/WebKitLegacy/win/BackForwardList.cpp

    r237157 r237184  
    100100}
    101101
    102 void BackForwardList::goToItem(HistoryItem* item)
    103 {
    104     if (!m_entries.size() || !item)
    105         return;
    106        
     102void BackForwardList::goToItem(HistoryItem& item)
     103{
     104    if (!m_entries.size())
     105        return;
     106
    107107    unsigned int index = 0;
    108108    for (; index < m_entries.size(); ++index)
    109         if (m_entries[index].ptr() == item)
     109        if (m_entries[index].ptr() == &item)
    110110            break;
    111111    if (index < m_entries.size()) {
  • trunk/Source/WebKitLegacy/win/BackForwardList.h

    r237157 r237184  
    4343    void goBack();
    4444    void goForward();
    45     void goToItem(WebCore::HistoryItem*) override;
     45    void goToItem(WebCore::HistoryItem&) override;
    4646       
    4747    WebCore::HistoryItem* backItem();
  • trunk/Source/WebKitLegacy/win/ChangeLog

    r237165 r237184  
     12018-10-16  Alex Christensen  <achristensen@webkit.org>
     2
     3        Replace HistoryItem* with HistoryItem& where possible
     4        https://bugs.webkit.org/show_bug.cgi?id=190617
     5
     6        Reviewed by Chris Dumez.
     7
     8        * BackForwardList.cpp:
     9        (BackForwardList::goToItem):
     10        * BackForwardList.h:
     11        * WebBackForwardList.cpp:
     12        (WebBackForwardList::goToItem):
     13
    1142018-10-15  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebKitLegacy/win/WebBackForwardList.cpp

    r216823 r237184  
    146146        return E_FAIL;
    147147
    148     m_backForwardList->goToItem(webHistoryItem->historyItem());
     148    if (auto item = webHistoryItem->historyItem())
     149        m_backForwardList->goToItem(*item);
     150
    149151    return S_OK;
    150152}
Note: See TracChangeset for help on using the changeset viewer.