Bug 422294 - Crash [@ nsHTMLContainerFrame::CreateViewForFrame] on print preview, r+sr=roc
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 15 Jan 2009 16:24:40 +0200
changeset 23745 b01601d60e6172a9ada49ba7d8cf3cc8abbdcae8
parent 23744 e30f1765a42c06c8b7ad376facdb09e30f4cbe0f
child 23746 28c4ee827acdf62738aef350b0a9e9e6da7ff336
push id4697
push useropettay@mozilla.com
push dateThu, 15 Jan 2009 14:25:02 +0000
treeherdermozilla-central@b01601d60e61 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs422294
milestone1.9.2a1pre
Bug 422294 - Crash [@ nsHTMLContainerFrame::CreateViewForFrame] on print preview, r+sr=roc
layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -1859,16 +1859,37 @@ nsPrintEngine::ReflowPrintObject(nsPrint
       adjSize = nsSize(pageWidth, pageHeight);
     }
 #else
     adjSize = nsSize(pageWidth, pageHeight);
 #endif // XP_UNIX && !XP_MACOSX
     documentIsTopLevel = PR_TRUE;
   }
 
+  // Here we decide whether we need scrollbars and
+  // what the parent will be of the widget
+  // How this logic presently works: Print Preview is always as-is (as far
+  // as I can tell; not sure how it would work in other cases); only the root 
+  // is not eIFrame or eFrame.  The child documents get a parent widget from
+  // logic in nsFrameFrame.  In any case, a child widget is created for the root
+  // view of the document.
+  PRBool canCreateScrollbars = PR_FALSE;
+  nsIView* parentView;
+  // the top nsPrintObject's widget will always have scrollbars
+  if (frame) {
+    nsIView* view = frame->GetView();
+    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
+    view = view->GetFirstChild();
+    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
+    parentView = view;
+  } else {
+    canCreateScrollbars = PR_TRUE;
+    parentView = nsnull;
+  }
+
   // create the PresContext
   aPO->mPresContext = new nsPresContext(aPO->mDocument,
                                         mIsCreatingPrintPreview ?
                                          nsPresContext::eContext_PrintPreview:
                                          nsPresContext::eContext_Print);
   NS_ENSURE_TRUE(aPO->mPresContext, NS_ERROR_OUT_OF_MEMORY);
   aPO->mPresContext->SetPrintSettings(mPrt->mPrintSettings);
 
@@ -1902,37 +1923,16 @@ nsPrintEngine::ReflowPrintObject(nsPrint
 
   styleSet->EndUpdate();
   
   // The pres shell now owns the style set object.
 
   PR_PL(("In DV::ReflowPrintObject PO: %p (%9s) Setting w,h to %d,%d\n", aPO,
          gFrameTypesStr[aPO->mFrameType], adjSize.width, adjSize.height));
 
-  // Here we decide whether we need scrollbars and
-  // what the parent will be of the widget
-  // How this logic presently works: Print Preview is always as-is (as far
-  // as I can tell; not sure how it would work in other cases); only the root 
-  // is not eIFrame or eFrame.  The child documents get a parent widget from
-  // logic in nsFrameFrame.  In any case, a child widget is created for the root
-  // view of the document.
-  PRBool canCreateScrollbars = PR_FALSE;
-  nsIView* parentView;
-  // the top nsPrintObject's widget will always have scrollbars
-  if (frame) {
-    nsIView* view = frame->GetView();
-    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
-    view = view->GetFirstChild();
-    NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
-    parentView = view;
-  } else {
-    canCreateScrollbars = PR_TRUE;
-    parentView = nsnull;
-  }
-
   // Create a child window of the parent that is our "root view/window"
   nsRect tbounds = nsRect(nsPoint(0, 0), adjSize);
   nsIView* rootView = aPO->mViewManager->CreateView(tbounds, parentView);
   NS_ENSURE_TRUE(rootView, NS_ERROR_OUT_OF_MEMORY);
 
   // Only create a widget for print preview; when printing, a widget is
   // unnecessary and unexpected
   // Also, no widget should be needed except for the top-level document