Modernize BackForwardClient.h
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 00:14:41 +0000 (00:14 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 00:14:41 +0000 (00:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190610

Reviewed by Chris Dumez.

Source/WebCore:

* editing/markup.cpp:
(WebCore::createPageForSanitizingWebContent):
* history/BackForwardClient.h:
* history/BackForwardController.h:
(WebCore::BackForwardController::client):
(WebCore::BackForwardController::client const):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::overlayPage):
* loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
(WebCore::createEmptyFrameNetworkingContext): Deleted.
(WebCore::fillWithEmptyClients): Deleted.
(WebCore::createEmptyEditorClient): Deleted.
* loader/EmptyClients.h:
* page/Page.cpp:
(WebCore::Page::Page):
* page/PageConfiguration.cpp:
(WebCore::PageConfiguration::PageConfiguration):
* page/PageConfiguration.h:
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):

Source/WebKit:

* WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp:
(WebKit::InjectedBundleBackForwardList::clear):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
(WebKit::WebBackForwardListProxy::backListCount const):
(WebKit::WebBackForwardListProxy::forwardListCount const):
(WebKit::WebBackForwardListProxy::backListCount): Deleted.
(WebKit::WebBackForwardListProxy::forwardListCount): Deleted.
* WebProcess/WebPage/WebBackForwardListProxy.h:
(WebKit::WebBackForwardListProxy::create):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_cpuLimit):
(WebKit::WebPage::restoreSessionInternal):

Source/WebKitLegacy/mac:

* History/BackForwardList.h:
* History/BackForwardList.mm:
(BackForwardList::backListCount const):
(BackForwardList::forwardListCount const):
(BackForwardList::backListCount): Deleted.
(BackForwardList::forwardListCount): Deleted.
* History/WebBackForwardList.mm:
(-[WebBackForwardList init]):
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canCachePage const):
* WebView/WebFrameView.mm:
(-[WebFrameView keyDown:keyDown:]):
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
(-[WebView _loadBackForwardListFromOtherView:]):
(-[WebView initWithCoder:]):
(-[WebView encodeWithCoder:]):
(-[WebView backForwardList]):
(-[WebView setMaintainsBackForwardList:]):

Source/WebKitLegacy/win:

* BackForwardList.cpp:
(BackForwardList::backListCount const):
(BackForwardList::forwardListCount const):
(BackForwardList::backListCount): Deleted.
(BackForwardList::forwardListCount): Deleted.
* BackForwardList.h:
* WebView.cpp:
(WebView::initWithFrame):
(WebView::backForwardList):

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

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/editing/markup.cpp
Source/WebCore/history/BackForwardClient.h
Source/WebCore/history/BackForwardController.h
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.cpp
Source/WebKit/WebProcess/WebPage/WebBackForwardListProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/History/BackForwardList.h
Source/WebKitLegacy/mac/History/BackForwardList.mm
Source/WebKitLegacy/mac/History/WebBackForwardList.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebView/WebFrameView.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/BackForwardList.cpp
Source/WebKitLegacy/win/BackForwardList.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebView.cpp

index 64184b2..e471f23 100644 (file)
@@ -1,3 +1,32 @@
+2018-10-15  Alex Christensen  <achristensen@webkit.org>
+
+        Modernize BackForwardClient.h
+        https://bugs.webkit.org/show_bug.cgi?id=190610
+
+        Reviewed by Chris Dumez.
+
+        * editing/markup.cpp:
+        (WebCore::createPageForSanitizingWebContent):
+        * history/BackForwardClient.h:
+        * history/BackForwardController.h:
+        (WebCore::BackForwardController::client):
+        (WebCore::BackForwardController::client const):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::overlayPage):
+        * loader/EmptyClients.cpp:
+        (WebCore::pageConfigurationWithEmptyClients):
+        (WebCore::createEmptyFrameNetworkingContext): Deleted.
+        (WebCore::fillWithEmptyClients): Deleted.
+        (WebCore::createEmptyEditorClient): Deleted.
+        * loader/EmptyClients.h:
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        * page/PageConfiguration.cpp:
+        (WebCore::PageConfiguration::PageConfiguration):
+        * page/PageConfiguration.h:
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::dataChanged):
+
 2018-10-15  Timothy Hatcher  <timothy@apple.com>
 
         Add support for prefers-color-scheme media query
index e40e3aa..ffd74db 100644 (file)
@@ -174,9 +174,7 @@ void removeSubresourceURLAttributes(Ref<DocumentFragment>&& fragment, WTF::Funct
 
 std::unique_ptr<Page> createPageForSanitizingWebContent()
 {
-    PageConfiguration pageConfiguration(createEmptyEditorClient(), SocketProvider::create(), LibWebRTCProvider::create(), CacheStorageProvider::create());
-
-    fillWithEmptyClients(pageConfiguration);
+    auto pageConfiguration = pageConfigurationWithEmptyClients();
     
     auto page = std::make_unique<Page>(WTFMove(pageConfiguration));
     page->settings().setMediaEnabled(false);
index f1bafde..dd30084 100644 (file)
@@ -45,8 +45,8 @@ public:
     virtual void goToItem(HistoryItem*) = 0;
         
     virtual HistoryItem* itemAtIndex(int) = 0;
-    virtual int backListCount() = 0;
-    virtual int forwardListCount() = 0;
+    virtual int backListCount() const = 0;
+    virtual int forwardListCount() const = 0;
 
     virtual void close() = 0;
 };
index 60693d7..160a4a6 100644 (file)
@@ -41,7 +41,8 @@ public:
     BackForwardController(Page&, Ref<BackForwardClient>&&);
     ~BackForwardController();
 
-    BackForwardClient* client() const { return m_client.get(); }
+    BackForwardClient& client() { return m_client.get(); }
+    const BackForwardClient& client() const { return m_client.get(); }
 
     WEBCORE_EXPORT bool canGoBackOrForward(int distance) const;
     void goBackOrForward(int distance);
@@ -66,7 +67,7 @@ public:
 
 private:
     Page& m_page;
-    RefPtr<BackForwardClient> m_client;
+    Ref<BackForwardClient> m_client;
 };
 
 } // namespace WebCore
index c5b9aa5..1725e93 100644 (file)
@@ -704,13 +704,7 @@ Page* InspectorOverlay::overlayPage()
     if (m_overlayPage)
         return m_overlayPage.get();
 
-    PageConfiguration pageConfiguration(
-        createEmptyEditorClient(),
-        SocketProvider::create(),
-        LibWebRTCProvider::create(),
-        CacheStorageProvider::create()
-    );
-    fillWithEmptyClients(pageConfiguration);
+    auto pageConfiguration = pageConfigurationWithEmptyClients();
     m_overlayPage = std::make_unique<Page>(WTFMove(pageConfiguration));
     m_overlayPage->setDeviceScaleFactor(m_page.deviceScaleFactor());
 
index 7f82c5f..0fcf748 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ApplicationCacheStorage.h"
 #include "BackForwardClient.h"
+#include "CacheStorageProvider.h"
 #include "ColorChooser.h"
 #include "ContextMenuClient.h"
 #include "DataListSuggestionPicker.h"
@@ -48,6 +49,7 @@
 #include "HTMLFormElement.h"
 #include "InProcessIDBServer.h"
 #include "InspectorClient.h"
+#include "LibWebRTCProvider.h"
 #include "NetworkStorageSession.h"
 #include "Page.h"
 #include "PageConfiguration.h"
@@ -55,6 +57,7 @@
 #include "PluginInfoProvider.h"
 #include "ProgressTrackerClient.h"
 #include "SecurityOriginData.h"
+#include "SocketProvider.h"
 #include "StorageArea.h"
 #include "StorageNamespace.h"
 #include "StorageNamespaceProvider.h"
@@ -82,8 +85,8 @@ class EmptyBackForwardClient final : public BackForwardClient {
     void addItem(Ref<HistoryItem>&&) final { }
     void goToItem(HistoryItem*) final { }
     HistoryItem* itemAtIndex(int) final { return nullptr; }
-    int backListCount() final { return 0; }
-    int forwardListCount() final { return 0; }
+    int backListCount() const final { return 0; }
+    int forwardListCount() const final { return 0; }
     void close() final { }
 };
 
@@ -497,11 +500,6 @@ Ref<FrameNetworkingContext> EmptyFrameLoaderClient::createNetworkingContext()
     return EmptyFrameNetworkingContext::create();
 }
 
-Ref<FrameNetworkingContext> createEmptyFrameNetworkingContext()
-{
-    return EmptyFrameNetworkingContext::create();
-}
-
 void EmptyEditorClient::EmptyTextCheckerClient::requestCheckingOfString(TextCheckingRequest&, const VisibleSelection&)
 {
 }
@@ -534,8 +532,16 @@ RefPtr<StorageNamespace> EmptyStorageNamespaceProvider::createTransientLocalStor
     return adoptRef(*new EmptyStorageNamespace);
 }
 
-void fillWithEmptyClients(PageConfiguration& pageConfiguration)
+PageConfiguration pageConfigurationWithEmptyClients()
 {
+    PageConfiguration pageConfiguration {
+        makeUniqueRef<EmptyEditorClient>(),
+        SocketProvider::create(),
+        LibWebRTCProvider::create(),
+        CacheStorageProvider::create(),
+        adoptRef(*new EmptyBackForwardClient)
+    };
+
     static NeverDestroyed<EmptyChromeClient> dummyChromeClient;
     pageConfiguration.chromeClient = &dummyChromeClient.get();
 
@@ -563,7 +569,6 @@ void fillWithEmptyClients(PageConfiguration& pageConfiguration)
     static NeverDestroyed<EmptyProgressTrackerClient> dummyProgressTrackerClient;
     pageConfiguration.progressTrackerClient = &dummyProgressTrackerClient.get();
 
-    pageConfiguration.backForwardClient = adoptRef(*new EmptyBackForwardClient);
     pageConfiguration.diagnosticLoggingClient = std::make_unique<EmptyDiagnosticLoggingClient>();
 
     pageConfiguration.applicationCacheStorage = ApplicationCacheStorage::create({ }, { });
@@ -572,11 +577,8 @@ void fillWithEmptyClients(PageConfiguration& pageConfiguration)
     pageConfiguration.storageNamespaceProvider = adoptRef(*new EmptyStorageNamespaceProvider);
     pageConfiguration.userContentProvider = adoptRef(*new EmptyUserContentProvider);
     pageConfiguration.visitedLinkStore = adoptRef(*new EmptyVisitedLinkStore);
-}
-
-UniqueRef<EditorClient> createEmptyEditorClient()
-{
-    return makeUniqueRef<EmptyEditorClient>();
+    
+    return pageConfiguration;
 }
 
 DiagnosticLoggingClient& emptyDiagnosticLoggingClient()
index d83ffd9..e165039 100644 (file)
@@ -203,11 +203,7 @@ class EmptyChromeClient : public ChromeClient {
     RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) final { return nullptr; }
 };
 
-WEBCORE_EXPORT void fillWithEmptyClients(PageConfiguration&);
-WEBCORE_EXPORT UniqueRef<EditorClient> createEmptyEditorClient();
 DiagnosticLoggingClient& emptyDiagnosticLoggingClient();
-
-class EmptyFrameNetworkingContext;
-WEBCORE_EXPORT Ref<FrameNetworkingContext> createEmptyFrameNetworkingContext();
+WEBCORE_EXPORT PageConfiguration pageConfigurationWithEmptyClients();
 
 }
index 4ab40a7..b909cb2 100644 (file)
@@ -215,7 +215,7 @@ Page::Page(PageConfiguration&& pageConfiguration)
 #endif
     , m_settings(Settings::create(this))
     , m_progress(std::make_unique<ProgressTracker>(*pageConfiguration.progressTrackerClient))
-    , m_backForwardController(std::make_unique<BackForwardController>(*this, *WTFMove(pageConfiguration.backForwardClient)))
+    , m_backForwardController(std::make_unique<BackForwardController>(*this, WTFMove(pageConfiguration.backForwardClient)))
     , m_mainFrame(Frame::create(this, nullptr, pageConfiguration.loaderClientForMainFrame))
     , m_editorClient(WTFMove(pageConfiguration.editorClient))
     , m_plugInClient(pageConfiguration.plugInClient)
index 14c9915..d572ae4 100644 (file)
 
 namespace WebCore {
 
-PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider)
+PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient)
     : editorClient(WTFMove(editorClient))
     , socketProvider(WTFMove(socketProvider))
     , libWebRTCProvider(WTFMove(libWebRTCProvider))
+    , backForwardClient(WTFMove(backForwardClient))
     , cacheStorageProvider(WTFMove(cacheStorageProvider))
 {
 }
 
 PageConfiguration::~PageConfiguration() = default;
+PageConfiguration::PageConfiguration(PageConfiguration&&) = default;
 
 }
index 60bdec7..18a7723 100644 (file)
@@ -65,8 +65,9 @@ class WebGLStateTracker;
 class PageConfiguration {
     WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&);
+    WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&);
     WEBCORE_EXPORT ~PageConfiguration();
+    PageConfiguration(PageConfiguration&&);
 
     AlternativeTextClient* alternativeTextClient { nullptr };
     ChromeClient* chromeClient { nullptr };
@@ -93,7 +94,7 @@ public:
 
     PlugInClient* plugInClient { nullptr };
     ProgressTrackerClient* progressTrackerClient { nullptr };
-    RefPtr<BackForwardClient> backForwardClient;
+    Ref<BackForwardClient> backForwardClient;
     std::unique_ptr<ValidationMessageClient> validationMessageClient;
     FrameLoaderClient* loaderClientForMainFrame { nullptr };
     std::unique_ptr<DiagnosticLoggingClient> diagnosticLoggingClient;
index bdf92bd..088c10b 100644 (file)
@@ -453,13 +453,7 @@ EncodedDataStatus SVGImage::dataChanged(bool allDataReceived)
         return EncodedDataStatus::Complete;
 
     if (allDataReceived) {
-        PageConfiguration pageConfiguration(
-            createEmptyEditorClient(),
-            SocketProvider::create(),
-            LibWebRTCProvider::create(),
-            CacheStorageProvider::create()
-        );
-        fillWithEmptyClients(pageConfiguration);
+        auto pageConfiguration = pageConfigurationWithEmptyClients();
         m_chromeClient = std::make_unique<SVGImageChromeClient>(this);
         pageConfiguration.chromeClient = m_chromeClient.get();
 
index 91805a8..1e37a1c 100644 (file)
@@ -1,3 +1,26 @@
+2018-10-15  Alex Christensen  <achristensen@webkit.org>
+
+        Modernize BackForwardClient.h
+        https://bugs.webkit.org/show_bug.cgi?id=190610
+
+        Reviewed by Chris Dumez.
+
+        * WebProcess/InjectedBundle/InjectedBundleBackForwardList.cpp:
+        (WebKit::InjectedBundleBackForwardList::clear):
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
+        (WebKit::WebBackForwardListProxy::WebBackForwardListProxy):
+        (WebKit::WebBackForwardListProxy::backListCount const):
+        (WebKit::WebBackForwardListProxy::forwardListCount const):
+        (WebKit::WebBackForwardListProxy::backListCount): Deleted.
+        (WebKit::WebBackForwardListProxy::forwardListCount): Deleted.
+        * WebProcess/WebPage/WebBackForwardListProxy.h:
+        (WebKit::WebBackForwardListProxy::create):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_cpuLimit):
+        (WebKit::WebPage::restoreSessionInternal):
+
 2018-10-15  Timothy Hatcher  <timothy@apple.com>
 
         Add support for prefers-color-scheme media query
index ffb9cd0..83ad0e2 100644 (file)
@@ -72,7 +72,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 afdb436..04e9aa7 100644 (file)
@@ -139,14 +139,7 @@ void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerCont
 {
     LOG(ServiceWorker, "WebSWContextManagerConnection::installServiceWorker for worker %s", data.serviceWorkerIdentifier.loggingString().utf8().data());
 
-    PageConfiguration pageConfiguration {
-        createEmptyEditorClient(),
-        WebSocketProvider::create(),
-        WebCore::LibWebRTCProvider::create(),
-        WebProcess::singleton().cacheStorageProvider()
-    };
-
-    fillWithEmptyClients(pageConfiguration);
+    auto pageConfiguration = pageConfigurationWithEmptyClients();
 
 #if ENABLE(INDEXED_DATABASE)
     pageConfiguration.databaseProvider = WebDatabaseProvider::getOrCreate(m_pageGroupID);
index ed48593..68b221f 100644 (file)
@@ -82,8 +82,8 @@ void WebBackForwardListProxy::removeItem(const BackForwardItemIdentifier& itemID
     WebCore::Page::clearPreviousItemFromAllPages(item.get());
 }
 
-WebBackForwardListProxy::WebBackForwardListProxy(WebPage* page)
-    : m_page(page)
+WebBackForwardListProxy::WebBackForwardListProxy(WebPage& page)
+    : m_page(&page)
 {
     WebCore::notifyHistoryItemChanged = WK2NotifyHistoryItemChanged;
 }
@@ -125,7 +125,7 @@ HistoryItem* WebBackForwardListProxy::itemAtIndex(int itemIndex)
     return idToHistoryItemMap().get(*itemID);
 }
 
-int WebBackForwardListProxy::backListCount()
+int WebBackForwardListProxy::backListCount() const
 {
     if (!m_page)
         return 0;
@@ -137,7 +137,7 @@ int WebBackForwardListProxy::backListCount()
     return backListCount;
 }
 
-int WebBackForwardListProxy::forwardListCount()
+int WebBackForwardListProxy::forwardListCount() const
 {
     if (!m_page)
         return 0;
index c6fe437..4b464b6 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebBackForwardListProxy_h
-#define WebBackForwardListProxy_h
+#pragma once
 
 #include <WebCore/BackForwardClient.h>
 #include <wtf/HashSet.h>
@@ -39,7 +38,7 @@ class WebPage;
 
 class WebBackForwardListProxy : public WebCore::BackForwardClient {
 public: 
-    static Ref<WebBackForwardListProxy> create(WebPage* page) { return adoptRef(*new WebBackForwardListProxy(page)); }
+    static Ref<WebBackForwardListProxy> create(WebPage& page) { return adoptRef(*new WebBackForwardListProxy(page)); }
 
     static WebCore::HistoryItem* itemForID(const WebCore::BackForwardItemIdentifier&);
     static void removeItem(const WebCore::BackForwardItemIdentifier&);
@@ -53,15 +52,15 @@ public:
     void clear();
 
 private:
-    WebBackForwardListProxy(WebPage*);
+    WebBackForwardListProxy(WebPage&);
 
     void addItem(Ref<WebCore::HistoryItem>&&) override;
 
     void goToItem(WebCore::HistoryItem*) override;
         
     WebCore::HistoryItem* itemAtIndex(int) override;
-    int backListCount() override;
-    int forwardListCount() override;
+    int backListCount() const override;
+    int forwardListCount() const override;
 
     void close() override;
 
@@ -69,5 +68,3 @@ private:
 };
 
 } // namespace WebKit
-
-#endif // WebBackForwardListProxy_h
index bf56431..e1f6727 100644 (file)
@@ -408,7 +408,8 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
         makeUniqueRef<WebEditorClient>(this),
         WebSocketProvider::create(),
         makeUniqueRef<WebKit::LibWebRTCProvider>(),
-        WebProcess::singleton().cacheStorageProvider()
+        WebProcess::singleton().cacheStorageProvider(),
+        WebBackForwardListProxy::create(*this)
     );
     pageConfiguration.chromeClient = new WebChromeClient(*this);
 #if ENABLE(CONTEXT_MENUS)
@@ -417,7 +418,6 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
 #if ENABLE(DRAG_SUPPORT)
     pageConfiguration.dragClient = new WebDragClient(this);
 #endif
-    pageConfiguration.backForwardClient = WebBackForwardListProxy::create(this);
     pageConfiguration.inspectorClient = new WebInspectorClient(this);
 #if USE(AUTOCORRECTION_PANEL)
     pageConfiguration.alternativeTextClient = new WebAlternativeTextClient(this);
@@ -2527,7 +2527,7 @@ void WebPage::restoreSessionInternal(const Vector<BackForwardListItemState>& ite
     for (const auto& itemState : itemStates) {
         auto historyItem = toHistoryItem(itemState);
         historyItem->setWasRestoredFromSession(restoredByAPIRequest == WasRestoredByAPIRequest::Yes);
-        static_cast<WebBackForwardListProxy*>(corePage()->backForward().client())->addItemFromUIProcess(itemState.identifier, WTFMove(historyItem), m_pageID, overwrite);
+        static_cast<WebBackForwardListProxy&>(corePage()->backForward().client()).addItemFromUIProcess(itemState.identifier, WTFMove(historyItem), m_pageID, overwrite);
     }
 }
 
index be3a5ed..a0c018e 100644 (file)
@@ -1,3 +1,31 @@
+2018-10-15  Alex Christensen  <achristensen@webkit.org>
+
+        Modernize BackForwardClient.h
+        https://bugs.webkit.org/show_bug.cgi?id=190610
+
+        Reviewed by Chris Dumez.
+
+        * History/BackForwardList.h:
+        * History/BackForwardList.mm:
+        (BackForwardList::backListCount const):
+        (BackForwardList::forwardListCount const):
+        (BackForwardList::backListCount): Deleted.
+        (BackForwardList::forwardListCount): Deleted.
+        * History/WebBackForwardList.mm:
+        (-[WebBackForwardList init]):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::canCachePage const):
+        * WebView/WebFrameView.mm:
+        (-[WebFrameView keyDown:keyDown:]):
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+        (-[WebView _loadBackForwardListFromOtherView:]):
+        (-[WebView initWithCoder:]):
+        (-[WebView encodeWithCoder:]):
+        (-[WebView backForwardList]):
+        (-[WebView setMaintainsBackForwardList:]):
+
 2018-10-15  Timothy Hatcher  <timothy@apple.com>
 
         Add support for prefers-color-scheme media query
index 48a1781..c9450e8 100644 (file)
@@ -59,8 +59,8 @@ public:
     void setCapacity(int);
     bool enabled();
     void setEnabled(bool);
-    int backListCount() override;
-    int forwardListCount() override;
+    int backListCount() const override;
+    int forwardListCount() const override;
     bool containsItem(WebCore::HistoryItem&);
 
     void close() override;
index ec62e3b..4a166f9 100644 (file)
@@ -189,14 +189,14 @@ void BackForwardList::setEnabled(bool enabled)
     }
 }
 
-int BackForwardList::backListCount()
+int BackForwardList::backListCount() const
 {
     return m_current == NoCurrentItemIndex ? 0 : m_current;
 }
 
-int BackForwardList::forwardListCount()
+int BackForwardList::forwardListCount() const
 {
-    return m_current == NoCurrentItemIndex ? 0 : (int)m_entries.size() - (m_current + 1);
+    return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
 }
 
 HistoryItem* BackForwardList::itemAtIndex(int index)
index 78e30f9..9120e0f 100644 (file)
@@ -107,7 +107,7 @@ WebBackForwardList *kit(BackForwardList* backForwardList)
 
 - (id)init
 {
-    return [self initWithBackForwardList:BackForwardList::create(0)];
+    return [self initWithBackForwardList:BackForwardList::create(nullptr)];
 }
 
 - (void)dealloc
index b261580..4a2876a 100644 (file)
@@ -1604,11 +1604,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 bdda815..eb8718a 100644 (file)
@@ -910,7 +910,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 fdef467..b32163f 100644 (file)
@@ -1437,7 +1437,8 @@ static void WebKitInitializeGamepadProviderIfNecessary()
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
-        WebCore::CacheStorageProvider::create()
+        WebCore::CacheStorageProvider::create(),
+        BackForwardList::create(self)
     );
 #if !PLATFORM(IOS)
     pageConfiguration.chromeClient = new WebChromeClient(self);
@@ -1454,8 +1455,6 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     pageConfiguration.dragClient = new WebDragClient(self);
 #endif
 
-    pageConfiguration.backForwardClient = BackForwardList::create(self);
-
 #if ENABLE(APPLE_PAY)
     pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinatorClient();
 #endif
@@ -1703,7 +1702,8 @@ static void WebKitInitializeGamepadProviderIfNecessary()
         makeUniqueRef<WebEditorClient>(self),
         SocketProvider::create(),
         LibWebRTCProvider::create(),
-        WebCore::CacheStorageProvider::create()
+        WebCore::CacheStorageProvider::create(),
+        makeUniqueRef<BackForwardList>(),
     );
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
 #if ENABLE(DRAG_SUPPORT)
@@ -1714,7 +1714,6 @@ static void WebKitInitializeGamepadProviderIfNecessary()
     pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinatorClient();
 #endif
 
-    pageConfiguration.backForwardClient = BackForwardList::create(self);
     pageConfiguration.inspectorClient = new WebInspectorClient(self);
     pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageConfiguration.progressTrackerClient = new WebProgressTrackerClient(self);
@@ -2641,7 +2640,7 @@ ALLOW_DEPRECATED_DECLARATIONS_END
         Ref<HistoryItem> newItem = otherBackForward.itemAtIndex(i)->copy();
         if (i == 0) 
             newItemToGoTo = newItem.ptr();
-        backForward.client()->addItem(WTFMove(newItem));
+        backForward.client().addItem(WTFMove(newItem));
     }
 
     ASSERT(newItemToGoTo);
@@ -5876,7 +5875,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];
@@ -5904,7 +5903,7 @@ static bool needsWebViewInitThreadWorkaround()
     _subviews = originalSubviews;
     ALLOW_DEPRECATED_DECLARATIONS_END
 
-    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"];
@@ -6386,17 +6385,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 62057cc..5ede07c 100644 (file)
@@ -196,12 +196,12 @@ void BackForwardList::setEnabled(bool enabled)
     }
 }
 
-int BackForwardList::backListCount()
+int BackForwardList::backListCount() const
 {
     return m_current == NoCurrentItemIndex ? 0 : m_current;
 }
 
-int BackForwardList::forwardListCount()
+int BackForwardList::forwardListCount() const
 {
     return m_current == NoCurrentItemIndex ? 0 : (int)m_entries.size() - (m_current + 1);
 }
index 0c19e80..7479982 100644 (file)
@@ -56,8 +56,8 @@ public:
     void setCapacity(int);
     bool enabled();
     void setEnabled(bool);
-    int backListCount() override;
-    int forwardListCount() override;
+    int backListCount() const final;
+    int forwardListCount() const final;
     bool containsItem(WebCore::HistoryItem*);
 
     void close() override;
index 9be875a..af1f377 100644 (file)
@@ -1,5 +1,22 @@
 2018-10-15  Alex Christensen  <achristensen@webkit.org>
 
+        Modernize BackForwardClient.h
+        https://bugs.webkit.org/show_bug.cgi?id=190610
+
+        Reviewed by Chris Dumez.
+
+        * BackForwardList.cpp:
+        (BackForwardList::backListCount const):
+        (BackForwardList::forwardListCount const):
+        (BackForwardList::backListCount): Deleted.
+        (BackForwardList::forwardListCount): Deleted.
+        * BackForwardList.h:
+        * WebView.cpp:
+        (WebView::initWithFrame):
+        (WebView::backForwardList):
+
+2018-10-15  Alex Christensen  <achristensen@webkit.org>
+
         Remove unused WebView._globalHistoryItem
         https://bugs.webkit.org/show_bug.cgi?id=190601
 
index a86cb7f..91f90a5 100644 (file)
@@ -3109,9 +3109,9 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
         makeUniqueRef<WebEditorClient>(this),
         SocketProvider::create(),
         makeUniqueRef<LibWebRTCProvider>(),
-        WebCore::CacheStorageProvider::create()
+        WebCore::CacheStorageProvider::create(),
+        BackForwardList::create()
     );
-    configuration.backForwardClient = BackForwardList::create();
     configuration.chromeClient = new WebChromeClient(this);
     configuration.contextMenuClient = new WebContextMenuClient(this);
     configuration.dragClient = new WebDragClient(this);
@@ -3394,7 +3394,7 @@ HRESULT WebView::backForwardList(_COM_Outptr_opt_ IWebBackForwardList** list)
     if (!m_useBackForwardList)
         return E_FAIL;
  
-    *list = WebBackForwardList::createInstance(static_cast<BackForwardList*>(m_page->backForward().client()));
+    *list = WebBackForwardList::createInstance(makeRef(&static_cast<BackForwardList&>(m_page->backForward().client())));
 
     return S_OK;
 }