Create a rendering context before calling GetPrefSize and friends and assert in those methods that we have one. b=379090 r+sr=dbaron
authormats.palmgren@bredband.net
Sun, 29 Apr 2007 15:24:59 -0700
changeset 918 e0037c1de786983844e3b2a654a4f0d523d0ea01
parent 917 8fd383d615f45195f7c4fc99ee7ca34bce7e3d81
child 919 1974f4b270d6d1c5b5b00a5590fe545fb87bb21a
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs379090
milestone1.9a5pre
Create a rendering context before calling GetPrefSize and friends and assert in those methods that we have one. b=379090 r+sr=dbaron
layout/xul/base/src/nsBox.cpp
layout/xul/base/src/nsBoxFrame.cpp
layout/xul/base/src/nsSplitterFrame.cpp
--- a/layout/xul/base/src/nsBox.cpp
+++ b/layout/xul/base/src/nsBox.cpp
@@ -451,16 +451,18 @@ nsBox::GetLayoutManager(nsIBoxLayout** a
   *aLayout = nsnull;
   return NS_OK;
 }
 
 
 nsSize
 nsBox::GetPrefSize(nsBoxLayoutState& aState)
 {
+  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
+
   nsSize pref(0,0);
   DISPLAY_PREF_SIZE(this, pref);
 
   if (IsCollapsed(aState))
     return pref;
 
   AddBorderAndPadding(pref);
   nsIBox::AddCSSPrefSize(aState, this, pref);
@@ -470,16 +472,18 @@ nsBox::GetPrefSize(nsBoxLayoutState& aSt
   BoundsCheck(minSize, pref, maxSize);
 
   return pref;
 }
 
 nsSize
 nsBox::GetMinSize(nsBoxLayoutState& aState)
 {
+  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
+
   nsSize min(0,0);
   DISPLAY_MIN_SIZE(this, min);
 
   if (IsCollapsed(aState))
     return min;
 
   AddBorderAndPadding(min);
   nsIBox::AddCSSMinSize(aState, this, min);
@@ -490,16 +494,18 @@ nsSize
 nsBox::GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState)
 {
   return nsSize(0, 0);
 }
 
 nsSize
 nsBox::GetMaxSize(nsBoxLayoutState& aState)
 {
+  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
+
   nsSize max(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
   DISPLAY_MAX_SIZE(this, max);
 
   if (IsCollapsed(aState))
     return max;
 
   AddBorderAndPadding(max);
   nsIBox::AddCSSMaxSize(aState, this, max);
@@ -542,16 +548,18 @@ nsBox::IsCollapsed(nsBoxLayoutState& aSt
   nsIBox::AddCSSCollapsed(aState, this, collapsed);
 
   return collapsed;
 }
 
 nsresult
 nsIFrame::Layout(nsBoxLayoutState& aState)
 {
+  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
+
   nsBox *box = NS_STATIC_CAST(nsBox*, this);
   DISPLAY_LAYOUT(box);
 
   box->BeginLayout(aState);
 
   box->DoLayout(aState);
 
   box->EndLayout(aState);
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -799,16 +799,19 @@ nsBoxFrame::Reflow(nsPresContext*       
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
   return NS_OK;
 }
 
 nsSize
 nsBoxFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState)
 {
+  NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
+               "must have rendering context");
+
   nsSize size(0,0);
   DISPLAY_PREF_SIZE(this, size);
   if (!DoesNeedRecalc(mPrefSize)) {
      size = mPrefSize;
      return size;
   }
 
 #ifdef DEBUG_LAYOUT
@@ -855,16 +858,19 @@ nsBoxFrame::GetBoxAscent(nsBoxLayoutStat
     mAscent = nsBox::GetBoxAscent(aBoxLayoutState);
 
   return mAscent;
 }
 
 nsSize
 nsBoxFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState)
 {
+  NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
+               "must have rendering context");
+
   nsSize size(0,0);
   DISPLAY_MIN_SIZE(this, size);
   if (!DoesNeedRecalc(mMinSize)) {
     size = mMinSize;
     return size;
   }
 
 #ifdef DEBUG_LAYOUT
@@ -888,16 +894,19 @@ nsBoxFrame::GetMinSize(nsBoxLayoutState&
   mMinSize = size;
 
   return size;
 }
 
 nsSize
 nsBoxFrame::GetMaxSize(nsBoxLayoutState& aBoxLayoutState)
 {
+  NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
+               "must have rendering context");
+
   nsSize size(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
   DISPLAY_MAX_SIZE(this, size);
   if (!DoesNeedRecalc(mMaxSize)) {
     size = mMaxSize;
     return size;
   }
 
 #ifdef DEBUG_LAYOUT
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -719,19 +719,21 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
   nsPresContext* outerPresContext = mOuter->PresContext();
   nscoord childIndex = nsFrameNavigator::IndexOf(outerPresContext, mParentBox, mOuter);
   PRInt32 childCount = nsFrameNavigator::CountFrames(outerPresContext, mParentBox);
 
   // if it's 0 or the last index then stop right here.
   if (childIndex == 0 || childIndex == childCount - 1)
     return NS_OK;
 
-  // XXXbz using this state for GetPrefSize/GetMinSize is wrong.  It
-  // needs a rendering context!
-  nsBoxLayoutState state(outerPresContext);
+  nsCOMPtr<nsIRenderingContext> rc;
+  nsresult rv = outerPresContext->PresShell()->
+                  CreateRenderingContext(mOuter, getter_AddRefs(rc));
+  NS_ENSURE_SUCCESS(rv, rv);
+  nsBoxLayoutState state(outerPresContext, rc);
   mCurrentPos = 0;
   mPressed = PR_TRUE;
 
   mDidDrag = PR_FALSE;
 
   EnsureOrient();
   PRBool isHorizontal = !mOuter->IsHorizontal();
   
@@ -748,17 +750,16 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
   mChildInfosBeforeCount = 0;
   mChildInfosAfterCount = 0;
 
   nsIBox* childBox = mParentBox->GetChildBox();
 
   while (nsnull != childBox) 
   { 
     nsIContent* content = childBox->GetContent();
-    nsresult rv;
     nsIDocument* doc = content->GetOwnerDoc();
     nsIAtom* atom;
     if (doc) {
       PRInt32 dummy;
       atom = doc->BindingManager()->ResolveTag(content, &dummy);
     } else {
       atom = content->Tag();
     }