Title: [155094] trunk/Source/WebCore
Revision
155094
Author
akl...@apple.com
Date
2013-09-04 23:20:09 -0700 (Wed, 04 Sep 2013)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155093 => 155094)


--- trunk/Source/WebCore/ChangeLog	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/ChangeLog	2013-09-05 06:20:09 UTC (rev 155094)
@@ -1,3 +1,23 @@
+2013-09-04  Andreas Kling  <akl...@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....@samsung.com>
 
         setAttributeNode() does not set the new value to an existing attribute if specified attribute is in a different case.

Modified: trunk/Source/WebCore/history/CachedPage.cpp (155093 => 155094)


--- trunk/Source/WebCore/history/CachedPage.cpp	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/history/CachedPage.cpp	2013-09-05 06:20:09 UTC (rev 155094)
@@ -45,15 +45,15 @@
 
 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 @@
     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();

Modified: trunk/Source/WebCore/history/CachedPage.h (155093 => 155094)


--- trunk/Source/WebCore/history/CachedPage.h	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/history/CachedPage.h	2013-09-05 06:20:09 UTC (rev 155094)
@@ -36,10 +36,10 @@
 
 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 @@
 #endif
 
 private:
-    CachedPage(Page*);
+    explicit CachedPage(Page&);
     void destroy();
 
     double m_timeStamp;

Modified: trunk/Source/WebCore/history/PageCache.cpp (155093 => 155094)


--- trunk/Source/WebCore/history/PageCache.cpp	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/history/PageCache.cpp	2013-09-05 06:20:09 UTC (rev 155094)
@@ -424,11 +424,10 @@
 }
 #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().
 

Modified: trunk/Source/WebCore/history/PageCache.h (155093 => 155094)


--- trunk/Source/WebCore/history/PageCache.h	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/history/PageCache.h	2013-09-05 06:20:09 UTC (rev 155094)
@@ -48,7 +48,7 @@
         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);
 

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (155093 => 155094)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-09-05 06:05:16 UTC (rev 155093)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-09-05 06:20:09 UTC (rev 155094)
@@ -1713,7 +1713,7 @@
     // 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 @@
     
     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());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to