Bug 1320014 Part 13 - Convert NS_SIDE_TO_FULL_CORNER to a constexpr function.
MozReview-Commit-ID: 4r4jEN2LklH
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -484,11 +484,20 @@ constexpr HalfCorner FullToHalfCorner(Co
return HalfCorner(aCorner * 2 + aIsVertical);
}
constexpr bool SideIsVertical(Side aSide)
{
return aSide % 2;
}
+// @param aIsSecond when true, return the clockwise second of the two
+// corners associated with aSide. For example, with aSide = eSideBottom the
+// result is eCornerBottomRight when aIsSecond is false, and
+// eCornerBottomLeft when aIsSecond is true.
+constexpr Corner SideToFullCorner(Side aSide, bool aIsSecond)
+{
+ return Corner((aSide + aIsSecond) % 4);
+}
+
} // namespace mozilla
#endif /* MOZILLA_GFX_TYPES_H_ */
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -15,18 +15,16 @@
// XXX fold this into nsStyleContext and group by nsStyleXXX struct
namespace mozilla {
// The results of these conversion macros are exhaustively checked in
// nsStyleCoord.cpp.
// Arguments must not have side effects.
-#define NS_SIDE_TO_FULL_CORNER(side_, second_) \
- (((side_) + !!(second_)) % 4)
#define NS_SIDE_TO_HALF_CORNER(side_, second_, parallel_) \
((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8)
// Basic shapes
enum class StyleBasicShapeType : uint8_t {
Polygon,
Circle,
Ellipse,
--- a/layout/style/nsStyleCoord.cpp
+++ b/layout/style/nsStyleCoord.cpp
@@ -377,20 +377,20 @@ CASE(eCornerTopLeft, true, eCornerT
CASE(eCornerTopRight, false, eCornerTopRightX);
CASE(eCornerTopRight, true, eCornerTopRightY);
CASE(eCornerBottomRight, false, eCornerBottomRightX);
CASE(eCornerBottomRight, true, eCornerBottomRightY);
CASE(eCornerBottomLeft, false, eCornerBottomLeftX);
CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
#undef CASE
-// Validation of NS_SIDE_TO_{FULL,HALF}_CORNER.
+// Validation of SideToFullCorner.
#define CASE(side, second, result) \
- static_assert(NS_SIDE_TO_FULL_CORNER(side, second) == result, \
- "NS_SIDE_TO_FULL_CORNER is wrong")
+ static_assert(SideToFullCorner(side, second) == result, \
+ "SideToFullCorner is wrong")
CASE(eSideTop, false, eCornerTopLeft);
CASE(eSideTop, true, eCornerTopRight);
CASE(eSideRight, false, eCornerTopRight);
CASE(eSideRight, true, eCornerBottomRight);
CASE(eSideBottom, false, eCornerBottomRight);
CASE(eSideBottom, true, eCornerBottomLeft);