Bug 1148298 part 2: Replace flexbox static helper-function GetSizePropertyForAxis() with a FlexboxAxisTracker method. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 27 Mar 2015 12:06:03 -0700
changeset 266586 667d53879f65b5fc77e182ce4333e1c1cad6f225
parent 266585 893ec9c54ffb67ab7528f7a89d34914a8e35aa05
child 266587 fff94cb6ddf49d154a064f6be1f2f233eb874ee8
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1148298
milestone39.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 1148298 part 2: Replace flexbox static helper-function GetSizePropertyForAxis() with a FlexboxAxisTracker method. r=mats
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -119,28 +119,16 @@ GetReverseAxis(AxisOrientationType aAxis
 
   // Check that we're still in the enum's valid range
   MOZ_ASSERT(reversedAxis >= eAxis_LR &&
              reversedAxis <= eAxis_BT);
 
   return reversedAxis;
 }
 
-// Returns aFrame's computed value for 'height' or 'width' -- whichever is in
-// the same dimension as aAxis.
-static inline const nsStyleCoord&
-GetSizePropertyForAxis(const nsIFrame* aFrame, AxisOrientationType aAxis)
-{
-  const nsStylePosition* stylePos = aFrame->StylePosition();
-
-  return IsAxisHorizontal(aAxis) ?
-    stylePos->mWidth :
-    stylePos->mHeight;
-}
-
 /**
  * Converts a "flex-relative" coordinate in a single axis (a main- or cross-axis
  * coordinate) into a coordinate in the corresponding physical (x or y) axis. If
  * the flex-relative axis in question already maps *directly* to a physical
  * axis (i.e. if it's LTR or TTB), then the physical coordinate has the same
  * numeric value as the provided flex-relative coordinate. Otherwise, we have to
  * subtract the flex-relative coordinate from the flex container's size in that
  * axis, to flip the polarity. (So e.g. a main-axis position of 2px in a RTL
@@ -203,16 +191,27 @@ public:
       aMargin.TopBottom();
   }
   nscoord GetMarginSizeInCrossAxis(const nsMargin& aMargin) const {
     return IsCrossAxisHorizontal() ?
       aMargin.LeftRight() :
       aMargin.TopBottom();
   }
 
+  // Returns aFrame's computed value for 'height' or 'width' -- whichever is in
+  // the cross-axis. (NOTE: This is cross-axis-specific for now. If we need a
+  // main-axis version as well, we could generalize or clone this function.)
+  const nsStyleCoord& ComputedCrossSize(const nsIFrame* aFrame) const {
+    const nsStylePosition* stylePos = aFrame->StylePosition();
+
+    return IsCrossAxisHorizontal() ?
+      stylePos->mWidth :
+      stylePos->mHeight;
+  }
+
   /**
    * Converts a "flex-relative" point (a main-axis & cross-axis coordinate)
    * into a "physical" x,y point.
    *
    * In the simplest case where the main-axis is left-to-right and the
    * cross-axis is top-to-bottom, this just returns
    * nsPoint(aMainCoord, aCrossCoord).
    *
@@ -2737,17 +2736,17 @@ FlexItem::ResolveStretchedCrossSize(nsco
                                     const FlexboxAxisTracker& aAxisTracker)
 {
   AxisOrientationType crossAxis = aAxisTracker.GetCrossAxis();
   // We stretch IFF we are align-self:stretch, have no auto margins in
   // cross axis, and have cross-axis size property == "auto". If any of those
   // conditions don't hold up, we won't stretch.
   if (mAlignSelf != NS_STYLE_ALIGN_ITEMS_STRETCH ||
       GetNumAutoMarginsInAxis(crossAxis) != 0 ||
-      eStyleUnit_Auto != GetSizePropertyForAxis(mFrame, crossAxis).GetUnit()) {
+      eStyleUnit_Auto != aAxisTracker.ComputedCrossSize(mFrame).GetUnit()) {
     return;
   }
 
   // If we've already been stretched, we can bail out early, too.
   // No need to redo the calculation.
   if (mIsStretched) {
     return;
   }