Clean up unnecessary methods in the BackForwardClient interface
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Apr 2014 20:42:19 +0000 (20:42 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Apr 2014 20:42:19 +0000 (20:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131637

Reviewed by Andreas Kling.

Source/WebCore:
Demote back/current/forwardItem and iOS-specific methods from the
BackForwardClient interface. Convert the class to not be refcounted.

No new tests, no behavior was changed.

* WebCore.exp.in:
* history/BackForwardClient.h:
(WebCore::BackForwardClient::~BackForwardClient): Deleted.
(WebCore::BackForwardClient::backItem): Deleted.
(WebCore::BackForwardClient::currentItem): Deleted.
(WebCore::BackForwardClient::forwardItem): Deleted.
* history/BackForwardController.cpp:
(WebCore::BackForwardController::BackForwardController):
* history/BackForwardController.h: Take ownership of the passed BackForwardClient.
(WebCore::BackForwardController::client): Return a reference.
* history/BackForwardList.h: Remove the Page field, since it isn't used any more.
(WebCore::BackForwardList::create): Deleted.
* page/Page.h: Remove RefPtr from PageClient.
* page/Page.cpp:
(WebCore::PageClients::PageClients): Initialize client to nullptr.

Source/WebKit/efl:
Remove uses of reference counting for BackForwardList.
Use references to BackForwardClient instead of pointers.
Stop using BackForwardClient::page() since it was removed.

* ewk/ewk_history.cpp:
(ewk_history_clear):
(ewk_history_new):
(ewk_history_free):
* ewk/ewk_view.cpp:
(_ewk_view_priv_new):
(ewk_view_history_enable_get):
(ewk_view_history_enable_set):
(ewk_view_history_get):

Source/WebKit/mac:
BackForwardClient instances now have ownership lifetime semantics, so
WebBackForwardList now explicitly deletes its inner BackForwardList.

Convert uses of WebCore::BackForwardList through backForward().client() to
accept references instead of pointers.

Use BackForwardController methods rather than directly operating with the
BackForwardClient where possible.

Remove page cache-related methods that are not used anywhere and that call
BackForwardClient::page(), which is removed by this change.

* History/WebBackForwardList.mm:
(-[WebBackForwardList initWithBackForwardList:]):
(-[WebBackForwardList init]):
(-[WebBackForwardList dealloc]):
(-[WebBackForwardList finalize]):
(-[WebBackForwardList setPageCacheSize]): Deleted.
(-[WebBackForwardList pageCacheSize]): Deleted.
(-[WebBackForwardList itemAtIndex:]): Deleted.
* History/WebBackForwardListInternal.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canCachePage):
* WebView/WebFrameView.mm:
(-[WebFrameView keyDown:keyDown:]):
* WebView/WebView.mm:
(-[WebView _loadBackForwardListFromOtherView:]):
(-[WebView initWithCoder:]):
(-[WebView encodeWithCoder:]):
(-[WebView backForwardList]):
(-[WebView setMaintainsBackForwardList:]):

Source/WebKit/win:
Remove uses of reference counting for BackForwardList.
Use BackForwardController instead of BackForwardClient where possible.

* WebBackForwardList.cpp:
(WebBackForwardList::WebBackForwardList):
(WebBackForwardList::~WebBackForwardList):
(WebBackForwardList::createInstance):
* WebBackForwardList.h:
* WebView.cpp:
(WebView::backForwardList):
(WebView::canGoBack):
(WebView::canGoForward):
(WebView::loadBackForwardListFromOtherView):

Source/WebKit2:
Remove stubs for iOS-specific methods in the BackForwardClient interface.

Construct a WebBackForwardListProxy directly, and make the WebCore page
own the BackForwardClient instance. Convert uses of backForward().client()
to accept references instead of raw pointers.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp:
(WebKit::InjectedBundleBackForwardList::clear):
* WebProcess/WebPage/WebBackForwardListProxy.cpp: Store a reference to
WebCore::Page instead of a pointer.
(WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
(WebKit::WebBackForwardListProxy::create): Deleted.
(WebKit::WebBackForwardListProxy::addItem):
(WebKit::WebBackForwardListProxy::goToItem):
(WebKit::WebBackForwardListProxy::itemAtIndex):
(WebKit::WebBackForwardListProxy::backListCount):
(WebKit::WebBackForwardListProxy::forwardListCount):
(WebKit::WebBackForwardListProxy::close):
(WebKit::WebBackForwardListProxy::clear):
(WebKit::WebBackForwardListProxy::isActive):
* WebProcess/WebPage/WebBackForwardListProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
* WebProcess/WebPage/ios/WebBackForwardListProxyIOS.mm: Removed.

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

29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/history/BackForwardClient.h
Source/WebCore/history/BackForwardController.cpp
Source/WebCore/history/BackForwardController.h
Source/WebCore/history/BackForwardList.cpp
Source/WebCore/history/BackForwardList.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_history.cpp
Source/WebKit/efl/ewk/ewk_view.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/History/WebBackForwardList.mm
Source/WebKit/mac/History/WebBackForwardListInternal.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebView/WebFrameView.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebBackForwardList.cpp
Source/WebKit/win/WebBackForwardList.h
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp
Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/ios/WebBackForwardListProxyIOS.mm [deleted file]

index 3b9b855..2aeafc3 100644 (file)
@@ -1,3 +1,31 @@
+2014-04-30  Brian J. Burg  <burg@cs.washington.edu>
+
+        Clean up unnecessary methods in the BackForwardClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=131637
+
+        Reviewed by Andreas Kling.
+
+        Demote back/current/forwardItem and iOS-specific methods from the
+        BackForwardClient interface. Convert the class to not be refcounted.
+
+        No new tests, no behavior was changed.
+
+        * WebCore.exp.in:
+        * history/BackForwardClient.h:
+        (WebCore::BackForwardClient::~BackForwardClient): Deleted.
+        (WebCore::BackForwardClient::backItem): Deleted.
+        (WebCore::BackForwardClient::currentItem): Deleted.
+        (WebCore::BackForwardClient::forwardItem): Deleted.
+        * history/BackForwardController.cpp:
+        (WebCore::BackForwardController::BackForwardController):
+        * history/BackForwardController.h: Take ownership of the passed BackForwardClient.
+        (WebCore::BackForwardController::client): Return a reference.
+        * history/BackForwardList.h: Remove the Page field, since it isn't used any more.
+        (WebCore::BackForwardList::create): Deleted.
+        * page/Page.h: Remove RefPtr from PageClient.
+        * page/Page.cpp:
+        (WebCore::PageClients::PageClients): Initialize client to nullptr.
+
 2014-04-30  Brent Fulgham  <bfulgham@apple.com>
 
         [Mac, iOS] Support caption activation via JS webkitHasClosedCaptions method
index 6d48c2e..621434b 100644 (file)
@@ -473,7 +473,7 @@ __ZN7WebCore15BackForwardList7entriesEv
 __ZN7WebCore15BackForwardList8backItemEv
 __ZN7WebCore15BackForwardList8capacityEv
 __ZN7WebCore15BackForwardList9goForwardEv
-__ZN7WebCore15BackForwardListC1EPNS_4PageE
+__ZN7WebCore15BackForwardListC1Ev
 __ZN7WebCore15CertificateInfoC1EPK9__CFArray
 __ZN7WebCore15CertificateInfoC1ERKNS_16ResourceResponseE
 __ZN7WebCore15CertificateInfoC1Ev
@@ -867,6 +867,7 @@ __ZN7WebCore20toUInt32EnforceRangeEPN3JSC9ExecStateENS0_7JSValueE
 __ZN7WebCore21AudioHardwareListener6createERNS0_6ClientE
 __ZN7WebCore21BackForwardController11itemAtIndexEi
 __ZN7WebCore21BackForwardController6goBackEv
+__ZN7WebCore21BackForwardController7addItemEN3WTF10PassRefPtrINS_11HistoryItemEEE
 __ZN7WebCore21BackForwardController9goForwardEv
 __ZN7WebCore21CrossThreadCopierBaseILb0ELb0EN3WTF6StringEE4copyERKS2_
 __ZN7WebCore21CrossThreadCopierBaseILb0ELb0ENS_19IDBDatabaseMetadataEE4copyERKS1_
index 4718736..5f931d0 100644 (file)
 #define BackForwardClient_h
 
 #include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
 class HistoryItem;
 
-class BackForwardClient : public RefCounted<BackForwardClient> {
-public: 
+class BackForwardClient {
+public:
     virtual ~BackForwardClient()
     {
     }
@@ -44,27 +43,12 @@ public:
     virtual void addItem(PassRefPtr<HistoryItem>) = 0;
 
     virtual void goToItem(HistoryItem*) = 0;
-        
+
     virtual HistoryItem* itemAtIndex(int) = 0;
     virtual int backListCount() = 0;
     virtual int forwardListCount() = 0;
 
     virtual void close() = 0;
-
-#if PLATFORM(IOS)
-    // FIXME: These methods seem to violate the encapsulation of this class.
-    virtual unsigned current() = 0;
-    virtual void setCurrent(unsigned newCurrent) = 0;
-
-    // FIXME: Consider renaming this method once we upstream the iOS changes to WebView.mm.
-    virtual bool clearAllPageCaches() = 0;
-#endif
-
-    // FIXME: Delete these once all callers are using BackForwardController
-    // instead of calling this directly.
-    HistoryItem* backItem() { return itemAtIndex(-1); }
-    HistoryItem* currentItem() { return itemAtIndex(0); }
-    HistoryItem* forwardItem() { return itemAtIndex(1); }
 };
 
 } // namespace WebCore
index 2d1d020..2a3f73b 100644 (file)
 
 namespace WebCore {
 
-BackForwardController::BackForwardController(Page& page, PassRefPtr<BackForwardClient> client)
+BackForwardController::BackForwardController(Page& page, std::unique_ptr<BackForwardClient> client)
     : m_page(page)
-    , m_client(client)
+    , m_client(std::move(client))
 {
     if (!m_client)
-        m_client = BackForwardList::create(&page);
+        m_client = std::make_unique<BackForwardList>();
 }
 
 BackForwardController::~BackForwardController()
index 6387746..aaa00d4 100644 (file)
@@ -28,7 +28,6 @@
 
 #include <wtf/Noncopyable.h>
 #include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
@@ -39,10 +38,11 @@ class Page;
 class BackForwardController {
     WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED;
 public:
-    BackForwardController(Page&, PassRefPtr<BackForwardClient>);
+    BackForwardController(Page&, std::unique_ptr<BackForwardClient>);
     ~BackForwardController();
 
-    BackForwardClient* client() const { return m_client.get(); }
+    // FIXME: Remove uses of this getter. <https://webkit.org/b/132027>
+    BackForwardClient& client() const { return *m_client; }
 
     bool canGoBackOrForward(int distance) const;
     void goBackOrForward(int distance);
@@ -52,7 +52,7 @@ public:
 
     void addItem(PassRefPtr<HistoryItem>);
     void setCurrentItem(HistoryItem*);
-        
+
     int count() const;
     int backCount() const;
     int forwardCount() const;
@@ -67,7 +67,7 @@ public:
 
 private:
     Page& m_page;
-    RefPtr<BackForwardClient> m_client;
+    std::unique_ptr<BackForwardClient> m_client;
 };
 
 } // namespace WebCore
index 1e5e774..4cdb283 100644 (file)
@@ -32,7 +32,6 @@
 #include "FrameLoaderClient.h"
 #include "HistoryItem.h"
 #include "Logging.h"
-#include "Page.h"
 #include "PageCache.h"
 #include "SerializedScriptValue.h"
 
@@ -41,9 +40,8 @@ namespace WebCore {
 static const unsigned DefaultCapacity = 100;
 static const unsigned NoCurrentItemIndex = UINT_MAX;
 
-BackForwardList::BackForwardList(Page* page)
-    : m_page(page)
-    , m_current(NoCurrentItemIndex)
+BackForwardList::BackForwardList()
+    : m_current(NoCurrentItemIndex)
     , m_capacity(DefaultCapacity)
     , m_closed(true)
     , m_enabled(true)
@@ -261,7 +259,6 @@ void BackForwardList::close()
         pageCache()->remove(m_entries[i].get());
     m_entries.clear();
     m_entryHash.clear();
-    m_page = 0;
     m_closed = true;
 }
 
index 3b05be9..f9c3e14 100644 (file)
 
 namespace WebCore {
 
-class Page;
-
 typedef Vector<RefPtr<HistoryItem>> HistoryItemVector;
 typedef HashSet<RefPtr<HistoryItem>> HistoryItemHashSet;
 
 class BackForwardList : public BackForwardClient {
-public: 
-    static PassRefPtr<BackForwardList> create(Page* page) { return adoptRef(new BackForwardList(page)); }
+public:
+    BackForwardList();
     virtual ~BackForwardList();
 
-    Page* page() { return m_page; }
-
     virtual void addItem(PassRefPtr<HistoryItem>) override;
     void goBack();
     void goForward();
     virtual void goToItem(HistoryItem*) override;
-        
+
     HistoryItem* backItem();
     HistoryItem* currentItem();
     HistoryItem* forwardItem();
@@ -74,16 +70,13 @@ public:
     HistoryItemVector& entries();
 
 #if PLATFORM(IOS)
-    virtual unsigned current() override;
-    virtual void setCurrent(unsigned newCurrent) override;
+    unsigned current();
+    void setCurrent(unsigned newCurrent);
 
-    virtual bool clearAllPageCaches() override;
+    bool clearAllPageCaches();
 #endif
 
 private:
-    explicit BackForwardList(Page*);
-
-    Page* m_page;
     HistoryItemVector m_entries;
     HistoryItemHashSet m_entryHash;
     unsigned m_current;
index 5adfc14..2674412 100644 (file)
@@ -144,7 +144,7 @@ Page::Page(PageClients& pageClients)
 #endif
     , m_settings(Settings::create(this))
     , m_progress(std::make_unique<ProgressTracker>(*pageClients.progressTrackerClient))
-    , m_backForwardController(std::make_unique<BackForwardController>(*this, pageClients.backForwardClient))
+    , m_backForwardController(std::make_unique<BackForwardController>(*this, std::move(pageClients.backForwardClient)))
     , m_mainFrame(MainFrame::create(*this, *pageClients.loaderClientForMainFrame))
     , m_theme(RenderTheme::themeForPage(this))
     , m_editorClient(pageClients.editorClient)
@@ -1605,6 +1605,7 @@ Page::PageClients::PageClients()
     , inspectorClient(nullptr)
     , plugInClient(nullptr)
     , progressTrackerClient(nullptr)
+    , backForwardClient(nullptr)
     , validationMessageClient(nullptr)
     , loaderClientForMainFrame(nullptr)
 {
index 59f8ae6..38e4256 100644 (file)
@@ -134,7 +134,7 @@ public:
         InspectorClient* inspectorClient;
         PlugInClient* plugInClient;
         ProgressTrackerClient* progressTrackerClient;
-        RefPtr<BackForwardClient> backForwardClient;
+        std::unique_ptr<BackForwardClient> backForwardClient;
         ValidationMessageClient* validationMessageClient;
         FrameLoaderClient* loaderClientForMainFrame;
 
index 285679f..f855cbd 100644 (file)
@@ -1,3 +1,24 @@
+2014-04-30  Brian J. Burg  <burg@cs.washington.edu>
+
+        Clean up unnecessary methods in the BackForwardClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=131637
+
+        Reviewed by Andreas Kling.
+
+        Remove uses of reference counting for BackForwardList.
+        Use references to BackForwardClient instead of pointers.
+        Stop using BackForwardClient::page() since it was removed.
+
+        * ewk/ewk_history.cpp:
+        (ewk_history_clear):
+        (ewk_history_new):
+        (ewk_history_free):
+        * ewk/ewk_view.cpp:
+        (_ewk_view_priv_new):
+        (ewk_view_history_enable_get):
+        (ewk_view_history_enable_set):
+        (ewk_view_history_get):
+
 2014-04-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         FontCache::fontCache() never returns nullptr so it can be made to return a reference instead
index 77f0a6d..d7de9c7 100644 (file)
@@ -92,11 +92,7 @@ static inline Eina_List* _ewk_history_item_list_get(const WebCore::HistoryItemVe
 
 Eina_Bool ewk_history_clear(Ewk_History* history)
 {
-    EWK_HISTORY_CORE_GET_OR_RETURN(history, core, false);
-
-    WebCore::Page* page = core->page();
-    if (page && page->groupPtr())
-        page->groupPtr()->removeVisitedLinks();
+    WebCore::PageGroup::removeAllVisitedLinks();
 
     const int limit = ewk_history_limit_get(history);
     ewk_history_limit_set(history, 0);
@@ -372,7 +368,6 @@ Ewk_History* ewk_history_new(WebCore::BackForwardList* core)
 
     history = new Ewk_History;
     history->core = core;
-    core->ref();
 
     return history;
 }
@@ -388,7 +383,6 @@ Ewk_History* ewk_history_new(WebCore::BackForwardList* core)
 void ewk_history_free(Ewk_History* history)
 {
     DBG("history=%p", history);
-    history->core->deref();
     delete history;
 }
 
index 2be759e..dd2e32f 100644 (file)
@@ -752,7 +752,7 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
     priv->settings.allowUniversalAccessFromFileURLs = pageSettings.allowUniversalAccessFromFileURLs();
     priv->settings.allowFileAccessFromFileURLs = pageSettings.allowFileAccessFromFileURLs();
 
-    priv->history = ewk_history_new(static_cast<WebCore::BackForwardList*>(priv->page->backForward().client()));
+    priv->history = ewk_history_new(static_cast<WebCore::BackForwardList*>(&priv->page->backForward().client()));
 
 #ifdef HAVE_ECORE_X
     priv->isUsingEcoreX = WebCore::isUsingEcoreX(smartData->base.evas);
@@ -1653,14 +1653,14 @@ Eina_Bool ewk_view_history_enable_get(const Evas_Object* ewkView)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
-    return static_cast<WebCore::BackForwardList*>(priv->page->backForward().client())->enabled();
+    return static_cast<WebCore::BackForwardList&>(priv->page->backForward().client()).enabled();
 }
 
 Eina_Bool ewk_view_history_enable_set(Evas_Object* ewkView, Eina_Bool enable)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
-    static_cast<WebCore::BackForwardList*>(priv->page->backForward().client())->setEnabled(enable);
+    static_cast<WebCore::BackForwardList&>(priv->page->backForward().client()).setEnabled(enable);
     return true;
 }
 
@@ -1668,7 +1668,7 @@ Ewk_History* ewk_view_history_get(const Evas_Object* ewkView)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
     EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
-    if (!static_cast<WebCore::BackForwardList*>(priv->page->backForward().client())->enabled()) {
+    if (!static_cast<WebCore::BackForwardList&>(priv->page->backForward().client()).enabled()) {
         ERR("asked history, but it's disabled! Returning 0!");
         return 0;
     }
index 869c72f..069dc1b 100644 (file)
@@ -1,3 +1,42 @@
+2014-04-30  Brian J. Burg  <burg@cs.washington.edu>
+
+        Clean up unnecessary methods in the BackForwardClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=131637
+
+        Reviewed by Andreas Kling.
+
+        BackForwardClient instances now have ownership lifetime semantics, so
+        WebBackForwardList now explicitly deletes its inner BackForwardList.
+
+        Convert uses of WebCore::BackForwardList through backForward().client() to
+        accept references instead of pointers.
+
+        Use BackForwardController methods rather than directly operating with the
+        BackForwardClient where possible.
+
+        Remove page cache-related methods that are not used anywhere and that call
+        BackForwardClient::page(), which is removed by this change.
+
+        * History/WebBackForwardList.mm:
+        (-[WebBackForwardList initWithBackForwardList:]):
+        (-[WebBackForwardList init]):
+        (-[WebBackForwardList dealloc]):
+        (-[WebBackForwardList finalize]):
+        (-[WebBackForwardList setPageCacheSize]): Deleted.
+        (-[WebBackForwardList pageCacheSize]): Deleted.
+        (-[WebBackForwardList itemAtIndex:]): Deleted.
+        * History/WebBackForwardListInternal.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::canCachePage):
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView keyDown:keyDown:]):
+        * WebView/WebView.mm:
+        (-[WebView _loadBackForwardListFromOtherView:]):
+        (-[WebView initWithCoder:]):
+        (-[WebView encodeWithCoder:]):
+        (-[WebView backForwardList]):
+        (-[WebView setMaintainsBackForwardList:]):
+
 2014-04-29  Sam Weinig  <sam@webkit.org>
 
         [iOS] -[WebHTMLView selectionImageForcingBlackText:] returns blank image on iOS
index 077c903..4b983d3 100644 (file)
@@ -85,14 +85,14 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
     return [[[WebBackForwardList alloc] initWithBackForwardList:backForwardList] autorelease];
 }
 
-- (id)initWithBackForwardList:(PassRefPtr<BackForwardList>)backForwardList
+- (id)initWithBackForwardList:(BackForwardList*)backForwardList
 {   
     WebCoreThreadViolationCheckRoundOne();
     self = [super init];
     if (!self)
         return nil;
 
-    _private = reinterpret_cast<WebBackForwardListPrivate*>(backForwardList.leakRef());
+    _private = reinterpret_cast<WebBackForwardListPrivate*>(backForwardList);
     backForwardLists().set(core(self), self);
     return self;
 }
@@ -113,7 +113,7 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
 
 - (id)init
 {
-    return [self initWithBackForwardList:BackForwardList::create(0)];
+    return [self initWithBackForwardList:new BackForwardList];
 }
 
 - (void)dealloc
@@ -126,7 +126,7 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
     if (backForwardList) {
         ASSERT(backForwardList->closed());
         backForwardLists().remove(backForwardList);
-        backForwardList->deref();
+        delete backForwardList;
     }
 
     [super dealloc];
@@ -140,9 +140,9 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
     if (backForwardList) {
         ASSERT(backForwardList->closed());
         backForwardLists().remove(backForwardList);
-        backForwardList->deref();
+        delete backForwardList;
     }
-        
+
     [super finalize];
 }
 
@@ -348,16 +348,6 @@ static bool bumperCarBackForwardHackNeeded()
     return result;
 }
 
-- (void)setPageCacheSize:(NSUInteger)size
-{
-    [kit(core(self)->page()) setUsesPageCache:size != 0];
-}
-
-- (NSUInteger)pageCacheSize
-{
-    return [kit(core(self)->page()) usesPageCache] ? pageCache()->capacity() : 0;
-}
-
 - (int)backListCount
 {
     return core(self)->backListCount();
index fbbb869..17062fe 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 #import <WebKit/WebBackForwardList.h>
-#import <wtf/PassRefPtr.h>
 
 namespace WebCore {
     class BackForwardList;
@@ -37,5 +36,5 @@ WebCore::BackForwardList* core(WebBackForwardList *);
 WebBackForwardList *kit(WebCore::BackForwardList*);
 
 @interface WebBackForwardList (WebBackForwardListInternal)
-- (id)initWithBackForwardList:(PassRefPtr<WebCore::BackForwardList>)backForwardList;
+- (id)initWithBackForwardList:(WebCore::BackForwardList*)backForwardList;
 @end
index 9624382..c11e501 100644 (file)
@@ -1567,11 +1567,11 @@ bool WebFrameLoaderClient::canCachePage() const
     if (!page)
         return false;
     
-    BackForwardList *backForwardList = static_cast<BackForwardList*>(page->backForward().client());
-    if (!backForwardList->enabled())
+    BackForwardList& backForwardList = static_cast<BackForwardList&>(page->backForward().client());
+    if (!backForwardList.enabled())
         return false;
     
-    if (!backForwardList->capacity())
+    if (!backForwardList.capacity())
         return false;
     
     return true;
index df799ba..f80cb18 100644 (file)
@@ -927,7 +927,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
     int index, count;
     BOOL callSuper = YES;
     Frame* coreFrame = [self _web_frame];
-    BOOL maintainsBackForwardList = coreFrame && static_cast<BackForwardList*>(coreFrame->page()->backForward().client())->enabled() ? YES : NO;
+    BOOL maintainsBackForwardList = coreFrame && static_cast<BackForwardList&>(coreFrame->page()->backForward().client()).enabled() ? YES : NO;
     
     count = [characters length];
     for (index = 0; index < count; ++index) {
index 9687c4b..ac6bea5 100644 (file)
@@ -2001,32 +2001,31 @@ static bool fastDocumentTeardownEnabled()
         return;
     
     // It turns out the right combination of behavior is done with the back/forward load
-    // type.  (See behavior matrix at the top of WebFramePrivate.)  So we copy all the items
+    // type. (See behavior matrix at the top of WebFramePrivate.)  So we copy all the items
     // in the back forward list, and go to the current one.
+    BackForwardController& backForward = _private->page->backForward();
+    ASSERT(!backForward.currentItem()); // destination list should be empty
 
-    BackForwardClient* backForwardClient = _private->page->backForward().client();
-    ASSERT(!backForwardClient->currentItem()); // destination list should be empty
-
-    BackForwardClient* otherBackForwardClient = otherView->_private->page->backForward().client();
-    if (!otherBackForwardClient->currentItem())
+    BackForwardController& otherBackForward = otherView->_private->page->backForward();
+    if (!otherBackForward.currentItem())
         return; // empty back forward list, bail
-    
+
     HistoryItem* newItemToGoTo = 0;
 
-    int lastItemIndex = otherBackForwardClient->forwardListCount();
-    for (int i = -otherBackForwardClient->backListCount(); i <= lastItemIndex; ++i) {
+    int lastItemIndex = otherBackForward.forwardCount();
+    for (int i = -otherBackForward.backCount(); i <= lastItemIndex; ++i) {
         if (i == 0) {
-            // If this item is showing , save away its current scroll and form state,
+            // If this item is showing, save away its current scroll and form state,
             // since that might have changed since loading and it is normally not saved
             // until we leave that page.
             otherView->_private->page->mainFrame().loader().history().saveDocumentAndScrollState();
         }
-        RefPtr<HistoryItem> newItem = otherBackForwardClient->itemAtIndex(i)->copy();
-        if (i == 0) 
+        RefPtr<HistoryItem> newItem = otherBackForward.itemAtIndex(i)->copy();
+        if (i == 0)
             newItemToGoTo = newItem.get();
-        backForwardClient->addItem(newItem.release());
+        backForward.addItem(newItem.release());
     }
-    
+
     ASSERT(newItemToGoTo);
     _private->page->goToItem(newItemToGoTo, FrameLoadTypeIndexedBackForward);
 }
@@ -5116,7 +5115,7 @@ static bool needsWebViewInitThreadWorkaround()
 
         LOG(Encoding, "FrameName = %@, GroupName = %@, useBackForwardList = %d\n", frameName, groupName, (int)useBackForwardList);
         [result _commonInitializationWithFrameName:frameName groupName:groupName];
-        static_cast<BackForwardList*>([result page]->backForward().client())->setEnabled(useBackForwardList);
+        static_cast<BackForwardList&>([result page]->backForward().client()).setEnabled(useBackForwardList);
         result->_private->allowsUndo = allowsUndo;
         if (preferences)
             [result setPreferences:preferences];
@@ -5140,7 +5139,7 @@ static bool needsWebViewInitThreadWorkaround()
     // Restore the subviews we set aside.
     _subviews = originalSubviews;
 
-    BOOL useBackForwardList = _private->page && static_cast<BackForwardList*>(_private->page->backForward().client())->enabled();
+    BOOL useBackForwardList = _private->page && static_cast<BackForwardList&>(_private->page->backForward().client()).enabled();
     if ([encoder allowsKeyedCoding]) {
         [encoder encodeObject:[[self mainFrame] name] forKey:@"FrameName"];
         [encoder encodeObject:[self groupName] forKey:@"GroupName"];
@@ -5610,17 +5609,17 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 {
     if (!_private->page)
         return nil;
-    BackForwardList* list = static_cast<BackForwardList*>(_private->page->backForward().client());
-    if (!list->enabled())
+    BackForwardList& list = static_cast<BackForwardList&>(_private->page->backForward().client());
+    if (!list.enabled())
         return nil;
-    return kit(list);
+    return kit(&list);
 }
 
 - (void)setMaintainsBackForwardList:(BOOL)flag
 {
     if (!_private->page)
         return;
-    static_cast<BackForwardList*>(_private->page->backForward().client())->setEnabled(flag);
+    static_cast<BackForwardList&>(_private->page->backForward().client()).setEnabled(flag);
 }
 
 - (BOOL)goBack
index e6133f7..73c493f 100644 (file)
@@ -1,3 +1,24 @@
+2014-04-30  Brian J. Burg  <burg@cs.washington.edu>
+
+        Clean up unnecessary methods in the BackForwardClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=131637
+
+        Reviewed by Andreas Kling.
+
+        Remove uses of reference counting for BackForwardList.
+        Use BackForwardController instead of BackForwardClient where possible.
+
+        * WebBackForwardList.cpp:
+        (WebBackForwardList::WebBackForwardList):
+        (WebBackForwardList::~WebBackForwardList):
+        (WebBackForwardList::createInstance):
+        * WebBackForwardList.h:
+        * WebView.cpp:
+        (WebView::backForwardList):
+        (WebView::canGoBack):
+        (WebView::canGoForward):
+        (WebView::loadBackForwardListFromOtherView):
+
 2014-04-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         FontCache::fontCache() never returns nullptr so it can be made to return a reference instead
index 7acaea2..6161f3e 100644 (file)
@@ -48,12 +48,12 @@ static HashMap<BackForwardList*, WebBackForwardList*>& backForwardListWrappers()
     return staticBackForwardListWrappers;
 }
 
-WebBackForwardList::WebBackForwardList(PassRefPtr<BackForwardList> backForwardList)
+WebBackForwardList::WebBackForwardList(BackForwardList* backForwardList)
     : m_refCount(0)
     , m_backForwardList(backForwardList)
 {
-    ASSERT(!backForwardListWrappers().contains(m_backForwardList.get()));
-    backForwardListWrappers().set(m_backForwardList.get(), this);
+    ASSERT(!backForwardListWrappers().contains(m_backForwardList));
+    backForwardListWrappers().set(m_backForwardList, this);
 
     gClassCount++;
     gClassNameCount.add("WebBackForwardList");
@@ -63,18 +63,18 @@ WebBackForwardList::~WebBackForwardList()
 {
     ASSERT(m_backForwardList->closed());
 
-    ASSERT(backForwardListWrappers().contains(m_backForwardList.get()));
-    backForwardListWrappers().remove(m_backForwardList.get());
+    ASSERT(backForwardListWrappers().contains(m_backForwardList));
+    backForwardListWrappers().remove(m_backForwardList);
 
     gClassCount--;
     gClassNameCount.remove("WebBackForwardList");
 }
 
-WebBackForwardList* WebBackForwardList::createInstance(PassRefPtr<BackForwardList> backForwardList)
+WebBackForwardList* WebBackForwardList::createInstance(BackForwardList* backForwardList)
 {
     WebBackForwardList* instance;
 
-    instance = backForwardListWrappers().get(backForwardList.get());
+    instance = backForwardListWrappers().get(backForwardList);
 
     if (!instance)
         instance = new WebBackForwardList(backForwardList);
index c317941..7103548 100644 (file)
@@ -40,9 +40,9 @@ namespace WebCore {
 class WebBackForwardList : public IWebBackForwardList, IWebBackForwardListPrivate
 {
 public:
-    static WebBackForwardList* createInstance(PassRefPtr<WebCore::BackForwardList>);
+    static WebBackForwardList* createInstance(WebCore::BackForwardList*);
 protected:
-    WebBackForwardList(PassRefPtr<WebCore::BackForwardList>);
+    WebBackForwardList(WebCore::BackForwardList*);
     ~WebBackForwardList();
 
 public:
@@ -109,7 +109,7 @@ public:
 
 protected:
     ULONG m_refCount;
-    RefPtr<WebCore::BackForwardList> m_backForwardList;
+    WebCore::BackForwardList* m_backForwardList;
 };
 
 #endif
index 7657a6c..634f63c 100644 (file)
@@ -3071,7 +3071,7 @@ HRESULT STDMETHODCALLTYPE WebView::backForwardList(
     if (!m_useBackForwardList)
         return E_FAIL;
  
-    *list = WebBackForwardList::createInstance(static_cast<WebCore::BackForwardList*>(m_page->backForward().client()));
+    *list = WebBackForwardList::createInstance(static_cast<WebCore::BackForwardList*>(&m_page->backForward().client()));
 
     return S_OK;
 }
@@ -3904,7 +3904,7 @@ HRESULT STDMETHODCALLTYPE WebView::canGoBack(
         /* [in] */ IUnknown* /*sender*/,
         /* [retval][out] */ BOOL* result)
 {
-    *result = !!(m_page->backForward().client()->backItem() && !m_page->defersLoading());
+    *result = !!(m_page->backForward().backItem() && !m_page->defersLoading());
     return S_OK;
 }
     
@@ -3919,7 +3919,7 @@ HRESULT STDMETHODCALLTYPE WebView::canGoForward(
         /* [in] */ IUnknown* /*sender*/,
         /* [retval][out] */ BOOL* result)
 {
-    *result = !!(m_page->backForward().client()->forwardItem() && !m_page->defersLoading());
+    *result = !!(m_page->backForward().forwardItem() && !m_page->defersLoading());
     return S_OK;
 }
     
@@ -5391,41 +5391,41 @@ HRESULT STDMETHODCALLTYPE WebView::addAdditionalPluginDirectory(
     return S_OK;
 }
 
-HRESULT STDMETHODCALLTYPE WebView::loadBackForwardListFromOtherView( 
+HRESULT STDMETHODCALLTYPE WebView::loadBackForwardListFromOtherView(
     /* [in] */ IWebView* otherView)
 {
     if (!m_page)
         return E_FAIL;
-    
+
     // It turns out the right combination of behavior is done with the back/forward load
-    // type.  (See behavior matrix at the top of WebFramePrivate.)  So we copy all the items
+    // type. (See behavior matrix at the top of WebFramePrivate.) So we copy all the items
     // in the back forward list, and go to the current one.
-    BackForwardClient* backForwardClient = m_page->backForward().client();
-    ASSERT(!backForwardClient->currentItem()); // destination list should be empty
+    BackForwardController& backForward = m_page->backForward();
+    ASSERT(!backForward.currentItem()); // Destination list should be empty.
 
     COMPtr<WebView> otherWebView;
     if (FAILED(otherView->QueryInterface(&otherWebView)))
         return E_FAIL;
-    BackForwardClient* otherBackForwardClient = otherWebView->m_page->backForward().client();
-    if (!otherBackForwardClient->currentItem())
-        return S_OK; // empty back forward list, bail
-    
+    BackForwardController& otherBackForward = otherWebView->m_page->backForward();
+    if (!otherBackForward.currentItem())
+        return S_OK; // If the back forward list is empty, bail.
+
     HistoryItem* newItemToGoTo = 0;
 
-    int lastItemIndex = otherBackForwardClient->forwardListCount();
-    for (int i = -otherBackForwardClient->backListCount(); i <= lastItemIndex; ++i) {
+    int lastItemIndex = otherBackForward.forwardCount();
+    for (int i = -otherBackForward.backCount(); i <= lastItemIndex; ++i) {
         if (!i) {
-            // If this item is showing , save away its current scroll and form state,
+            // If this item is showing, save away its current scroll and form state,
             // since that might have changed since loading and it is normally not saved
             // until we leave that page.
             otherWebView->m_page->mainFrame().loader().history().saveDocumentAndScrollState();
         }
-        RefPtr<HistoryItem> newItem = otherBackForwardClient->itemAtIndex(i)->copy();
-        if (!i) 
+        RefPtr<HistoryItem> newItem = otherBackForward.itemAtIndex(i)->copy();
+        if (!i)
             newItemToGoTo = newItem.get();
-        backForwardClient->addItem(newItem.release());
+        backForward.addItem(newItem.release());
     }
-    
+
     ASSERT(newItemToGoTo);
     m_page->goToItem(newItemToGoTo, FrameLoadTypeIndexedBackForward);
     return S_OK;
index 1a37637..024967d 100644 (file)
@@ -1,3 +1,36 @@
+2014-04-30  Brian J. Burg  <burg@cs.washington.edu>
+
+        Clean up unnecessary methods in the BackForwardClient interface
+        https://bugs.webkit.org/show_bug.cgi?id=131637
+
+        Reviewed by Andreas Kling.
+
+        Remove stubs for iOS-specific methods in the BackForwardClient interface.
+
+        Construct a WebBackForwardListProxy directly, and make the WebCore page
+        own the BackForwardClient instance. Convert uses of backForward().client()
+        to accept references instead of raw pointers.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp:
+        (WebKit::InjectedBundleBackForwardList::clear):
+        * WebProcess/WebPage/WebBackForwardListProxy.cpp: Store a reference to
+        WebCore::Page instead of a pointer.
+        (WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
+        (WebKit::WebBackForwardListProxy::create): Deleted.
+        (WebKit::WebBackForwardListProxy::addItem):
+        (WebKit::WebBackForwardListProxy::goToItem):
+        (WebKit::WebBackForwardListProxy::itemAtIndex):
+        (WebKit::WebBackForwardListProxy::backListCount):
+        (WebKit::WebBackForwardListProxy::forwardListCount):
+        (WebKit::WebBackForwardListProxy::close):
+        (WebKit::WebBackForwardListProxy::clear):
+        (WebKit::WebBackForwardListProxy::isActive):
+        * WebProcess/WebPage/WebBackForwardListProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        * WebProcess/WebPage/ios/WebBackForwardListProxyIOS.mm: Removed.
+
 2014-04-30  Gavin Barraclough  <baraclough@apple.com>
 
         Fix PageVisibility on iOS
index 37c078a..fa9968c 100644 (file)
                2DA944AE1884E9BA00ED86DB /* WebInspectorProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944AA1884E9BA00ED86DB /* WebInspectorProxyIOS.mm */; };
                2DA944AF1884E9BA00ED86DB /* WebPageProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */; };
                2DA944B01884E9BA00ED86DB /* WebProcessProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */; };
-               2DA944B91884EA3900ED86DB /* WebBackForwardListProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944B51884EA3500ED86DB /* WebBackForwardListProxyIOS.mm */; };
                2DA944BA1884EA3C00ED86DB /* WebPageIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944B61884EA3500ED86DB /* WebPageIOS.mm */; };
                2DA944BD188511E700ED86DB /* NetworkProcessIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */; };
                2DACE64E18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DACE64D18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h */; };
                2DA944AA1884E9BA00ED86DB /* WebInspectorProxyIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebInspectorProxyIOS.mm; path = ios/WebInspectorProxyIOS.mm; sourceTree = "<group>"; };
                2DA944AB1884E9BA00ED86DB /* WebPageProxyIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPageProxyIOS.mm; path = ios/WebPageProxyIOS.mm; sourceTree = "<group>"; };
                2DA944AC1884E9BA00ED86DB /* WebProcessProxyIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebProcessProxyIOS.mm; path = ios/WebProcessProxyIOS.mm; sourceTree = "<group>"; };
-               2DA944B51884EA3500ED86DB /* WebBackForwardListProxyIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebBackForwardListProxyIOS.mm; path = ios/WebBackForwardListProxyIOS.mm; sourceTree = "<group>"; };
                2DA944B61884EA3500ED86DB /* WebPageIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPageIOS.mm; path = ios/WebPageIOS.mm; sourceTree = "<group>"; };
                2DA944BC188511E700ED86DB /* NetworkProcessIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NetworkProcessIOS.mm; path = NetworkProcess/ios/NetworkProcessIOS.mm; sourceTree = "<group>"; };
                2DACE64D18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKThumbnailViewInternal.h; sourceTree = "<group>"; };
                2DA944B41884EA2A00ED86DB /* ios */ = {
                        isa = PBXGroup;
                        children = (
-                               2DA944B51884EA3500ED86DB /* WebBackForwardListProxyIOS.mm */,
                                2DA944B61884EA3500ED86DB /* WebPageIOS.mm */,
                                29232DF518B29DCE00D0596F /* WKAccessibilityWebPageObjectIOS.h */,
                                29232DF618B29DCE00D0596F /* WKAccessibilityWebPageObjectIOS.mm */,
                                2DA944A31884E4F000ED86DB /* WebTouchEventIOS.cpp in Sources */,
                                1A30EAC6115D7DA30053E937 /* ConnectionMac.cpp in Sources */,
                                5136183D163126DA00A99DDE /* ConnectionStack.cpp in Sources */,
-                               2DA944B91884EA3900ED86DB /* WebBackForwardListProxyIOS.mm in Sources */,
                                515E773318402D510007203F /* UniqueIDBDatabaseIdentifier.cpp in Sources */,
                                2DA049B7180CCD0A00AAFA9E /* GraphicsLayerCARemote.cpp in Sources */,
                                378E1A4D18208D700031007A /* WKNSURL.mm in Sources */,
index e87905b..717e986 100644 (file)
@@ -73,7 +73,7 @@ void InjectedBundleBackForwardList::clear()
     Page* page = m_page->corePage();
     if (!page)
         return;
-    static_cast<WebBackForwardListProxy*>(page->backForward().client())->clear();
+    static_cast<WebBackForwardListProxy&>(page->backForward().client()).clear();
 }
 
 } // namespace WebKit
index 11bb1a1..96806ef 100644 (file)
@@ -132,7 +132,7 @@ void WebBackForwardListProxy::removeItem(uint64_t itemID)
     historyItemToIDMap().remove(item);
 }
 
-WebBackForwardListProxy::WebBackForwardListProxy(WebPage* page)
+WebBackForwardListProxy::WebBackForwardListProxy(WebPage& page)
     : m_page(page)
 {
     WebCore::notifyHistoryItemChanged = WK2NotifyHistoryItemChanged;
@@ -144,9 +144,6 @@ void WebBackForwardListProxy::addItem(PassRefPtr<HistoryItem> prpItem)
 
     ASSERT(!historyItemToIDMap().contains(item));
 
-    if (!m_page)
-        return;
-
     uint64_t itemID = generateHistoryItemID();
 
     ASSERT(!idToHistoryItemMap().contains(itemID));
@@ -157,41 +154,32 @@ void WebBackForwardListProxy::addItem(PassRefPtr<HistoryItem> prpItem)
     idToHistoryItemMap().set(itemID, item);
 
     updateBackForwardItem(itemID, item.get());
-    m_page->send(Messages::WebPageProxy::BackForwardAddItem(itemID));
+    m_page.send(Messages::WebPageProxy::BackForwardAddItem(itemID));
 }
 
 void WebBackForwardListProxy::goToItem(HistoryItem* item)
 {
-    if (!m_page)
-        return;
-
     SandboxExtension::Handle sandboxExtensionHandle;
-    m_page->sendSync(Messages::WebPageProxy::BackForwardGoToItem(historyItemToIDMap().get(item)), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
-    m_page->sandboxExtensionTracker().beginLoad(m_page->mainWebFrame(), sandboxExtensionHandle);
+    m_page.sendSync(Messages::WebPageProxy::BackForwardGoToItem(historyItemToIDMap().get(item)), Messages::WebPageProxy::BackForwardGoToItem::Reply(sandboxExtensionHandle));
+    m_page.sandboxExtensionTracker().beginLoad(m_page.mainWebFrame(), sandboxExtensionHandle);
 }
 
 HistoryItem* WebBackForwardListProxy::itemAtIndex(int itemIndex)
 {
-    if (!m_page)
-        return 0;
-
     uint64_t itemID = 0;
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardItemAtIndex(itemIndex), Messages::WebPageProxy::BackForwardItemAtIndex::Reply(itemID), m_page->pageID()))
-        return 0;
+    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardItemAtIndex(itemIndex), Messages::WebPageProxy::BackForwardItemAtIndex::Reply(itemID), m_page.pageID()))
+        return nullptr;
 
     if (!itemID)
-        return 0;
+        return nullptr;
 
     return idToHistoryItemMap().get(itemID);
 }
 
 int WebBackForwardListProxy::backListCount()
 {
-    if (!m_page)
-        return 0;
-
     int backListCount = 0;
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardBackListCount(), Messages::WebPageProxy::BackForwardBackListCount::Reply(backListCount), m_page->pageID()))
+    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardBackListCount(), Messages::WebPageProxy::BackForwardBackListCount::Reply(backListCount), m_page.pageID()))
         return 0;
 
     return backListCount;
@@ -199,11 +187,8 @@ int WebBackForwardListProxy::backListCount()
 
 int WebBackForwardListProxy::forwardListCount()
 {
-    if (!m_page)
-        return 0;
-
     int forwardListCount = 0;
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardForwardListCount(), Messages::WebPageProxy::BackForwardForwardListCount::Reply(forwardListCount), m_page->pageID()))
+    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebPageProxy::BackForwardForwardListCount(), Messages::WebPageProxy::BackForwardForwardListCount::Reply(forwardListCount), m_page.pageID()))
         return 0;
 
     return forwardListCount;
@@ -216,8 +201,6 @@ void WebBackForwardListProxy::close()
         WebCore::pageCache()->remove(itemForID(*i));
 
     m_associatedItemIDs.clear();
-
-    m_page = 0;
 }
 
 bool WebBackForwardListProxy::isActive()
@@ -228,7 +211,7 @@ bool WebBackForwardListProxy::isActive()
 
 void WebBackForwardListProxy::clear()
 {
-    m_page->send(Messages::WebPageProxy::BackForwardClear());
+    m_page.send(Messages::WebPageProxy::BackForwardClear());
 }
 
 } // namespace WebKit
index e47eed7..a484e58 100644 (file)
@@ -35,8 +35,8 @@ namespace WebKit {
 class WebPage;
 
 class WebBackForwardListProxy : public WebCore::BackForwardClient {
-public: 
-    static PassRefPtr<WebBackForwardListProxy> create(WebPage* page) { return adoptRef(new WebBackForwardListProxy(page)); }
+public:
+    explicit WebBackForwardListProxy(WebPage&);
 
     static WebCore::HistoryItem* itemForID(uint64_t);
     static uint64_t idForItem(WebCore::HistoryItem*);
@@ -44,16 +44,15 @@ public:
 
     static void addItemFromUIProcess(uint64_t itemID, PassRefPtr<WebCore::HistoryItem>);
     static void setHighestItemIDFromUIProcess(uint64_t itemID);
-    
+
     void clear();
 
 private:
-    WebBackForwardListProxy(WebPage*);
 
     virtual void addItem(PassRefPtr<WebCore::HistoryItem>);
 
     virtual void goToItem(WebCore::HistoryItem*);
-        
+
     virtual WebCore::HistoryItem* itemAtIndex(int);
     virtual int backListCount();
     virtual int forwardListCount();
@@ -62,13 +61,7 @@ private:
 
     virtual void close();
 
-#if PLATFORM(IOS)
-    virtual unsigned current() override;
-    virtual void setCurrent(unsigned newCurrent) override;
-    virtual bool clearAllPageCaches() override;
-#endif
-
-    WebPage* m_page;
+    WebPage& m_page;
     HashSet<uint64_t> m_associatedItemIDs;
 };
 
index 3142493..195d549 100644 (file)
@@ -328,7 +328,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #if ENABLE(DRAG_SUPPORT)
     pageClients.dragClient = new WebDragClient(this);
 #endif
-    pageClients.backForwardClient = WebBackForwardListProxy::create(this);
+    pageClients.backForwardClient = std::make_unique<WebBackForwardListProxy>(*this);
 #if ENABLE(INSPECTOR)
     m_inspectorClient = new WebInspectorClient(this);
     pageClients.inspectorClient = m_inspectorClient;
diff --git a/Source/WebKit2/WebProcess/WebPage/ios/WebBackForwardListProxyIOS.mm b/Source/WebKit2/WebProcess/WebPage/ios/WebBackForwardListProxyIOS.mm
deleted file mode 100644 (file)
index 5da7c9a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebBackForwardListProxy.h"
-
-#if PLATFORM(IOS)
-
-#import <WebCore/NotImplemented.h>
-
-namespace WebKit {
-
-unsigned WebBackForwardListProxy::current()
-{
-    notImplemented();
-    return 0;
-}
-
-void WebBackForwardListProxy::setCurrent(unsigned)
-{
-    notImplemented();
-}
-
-bool WebBackForwardListProxy::clearAllPageCaches()
-{
-    notImplemented();
-    return false;
-}
-
-} // namespace WebKit
-
-#endif // PLATFORM(IOS)