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
--- 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);