Bug 1174003 part 9: [css-flexbox] Remove GET_MAIN_COMPONENT calls from CheckForMinSizeAuto(). r?mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 28 Feb 2018 09:40:48 -0800
changeset 761089 c62879621af1823e7a8075d425648f6be90042c6
parent 760720 69780811f58b21177071441c56b55ab7f916cc17
child 761090 ca582e8ddad3401c524a9e80210a45d6af150d3f
push id100857
push userdholbert@mozilla.com
push dateWed, 28 Feb 2018 17:41:29 +0000
reviewersmats
bugs1174003
milestone60.0a1
Bug 1174003 part 9: [css-flexbox] Remove GET_MAIN_COMPONENT calls from CheckForMinSizeAuto(). r?mats This patch doesn't change behavior. The GET_MAIN_COMPONENT macro (some of whose calls I'm removing here) makes a call to IsMainAxisHorizontal() under the hood. So I want to get rid of calls to this this macro, to get closer to killing that method. In this code, we're interested in the flex item's min-size property in the flex container's main axis. This patch makes us simply use MinISize/MinBSize (in terms of the *flex container's* writing mode) to get the appropriate min-size property. The call to IsRowOriented() (querying the flex container's "flex-direction" property) tells us whether the inline or block axis is the main axis. This patch also does away with an unnecessary axis-specific 'overflow-{x/y}' check, which we don't need to bother with, as noted in a new code-comment (due to how the 'overflow' subproperties influence each other). MozReview-Commit-ID: Kqyh69W5IQJ
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1937,30 +1937,30 @@ FlexItem::FlexItem(nsIFrame* aChildFrame
 void
 FlexItem::CheckForMinSizeAuto(const ReflowInput& aFlexItemReflowInput,
                               const FlexboxAxisTracker& aAxisTracker)
 {
   const nsStylePosition* pos = aFlexItemReflowInput.mStylePosition;
   const nsStyleDisplay* disp = aFlexItemReflowInput.mStyleDisplay;
 
   // We'll need special behavior for "min-[width|height]:auto" (whichever is in
-  // the main axis) iff:
+  // the flex container's main axis) iff:
   // (a) its computed value is "auto"
   // (b) the "overflow" sub-property in the same axis (the main axis) has a
   //     computed value of "visible"
-  const nsStyleCoord& minSize = GET_MAIN_COMPONENT(aAxisTracker,
-                                                   pos->mMinWidth,
-                                                   pos->mMinHeight);
-
-  const uint8_t overflowVal = GET_MAIN_COMPONENT(aAxisTracker,
-                                                 disp->mOverflowX,
-                                                 disp->mOverflowY);
-
-  mNeedsMinSizeAutoResolution = (minSize.GetUnit() == eStyleUnit_Auto &&
-                                 overflowVal == NS_STYLE_OVERFLOW_VISIBLE);
+  const nsStyleCoord& mainMinSize = aAxisTracker.IsRowOriented()
+    ? pos->MinISize(aAxisTracker.GetWritingMode())
+    : pos->MinBSize(aAxisTracker.GetWritingMode());
+
+  // NOTE: Technically we should be checking the 'overflow' subproperty in the
+  // main axis. But since we only care whether it's 'visible', we can check
+  // either subproperty -- because they must be BOTH 'visible' or BOTH
+  // non-'visible' due to the way the subproperties interact.
+  mNeedsMinSizeAutoResolution = (mainMinSize.GetUnit() == eStyleUnit_Auto &&
+                                 disp->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE);
 }
 
 nscoord
 FlexItem::GetBaselineOffsetFromOuterCrossEdge(
   AxisEdgeType aEdge,
   const FlexboxAxisTracker& aAxisTracker,
   bool aUseFirstLineBaseline) const
 {