Bug 1317351 - Make CloneReflowInputWithReducedContentBox use logical coordinates, which avoids doing math on NS_UNCONSTRAINEDSIZE ComputedWidth() when it's an unconstrained block-size. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Tue, 15 Nov 2016 19:31:14 +0100
changeset 367741 e4e19a28e8af70b9de83f3d8dbf9f5e062720691
parent 367740 355aec7f1abec8f42fe12c93dda494e70dd7fb1e
child 367742 2e3043cf0b4dec6fe9fe7c2a97be05a072a57335
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1317351
milestone53.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 1317351 - Make CloneReflowInputWithReducedContentBox use logical coordinates, which avoids doing math on NS_UNCONSTRAINEDSIZE ComputedWidth() when it's an unconstrained block-size. r=jfkthame
layout/forms/nsHTMLButtonControlFrame.cpp
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -240,32 +240,33 @@ nsHTMLButtonControlFrame::Reflow(nsPresC
 // Helper-function that lets us clone the button's reflow state, but with its
 // ComputedWidth and ComputedHeight reduced by the amount of renderer-specific
 // focus border and padding that we're using. (This lets us provide a more
 // appropriate content-box size for descendents' percent sizes to resolve
 // against.)
 static ReflowInput
 CloneReflowInputWithReducedContentBox(
   const ReflowInput& aButtonReflowInput,
-  const nsMargin& aFocusPadding)
+  const LogicalMargin& aFocusPadding)
 {
-  nscoord adjustedWidth =
-    aButtonReflowInput.ComputedWidth() - aFocusPadding.LeftRight();
-  adjustedWidth = std::max(0, adjustedWidth);
+  auto wm = aButtonReflowInput.GetWritingMode();
+  nscoord adjustedISize = aButtonReflowInput.ComputedISize();
+  adjustedISize -= aFocusPadding.IStartEnd(wm);
+  adjustedISize = std::max(0, adjustedISize);
 
-  // (Only adjust height if it's an actual length.)
-  nscoord adjustedHeight = aButtonReflowInput.ComputedHeight();
-  if (adjustedHeight != NS_INTRINSICSIZE) {
-    adjustedHeight -= aFocusPadding.TopBottom();
-    adjustedHeight = std::max(0, adjustedHeight);
+  // (Only adjust the block-size if it's an actual length.)
+  nscoord adjustedBSize = aButtonReflowInput.ComputedBSize();
+  if (adjustedBSize != NS_INTRINSICSIZE) {
+    adjustedBSize -= aFocusPadding.BStartEnd(wm);
+    adjustedBSize = std::max(0, adjustedBSize);
   }
 
   ReflowInput clone(aButtonReflowInput);
-  clone.SetComputedWidth(adjustedWidth);
-  clone.SetComputedHeight(adjustedHeight);
+  clone.SetComputedISize(adjustedISize);
+  clone.SetComputedBSize(adjustedBSize);
 
   return clone;
 }
 
 void
 nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
                                                ReflowOutput& aButtonDesiredSize,
                                                const ReflowInput& aButtonReflowInput,
@@ -311,18 +312,17 @@ nsHTMLButtonControlFrame::ReflowButtonCo
 
   LogicalPoint childPos(wm);
   childPos.I(wm) = focusPadding.IStart(wm) + clbp.IStart(wm);
   availSize.ISize(wm) = std::max(availSize.ISize(wm), 0);
 
   // Give child a clone of the button's reflow state, with height/width reduced
   // by focusPadding, so that descendants with height:100% don't protrude.
   ReflowInput adjustedButtonReflowInput =
-    CloneReflowInputWithReducedContentBox(aButtonReflowInput,
-                                          focusPadding.GetPhysicalMargin(wm));
+    CloneReflowInputWithReducedContentBox(aButtonReflowInput, focusPadding);
 
   ReflowInput contentsReflowInput(aPresContext,
                                         adjustedButtonReflowInput,
                                         aFirstKid, availSize);
 
   nsReflowStatus contentsReflowStatus;
   ReflowOutput contentsDesiredSize(aButtonReflowInput);
   childPos.B(wm) = 0; // This will be set properly later, after reflowing the