Patch for https://bugs.webkit.org/show_bug.cgi?id=41723
Add BackForwardController class

Reviewed by Anders Carlsson.

- Add BackForwardController which currently only forwards to the existing
  BackForwardList implementation. This is a first step toward allowing
  for a proxying BackForwardList implementation.

* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.base.exp:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* history/BackForwardController.cpp: Added.
(WebCore::BackForwardController::BackForwardController):
(WebCore::BackForwardController::~BackForwardController):
* history/BackForwardController.h: Added.
(WebCore::BackForwardController::client):
(WebCore::BackForwardController::list):
* history/BackForwardControllerClient.h: Added.
(WebCore::BackForwardControllerClient::~BackForwardControllerClient):
* page/Page.cpp:
(WebCore::Page::Page):
(WebCore::Page::~Page):
(WebCore::Page::backForwardList):
(WebCore::Page::goBack):
(WebCore::Page::goForward):
(WebCore::Page::canGoBackOrForward):
(WebCore::Page::goBackOrForward):
(WebCore::Page::getHistoryLength):
* page/Page.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@62607 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index cbafd5a..4c2a095 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -898,6 +898,7 @@
     editing/markup.cpp
     editing/visible_units.cpp
 
+    history/BackForwardController.cpp
     history/BackForwardList.cpp
     history/CachedFrame.cpp
     history/CachedPage.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e8c2a7d..aba9c09 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-07-06  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        Patch for https://bugs.webkit.org/show_bug.cgi?id=41723
+        Add BackForwardController class
+
+        - Add BackForwardController which currently only forwards to the existing
+          BackForwardList implementation. This is a first step toward allowing
+          for a proxying BackForwardList implementation.
+
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.base.exp:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * history/BackForwardController.cpp: Added.
+        (WebCore::BackForwardController::BackForwardController):
+        (WebCore::BackForwardController::~BackForwardController):
+        * history/BackForwardController.h: Added.
+        (WebCore::BackForwardController::client):
+        (WebCore::BackForwardController::list):
+        * history/BackForwardControllerClient.h: Added.
+        (WebCore::BackForwardControllerClient::~BackForwardControllerClient):
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        (WebCore::Page::~Page):
+        (WebCore::Page::backForwardList):
+        (WebCore::Page::goBack):
+        (WebCore::Page::goForward):
+        (WebCore::Page::canGoBackOrForward):
+        (WebCore::Page::goBackOrForward):
+        (WebCore::Page::getHistoryLength):
+        * page/Page.h:
+
 2010-07-06  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
 
         Unreviewed.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 7db9704..46e5a75 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1051,6 +1051,9 @@
 	WebCore/editing/visible_units.cpp \
 	WebCore/editing/visible_units.h \
 	WebCore/editing/gtk/SelectionControllerGtk.cpp \
+	WebCore/history/BackForwardConstroller.cpp \
+	WebCore/history/BackForwardConstroller.h \
+	WebCore/history/BackForwardConstrollerClient.h \
 	WebCore/history/BackForwardList.cpp \
 	WebCore/history/BackForwardList.h \
 	WebCore/history/CachedFrame.cpp \
diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp
index beb5b44..98417c6 100644
--- a/WebCore/WebCore.base.exp
+++ b/WebCore/WebCore.base.exp
@@ -515,7 +515,6 @@
 __ZN7WebCore4Page14didStartPluginEPNS_14HaltablePluginE
 __ZN7WebCore4Page14setMediaVolumeEf
 __ZN7WebCore4Page15addSchedulePairEN3WTF10PassRefPtrINS_12SchedulePairEEE
-__ZN7WebCore4Page15backForwardListEv
 __ZN7WebCore4Page15didMoveOnscreenEv
 __ZN7WebCore4Page16setCanStartMediaEb
 __ZN7WebCore4Page16setDefersLoadingEb
@@ -916,6 +915,7 @@
 __ZNK7WebCore4Node18getSubresourceURLsERN3WTF11ListHashSetINS_4KURLELm256ENS_8KURLHashEEE
 __ZNK7WebCore4Node9nodeIndexEv
 __ZNK7WebCore4Page10pluginDataEv
+__ZNK7WebCore4Page15backForwardListEv
 __ZNK7WebCore4Page34inLowQualityImageInterpolationModeEv
 __ZNK7WebCore4Page9groupNameEv
 __ZNK7WebCore5Frame11currentFormEv
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index f921d1b..64d0283 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1387,6 +1387,9 @@
             'editing/visible_units.cpp',
             'editing/visible_units.h',
             'history/mac/HistoryItemMac.mm',
+            'history/BackForwardController.cpp',
+            'history/BackForwardController.h',
+            'history/BackForwardControllerClient.h',
             'history/BackForwardList.cpp',
             'history/BackForwardList.h',
             'history/BackForwardListChromium.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 8299889..29462e8 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -599,6 +599,7 @@
     editing/VisibleSelection.cpp \
     editing/visible_units.cpp \
     editing/WrapContentsInDummySpanCommand.cpp \
+    history/BackForwardController.cpp \
     history/BackForwardList.cpp \
     history/CachedFrame.cpp \
     history/CachedPage.cpp \
@@ -1350,6 +1351,8 @@
     editing/VisibleSelection.h \
     editing/visible_units.h \
     editing/WrapContentsInDummySpanCommand.h \
+    history/BackForwardController.h \
+    history/BackForwardControllerClient.h \
     history/BackForwardList.h \
     history/CachedFrame.h \
     history/CachedPage.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 94fab3d..df9913b 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -49445,6 +49445,18 @@
 			Name="history"

 			>

 			<File

+				RelativePath="..\history\BackForwardController.cpp"

+				>

+			</File>

+			<File

+				RelativePath="..\history\BackForwardController.h"

+				>

+			</File>

+			<File

+				RelativePath="..\history\BackForwardControllerClient.h"

+				>

+			</File>

+			<File

 				RelativePath="..\history\BackForwardList.cpp"

 				>

 			</File>

diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 78b2301..87f9f42 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -4664,6 +4664,9 @@
 		BCA846D60DC67A350026C309 /* RenderReplica.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA846D40DC67A350026C309 /* RenderReplica.cpp */; };
 		BCA846D70DC67A350026C309 /* RenderReplica.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA846D50DC67A350026C309 /* RenderReplica.h */; };
 		BCA85A100C3AEAF4006F8308 /* DOMSVGNumberInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA85A0F0C3AEAF4006F8308 /* DOMSVGNumberInternal.h */; };
+		BCA8C81E11E3D36900812FB7 /* BackForwardController.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA8C81C11E3D36900812FB7 /* BackForwardController.h */; };
+		BCA8C81F11E3D36900812FB7 /* BackForwardController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCA8C81D11E3D36900812FB7 /* BackForwardController.cpp */; };
+		BCA8C83111E3D53200812FB7 /* BackForwardControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA8C83011E3D53200812FB7 /* BackForwardControllerClient.h */; };
 		BCAA90C30A7EBA60008B1229 /* Scrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */; };
 		BCACF3BC1072921A00C0C8A3 /* UserContentURLPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */; };
 		BCACF3BD1072921A00C0C8A3 /* UserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10260,6 +10263,9 @@
 		BCA846D40DC67A350026C309 /* RenderReplica.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderReplica.cpp; sourceTree = "<group>"; };
 		BCA846D50DC67A350026C309 /* RenderReplica.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderReplica.h; sourceTree = "<group>"; };
 		BCA85A0F0C3AEAF4006F8308 /* DOMSVGNumberInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGNumberInternal.h; sourceTree = "<group>"; };
+		BCA8C81C11E3D36900812FB7 /* BackForwardController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardController.h; sourceTree = "<group>"; };
+		BCA8C81D11E3D36900812FB7 /* BackForwardController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackForwardController.cpp; sourceTree = "<group>"; };
+		BCA8C83011E3D53200812FB7 /* BackForwardControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardControllerClient.h; sourceTree = "<group>"; };
 		BCAA90C20A7EBA60008B1229 /* Scrollbar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Scrollbar.cpp; path = platform/Scrollbar.cpp; sourceTree = SOURCE_ROOT; };
 		BCACF3BA1072921A00C0C8A3 /* UserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentURLPattern.cpp; sourceTree = "<group>"; };
 		BCACF3BB1072921A00C0C8A3 /* UserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentURLPattern.h; sourceTree = "<group>"; };
@@ -11874,6 +11880,9 @@
 				5160F4920B0AA71500C1D2AF /* mac */,
 				51741D0C0B07259A00ED442C /* BackForwardList.cpp */,
 				51741D0B0B07259A00ED442C /* BackForwardList.h */,
+				BCA8C81D11E3D36900812FB7 /* BackForwardController.cpp */,
+				BCA8C81C11E3D36900812FB7 /* BackForwardController.h */,
+				BCA8C83011E3D53200812FB7 /* BackForwardControllerClient.h */,
 				51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */,
 				51C0AA380F2AA10A001648C2 /* CachedFrame.h */,
 				51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */,
@@ -19706,6 +19715,8 @@
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
 				CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
 				B885E8D511E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h in Headers */,
+				BCA8C81E11E3D36900812FB7 /* BackForwardController.h in Headers */,
+				BCA8C83111E3D53200812FB7 /* BackForwardControllerClient.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -22045,6 +22056,7 @@
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
 				B885E8D411E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp in Sources */,
+				BCA8C81F11E3D36900812FB7 /* BackForwardController.cpp in Sources */,
 				4F4F5FFB11CBD2E100A186BF /* RemoteInspectorFrontend2.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
diff --git a/WebCore/history/BackForwardController.cpp b/WebCore/history/BackForwardController.cpp
new file mode 100644
index 0000000..5ec90c2
--- /dev/null
+++ b/WebCore/history/BackForwardController.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "BackForwardController.h"
+
+#include "BackForwardControllerClient.h"
+#include "BackForwardList.h"
+
+namespace WebCore {
+
+BackForwardController::BackForwardController(Page* page, BackForwardControllerClient* client)
+    : m_page(page)
+    , m_client(client)
+{
+    if (!m_client)
+        m_list = BackForwardList::create(page);
+}
+
+BackForwardController::~BackForwardController()
+{
+    if (m_client)
+        m_client->backForwardControllerDestroyed();
+}
+
+} // namespace WebCore
diff --git a/WebCore/history/BackForwardController.h b/WebCore/history/BackForwardController.h
new file mode 100644
index 0000000..41aa65c
--- /dev/null
+++ b/WebCore/history/BackForwardController.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef BackForwardController_h
+#define BackForwardController_h
+
+#include "BackForwardList.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class BackForwardControllerClient;
+
+class BackForwardController : public Noncopyable {
+public:
+    BackForwardController(Page*, BackForwardControllerClient*);
+    ~BackForwardController();
+
+    BackForwardControllerClient* client() const { return m_client; }
+    BackForwardList* list() const { return m_list.get(); }
+
+private:
+    Page* m_page;
+    BackForwardControllerClient* m_client;
+    RefPtr<BackForwardList> m_list;
+};
+
+} // namespace WebCore
+
+#endif // BackForwardController_h
diff --git a/WebCore/history/BackForwardControllerClient.h b/WebCore/history/BackForwardControllerClient.h
new file mode 100644
index 0000000..a4d9f76
--- /dev/null
+++ b/WebCore/history/BackForwardControllerClient.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef BackForwardControllerClient_h
+#define BackForwardControllerClient_h
+
+namespace WebCore {
+
+class BackForwardControllerClient {
+public:
+    virtual void backForwardControllerDestroyed() = 0;
+
+protected:
+    virtual ~BackForwardControllerClient() { }
+};
+
+} // namespace WebCore
+
+#endif // BackForwardControllerClient_h
diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp
index 9bdbe79..509a7d1 100644
--- a/WebCore/page/Page.cpp
+++ b/WebCore/page/Page.cpp
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "Page.h"
 
+#include "BackForwardController.h"
 #include "BackForwardList.h"
 #include "Base64.h"
 #include "CSSStyleSelector.h"
@@ -141,7 +142,7 @@
 #endif
     , m_settings(new Settings(this))
     , m_progress(new ProgressTracker)
-    , m_backForwardList(BackForwardList::create(this))
+    , m_backForwardController(new BackForwardController(this, 0))
     , m_theme(RenderTheme::themeForPage(this))
     , m_editorClient(editorClient)
     , m_frameCount(0)
@@ -214,7 +215,7 @@
     m_inspectorController->inspectedPageDestroyed();
 #endif
 
-    m_backForwardList->close();
+    backForwardList()->close();
 
 #ifndef NDEBUG
     pageCounter.decrement();
@@ -242,14 +243,14 @@
     m_openedByDOM = true;
 }
 
-BackForwardList* Page::backForwardList()
+BackForwardList* Page::backForwardList() const
 {
-    return m_backForwardList.get();
+    return m_backForwardController->list();
 }
 
 bool Page::goBack()
 {
-    HistoryItem* item = m_backForwardList->backItem();
+    HistoryItem* item = backForwardList()->backItem();
     
     if (item) {
         goToItem(item, FrameLoadTypeBack);
@@ -260,7 +261,7 @@
 
 bool Page::goForward()
 {
-    HistoryItem* item = m_backForwardList->forwardItem();
+    HistoryItem* item = backForwardList()->forwardItem();
     
     if (item) {
         goToItem(item, FrameLoadTypeForward);
@@ -273,9 +274,9 @@
 {
     if (distance == 0)
         return true;
-    if (distance > 0 && distance <= m_backForwardList->forwardListCount())
+    if (distance > 0 && distance <= backForwardList()->forwardListCount())
         return true;
-    if (distance < 0 && -distance <= m_backForwardList->backListCount())
+    if (distance < 0 && -distance <= backForwardList()->backListCount())
         return true;
     return false;
 }
@@ -285,16 +286,16 @@
     if (distance == 0)
         return;
 
-    HistoryItem* item = m_backForwardList->itemAtIndex(distance);
+    HistoryItem* item = backForwardList()->itemAtIndex(distance);
     if (!item) {
         if (distance > 0) {
-            int forwardListCount = m_backForwardList->forwardListCount();
+            int forwardListCount = backForwardList()->forwardListCount();
             if (forwardListCount > 0) 
-                item = m_backForwardList->itemAtIndex(forwardListCount);
+                item = backForwardList()->itemAtIndex(forwardListCount);
         } else {
-            int backListCount = m_backForwardList->backListCount();
+            int backListCount = backForwardList()->backListCount();
             if (backListCount > 0)
-                item = m_backForwardList->itemAtIndex(-backListCount);
+                item = backForwardList()->itemAtIndex(-backListCount);
         }
     }
 
@@ -328,7 +329,7 @@
 
 int Page::getHistoryLength()
 {
-    return m_backForwardList->backListCount() + 1 + m_backForwardList->forwardListCount();
+    return backForwardList()->backListCount() + 1 + backForwardList()->forwardListCount();
 }
 
 void Page::setGlobalHistoryItem(HistoryItem* item)
diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h
index b931092..e17507c 100644
--- a/WebCore/page/Page.h
+++ b/WebCore/page/Page.h
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 
+    class BackForwardController;
     class BackForwardList;
     class Chrome;
     class ChromeClient;
@@ -106,7 +107,7 @@
         bool openedByDOM() const;
         void setOpenedByDOM();
 
-        BackForwardList* backForwardList();
+        BackForwardList* backForwardList() const;
 
         // FIXME: The following three methods don't fall under the responsibilities of the Page object
         // They seem to fit a hypothetical Page-controller object that would be akin to the 
@@ -270,7 +271,7 @@
         OwnPtr<Settings> m_settings;
         OwnPtr<ProgressTracker> m_progress;
         
-        RefPtr<BackForwardList> m_backForwardList;
+        OwnPtr<BackForwardController> m_backForwardController;
         RefPtr<Frame> m_mainFrame;
 
         RefPtr<HistoryItem> m_globalHistoryItem;