mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 04:17:31 +09:00
Issue #1925 - Convert NS_SIDE_TO_FULL_CORNER to a constexpr function.
This commit is contained in:
parent
b0b13b8719
commit
2a399b60a1
3 changed files with 13 additions and 5 deletions
|
|
@ -479,6 +479,16 @@ constexpr bool SideIsVertical(Side aSide)
|
||||||
return aSide % 2;
|
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
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* MOZILLA_GFX_TYPES_H_ */
|
#endif /* MOZILLA_GFX_TYPES_H_ */
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ namespace mozilla {
|
||||||
// nsStyleCoord.cpp.
|
// nsStyleCoord.cpp.
|
||||||
// Arguments must not have side effects.
|
// 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_) \
|
#define NS_SIDE_TO_HALF_CORNER(side_, second_, parallel_) \
|
||||||
((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8)
|
((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,10 +380,10 @@ CASE(eCornerBottomLeft, false, eCornerBottomLeftX);
|
||||||
CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
|
CASE(eCornerBottomLeft, true, eCornerBottomLeftY);
|
||||||
#undef CASE
|
#undef CASE
|
||||||
|
|
||||||
// Validation of NS_SIDE_TO_{FULL,HALF}_CORNER.
|
// Validation of SideToFullCorner.
|
||||||
#define CASE(side, second, result) \
|
#define CASE(side, second, result) \
|
||||||
static_assert(NS_SIDE_TO_FULL_CORNER(side, second) == result, \
|
static_assert(SideToFullCorner(side, second) == result, \
|
||||||
"NS_SIDE_TO_FULL_CORNER is wrong")
|
"SideToFullCorner is wrong")
|
||||||
CASE(eSideTop, false, eCornerTopLeft);
|
CASE(eSideTop, false, eCornerTopLeft);
|
||||||
CASE(eSideTop, true, eCornerTopRight);
|
CASE(eSideTop, true, eCornerTopRight);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue