CachedPage construction should begin with a Page&.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 06:20:09 +0000 (06:20 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 06:20:09 +0000 (06:20 +0000)
<https://webkit.org/b/120721>

Reviewed by Anders Carlsson.

We can't create a CachedPage from a null Page anyway.

* history/CachedPage.cpp:
(WebCore::CachedPage::create):
(WebCore::CachedPage::CachedPage):
(WebCore::CachedPage::restore):
* history/CachedPage.h:
* history/PageCache.cpp:
(WebCore::PageCache::add):
* history/PageCache.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):

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

Source/WebCore/ChangeLog
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/loader/FrameLoader.cpp

index bd02e95..dd97383 100644 (file)
@@ -1,3 +1,23 @@
+2013-09-04  Andreas Kling  <akling@apple.com>
+
+        CachedPage construction should begin with a Page&.
+        <https://webkit.org/b/120721>
+
+        Reviewed by Anders Carlsson.
+
+        We can't create a CachedPage from a null Page anyway.
+
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::create):
+        (WebCore::CachedPage::CachedPage):
+        (WebCore::CachedPage::restore):
+        * history/CachedPage.h:
+        * history/PageCache.cpp:
+        (WebCore::PageCache::add):
+        * history/PageCache.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+
 2013-09-04  Arpita Bahuguna  <a.bah@samsung.com>
 
         setAttributeNode() does not set the new value to an existing attribute if specified attribute is in a different case.
index cd0713b..8ddd331 100644 (file)
@@ -45,15 +45,15 @@ namespace WebCore {
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedPageCounter, ("CachedPage"));
 
-PassOwnPtr<CachedPage> CachedPage::create(Page* page)
+PassOwnPtr<CachedPage> CachedPage::create(Page& page)
 {
     return adoptPtr(new CachedPage(page));
 }
 
-CachedPage::CachedPage(Page* page)
+CachedPage::CachedPage(Page& page)
     : m_timeStamp(monotonicallyIncreasingTime())
-    , m_expirationTime(m_timeStamp + page->settings().backForwardCacheExpirationInterval())
-    , m_cachedMainFrame(CachedFrame::create(page->mainFrame()))
+    , m_expirationTime(m_timeStamp + page.settings().backForwardCacheExpirationInterval())
+    , m_cachedMainFrame(CachedFrame::create(page.mainFrame()))
     , m_needStyleRecalcForVisitedLinks(false)
     , m_needsFullStyleRecalc(false)
     , m_needsCaptionPreferencesChanged(false)
@@ -74,37 +74,37 @@ CachedPage::~CachedPage()
     ASSERT(!m_cachedMainFrame);
 }
 
-void CachedPage::restore(Page* page)
+void CachedPage::restore(Page& page)
 {
     ASSERT(m_cachedMainFrame);
-    ASSERT(page && page->frameIsMainFrame(&m_cachedMainFrame->view()->frame()));
-    ASSERT(!page->subframeCount());
+    ASSERT(page.frameIsMainFrame(&m_cachedMainFrame->view()->frame()));
+    ASSERT(!page.subframeCount());
 
     m_cachedMainFrame->open();
     
     // Restore the focus appearance for the focused element.
     // FIXME: Right now we don't support pages w/ frames in the b/f cache.  This may need to be tweaked when we add support for that.
-    Document* focusedDocument = page->focusController().focusedOrMainFrame().document();
+    Document* focusedDocument = page.focusController().focusedOrMainFrame().document();
     if (Element* element = focusedDocument->focusedElement())
         element->updateFocusAppearance(true);
 
     if (m_needStyleRecalcForVisitedLinks) {
-        for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
+        for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext())
             frame->document()->visitedLinkState().invalidateStyleForAllLinks();
     }
 
 #if USE(ACCELERATED_COMPOSITING)
     if (m_needsDeviceScaleChanged) {
-        page->mainFrame().deviceOrPageScaleFactorChanged();
+        page.mainFrame().deviceOrPageScaleFactorChanged();
     }
 #endif
 
     if (m_needsFullStyleRecalc)
-        page->setNeedsRecalcStyleInAllFrames();
+        page.setNeedsRecalcStyleInAllFrames();
 
 #if ENABLE(VIDEO_TRACK)
     if (m_needsCaptionPreferencesChanged)
-        page->captionPreferencesChanged();
+        page.captionPreferencesChanged();
 #endif
 
     clear();
index eda704b..d8fb3e0 100644 (file)
@@ -36,10 +36,10 @@ class Page;
 
 class CachedPage {
 public:
-    static PassOwnPtr<CachedPage> create(Page*);
+    static PassOwnPtr<CachedPage> create(Page&);
     ~CachedPage();
 
-    void restore(Page*);
+    void restore(Page&);
     void clear();
 
     Document* document() const { return m_cachedMainFrame->document(); }
@@ -61,7 +61,7 @@ public:
 #endif
 
 private:
-    CachedPage(Page*);
+    explicit CachedPage(Page&);
     void destroy();
 
     double m_timeStamp;
index 8532de3..d18f59e 100644 (file)
@@ -424,11 +424,10 @@ void PageCache::markPagesForCaptionPreferencesChanged()
 }
 #endif
 
-void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page* page)
+void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page)
 {
     ASSERT(prpItem);
-    ASSERT(page);
-    ASSERT(canCache(page));
+    ASSERT(canCache(&page));
     
     HistoryItem* item = prpItem.leakRef(); // Balanced in remove().
 
index 24d57da..77baa7f 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
         void setCapacity(int); // number of pages to cache
         int capacity() { return m_capacity; }
         
-        void add(PassRefPtr<HistoryItem>, Page*); // Prunes if capacity() is exceeded.
+        void add(PassRefPtr<HistoryItem>, Page&); // Prunes if capacity() is exceeded.
         void remove(HistoryItem*);
         CachedPage* get(HistoryItem* item);
 
index f311527..ec368f3 100644 (file)
@@ -1713,7 +1713,7 @@ void FrameLoader::commitProvisionalLoad()
     // We are doing this here because we know for sure that a new page is about to be loaded.
     HistoryItem* item = history().currentItem();
     if (!m_frame.tree().parent() && pageCache()->canCache(m_frame.page()) && !item->isInPageCache())
-        pageCache()->add(item, m_frame.page());
+        pageCache()->add(item, *m_frame.page());
 
     if (m_loadType != FrameLoadTypeReplace)
         closeOldDataSources();
@@ -1738,7 +1738,7 @@ void FrameLoader::commitProvisionalLoad()
     
     if (cachedPage && cachedPage->document()) {
         prepareForCachedPageRestore();
-        cachedPage->restore(m_frame.page());
+        cachedPage->restore(*m_frame.page());
 
         // The page should be removed from the cache immediately after a restoration in order for the PageCache to be consistent.
         pageCache()->remove(history().currentItem());