Bug 1320014 Part 10 - Convert NS_HALF_TO_FULL_CORNER to a constexpr function.
MozReview-Commit-ID: 1PECc7hm249
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -469,11 +469,16 @@ static inline HalfCorner operator++(Half
return aHalfCorner;
}
constexpr bool HalfCornerIsX(HalfCorner aHalfCorner)
{
return !(aHalfCorner % 2);
}
+constexpr Corner HalfToFullCorner(HalfCorner aHalfCorner)
+{
+ return Corner(aHalfCorner / 2);
+}
+
} // namespace mozilla
#endif /* MOZILLA_GFX_TYPES_H_ */
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -15,17 +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_HALF_TO_FULL_CORNER(var_) ((var_)/2)
#define NS_FULL_TO_HALF_CORNER(var_, vert_) ((var_)*2 + !!(vert_))
#define NS_SIDE_IS_VERTICAL(side_) ((side_) % 2)
#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)
--- a/layout/style/nsStyleCoord.cpp
+++ b/layout/style/nsStyleCoord.cpp
@@ -349,20 +349,20 @@ CASE(eCornerTopLeftY, false);
CASE(eCornerTopRightX, true);
CASE(eCornerTopRightY, false);
CASE(eCornerBottomRightX, true);
CASE(eCornerBottomRightY, false);
CASE(eCornerBottomLeftX, true);
CASE(eCornerBottomLeftY, false);
#undef CASE
-// Validation of NS_HALF_TO_FULL_CORNER.
+// Validation of HalfToFullCorner.
#define CASE(corner, result) \
- static_assert(NS_HALF_TO_FULL_CORNER(corner) == result, \
- "NS_HALF_TO_FULL_CORNER is wrong")
+ static_assert(HalfToFullCorner(corner) == result, \
+ "HalfToFullCorner is wrong")
CASE(eCornerTopLeftX, eCornerTopLeft);
CASE(eCornerTopLeftY, eCornerTopLeft);
CASE(eCornerTopRightX, eCornerTopRight);
CASE(eCornerTopRightY, eCornerTopRight);
CASE(eCornerBottomRightX, eCornerBottomRight);
CASE(eCornerBottomRightY, eCornerBottomRight);
CASE(eCornerBottomLeftX, eCornerBottomLeft);
CASE(eCornerBottomLeftY, eCornerBottomLeft);