Bug 1124636 patch 2: use logical ReflowChild, FinishReflowChild and ApplyRelativePositioning in nsFieldSetFrame. r=jfkthame
authorSimon Montagu <smontagu@smontagu.org>
Wed, 11 Feb 2015 01:43:03 -0800
changeset 228661 70dda75a914f01300422fb5d65324089e4556b4f
parent 228660 31f86276a98b2a1da9f0073f11f8ec541e1b6e3d
child 228662 71d4403b474ae9f4dd1ca9a1dc7058204d932795
push id28267
push userryanvm@gmail.com
push dateWed, 11 Feb 2015 21:28:56 +0000
treeherdermozilla-central@650863f6987b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1124636
milestone38.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 1124636 patch 2: use logical ReflowChild, FinishReflowChild and ApplyRelativePositioning in nsFieldSetFrame. r=jfkthame
layout/forms/nsFieldSetFrame.cpp
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -428,72 +428,74 @@ nsFieldSetFrame::Reflow(nsPresContext*  
   NS_ASSERTION(!legend ||
       nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
                                            legend,
                                            nsLayoutUtils::MIN_ISIZE) <=
                legendAvailSize.ISize(legendWM),
                "Bogus availSize.ISize; should be bigger");
 
   // get our border and padding
-  nsMargin border = aReflowState.ComputedPhysicalBorderPadding() -
-                      aReflowState.ComputedPhysicalPadding();
-  LogicalMargin logBorder(wm, border);
+  LogicalMargin border = aReflowState.ComputedLogicalBorderPadding() -
+                         aReflowState.ComputedLogicalPadding();
 
   // Figure out how big the legend is if there is one.
   // get the legend's margin
   LogicalMargin legendMargin(wm);
   // reflow the legend only if needed
   Maybe<nsHTMLReflowState> legendReflowState;
   if (legend) {
     legendReflowState.emplace(aPresContext, aReflowState, legend,
                                 legendAvailSize);
   }
   if (reflowLegend) {
     nsHTMLReflowMetrics legendDesiredSize(aReflowState);
 
     ReflowChild(legend, aPresContext, legendDesiredSize, *legendReflowState,
-                0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
+                wm, LogicalPoint(wm), 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
 #ifdef NOISY_REFLOW
     printf("  returned (%d, %d)\n",
            legendDesiredSize.Width(), legendDesiredSize.Height());
 #endif
     // figure out the legend's rectangle
     legendMargin = legend->GetLogicalUsedMargin(wm);
     mLegendRect =
       LogicalRect(wm, 0, 0,
                   legendDesiredSize.ISize(wm) + legendMargin.IStartEnd(wm),
                   legendDesiredSize.BSize(wm) + legendMargin.BStartEnd(wm));
     nscoord oldSpace = mLegendSpace;
     mLegendSpace = 0;
-    if (mLegendRect.BSize(wm) > logBorder.BStart(wm)) {
+    if (mLegendRect.BSize(wm) > border.BStart(wm)) {
       // center the border on the legend
-      mLegendSpace = mLegendRect.BSize(wm) - logBorder.BStart(wm);
+      mLegendSpace = mLegendRect.BSize(wm) - border.BStart(wm);
     } else {
       mLegendRect.BStart(wm) =
-        (logBorder.BStart(wm) - mLegendRect.BSize(wm)) / 2;
+        (border.BStart(wm) - mLegendRect.BSize(wm)) / 2;
     }
 
     // if the legend space changes then we need to reflow the
     // content area as well.
     if (mLegendSpace != oldSpace && inner) {
       reflowInner = true;
     }
 
     // We'll move the legend to its proper place later.
     FinishReflowChild(legend, aPresContext, legendDesiredSize,
-                      legendReflowState.ptr(), 0, 0, NS_FRAME_NO_MOVE_FRAME);
+                      legendReflowState.ptr(), wm, LogicalPoint(wm), 0,
+                      NS_FRAME_NO_MOVE_FRAME);
   } else if (!legend) {
     mLegendRect.SetEmpty();
     mLegendSpace = 0;
   } else {
     // mLegendSpace and mLegendRect haven't changed, but we need
     // the used margin when placing the legend.
     legendMargin = legend->GetLogicalUsedMargin(wm);
   }
 
+  nscoord containerWidth = (wm.IsVertical() ? mLegendSpace : 0) +
+                            border.LeftRight(wm);
   // reflow the content frame only if needed
   if (reflowInner) {
     nsHTMLReflowState kidReflowState(aPresContext, aReflowState, inner,
                                      innerAvailSize, -1, -1,
                                      nsHTMLReflowState::CALLER_WILL_INIT);
     // Override computed padding, in case it's percentage padding
     kidReflowState.Init(aPresContext, -1, -1, nullptr,
                         &aReflowState.ComputedPhysicalPadding());
@@ -515,33 +517,31 @@ nsFieldSetFrame::Reflow(nsPresContext*  
         std::max(0, aReflowState.ComputedMaxBSize() - mLegendSpace);
     }
 
     nsHTMLReflowMetrics kidDesiredSize(kidReflowState,
                                        aDesiredSize.mFlags);
     // Reflow the frame
     NS_ASSERTION(kidReflowState.ComputedPhysicalMargin() == nsMargin(0,0,0,0),
                  "Margins on anonymous fieldset child not supported!");
-    nsPoint pt(border.left, border.top);
-    if (wm.IsVerticalLR()) {
-      pt.x += mLegendSpace;
-    } else if (!wm.IsVertical()) {
-      pt.y += mLegendSpace;
-    }
+    LogicalPoint pt(wm, border.IStart(wm), border.BStart(wm) + mLegendSpace);
+
     ReflowChild(inner, aPresContext, kidDesiredSize, kidReflowState,
-                pt.x, pt.y, 0, aStatus);
+                wm, pt, containerWidth, 0, aStatus);
 
+    // update the container width after reflowing the inner frame
     FinishReflowChild(inner, aPresContext, kidDesiredSize,
-                      &kidReflowState, pt.x, pt.y, 0);
+                      &kidReflowState, wm, pt,
+                      containerWidth + kidDesiredSize.Width(), 0);
     NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus);
   }
 
-  nscoord containerWidth =
-    (wm.IsVertical() ? mLegendSpace : 0) +
-    logBorder.LeftRight(wm) + (inner ? inner->GetSize().width : 0);
+  if (inner) {
+    containerWidth += inner->GetSize().width;
+  }
 
   LogicalRect contentRect(wm);
   if (inner) {
     // We don't support margins on inner, so our content rect is just the
     // inner's border-box. We don't care about container-width at this point,
     // as we'll figure out the actual positioning later.
     contentRect = inner->GetLogicalRect(wm, containerWidth);
   }
@@ -600,19 +600,19 @@ nsFieldSetFrame::Reflow(nsPresContext*  
     LogicalPoint actualLegendPos(actualLegendRect.Origin(wm));
     legendReflowState->ApplyRelativePositioning(&actualLegendPos, containerWidth);
     legend->SetPosition(wm, actualLegendPos, containerWidth);
     nsContainerFrame::PositionFrameView(legend);
     nsContainerFrame::PositionChildViews(legend);
   }
 
   // Return our size and our result.
-  LogicalSize finalSize(wm, contentRect.ISize(wm) + logBorder.IStartEnd(wm),
-                        mLegendSpace + logBorder.BStartEnd(wm) +
-                        (inner ? inner->GetLogicalSize(wm).BSize(wm) : 0));
+  LogicalSize finalSize(wm, contentRect.ISize(wm) + border.IStartEnd(wm),
+                        mLegendSpace + border.BStartEnd(wm) +
+                        (inner ? inner->BSize(wm) : 0));
   aDesiredSize.SetSize(wm, finalSize);
   aDesiredSize.SetOverflowAreasToDesiredBounds();
 
   if (legend) {
     ConsiderChildOverflow(aDesiredSize.mOverflowAreas, legend);
   }
   if (inner) {
     ConsiderChildOverflow(aDesiredSize.mOverflowAreas, inner);