Bug 865477: Use Maybe<> instead of nsAutoPtr<> for lazily-constructed nsHTMLReflowState in nsBlockFrame::Reflow(). r=bz
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 25 Apr 2013 09:03:28 -0700
changeset 129874 6594045f097555ebf346e6e1d2652b7553d43e6d
parent 129873 a536a231fafbd6e86799cdaebfb7f472b7d4a94d
child 129875 de487abe67a2bc8888315eb822dbd031b48f2e67
push id27064
push userdholbert@mozilla.com
push dateThu, 25 Apr 2013 16:04:14 +0000
treeherdermozilla-inbound@de487abe67a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs865477
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 865477: Use Maybe<> instead of nsAutoPtr<> for lazily-constructed nsHTMLReflowState in nsBlockFrame::Reflow(). r=bz
layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -6,16 +6,17 @@
 
 /*
  * rendering object for CSS display:block, inline-block, and list-item
  * boxes, also used for various anonymous boxes
  */
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Likely.h"
+#include "mozilla/Util.h"
 
 #include "nsCOMPtr.h"
 #include "nsBlockFrame.h"
 #include "nsAbsoluteContainingBlock.h"
 #include "nsBlockReflowContext.h"
 #include "nsBlockReflowState.h"
 #include "nsBulletFrame.h"
 #include "nsLineBox.h"
@@ -969,36 +970,36 @@ nsBlockFrame::Reflow(nsPresContext*     
   int32_t ctc = 0;        // We only use these if they are set (gLameReflowMetrics).
   if (gLameReflowMetrics) {
     start = PR_Now();
     ctc = nsLineBox::GetCtorCount();
   }
 #endif
 
   const nsHTMLReflowState *reflowState = &aReflowState;
-  nsAutoPtr<nsHTMLReflowState> mutableReflowState;
+  Maybe<nsHTMLReflowState> mutableReflowState;
   // If we have non-auto height, we're clipping our kids and we fit,
   // make sure our kids fit too.
   if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE &&
       aReflowState.ComputedHeight() != NS_AUTOHEIGHT &&
       ShouldApplyOverflowClipping(this, aReflowState.mStyleDisplay)) {
     nsMargin heightExtras = aReflowState.mComputedBorderPadding;
     if (GetSkipSides() & NS_SIDE_TOP) {
       heightExtras.top = 0;
     } else {
       // Bottom margin never causes us to create continuations, so we
       // don't need to worry about whether it fits in its entirety.
       heightExtras.top += aReflowState.mComputedMargin.top;
     }
 
     if (GetEffectiveComputedHeight(aReflowState) + heightExtras.TopBottom() <=
         aReflowState.availableHeight) {
-      mutableReflowState = new nsHTMLReflowState(aReflowState);
-      mutableReflowState->availableHeight = NS_UNCONSTRAINEDSIZE;
-      reflowState = mutableReflowState;
+      mutableReflowState.construct(aReflowState);
+      mutableReflowState.ref().availableHeight = NS_UNCONSTRAINEDSIZE;
+      reflowState = mutableReflowState.addr();
     }
   }
 
   // See comment below about oldSize. Use *only* for the
   // abs-pos-containing-block-size-change optimization!
   nsSize oldSize = GetSize();
 
   // Should we create a float manager?