Bug 1173662 part 3: Use a LogicalPoint for child position in nsNumberControlFrame::Reflow. r=jfkthame
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 12 Jun 2015 14:20:01 -0700
changeset 248656 0bab6071fcd30beec8431bb1474fad0acc340f43
parent 248655 b275d17433afa6e97de67f4a248606d9b55b85de
child 248657 3f6b09143c8b6fe2a6345a6c9c7163d0fc73d0b8
push id61024
push userdholbert@mozilla.com
push dateFri, 12 Jun 2015 21:20:19 +0000
treeherdermozilla-inbound@0bab6071fcd3 [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 3: Use a LogicalPoint for child position in nsNumberControlFrame::Reflow. r=jfkthame
layout/forms/nsNumberControlFrame.cpp
layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl-ref.html
layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl.html
layout/reftests/forms/input/number/reftest.list
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -126,49 +126,66 @@ nsNumberControlFrame::Reflow(nsPresConte
 
   const WritingMode myWM = aReflowState.GetWritingMode();
 
   // The ISize of our content box, which is the available ISize
   // for our anonymous content:
   const nscoord contentBoxISize = aReflowState.ComputedISize();
   nscoord contentBoxBSize = aReflowState.ComputedBSize();
 
+  // Figure out our border-box sizes as well (by adding borderPadding to
+  // content-box sizes):
+  const nscoord borderBoxISize = contentBoxISize +
+    aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM);
+
+  nscoord borderBoxBSize;
+  if (contentBoxBSize != NS_INTRINSICSIZE) {
+    borderBoxBSize = contentBoxBSize +
+      aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
+  } // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
+
   nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
 
   if (!outerWrapperFrame) { // display:none?
     if (contentBoxBSize == NS_INTRINSICSIZE) {
       contentBoxBSize = 0;
+      borderBoxBSize =
+        aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
     }
   } else {
     NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
 
     nsHTMLReflowMetrics wrappersDesiredSize(aReflowState);
 
     WritingMode wrapperWM = outerWrapperFrame->GetWritingMode();
     LogicalSize availSize = aReflowState.ComputedSize(wrapperWM);
     availSize.BSize(wrapperWM) = NS_UNCONSTRAINEDSIZE;
 
     nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
                                          outerWrapperFrame, availSize);
 
-    // offsets of wrapper frame
-    nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left +
-                        wrapperReflowState.ComputedPhysicalMargin().left;
-    nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
-                        wrapperReflowState.ComputedPhysicalMargin().top;
+    // Convert wrapper margin into my own writing-mode (in case it differs):
+    LogicalMargin wrapperMargin =
+      wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
+
+    // offsets of wrapper frame within this frame:
+    LogicalPoint
+      wrapperOffset(myWM,
+                    aReflowState.ComputedLogicalBorderPadding().IStart(myWM) +
+                    wrapperMargin.IStart(myWM),
+                    aReflowState.ComputedLogicalBorderPadding().BStart(myWM) +
+                    wrapperMargin.BStart(myWM));
 
     nsReflowStatus childStatus;
     ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
-                wrapperReflowState, xoffset, yoffset, 0, childStatus);
+                wrapperReflowState, myWM, wrapperOffset, 0, 0, childStatus);
     MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
                "We gave our child unconstrained available block-size, "
                "so it should be complete");
 
-    LogicalMargin wrapperMargin =
-      wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
     nscoord wrappersMarginBoxBSize =
       wrappersDesiredSize.BSize(myWM) + wrapperMargin.BStartEnd(myWM);
 
     if (contentBoxBSize == NS_INTRINSICSIZE) {
       // We are intrinsically sized -- we should shrinkwrap the outer wrapper's
       // block-size:
       contentBoxBSize = wrappersMarginBoxBSize;
 
@@ -176,38 +193,41 @@ nsNumberControlFrame::Reflow(nsPresConte
       // sizing (we get it for free when we have a non-intrinsic
       // 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());
+
+      borderBoxBSize = contentBoxBSize +
+        aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
     }
 
     // Center child in block axis
     nscoord extraSpace = contentBoxBSize - wrappersMarginBoxBSize;
-    yoffset += std::max(0, extraSpace / 2);
+    wrapperOffset.B(myWM) += std::max(0, extraSpace / 2);
+
+    // Needed in FinishReflowChild, for logical-to-physical conversion:
+    nscoord borderBoxWidth = myWM.IsVertical() ?
+      borderBoxBSize : borderBoxISize;
 
     // Place the child
     FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
-                      &wrapperReflowState, xoffset, yoffset, 0);
+                      &wrapperReflowState, myWM, wrapperOffset,
+                      borderBoxWidth, 0);
 
     aDesiredSize.SetBlockStartAscent(
        wrappersDesiredSize.BlockStartAscent() +
        outerWrapperFrame->BStart(aReflowState.GetWritingMode(),
                                  contentBoxISize));
   }
 
-  LogicalSize
-    logicalDesiredSize(myWM,
-                       contentBoxISize +
-                       aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM),
-                       contentBoxBSize +
-                       aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM));
+  LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
   aDesiredSize.SetSize(myWM, logicalDesiredSize);
 
   aDesiredSize.SetOverflowAreasToDesiredBounds();
 
   if (outerWrapperFrame) {
     ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
   }
 
copy from layout/reftests/forms/input/number/number-similar-to-text-unthemed-ref.html
copy to layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl-ref.html
--- a/layout/reftests/forms/input/number/number-similar-to-text-unthemed-ref.html
+++ b/layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl-ref.html
@@ -1,8 +1,8 @@
 <!DOCTYPE html>
 <html>
-  <body>
-    <input type="text" style="-moz-appearance:none; width:200px;">
+  <body style="direction: rtl">
+    <input type="text" style="-moz-appearance:none; width:200px;" value="1">
     <!-- div to cover spin box area -->
-    <div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
+    <div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; right:100px;"></div>
   </body>
 </html>
copy from layout/reftests/forms/input/number/number-similar-to-text-unthemed.html
copy to layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl.html
--- a/layout/reftests/forms/input/number/number-similar-to-text-unthemed.html
+++ b/layout/reftests/forms/input/number/number-similar-to-text-unthemed-rtl.html
@@ -1,8 +1,8 @@
 <!DOCTYPE html>
 <html>
-  <body>
-    <input type="number" style="-moz-appearance:none; width:200px;">
+  <body style="direction: rtl">
+    <input type="number" style="-moz-appearance:none; width:200px;" value="1">
     <!-- div to cover spin box area -->
-    <div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; left:100px;">
+    <div style="display:block; position:absolute; background-color:black; width:200px; height:100px; top:0px; right:100px;"></div>
   </body>
 </html>
--- a/layout/reftests/forms/input/number/reftest.list
+++ b/layout/reftests/forms/input/number/reftest.list
@@ -4,16 +4,17 @@ default-preferences pref(dom.forms.numbe
 # not valid on Android/B2G where type=number looks like type=text
 skip-if(Android||B2G||Mulet) != not-other-type-unthemed-1.html not-other-type-unthemed-1a-notref.html # Initial mulet triage: parity with B2G/B2G Desktop
 skip-if(Android||B2G||Mulet) != not-other-type-unthemed-1.html not-other-type-unthemed-1b-notref.html # Initial mulet triage: parity with B2G/B2G Desktop
 # only valid on Android/B2G where type=number looks the same as type=text
 skip-if(!Android&&!B2G&&!Mulet) == number-same-as-text-unthemed.html number-same-as-text-unthemed-ref.html # Initial mulet triage: parity with B2G/B2G Desktop
 
 # should look the same as type=text, except for the spin box
 == number-similar-to-text-unthemed.html number-similar-to-text-unthemed-ref.html
+== number-similar-to-text-unthemed-rtl.html number-similar-to-text-unthemed-rtl-ref.html
 
 # dynamic type changes:
 fuzzy-if(/^Windows\x20NT\x205\.1/.test(http.oscpu),64,4) fuzzy-if(cocoaWidget,63,4) == to-number-from-other-type-unthemed-1.html to-number-from-other-type-unthemed-1-ref.html
 == from-number-to-other-type-unthemed-1.html from-number-to-other-type-unthemed-1-ref.html
 
 # dynamic value changes:
 == show-value.html show-value-ref.html