Bug 1174003 part 10: [css-flexbox] Remove GET_MAIN_COMPONENT/GET_CROSS_COMPONENT macros (expanding each at its only remaining callsite). r?mats draft
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 28 Feb 2018 09:41:13 -0800
changeset 761090 ca582e8ddad3401c524a9e80210a45d6af150d3f
parent 761089 c62879621af1823e7a8075d425648f6be90042c6
child 761091 f7ee17a9d5481c682b41907ebde2007a0f03ad3a
push id100857
push userdholbert@mozilla.com
push dateWed, 28 Feb 2018 17:41:29 +0000
reviewersmats
bugs1174003
milestone60.0a1
Bug 1174003 part 10: [css-flexbox] Remove GET_MAIN_COMPONENT/GET_CROSS_COMPONENT macros (expanding each at its only remaining callsite). r?mats This patch doesn't affect behavior. Each of these macros only had one caller remaining, and this patch simply expands each of these macros at its sole callsite. Note that I'm using the "IsMainAxisHorizontal()" helper in *both* expansions here, which makes the alternative variant "IsCrossAxisHorizontal()" unused as of this patch. The next patch in this series will remove that now-unused method, which will reduce the "Horizontal"-querying API surface here. The documentation for the macros is still relevant to their still-existing "_LOGICAL" variants (and those variants do still have callers), so I'm updating the documentation to be about those variants. MozReview-Commit-ID: 5i32VYXzo3r
layout/generic/nsFlexContainerFrame.cpp
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -249,31 +249,25 @@ PhysicalCoordFromFlexRelativeCoord(nscoo
                                    nscoord aContainerSize,
                                    AxisOrientationType aAxis) {
   if (AxisGrowsInPositiveDirection(aAxis)) {
     return aFlexRelativeCoord;
   }
   return aContainerSize - aFlexRelativeCoord;
 }
 
-// Helper-macro to let us pick one of two expressions to evaluate
-// (a width expression vs. a height expression), to get a main-axis or
-// cross-axis component.
-// For code that has e.g. a nsSize object, FlexboxAxisTracker::GetMainComponent
-// and GetCrossComponent are cleaner; but in cases where we simply have
-// two separate expressions for width and height (which may be expensive to
-// evaluate), these macros will ensure that only the expression for the correct
-// axis gets evaluated.
-#define GET_MAIN_COMPONENT(axisTracker_, width_, height_)  \
-  (axisTracker_).IsMainAxisHorizontal() ? (width_) : (height_)
-
-#define GET_CROSS_COMPONENT(axisTracker_, width_, height_)  \
-  (axisTracker_).IsCrossAxisHorizontal() ? (width_) : (height_)
-
-// Logical versions of helper-macros above:
+// Helper-macros to let us pick one of two expressions to evaluate
+// (an inline-axis expression vs. a block-axis expression), to get a
+// main-axis or cross-axis component.
+// For code that has e.g. a LogicalSize object, the methods
+// FlexboxAxisTracker::GetMainComponent and GetCrossComponent are cleaner
+// than these macros. But in cases where we simply have two separate
+// expressions for ISize and BSize (which may be expensive to evaluate),
+// these macros can be used to ensure that only the needed expression is
+// evaluated.
 #define GET_MAIN_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_)  \
   wm_.IsOrthogonalTo(axisTracker_.GetWritingMode()) != \
     (axisTracker_).IsRowOriented() ? (isize_) : (bsize_)
 
 #define GET_CROSS_COMPONENT_LOGICAL(axisTracker_, wm_, isize_, bsize_)  \
   wm_.IsOrthogonalTo(axisTracker_.GetWritingMode()) != \
     (axisTracker_).IsRowOriented() ? (bsize_) : (isize_)
 
@@ -329,25 +323,25 @@ public:
   bool IsRowOriented() const { return mIsRowOriented; }
   bool IsColumnOriented() const { return !mIsRowOriented; }
 
   // aSize is expected to match the flex container's WritingMode.
   nscoord GetMainComponent(const LogicalSize& aSize) const {
     return IsRowOriented() ? aSize.ISize(mWM) : aSize.BSize(mWM);
   }
   int32_t GetMainComponent(const LayoutDeviceIntSize& aIntSize) const {
-    return GET_MAIN_COMPONENT(*this, aIntSize.width, aIntSize.height);
+    return IsMainAxisHorizontal() ? aIntSize.width : aIntSize.height;
   }
 
   // aSize is expected to match the flex container's WritingMode.
   nscoord GetCrossComponent(const LogicalSize& aSize) const {
     return IsRowOriented() ? aSize.BSize(mWM) : aSize.ISize(mWM);
   }
   int32_t GetCrossComponent(const LayoutDeviceIntSize& aIntSize) const {
-    return GET_CROSS_COMPONENT(*this, aIntSize.width, aIntSize.height);
+    return IsMainAxisHorizontal() ? aIntSize.height : aIntSize.width;
   }
 
   // NOTE: aMargin is expected to use the flex container's WritingMode.
   nscoord GetMarginSizeInMainAxis(const LogicalMargin& aMargin) const {
     // If we're row-oriented, our main axis is the inline axis.
     return IsRowOriented()
       ? aMargin.IStartEnd(mWM)
       : aMargin.BStartEnd(mWM);