Bug 1313421 part 1: Unconditionally cache a FlexItem's ascent, after it's been reflowed. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 27 Oct 2016 18:56:41 -0700
changeset 319882 c565ba669d962165dc90b99f77b0b26d4acb4d92
parent 319881 1145a10a2fd5e23d0191ae9e1c22a6fa6e47ec0a
child 319883 ae632144724fc5efae24a32acab2d7d938384123
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1313421
milestone52.0a1
Bug 1313421 part 1: Unconditionally cache a FlexItem's ascent, after it's been reflowed. r=mats This removes a (very minor) optimization. The optimization was simply that we avoided storing this nscoord value, if we could tell that we weren't ever going to need it. Now it's becoming a bit more complicated to prove that we'll never need it, so we might as well just store it unconditionally. MozReview-Commit-ID: 94FFc9SO516
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1640,24 +1640,17 @@ nsFlexContainerFrame::
              "We gave flex item unconstrained available height, so it "
              "should be complete");
 
   FinishReflowChild(aFlexItem.Frame(), aPresContext,
                     childDesiredSize, &childRIForMeasuringHeight,
                     0, 0, flags);
 
   aFlexItem.SetHadMeasuringReflow();
-
-  // If this is the first child, save its ascent, since it may be what
-  // establishes the container's baseline. Also save the ascent if this child
-  // needs to be baseline-aligned. (Else, we don't care about ascent/baseline.)
-  if (aFlexItem.Frame() == mFrames.FirstChild() ||
-      aFlexItem.GetAlignSelf() == NS_STYLE_ALIGN_BASELINE) {
-    aFlexItem.SetAscent(childDesiredSize.BlockStartAscent());
-  }
+  aFlexItem.SetAscent(childDesiredSize.BlockStartAscent());
 
   // Subtract border/padding in vertical axis, to get _just_
   // the effective computed value of the "height" property.
   nscoord childDesiredHeight = childDesiredSize.Height() -
     childRIForMeasuringHeight.ComputedPhysicalBorderPadding().TopBottom();
 
   return std::max(0, childDesiredHeight);
 }
@@ -3777,23 +3770,17 @@ nsFlexContainerFrame::SizeItemInCrossAxi
       !aItem.Frame()->GetType(),
       "Child should at least request space for border/padding");
     aItem.SetCrossSize(0);
   } else {
     // (normal case)
     aItem.SetCrossSize(childDesiredSize.Height() - crossAxisBorderPadding);
   }
 
-  // If this is the first child, save its ascent, since it may be what
-  // establishes the container's baseline. Also save the ascent if this child
-  // needs to be baseline-aligned. (Else, we don't care about baseline/ascent.)
-  if (aItem.Frame() == mFrames.FirstChild() ||
-      aItem.GetAlignSelf() == NS_STYLE_ALIGN_BASELINE) {
-    aItem.SetAscent(childDesiredSize.BlockStartAscent());
-  }
+  aItem.SetAscent(childDesiredSize.BlockStartAscent());
 }
 
 void
 FlexLine::PositionItemsInCrossAxis(nscoord aLineStartPosition,
                                    const FlexboxAxisTracker& aAxisTracker)
 {
   SingleLineCrossAxisPositionTracker lineCrossAxisPosnTracker(aAxisTracker);
 
@@ -4446,20 +4433,17 @@ nsFlexContainerFrame::ReflowFlexItem(nsP
   ReflowInput::ApplyRelativePositioning(aItem.Frame(), outerWM,
                                               offsets, &aFramePos,
                                               aContainerSize);
 
   FinishReflowChild(aItem.Frame(), aPresContext,
                     childDesiredSize, &childReflowInput,
                     outerWM, aFramePos, aContainerSize, 0);
 
-  // Save the first child's ascent; it may establish container's baseline.
-  if (aItem.Frame() == mFrames.FirstChild()) {
-    aItem.SetAscent(childDesiredSize.BlockStartAscent());
-  }
+  aItem.SetAscent(childDesiredSize.BlockStartAscent());
 }
 
 /* virtual */ nscoord
 nsFlexContainerFrame::GetMinISize(nsRenderingContext* aRenderingContext)
 {
   nscoord minISize = 0;
   DISPLAY_MIN_WIDTH(this, minISize);