bug 784837 - call SetPrimaryFrame earlier during nsSubDocumentFrame::Init. r=roc
authorJonathan Kew <jkew@mozilla.com>
Fri, 24 Aug 2012 10:16:15 +0100
changeset 105319 5f8728a398a91ca95c9746e03ad293a5e0c48961
parent 105318 ede84a1a43cf1bae39b293f8447ad194cca1f42c
child 105320 a485ff9049542ead6fb380e3e8f047d7e05eec7b
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersroc
bugs784837
milestone17.0a1
bug 784837 - call SetPrimaryFrame earlier during nsSubDocumentFrame::Init. r=roc
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -147,16 +147,20 @@ nsSubDocumentFrame::Init(nsIContent*    
   // really need it or not, and the inner view will get it as the
   // parent.
   if (!HasView()) {
     rv = nsContainerFrame::CreateViewForFrame(this, true);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   EnsureInnerView();
 
+  // Set the primary frame now so that DocumentViewerImpl::FindContainerView
+  // called from within EndSwapDocShellsForViews below can find it if needed.
+  aContent->SetPrimaryFrame(this);
+
   // If we have a detached subdoc's root view on our frame loader, re-insert
   // it into the view tree. This happens when we've been reframed, and
   // ensures the presentation persists across reframes. If the frame element
   // has changed documents however, we blow away the presentation.
   nsRefPtr<nsFrameLoader> frameloader = FrameLoader();
   if (frameloader) {
     nsCOMPtr<nsIDocument> oldContainerDoc;
     nsIView* detachedViews =
@@ -169,21 +173,16 @@ nsSubDocumentFrame::Init(nsIContent*    
       } else {
         // Presentation is for a different document, don't restore it.
         frameloader->Hide();
       }
     }
     frameloader->SetDetachedSubdocView(nullptr, nullptr);
   }
 
-  // Set the primary frame now so that
-  // DocumentViewerImpl::FindContainerView called by ShowViewer below
-  // can find it if necessary.
-  aContent->SetPrimaryFrame(this);
-
   nsContentUtils::AddScriptRunner(new AsyncFrameInit(this));
   return NS_OK;
 }
 
 inline int32_t ConvertOverflow(uint8_t aOverflow)
 {
   switch (aOverflow) {
     case NS_STYLE_OVERFLOW_VISIBLE: