Bug 1173662 part 2: Use logical sizes in nsNumberControlFrame::Reflow. r=jfkthame
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 12 Jun 2015 14:19:43 -0700
changeset 248723 b275d17433afa6e97de67f4a248606d9b55b85de
parent 248722 0f9cdb5ebfa8260ed9eb0c86a010b7dbc7b7df59
child 248724 0bab6071fcd30beec8431bb1474fad0acc340f43
push id28904
push userphilringnalda@gmail.com
push dateSun, 14 Jun 2015 02:49:28 +0000
treeherdermozilla-central@c223b8844264 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1173662
milestone41.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 1173662 part 2: Use logical sizes in nsNumberControlFrame::Reflow. r=jfkthame
layout/forms/nsNumberControlFrame.cpp
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -119,26 +119,28 @@ nsNumberControlFrame::Reflow(nsPresConte
   NS_ASSERTION(!mFrames.FirstChild() ||
                !mFrames.FirstChild()->GetNextSibling(),
                "We expect at most one direct child frame");
 
   if (mState & NS_FRAME_FIRST_REFLOW) {
     nsFormControlFrame::RegUnRegAccessKey(this, true);
   }
 
-  // The width of our content box, which is the available width
+  const WritingMode myWM = aReflowState.GetWritingMode();
+
+  // The ISize of our content box, which is the available ISize
   // for our anonymous content:
-  const nscoord contentBoxWidth = aReflowState.ComputedWidth();
-  nscoord contentBoxHeight = aReflowState.ComputedHeight();
+  const nscoord contentBoxISize = aReflowState.ComputedISize();
+  nscoord contentBoxBSize = aReflowState.ComputedBSize();
 
   nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
 
   if (!outerWrapperFrame) { // display:none?
-    if (contentBoxHeight == NS_INTRINSICSIZE) {
-      contentBoxHeight = 0;
+    if (contentBoxBSize == NS_INTRINSICSIZE) {
+      contentBoxBSize = 0;
     }
   } else {
     NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
 
     nsHTMLReflowMetrics wrappersDesiredSize(aReflowState);
 
     WritingMode wrapperWM = outerWrapperFrame->GetWritingMode();
     LogicalSize availSize = aReflowState.ComputedSize(wrapperWM);
@@ -152,55 +154,61 @@ nsNumberControlFrame::Reflow(nsPresConte
                         wrapperReflowState.ComputedPhysicalMargin().left;
     nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
                         wrapperReflowState.ComputedPhysicalMargin().top;
 
     nsReflowStatus childStatus;
     ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
                 wrapperReflowState, xoffset, yoffset, 0, childStatus);
     MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
-               "We gave our child unconstrained height, so it should be complete");
-
-    nscoord wrappersMarginBoxHeight = wrappersDesiredSize.Height() +
-      wrapperReflowState.ComputedPhysicalMargin().TopBottom();
+               "We gave our child unconstrained available block-size, "
+               "so it should be complete");
 
-    if (contentBoxHeight == NS_INTRINSICSIZE) {
-      // We are intrinsically sized -- we should shrinkwrap the outer wrapper's
-      // height:
-      contentBoxHeight = wrappersMarginBoxHeight;
+    LogicalMargin wrapperMargin =
+      wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
+    nscoord wrappersMarginBoxBSize =
+      wrappersDesiredSize.BSize(myWM) + wrapperMargin.BStartEnd(myWM);
 
-      // Make sure we obey min/max-height in the case when we're doing intrinsic
+    if (contentBoxBSize == NS_INTRINSICSIZE) {
+      // We are intrinsically sized -- we should shrinkwrap the outer wrapper's
+      // block-size:
+      contentBoxBSize = wrappersMarginBoxBSize;
+
+      // Make sure we obey min/max-bsize in the case when we're doing intrinsic
       // sizing (we get it for free when we have a non-intrinsic
-      // aReflowState.ComputedHeight()).  Note that we do this before
-      // adjusting for borderpadding, since mComputedMaxHeight and
-      // mComputedMinHeight are content heights.
-      contentBoxHeight =
-        NS_CSS_MINMAX(contentBoxHeight,
-                      aReflowState.ComputedMinHeight(),
-                      aReflowState.ComputedMaxHeight());
+      // aReflowState.ComputedBSize()).  Note that we do this before
+      // adjusting for borderpadding, since ComputedMaxBSize and
+      // ComputedMinBSize are content heights.
+      contentBoxBSize =
+        NS_CSS_MINMAX(contentBoxBSize,
+                      aReflowState.ComputedMinBSize(),
+                      aReflowState.ComputedMaxBSize());
     }
 
-    // Center child vertically
-    nscoord extraSpace = contentBoxHeight - wrappersMarginBoxHeight;
+    // Center child in block axis
+    nscoord extraSpace = contentBoxBSize - wrappersMarginBoxBSize;
     yoffset += std::max(0, extraSpace / 2);
 
     // Place the child
     FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
                       &wrapperReflowState, xoffset, yoffset, 0);
 
     aDesiredSize.SetBlockStartAscent(
        wrappersDesiredSize.BlockStartAscent() +
        outerWrapperFrame->BStart(aReflowState.GetWritingMode(),
-                                 contentBoxWidth));
+                                 contentBoxISize));
   }
 
-  aDesiredSize.Width() = contentBoxWidth +
-                         aReflowState.ComputedPhysicalBorderPadding().LeftRight();
-  aDesiredSize.Height() = contentBoxHeight +
-                          aReflowState.ComputedPhysicalBorderPadding().TopBottom();
+  LogicalSize
+    logicalDesiredSize(myWM,
+                       contentBoxISize +
+                       aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM),
+                       contentBoxBSize +
+                       aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM));
+  aDesiredSize.SetSize(myWM, logicalDesiredSize);
 
   aDesiredSize.SetOverflowAreasToDesiredBounds();
 
   if (outerWrapperFrame) {
     ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
   }
 
   FinishAndStoreOverflow(&aDesiredSize);