Bug 1079154 patch 6: convert ApplyRelativePosition, ReflowChild and FinishReflowChild in nsFlexContainerFrame to the logical versions, r=dholbert
authorSimon Montagu <smontagu@smontagu.org>
Tue, 06 Jan 2015 23:10:07 -0800
changeset 248196 d2a2cdfc45ec6b2455ea9ad36c048a5f94fd2107
parent 248195 0b2d6f002feea0a8ebb8f4b922c7b17a9fddac20
child 248197 547a2d626a62f219b484a54608331db8f1841530
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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 1079154 patch 6: convert ApplyRelativePosition, ReflowChild and FinishReflowChild in nsFlexContainerFrame to the logical versions, r=dholbert
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -3603,31 +3603,39 @@ nsFlexContainerFrame::DoFlexLayout(nsPre
   // Before giving each child a final reflow, calculate the origin of the
   // flex container's content box (with respect to its border-box), so that
   // we can compute our flex item's final positions.
   nsMargin containerBorderPadding(aReflowState.ComputedPhysicalBorderPadding());
   const nsPoint containerContentBoxOrigin(containerBorderPadding.left,
+  WritingMode outerWM = aReflowState.GetWritingMode();
+  nscoord containerWidth = IsAxisHorizontal(aAxisTracker.GetMainAxis()) ?
+                             aContentBoxMainSize : contentBoxCrossSize;
   // FINAL REFLOW: Give each child frame another chance to reflow, now that
   // we know its final size and position.
   for (const FlexLine* line = lines.getFirst(); line; line = line->getNext()) {
     for (const FlexItem* item = line->GetFirstItem(); item;
          item = item->getNext()) {
       nsPoint physicalPosn = aAxisTracker.PhysicalPointFromLogicalPoint(
       // Adjust physicalPosn to be relative to the container's border-box
       // (i.e. its frame rect), instead of the container's content-box:
       physicalPosn += containerContentBoxOrigin;
+      //XXX Can we calculate the logical position more directly instead
+      //    of this double conversion?
+      LogicalPoint framePos(outerWM, physicalPosn,
+                            containerWidth - item->Frame()->GetRect().width);
       WritingMode wm = item->Frame()->GetWritingMode();
       LogicalSize availSize = aReflowState.ComputedSize(wm);
       availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
       nsHTMLReflowState childReflowState(aPresContext, aReflowState,
                                          item->Frame(), availSize);
       // Keep track of whether we've overriden the child's computed height
       // and/or width, so we can set its resize flags accordingly.
@@ -3680,48 +3688,47 @@ nsFlexContainerFrame::DoFlexLayout(nsPre
       // NOTE: Be very careful about doing anything else with childReflowState
       // after this point, because some of its methods (e.g. SetComputedWidth)
       // internally call InitResizeFlags and stomp on mVResize & mHResize.
       nsHTMLReflowMetrics childDesiredSize(childReflowState);
       nsReflowStatus childReflowStatus;
       ReflowChild(item->Frame(), aPresContext,
                   childDesiredSize, childReflowState,
-                  physicalPosn.x, physicalPosn.y,
+                  outerWM, framePos, containerWidth,
                   0, childReflowStatus);
       // XXXdholbert Once we do pagination / splitting, we'll need to actually
       // handle incomplete childReflowStatuses. But for now, we give our kids
       // unconstrained available height, which means they should always
       // complete.
                  "We gave flex item unconstrained available height, so it "
                  "should be complete");
-      childReflowState.ApplyRelativePositioning(&physicalPosn);
+      childReflowState.ApplyRelativePositioning(&framePos, containerWidth);
       FinishReflowChild(item->Frame(), aPresContext,
                         childDesiredSize, &childReflowState,
-                        physicalPosn.x, physicalPosn.y, 0);
+                        outerWM, framePos, containerWidth, 0);
       // If this is our first child and we haven't established a baseline for
       // the container yet (i.e. if we don't have 'align-self: baseline' on any
       // children), then use this child's baseline as the container's baseline.
       if (item->Frame() == mFrames.FirstChild() &&
           flexContainerAscent == nscoord_MIN) {
         ResolveReflowedChildAscent(item->Frame(), childDesiredSize);
         // (We use GetNormalPosition() instead of physicalPosn because we don't
         // want relative positioning on the child to affect the baseline that we
         // read from it).
-        WritingMode wm = aReflowState.GetWritingMode();
-        flexContainerAscent =
-          item->Frame()->GetLogicalNormalPosition(wm,
-                                                  childDesiredSize.Width()).B(wm) +
-          childDesiredSize.BlockStartAscent();
+        flexContainerAscent = item->Frame()->GetLogicalNormalPosition(
+                                outerWM,
+                                childDesiredSize.Width()).B(outerWM) +
+                              childDesiredSize.BlockStartAscent();
   nsSize desiredContentBoxSize =