Bug 559705 - "ASSERTION: Subdoc frames must have an inner view too". r=roc a2.0=roc
authorMats Palmgren <matspal@gmail.com>
Sat, 18 Sep 2010 13:28:50 +0200
changeset 54315 bec2fa4a0b62bf1f5422d37e3a34a66ceb72111c
parent 54314 e3c9e026315f999180ee458ade1303a193f91b2c
child 54316 41a4b61d685b476b82bc30ba1cc114fd035b299c
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs559705
milestone2.0b7pre
Bug 559705 - "ASSERTION: Subdoc frames must have an inner view too". r=roc a2.0=roc
content/base/src/nsFrameLoader.cpp
layout/base/nsDocumentViewer.cpp
layout/generic/nsSubDocumentFrame.cpp
layout/generic/nsSubDocumentFrame.h
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -657,17 +657,17 @@ nsFrameLoader::Show(PRInt32 marginWidth,
       contentType = eContentTypeUI;
     else {
       nsCOMPtr<nsIDocShellTreeItem> sameTypeParent;
       treeItem->GetSameTypeParent(getter_AddRefs(sameTypeParent));
       contentType = sameTypeParent ? eContentTypeContentFrame : eContentTypeContent;
     }
   }
 
-  nsIView* view = frame->CreateViewAndWidget(contentType);
+  nsIView* view = frame->EnsureInnerView();
   if (!view)
     return PR_FALSE;
 
 #ifdef MOZ_IPC
   if (mRemoteFrame) {
     return ShowRemoteFrame(GetSubDocumentSize(frame));
   }
 #endif
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -58,33 +58,33 @@
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIEventStateManager.h"
 #include "nsStyleSet.h"
 #include "nsIStyleSheet.h"
 #include "nsCSSStyleSheet.h"
 #include "nsIFrame.h"
+#include "nsSubDocumentFrame.h"
 
 #include "nsILinkHandler.h"
 #include "nsIDOMDocument.h"
 #include "nsISelectionListener.h"
 #include "nsISelectionPrivate.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMNSHTMLDocument.h"
 #include "nsIDOMHTMLCollection.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMRange.h"
 #include "nsContentCID.h"
 #include "nsLayoutCID.h"
 #include "nsContentUtils.h"
 #include "nsLayoutStylesheetCache.h"
 
 #include "nsViewsCID.h"
-#include "nsWidgetsCID.h"
 #include "nsIDeviceContext.h"
 #include "nsIDeviceContextSpec.h"
 #include "nsIViewManager.h"
 #include "nsIView.h"
 
 #include "nsIPageSequenceFrame.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
@@ -2411,20 +2411,19 @@ DocumentViewerImpl::FindContainerView()
         nsIFrame* f = parentPresShell->GetRealPrimaryFrameFor(containerElement);
         if (f) {
           nsIFrame* subdocFrame = f->GetContentInsertionFrame();
           // subdocFrame might not be a subdocument frame; the frame
           // constructor can treat a <frame> as an inline in some XBL
           // cases. Treat that as display:none, the document is not
           // displayed.
           if (subdocFrame->GetType() == nsGkAtoms::subDocumentFrame) {
-            nsIView* subdocFrameView = subdocFrame->GetView();
-            NS_ASSERTION(subdocFrameView, "Subdoc frames must have views");
-            nsIView* innerView = subdocFrameView->GetFirstChild();
-            NS_ASSERTION(innerView, "Subdoc frames must have an inner view too");
+            NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views");
+            nsIView* innerView =
+              static_cast<nsSubDocumentFrame*>(subdocFrame)->EnsureInnerView();
             containerView = innerView;
           } else {
             NS_WARNING("Subdocument container has non-subdocument frame");
           }
         } else {
           NS_WARNING("Subdocument container has no frame");
         }
       }
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -64,18 +64,16 @@ using mozilla::layout::RenderFrameParent
 #include "nsIComponentManager.h"
 #include "nsFrameManager.h"
 #include "nsIStreamListener.h"
 #include "nsIURL.h"
 #include "nsNetUtil.h"
 #include "nsIDocument.h"
 #include "nsIView.h"
 #include "nsIViewManager.h"
-#include "nsWidgetsCID.h"
-#include "nsViewsCID.h"
 #include "nsGkAtoms.h"
 #include "nsStyleCoord.h"
 #include "nsStyleContext.h"
 #include "nsStyleConsts.h"
 #include "nsFrameSetFrame.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMHTMLIFrameElement.h"
 #include "nsIDOMXULElement.h"
@@ -216,18 +214,18 @@ void
 nsSubDocumentFrame::ShowViewer()
 {
   if (mCallingShow) {
     return;
   }
 
   if (!PresContext()->IsDynamic()) {
     // We let the printing code take care of loading the document; just
-    // create a widget for it to use
-    (void) CreateViewAndWidget(eContentTypeContent);
+    // create the inner view for it to use.
+    (void) EnsureInnerView();
   } else {
     nsRefPtr<nsFrameLoader> frameloader = FrameLoader();
     if (frameloader) {
       nsIntSize margin = GetMarginAttributes();
       const nsStyleDisplay* disp = GetStyleDisplay();
       nsWeakFrame weakThis(this);
       mCallingShow = PR_TRUE;
       PRBool didCreateDoc =
@@ -1006,20 +1004,19 @@ nsSubDocumentFrame::EndSwapDocShells(nsI
   if (weakOther.IsAlive()) {
     other->PresContext()->PresShell()->
       FrameNeedsReflow(other, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
     other->InvalidateFrameSubtree();
   }
 }
 
 nsIView*
-nsSubDocumentFrame::CreateViewAndWidget(nsContentType aContentType)
+nsSubDocumentFrame::EnsureInnerView()
 {
   if (mInnerView) {
-    // Nothing to do here
     return mInnerView;
   }
 
   // create, init, set the parent of the view
   nsIView* outerView = GetView();
   NS_ASSERTION(outerView, "Must have an outer view already");
   nsRect viewBounds(0, 0, 0, 0); // size will be fixed during reflow
 
--- a/layout/generic/nsSubDocumentFrame.h
+++ b/layout/generic/nsSubDocumentFrame.h
@@ -112,17 +112,17 @@ public:
 
 #ifdef ACCESSIBILITY
   virtual already_AddRefed<nsAccessible> CreateAccessible();
 #endif
 
   nsresult GetDocShell(nsIDocShell **aDocShell);
   nsresult BeginSwapDocShells(nsIFrame* aOther);
   void EndSwapDocShells(nsIFrame* aOther);
-  nsIView* CreateViewAndWidget(nsContentType aContentType);
+  nsIView* EnsureInnerView();
   nsIFrame* GetSubdocumentRootFrame();
 
   // nsIReflowCallback
   virtual PRBool ReflowFinished();
   virtual void ReflowCallbackCanceled();
 
 protected:
   friend class AsyncFrameInit;