CachedFrame construction should begin with a Frame&.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 03:13:24 +0000 (03:13 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 03:13:24 +0000 (03:13 +0000)
<https://webkit.org/b/120719>

Reviewed by Anders Carlsson.

We can't create a CachedFrame from a null Frame anyway.

* bindings/js/ScriptCachedFrameData.cpp:
(WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
(WebCore::ScriptCachedFrameData::restore):
* bindings/js/ScriptCachedFrameData.h:
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::CachedFrameBase):
(WebCore::CachedFrameBase::restore):
(WebCore::CachedFrame::CachedFrame):
* history/CachedFrame.h:
(WebCore::CachedFrame::create):
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptCachedFrameData.cpp
Source/WebCore/bindings/js/ScriptCachedFrameData.h
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/history/CachedFrame.h
Source/WebCore/history/CachedPage.cpp

index 938d532..1da22c7 100644 (file)
@@ -1,5 +1,27 @@
 2013-09-04  Andreas Kling  <akling@apple.com>
 
+        CachedFrame construction should begin with a Frame&.
+        <https://webkit.org/b/120719>
+
+        Reviewed by Anders Carlsson.
+
+        We can't create a CachedFrame from a null Frame anyway.
+
+        * bindings/js/ScriptCachedFrameData.cpp:
+        (WebCore::ScriptCachedFrameData::ScriptCachedFrameData):
+        (WebCore::ScriptCachedFrameData::restore):
+        * bindings/js/ScriptCachedFrameData.h:
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrameBase::CachedFrameBase):
+        (WebCore::CachedFrameBase::restore):
+        (WebCore::CachedFrame::CachedFrame):
+        * history/CachedFrame.h:
+        (WebCore::CachedFrame::create):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::CachedPage):
+
+2013-09-04  Andreas Kling  <akling@apple.com>
+
         Set "render tree being torn down" flag a bit earlier.
         <https://webkit.org/b/120717>
 
index 5051ef5..fc90167 100644 (file)
@@ -44,11 +44,11 @@ using namespace JSC;
 
 namespace WebCore {
 
-ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame)
+ScriptCachedFrameData::ScriptCachedFrameData(Frame& frame)
 {
     JSLockHolder lock(JSDOMWindowBase::commonVM());
 
-    ScriptController& scriptController = frame->script();
+    ScriptController& scriptController = frame.script();
     ScriptController::ShellMap& windowShells = scriptController.m_windowShells;
 
     ScriptController::ShellMap::iterator windowShellsEnd = windowShells.end();
@@ -65,11 +65,11 @@ ScriptCachedFrameData::~ScriptCachedFrameData()
     clear();
 }
 
-void ScriptCachedFrameData::restore(Frame* frame)
+void ScriptCachedFrameData::restore(Frame& frame)
 {
     JSLockHolder lock(JSDOMWindowBase::commonVM());
 
-    ScriptController& scriptController = frame->script();
+    ScriptController& scriptController = frame.script();
     ScriptController::ShellMap& windowShells = scriptController.m_windowShells;
 
     ScriptController::ShellMap::iterator windowShellsEnd = windowShells.end();
@@ -80,13 +80,13 @@ void ScriptCachedFrameData::restore(Frame* frame)
         if (JSDOMWindow* window = m_windows.get(world).get())
             windowShell->setWindow(window->vm(), window);
         else {
-            DOMWindow* domWindow = frame->document()->domWindow();
+            DOMWindow* domWindow = frame.document()->domWindow();
             if (windowShell->window()->impl() == domWindow)
                 continue;
 
             windowShell->setWindow(domWindow);
 
-            if (Page* page = frame->page()) {
+            if (Page* page = frame.page()) {
                 scriptController.attachDebugger(windowShell, page->debugger());
                 windowShell->window()->setProfileGroup(page->group().identifier());
             }
index 05c109e..f95260e 100644 (file)
@@ -45,10 +45,10 @@ namespace WebCore {
         typedef HashMap< RefPtr<DOMWrapperWorld>, JSC::Strong<JSDOMWindow> > JSDOMWindowSet;
 
     public:
-        ScriptCachedFrameData(Frame*);
+        ScriptCachedFrameData(Frame&);
         ~ScriptCachedFrameData();
 
-        void restore(Frame*);
+        void restore(Frame&);
         void clear();
 
     private:
index 0f8d075..9a8d007 100644 (file)
@@ -72,15 +72,15 @@ static WTF::RefCountedLeakCounter& cachedFrameCounter()
 }
 #endif
 
-CachedFrameBase::CachedFrameBase(Frame* frame)
-    : m_document(frame->document())
-    , m_documentLoader(frame->loader().documentLoader())
-    , m_view(frame->view())
-    , m_mousePressNode(frame->eventHandler().mousePressNode())
-    , m_url(frame->document()->url())
-    , m_isMainFrame(!frame->tree().parent())
+CachedFrameBase::CachedFrameBase(Frame& frame)
+    : m_document(frame.document())
+    , m_documentLoader(frame.loader().documentLoader())
+    , m_view(frame.view())
+    , m_mousePressNode(frame.eventHandler().mousePressNode())
+    , m_url(frame.document()->url())
+    , m_isMainFrame(!frame.tree().parent())
 #if USE(ACCELERATED_COMPOSITING)
-    , m_isComposited(frame->view()->hasCompositedContent())
+    , m_isComposited(frame.view()->hasCompositedContent())
 #endif
 {
 }
@@ -102,7 +102,7 @@ void CachedFrameBase::restore()
         m_view->setParentVisible(true);
 
     Frame& frame = m_view->frame();
-    m_cachedFrameScriptData->restore(&frame);
+    m_cachedFrameScriptData->restore(frame);
 
 #if ENABLE(SVG)
     if (m_document->svgExtensions())
@@ -149,7 +149,7 @@ void CachedFrameBase::restore()
     m_document->documentDidResumeFromPageCache();
 }
 
-CachedFrame::CachedFrame(Frame* frame)
+CachedFrame::CachedFrame(Frame& frame)
     : CachedFrameBase(frame)
 {
 #ifndef NDEBUG
@@ -159,18 +159,18 @@ CachedFrame::CachedFrame(Frame* frame)
     ASSERT(m_documentLoader);
     ASSERT(m_view);
 
-    if (frame->page()->focusController().focusedFrame() == frame)
-        frame->page()->focusController().setFocusedFrame(&frame->page()->mainFrame());
+    if (frame.page()->focusController().focusedFrame() == &frame)
+        frame.page()->focusController().setFocusedFrame(&frame.page()->mainFrame());
 
     // Custom scrollbar renderers will get reattached when the document comes out of the page cache
     m_view->detachCustomScrollbars();
 
     m_document->setInPageCache(true);
-    frame->loader().stopLoading(UnloadEventPolicyUnloadAndPageHide);
+    frame.loader().stopLoading(UnloadEventPolicyUnloadAndPageHide);
 
     // Create the CachedFrames for all Frames in the FrameTree.
-    for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling())
-        m_childFrames.append(CachedFrame::create(child));
+    for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
+        m_childFrames.append(CachedFrame::create(*child));
 
     // Active DOM objects must be suspended before we cache the frame script data,
     // but after we've fired the pagehide event, in case that creates more objects.
@@ -183,27 +183,27 @@ CachedFrame::CachedFrame(Frame* frame)
 
     m_document->domWindow()->suspendForPageCache();
 
-    frame->loader().client().savePlatformDataToCachedFrame(this);
+    frame.loader().client().savePlatformDataToCachedFrame(this);
 
 #if USE(ACCELERATED_COMPOSITING)
     if (m_isComposited && pageCache()->shouldClearBackingStores())
-        frame->view()->clearBackingStores();
+        frame.view()->clearBackingStores();
 #endif
 
     // documentWillSuspendForPageCache() can set up a layout timer on the FrameView, so clear timers after that.
-    frame->clearTimers();
+    frame.clearTimers();
 
     // Deconstruct the FrameTree, to restore it later.
     // We do this for two reasons:
     // 1 - We reuse the main frame, so when it navigates to a new page load it needs to start with a blank FrameTree.
     // 2 - It's much easier to destroy a CachedFrame while it resides in the PageCache if it is disconnected from its parent.
     for (unsigned i = 0; i < m_childFrames.size(); ++i)
-        frame->tree().removeChild(&m_childFrames[i]->view()->frame());
+        frame.tree().removeChild(&m_childFrames[i]->view()->frame());
 
     if (!m_isMainFrame)
-        frame->page()->decrementSubframeCount();
+        frame.page()->decrementSubframeCount();
 
-    frame->loader().client().didSaveToPageCache();
+    frame.loader().client().didSaveToPageCache();
 
 #ifndef NDEBUG
     if (m_isMainFrame)
index 9277028..9838f73 100644 (file)
@@ -51,7 +51,7 @@ public:
     bool isMainFrame() { return m_isMainFrame; }
 
 protected:
-    CachedFrameBase(Frame*);
+    CachedFrameBase(Frame&);
     ~CachedFrameBase();
     
     RefPtr<Document> m_document;
@@ -71,7 +71,7 @@ protected:
 
 class CachedFrame : private CachedFrameBase {
 public:
-    static PassOwnPtr<CachedFrame> create(Frame* frame) { return adoptPtr(new CachedFrame(frame)); }
+    static PassOwnPtr<CachedFrame> create(Frame& frame) { return adoptPtr(new CachedFrame(frame)); }
 
     void open();
     void clear();
@@ -89,7 +89,7 @@ public:
     int descendantFrameCount() const;
 
 private:
-    explicit CachedFrame(Frame*);
+    explicit CachedFrame(Frame&);
 };
 
 } // namespace WebCore
index 056bbea..cd0713b 100644 (file)
@@ -53,7 +53,7 @@ PassOwnPtr<CachedPage> CachedPage::create(Page* page)
 CachedPage::CachedPage(Page* page)
     : m_timeStamp(monotonicallyIncreasingTime())
     , m_expirationTime(m_timeStamp + page->settings().backForwardCacheExpirationInterval())
-    , m_cachedMainFrame(CachedFrame::create(&page->mainFrame()))
+    , m_cachedMainFrame(CachedFrame::create(page->mainFrame()))
     , m_needStyleRecalcForVisitedLinks(false)
     , m_needsFullStyleRecalc(false)
     , m_needsCaptionPreferencesChanged(false)