Get rid of BackForwardController::isActive()
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jan 2014 17:16:49 +0000 (17:16 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jan 2014 17:16:49 +0000 (17:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127604

Reviewed by Sam Weinig.

Source/WebCore:

BackForwardController::isActive() used to mean "my page maintains a back forward
list that has zero capacity". Move that logic into WebKit instead, namely the
WebFrameLoaderClient::canCachePage function so we can simplify WebCore.

* history/BackForwardClient.h:
* history/BackForwardController.cpp:
* history/BackForwardController.h:
* history/BackForwardList.h:
* history/PageCache.cpp:
(WebCore::logCanCachePageDecision):
(WebCore::PageCache::canCache):

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::canCachePage):
Move isActive logic here.

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

Source/WebCore/ChangeLog
Source/WebCore/history/BackForwardClient.h
Source/WebCore/history/BackForwardController.cpp
Source/WebCore/history/BackForwardController.h
Source/WebCore/history/BackForwardList.h
Source/WebCore/history/PageCache.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm

index 4b18121..06cab41 100644 (file)
@@ -1,3 +1,22 @@
+2014-01-25  Anders Carlsson  <andersca@apple.com>
+
+        Get rid of BackForwardController::isActive()
+        https://bugs.webkit.org/show_bug.cgi?id=127604
+
+        Reviewed by Sam Weinig.
+
+        BackForwardController::isActive() used to mean "my page maintains a back forward
+        list that has zero capacity". Move that logic into WebKit instead, namely the
+        WebFrameLoaderClient::canCachePage function so we can simplify WebCore.
+
+        * history/BackForwardClient.h:
+        * history/BackForwardController.cpp:
+        * history/BackForwardController.h:
+        * history/BackForwardList.h:
+        * history/PageCache.cpp:
+        (WebCore::logCanCachePageDecision):
+        (WebCore::PageCache::canCache):
+
 2014-01-25  Antti Koivisto  <antti@apple.com>
 
         REGRESSION(r162744): wsj.com paints white
index eb5c3e9..8ba55e5 100644 (file)
@@ -49,8 +49,6 @@ public:
     virtual int backListCount() = 0;
     virtual int forwardListCount() = 0;
 
-    virtual bool isActive() = 0;
-
     virtual void close() = 0;
 
 #if PLATFORM(IOS)
index d2ef39c..2d1d020 100644 (file)
@@ -127,11 +127,6 @@ HistoryItem* BackForwardController::itemAtIndex(int i)
     return m_client->itemAtIndex(i);
 }
 
-bool BackForwardController::isActive()
-{
-    return m_client->isActive();
-}
-
 void BackForwardController::close()
 {
     m_client->close();
index fb05a38..6387746 100644 (file)
@@ -59,8 +59,6 @@ public:
 
     HistoryItem* itemAtIndex(int);
 
-    bool isActive();
-
     void close();
 
     HistoryItem* backItem() { return itemAtIndex(-1); }
index e1b3d34..ae7adfa 100644 (file)
@@ -45,7 +45,7 @@ public:
     virtual ~BackForwardList();
 
     Page* page() { return m_page; }
-    
+
     virtual void addItem(PassRefPtr<HistoryItem>) override;
     void goBack();
     void goForward();
@@ -83,8 +83,6 @@ public:
 private:
     explicit BackForwardList(Page*);
 
-    virtual bool isActive() override { return enabled() && capacity(); }
-
     Page* m_page;
     HistoryItemVector m_entries;
     HistoryItemHashSet m_entryHash;
index 1e8f208..57ec24e 100644 (file)
@@ -231,10 +231,6 @@ static void logCanCachePageDecision(Page* page)
     if (frameRejectReasons)
         rejectReasons |= 1 << FrameCannotBeInPageCache;
     
-    if (!page->backForward().isActive()) {
-        PCLOG("   -The back/forward list is disabled or has 0 capacity");
-        rejectReasons |= 1 << DisabledBackForwardList;
-    }
     if (!page->settings().usesPageCache()) {
         PCLOG("   -Page settings says b/f cache disabled");
         rejectReasons |= 1 << DisabledPageCache;
@@ -380,7 +376,6 @@ bool PageCache::canCache(Page* page) const
     
     return m_capacity > 0
         && canCachePageContainingThisFrame(&page->mainFrame())
-        && page->backForward().isActive()
         && page->settings().usesPageCache()
 #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS)
         && !DeviceMotionController::isActiveAt(page)
index f110327..a5b4df2 100644 (file)
@@ -1,3 +1,14 @@
+2014-01-25  Anders Carlsson  <andersca@apple.com>
+
+        Get rid of BackForwardController::isActive()
+        https://bugs.webkit.org/show_bug.cgi?id=127604
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::canCachePage):
+        Move isActive logic here.
+
 2014-01-24  Anders Carlsson  <andersca@apple.com>
 
         Remove back/forward list related functions from Page
index e19d802..37f2644 100644 (file)
@@ -80,6 +80,7 @@
 #import <WebCore/AuthenticationCF.h>
 #import <WebCore/AuthenticationMac.h>
 #import <WebCore/BackForwardController.h>
+#import <WebCore/BackForwardList.h>
 #import <WebCore/BlockExceptions.h>
 #import <WebCore/CachedFrame.h>
 #import <WebCore/Chrome.h>
@@ -1632,7 +1633,22 @@ NSDictionary *WebFrameLoaderClient::actionDictionary(const NavigationAction& act
 bool WebFrameLoaderClient::canCachePage() const
 {
     // We can only cache HTML pages right now
-    return [[[m_webFrame.get() _dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]];
+    if (![[[m_webFrame _dataSource] representation] isKindOfClass:[WebHTMLRepresentation class]])
+        return false;
+    
+    // We only cache pages if the back forward list is enabled and has a non-zero capacity.
+    Page* page = core(m_webFrame.get())->page();
+    if (!page)
+        return false;
+    
+    BackForwardList *backForwardList = static_cast<BackForwardList*>(page->backForward().client());
+    if (!backForwardList->enabled())
+        return false;
+    
+    if (!backForwardList->capacity())
+        return false;
+    
+    return true;
 }
 
 PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const URL& url, const String& name, HTMLFrameOwnerElement* ownerElement,