Bug 921174 part 4: Move focusPadding into ReflowButtonContents, the only place it's used now. r=bz
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 26 Sep 2013 23:43:16 -0700
changeset 148954 066962a4f2ee6dee81b69e64eb097dd570d70ec0
parent 148953 57288f5ade9d49188a242b26bfdd3d364b5ad9b0
child 148955 06ee4167c4bbdc10a15f865b82c7470993c0616a
push id34387
push userdholbert@mozilla.com
push dateFri, 27 Sep 2013 06:44:49 +0000
treeherdermozilla-inbound@c8c18d3a3f21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs921174
milestone27.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 921174 part 4: Move focusPadding into ReflowButtonContents, the only place it's used now. r=bz
layout/forms/nsHTMLButtonControlFrame.cpp
layout/forms/nsHTMLButtonControlFrame.h
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -179,53 +179,53 @@ nsHTMLButtonControlFrame::Reflow(nsPresC
 
   // Reflow the child
   nsIFrame* firstKid = mFrames.FirstChild();
 
   // XXXbz Eventually we may want to check-and-bail if
   // !aReflowState.ShouldReflowAllKids() &&
   // !NS_SUBTREE_DIRTY(firstKid).
   // We'd need to cache our ascent for that, of course.
-  
-  nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
-  
+
   // Reflow the contents of the button.
   // (This populates our aDesiredSize, too.)
   ReflowButtonContents(aPresContext, aDesiredSize,
-                       aReflowState, firstKid,
-                       focusPadding);
+                       aReflowState, firstKid);
 
   ConsiderChildOverflow(aDesiredSize.mOverflowAreas, firstKid);
 
   aStatus = NS_FRAME_COMPLETE;
   FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize,
                                  aReflowState, aStatus);
 
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
   return NS_OK;
 }
 
 void
 nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
                                                nsHTMLReflowMetrics& aButtonDesiredSize,
                                                const nsHTMLReflowState& aButtonReflowState,
-                                               nsIFrame* aFirstKid,
-                                               nsMargin aFocusPadding)
+                                               nsIFrame* aFirstKid)
 {
+  // Buttons have some bonus renderer-determined border/padding,
+  // which occupies part of the button's content-box area:
+  const nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
+
   nsSize availSize(aButtonReflowState.ComputedWidth(), NS_INTRINSICSIZE);
 
   // Indent the child inside us by the focus border. We must do this separate
   // from the regular border.
-  availSize.width -= aFocusPadding.LeftRight();
+  availSize.width -= focusPadding.LeftRight();
   
   // See whether out availSize's width is big enough.  If it's smaller than our
   // intrinsic min width, that means that the kid wouldn't really fit; for a
   // better look in such cases we adjust the available width and our left
   // offset to allow the kid to spill left into our padding.
-  nscoord xoffset = aFocusPadding.left +
+  nscoord xoffset = focusPadding.left +
     aButtonReflowState.mComputedBorderPadding.left;
   nscoord extrawidth = GetMinWidth(aButtonReflowState.rendContext) -
     aButtonReflowState.ComputedWidth();
   if (extrawidth > 0) {
     nscoord extraleft = extrawidth / 2;
     nscoord extraright = extrawidth - extraleft;
     NS_ASSERTION(extraright >=0, "How'd that happen?");
     
@@ -240,55 +240,55 @@ nsHTMLButtonControlFrame::ReflowButtonCo
   nsHTMLReflowState contentsReflowState(aPresContext, aButtonReflowState,
                                         aFirstKid, availSize);
 
   nsReflowStatus contentsReflowStatus;
   nsHTMLReflowMetrics contentsDesiredSize;
   ReflowChild(aFirstKid, aPresContext,
               contentsDesiredSize, contentsReflowState,
               xoffset,
-              aFocusPadding.top + aButtonReflowState.mComputedBorderPadding.top,
+              focusPadding.top + aButtonReflowState.mComputedBorderPadding.top,
               0, contentsReflowStatus);
   MOZ_ASSERT(NS_FRAME_IS_COMPLETE(contentsReflowStatus),
              "We gave button-contents frame unconstrained available height, "
              "so it should be complete");
 
   // Compute the button's content-box height:
   nscoord buttonContentBoxHeight = 0;
   if (aButtonReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
     // Button has a fixed height -- that's its content-box height.
     buttonContentBoxHeight = aButtonReflowState.ComputedHeight();
   } else {
     // Button is intrinsically sized -- it should shrinkwrap the
     // button-contents' height, plus any focus-padding space:
     buttonContentBoxHeight =
-      contentsDesiredSize.height + aFocusPadding.TopBottom();
+      contentsDesiredSize.height + focusPadding.TopBottom();
 
     // Make sure we obey min/max-height in the case when we're doing intrinsic
     // sizing (we get it for free when we have a non-intrinsic
     // aButtonReflowState.ComputedHeight()).  Note that we do this before
     // adjusting for borderpadding, since mComputedMaxHeight and
     // mComputedMinHeight are content heights.
     buttonContentBoxHeight =
       NS_CSS_MINMAX(buttonContentBoxHeight,
                     aButtonReflowState.mComputedMinHeight,
                     aButtonReflowState.mComputedMaxHeight);
   }
 
   // Center child vertically in the button
   // (technically, inside of the button's focus-padding area)
   nscoord extraSpace =
-    buttonContentBoxHeight - aFocusPadding.TopBottom() -
+    buttonContentBoxHeight - focusPadding.TopBottom() -
     contentsDesiredSize.height;
 
   nscoord yoffset = std::max(0, extraSpace / 2);
 
   // Adjust yoffset to be in terms of the button's frame-rect, instead of
   // its focus-padding rect:
-  yoffset += aFocusPadding.top + aButtonReflowState.mComputedBorderPadding.top;
+  yoffset += focusPadding.top + aButtonReflowState.mComputedBorderPadding.top;
 
   // Place the child
   FinishReflowChild(aFirstKid, aPresContext,
                     &contentsReflowState, contentsDesiredSize,
                     xoffset, yoffset, 0);
 
   // Make sure we have a useful 'ascent' value for the child
   if (contentsDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
--- a/layout/forms/nsHTMLButtonControlFrame.h
+++ b/layout/forms/nsHTMLButtonControlFrame.h
@@ -92,18 +92,17 @@ public:
 
 protected:
   virtual bool IsInput() { return false; }
   // Reflows the button's sole child frame, and computes the desired size
   // of the button itself from the results.
   void ReflowButtonContents(nsPresContext* aPresContext,
                             nsHTMLReflowMetrics& aButtonDesiredSize,
                             const nsHTMLReflowState& aButtonReflowState,
-                            nsIFrame* aFirstKid,
-                            nsMargin aFocusPadding);
+                            nsIFrame* aFirstKid);
 
   nsButtonFrameRenderer mRenderer;
 };
 
 #endif