2011-03-03 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2011 03:21:07 +0000 (03:21 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Mar 2011 03:21:07 +0000 (03:21 +0000)
        Reviewed by Sam Weinig.

        Get rid of Page::globalHistoryItem
        https://bugs.webkit.org/show_bug.cgi?id=55738

        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::updateGlobalHistoryItemForPage):
        Get the current history item and update it using WebView::setGlobalHistoryItem.

        * WebCoreSupport/WebFrameLoaderClient.h:
        * WebView.cpp:
        (WebView::globalHistoryItem):
        (WebView::setGlobalHistoryItem):
        * WebView.h:
2011-03-03  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam Weinig.

        Get rid of Page::globalHistoryItem
        https://bugs.webkit.org/show_bug.cgi?id=55738

        * WebCoreSupport/WebFrameLoaderClient.h:
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::updateGlobalHistoryItemForPage):
        Get the current history item and update it using -[WebView _setGlobalHistoryItem:].

        * WebView/WebView.mm:
        (-[WebView _globalHistoryItem]):
        (-[WebView _setGlobalHistoryItem:]):
        Set _globalHistoryItem ivar.

        * WebView/WebViewData.h:
        * WebView/WebViewData.mm:
        Add _globalHistoryItem ivar.
2011-03-03  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam Weinig.

        Get rid of Page::globalHistoryItem
        https://bugs.webkit.org/show_bug.cgi?id=55738

        The m_globalHistoryItem is only used by Mac and Windows WebKit1.
        Instead of having WebCore updating this member variable, just call out
        to a FrameLoaderClient member function and let WebKit keep it up to date.

        * loader/EmptyClients.h:
        (WebCore::EmptyFrameLoaderClient::dispatchDidRemoveBackForwardItem):
        (WebCore::EmptyFrameLoaderClient::updateGlobalHistoryItemForPage):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
        * loader/FrameLoaderClient.h:
        (WebCore::FrameLoaderClient::updateGlobalHistoryItemForPage):
        * loader/HistoryController.cpp:
        (WebCore::HistoryController::goToItem):
        (WebCore::HistoryController::updateForStandardLoad):
        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
        * page/Page.cpp:
        * page/Page.h:

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h
Source/WebKit/mac/WebView/WebViewData.mm
Source/WebKit/mac/WebView/WebViewInternal.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/win/WebView.cpp
Source/WebKit/win/WebView.h

index 356065e..d3e92f3 100644 (file)
@@ -1,3 +1,29 @@
+2011-03-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Get rid of Page::globalHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=55738
+
+        The m_globalHistoryItem is only used by Mac and Windows WebKit1.
+        Instead of having WebCore updating this member variable, just call out
+        to a FrameLoaderClient member function and let WebKit keep it up to date.
+
+        * loader/EmptyClients.h:
+        (WebCore::EmptyFrameLoaderClient::dispatchDidRemoveBackForwardItem):
+        (WebCore::EmptyFrameLoaderClient::updateGlobalHistoryItemForPage):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+        * loader/FrameLoaderClient.h:
+        (WebCore::FrameLoaderClient::updateGlobalHistoryItemForPage):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::goToItem):
+        (WebCore::HistoryController::updateForStandardLoad):
+        (WebCore::HistoryController::updateForRedirectWithLockedBackForwardList):
+        * page/Page.cpp:
+        * page/Page.h:
+
 2011-03-02  Jeremy Orlow  <jorlow@chromium.org>
 
         Reviewed by Steve Block.
index ce95c9c..4977953 100644 (file)
@@ -352,8 +352,9 @@ public:
     virtual bool shouldGoToHistoryItem(HistoryItem*) const { return false; }
     virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const { return false; }
     virtual void dispatchDidAddBackForwardItem(HistoryItem*) const { }
-    virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const { };
+    virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const { }
     virtual void dispatchDidChangeBackForwardIndex() const { }
+    virtual void updateGlobalHistoryItemForPage() { }
     virtual void saveViewStateToItem(HistoryItem*) { }
     virtual bool canCachePage() const { return false; }
     virtual void didDisplayInsecureContent() { }
index 35f206a..622159d 100644 (file)
@@ -2391,8 +2391,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
             if (shouldReset && item)
                 if (Page* page = m_frame->page()) {
                     page->backForward()->setCurrentItem(item.get());
-                    Settings* settings = m_frame->settings();
-                    page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : item.get());
+                    m_frame->loader()->client()->updateGlobalHistoryItemForPage();
                 }
             return;
         }
@@ -2962,15 +2961,15 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass
         // If the navigation request came from the back/forward menu, and we punt on it, we have the 
         // problem that we have optimistically moved the b/f cursor already, so move it back.  For sanity, 
         // we only do this when punting a navigation for the target frame or top-level frame.  
-        if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(policyChecker()->loadType()))
+        if ((isTargetItem || isLoadingMainFrame()) && isBackForwardLoadType(policyChecker()->loadType())) {
             if (Page* page = m_frame->page()) {
                 Frame* mainFrame = page->mainFrame();
                 if (HistoryItem* resetItem = mainFrame->loader()->history()->currentItem()) {
                     page->backForward()->setCurrentItem(resetItem);
-                    Settings* settings = m_frame->settings();
-                    page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : resetItem);
+                    m_frame->loader()->client()->updateGlobalHistoryItemForPage();
                 }
             }
+        }
         return;
     }
 
index da32700..12792d3 100644 (file)
@@ -191,6 +191,7 @@ namespace WebCore {
         virtual void dispatchDidAddBackForwardItem(HistoryItem*) const = 0;
         virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const = 0;
         virtual void dispatchDidChangeBackForwardIndex() const = 0;
+        virtual void updateGlobalHistoryItemForPage() { }
 
         // This frame has displayed inactive content (such as an image) from an
         // insecure source.  Inactive content cannot spread to other frames.
index f6b61b0..b8bece9 100644 (file)
@@ -250,8 +250,7 @@ void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type)
     // as opposed to happening for some/one of the page commits that might happen soon
     RefPtr<HistoryItem> currentItem = page->backForward()->currentItem();
     page->backForward()->setCurrentItem(targetItem);
-    Settings* settings = m_frame->settings();
-    page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem);
+    m_frame->loader()->client()->updateGlobalHistoryItemForPage();
 
     // First set the provisional item of any frames that are not actually navigating.
     // This must be done before trying to navigate the desired frame, because some
@@ -323,8 +322,8 @@ void HistoryController::updateForStandardLoad(HistoryUpdateType updateType)
                 if (frameLoader->documentLoader()->unreachableURL().isEmpty())
                     frameLoader->client()->updateGlobalHistoryRedirectLinks();
             }
-            if (Page* page = m_frame->page())
-                page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem());
+
+            m_frame->loader()->client()->updateGlobalHistoryItemForPage();
         }
     } else {
         // The client redirect replaces the current history item.
@@ -361,8 +360,8 @@ void HistoryController::updateForRedirectWithLockedBackForwardList()
                     if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
                         m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
                 }
-                if (Page* page = m_frame->page())
-                    page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem());
+
+                m_frame->loader()->client()->updateGlobalHistoryItemForPage();
             }
         }
         // The client redirect replaces the current history item.
index 995db05..411ea3c 100644 (file)
@@ -343,11 +343,6 @@ int Page::getHistoryLength()
     return backForward()->backCount() + 1 + backForward()->forwardCount();
 }
 
-void Page::setGlobalHistoryItem(HistoryItem* item)
-{
-    m_globalHistoryItem = item;
-}
-
 void Page::setGroupName(const String& name)
 {
     if (m_group && !m_group->name().isEmpty()) {
index fc929e3..4498d36 100644 (file)
@@ -147,9 +147,6 @@ namespace WebCore {
 
         void goToItem(HistoryItem*, FrameLoadType);
 
-        HistoryItem* globalHistoryItem() const { return m_globalHistoryItem.get(); }
-        void setGlobalHistoryItem(HistoryItem*);
-
         void setGroupName(const String&);
         const String& groupName() const;
 
@@ -335,8 +332,6 @@ namespace WebCore {
         OwnPtr<BackForwardController> m_backForwardController;
         RefPtr<Frame> m_mainFrame;
 
-        RefPtr<HistoryItem> m_globalHistoryItem;
-
         mutable RefPtr<PluginData> m_pluginData;
 
         RefPtr<RenderTheme> m_theme;
index add125f..7fea19e 100644 (file)
@@ -1,3 +1,24 @@
+2011-03-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Get rid of Page::globalHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=55738
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::updateGlobalHistoryItemForPage):
+        Get the current history item and update it using -[WebView _setGlobalHistoryItem:].
+    
+        * WebView/WebView.mm:
+        (-[WebView _globalHistoryItem]):
+        (-[WebView _setGlobalHistoryItem:]):
+        Set _globalHistoryItem ivar.
+
+        * WebView/WebViewData.h:
+        * WebView/WebViewData.mm:
+        Add _globalHistoryItem ivar.
+
 2011-03-03  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Darin Adler.
index ac2c3d5..c56b165 100644 (file)
@@ -155,6 +155,7 @@ private:
     virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const;
     virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const;
     virtual void dispatchDidChangeBackForwardIndex() const;
+    virtual void updateGlobalHistoryItemForPage();
 
     virtual void didDisplayInsecureContent();
     virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL&);
index 7bf5bb5..3c99c5b 100644 (file)
@@ -75,6 +75,7 @@
 #import "WebUIDelegatePrivate.h"
 #import "WebViewInternal.h"
 #import <WebCore/AuthenticationMac.h>
+#import <WebCore/BackForwardController.h>
 #import <WebCore/BlockExceptions.h>
 #import <WebCore/CachedFrame.h>
 #import <WebCore/Chrome.h>
@@ -966,6 +967,19 @@ void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
 {
 }
 
+void WebFrameLoaderClient::updateGlobalHistoryItemForPage()
+{
+    HistoryItem* historyItem = 0;
+
+    if (Page* page = core(m_webFrame.get())->page()) {
+        if (!page->settings()->privateBrowsingEnabled())
+            historyItem = page->backForward()->currentItem();
+    }
+
+    WebView *webView = getWebView(m_webFrame.get());
+    [webView _setGlobalHistoryItem:historyItem];
+}
+
 void WebFrameLoaderClient::didDisplayInsecureContent()
 {
     WebView *webView = getWebView(m_webFrame.get());   
index 0b0eece..81dbc61 100644 (file)
@@ -2252,9 +2252,15 @@ static inline IMP getMethod(id o, SEL s)
 
 - (WebHistoryItem *)_globalHistoryItem
 {
-    if (!_private->page)
+    if (!_private)
         return nil;
-    return kit(_private->page->globalHistoryItem());
+
+    return kit(_private->_globalHistoryItem.get());
+}
+
+- (void)_setGlobalHistoryItem:(HistoryItem*)historyItem
+{
+    _private->_globalHistoryItem = historyItem;
 }
 
 - (WebTextIterator *)textIteratorForRect:(NSRect)rect
index e22bccd..e8b9188 100644 (file)
@@ -35,6 +35,7 @@
 #import <wtf/RetainPtr.h>
 
 namespace WebCore {
+    class HistoryItem;
     class Page;
 }
 
@@ -183,5 +184,7 @@ extern int pluginDatabaseClientCount;
 #endif
     id<WebGeolocationProvider> _geolocationProvider;
     id<WebDeviceOrientationProvider> m_deviceOrientationProvider;
+
+    RefPtr<WebCore::HistoryItem> _globalHistoryItem;
 }
 @end
index 9794d03..df7563e 100644 (file)
@@ -32,6 +32,7 @@
 #import "WebKitLogging.h"
 #import "WebPreferenceKeysPrivate.h"
 #import <WebCore/WebCoreObjCExtras.h>
+#import <WebCore/HistoryItem.h>
 #import <objc/objc-auto.h>
 #import <runtime/InitializeThreading.h>
 #import <wtf/Threading.h>
index 555c4d1..59f80f9 100644 (file)
@@ -41,6 +41,7 @@
 namespace WebCore {
     class Element;
     class Frame;
+    class HistoryItem;
     class KURL;
     class KeyboardEvent;
     class Page;
@@ -114,6 +115,7 @@ namespace WebCore {
 
 #ifdef __cplusplus
 - (WebCore::Page*)page;
+- (void)_setGlobalHistoryItem:(WebCore::HistoryItem*)historyItem;
 #endif
 
 - (NSMenu *)_menuForElement:(NSDictionary *)element defaultItems:(NSArray *)items;
index 78a9492..1663b14 100644 (file)
@@ -1,3 +1,20 @@
+2011-03-03  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Get rid of Page::globalHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=55738
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::updateGlobalHistoryItemForPage):
+        Get the current history item and update it using WebView::setGlobalHistoryItem.
+        
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebView.cpp:
+        (WebView::globalHistoryItem):
+        (WebView::setGlobalHistoryItem):
+        * WebView.h:
+
 2011-03-03  Brent Fulgham  <bfulgham@webkit.org>
 
         Unreviewed build correction.
index 95394fd..03041a6 100644 (file)
@@ -50,6 +50,7 @@
 #include "WebURLResponse.h"
 #include "WebView.h"
 #pragma warning(push, 0)
+#include <WebCore/BackForwardController.h>
 #include <WebCore/CachedFrame.h>
 #include <WebCore/DocumentLoader.h>
 #include <WebCore/FrameLoader.h>
@@ -67,6 +68,7 @@
 #include <WebCore/PluginView.h>
 #include <WebCore/RenderPart.h>
 #include <WebCore/ResourceHandle.h>
+#include <WebCore/Settings.h>
 #pragma warning(pop)
 
 using namespace WebCore;
@@ -619,6 +621,19 @@ void WebFrameLoaderClient::dispatchDidChangeBackForwardIndex() const
 {
 }
 
+void WebFrameLoaderClient::updateGlobalHistoryItemForPage()
+{
+    HistoryItem* historyItem = 0;
+    WebView* webView = m_webFrame->webView();
+
+    if (Page* page = webView->page()) {
+        if (!page->settings()->privateBrowsingEnabled())
+            historyItem = page->backForward()->currentItem();
+    }
+
+    webView->setGlobalHistoryItem(historyItem);
+}
+
 void WebFrameLoaderClient::didDisplayInsecureContent()
 {
     WebView* webView = m_webFrame->webView();
index 9234e97..57de2ad 100644 (file)
@@ -98,6 +98,7 @@ public:
     virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const;
     virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const;
     virtual void dispatchDidChangeBackForwardIndex() const;
+    virtual void updateGlobalHistoryItemForPage();
 
     virtual void didDisplayInsecureContent();
     virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL&);
index dfcfd15..fdb539d 100644 (file)
@@ -5892,12 +5892,12 @@ HRESULT STDMETHODCALLTYPE WebView::globalHistoryItem(IWebHistoryItem** item)
     if (!m_page)
         return E_FAIL;
 
-    if (!m_page->globalHistoryItem()) {
+    if (!m_globalHistoryItem) {
         *item = 0;
         return S_OK;
     }
 
-    *item = WebHistoryItem::createInstance(m_page->globalHistoryItem());
+    *item = WebHistoryItem::createInstance(m_globalHistoryItem);
     return S_OK;
 }
 
@@ -6633,3 +6633,8 @@ HRESULT WebView::setMinimumTimerInterval(double interval)
     page()->settings()->setMinDOMTimerInterval(interval);
     return S_OK;
 }
+
+void WebView::setGlobalHistoryItem(HistoryItem* historyItem)
+{
+    m_globalHistoryItem = historyItem;
+}
index b036668..957f0a5 100644 (file)
@@ -48,6 +48,10 @@ namespace WebCore {
 }
 #endif
 
+namespace WebCore {
+    class HistoryItem;
+}
+
 class FullscreenVideoController;
 class WebBackForwardList;
 class WebFrame;
@@ -924,6 +928,8 @@ public:
 
     void setLastCursor(HCURSOR cursor) { m_lastSetCursor = cursor; }
 
+    void setGlobalHistoryItem(WebCore::HistoryItem*);
+
 private:
     void setZoomMultiplier(float multiplier, bool isTextOnly);
     float zoomMultiplier(bool isTextOnly);
@@ -1073,6 +1079,8 @@ protected:
     bool m_nextDisplayIsSynchronous;
 
     HCURSOR m_lastSetCursor;
+
+    RefPtr<WebCore::HistoryItem> m_globalHistoryItem;
 };
 
 #endif