mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-22 16:37:31 +09:00
Issue #1925 - Convert NS_SIDE_TO_HALF_CORNER to a constexpr function.
This commit is contained in:
parent
2a399b60a1
commit
c096b46278
4 changed files with 29 additions and 15 deletions
|
|
@ -459,6 +459,9 @@ static inline mozilla::HalfCorner operator++(mozilla::HalfCorner& aHalfCorner) {
|
|||
return aHalfCorner;
|
||||
}
|
||||
|
||||
// The result of the conversion functions below are exhaustively checked in
|
||||
// nsStyleCoord.cpp, which also serves as usage examples.
|
||||
|
||||
constexpr bool HalfCornerIsX(HalfCorner aHalfCorner)
|
||||
{
|
||||
return !(aHalfCorner % 2);
|
||||
|
|
@ -489,6 +492,23 @@ constexpr Corner SideToFullCorner(Side aSide, bool aIsSecond)
|
|||
return Corner((aSide + aIsSecond) % 4);
|
||||
}
|
||||
|
||||
/* @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.
|
||||
* @param aIsParallel: return the half-corner that is parallel with aSide
|
||||
* when aIsParallel is true. For example with aSide=eSideTop, aIsSecond=true
|
||||
* the result is eCornerTopRightX when aIsParallel is true, and
|
||||
* eCornerTopRightY when aIsParallel is false (because "X" is parallel with
|
||||
* eSideTop/eSideBottom, similarly "Y" is parallel with eSideLeft/eSideRight)
|
||||
*/
|
||||
constexpr HalfCorner SideToHalfCorner(Side aSide,
|
||||
bool aIsSecond,
|
||||
bool aIsParallel)
|
||||
{
|
||||
return HalfCorner(((aSide + aIsSecond) * 2 + (aSide + !aIsParallel) % 2) % 8);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* MOZILLA_GFX_TYPES_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue