diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 7626987a87..ad83a79889 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -479,6 +479,16 @@ 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_ */ diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 879b77269d..96690ae2d8 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -20,8 +20,6 @@ namespace mozilla { // 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) diff --git a/layout/style/nsStyleCoord.cpp b/layout/style/nsStyleCoord.cpp index ba673201e3..263b0844b2 100644 --- a/layout/style/nsStyleCoord.cpp +++ b/layout/style/nsStyleCoord.cpp @@ -380,10 +380,10 @@ 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);