From 173019975597b59055abead0afb3cfc428af3614 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 2 Aug 2024 08:10:52 +0200 Subject: [PATCH] Issue #1925 - Move NS_FOR_CSS_HALF_CORNER to gfx/2d/Types.h and rewrite it. --- gfx/2d/Types.h | 16 ++++++++++++++++ layout/style/nsStyleConsts.h | 2 -- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index 8d094bcb15..09458ee002 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -443,6 +443,22 @@ enum HalfCorner { eCornerBottomLeftY = 7 }; +// Creates a for loop that walks over the eight mozilla::HalfCorner values. +// This implementation uses the same technique as NS_FOR_CSS_SIDES. +#define NS_FOR_CSS_HALF_CORNERS(var_) \ + int32_t MOZ_CONCAT(var_,__LINE__) = mozilla::eCornerTopLeftX; \ + for (mozilla::HalfCorner var_; \ + MOZ_CONCAT(var_,__LINE__) <= mozilla::eCornerBottomLeftY && \ + (var_ = mozilla::HalfCorner(MOZ_CONCAT(var_,__LINE__)), true); \ + ++MOZ_CONCAT(var_,__LINE__)) + +static inline mozilla::HalfCorner operator++(mozilla::HalfCorner& aHalfCorner) { + MOZ_ASSERT(aHalfCorner >= eCornerTopLeftX && aHalfCorner <= eCornerBottomLeftY, + "Out of range half corner!"); + aHalfCorner = mozilla::HalfCorner(aHalfCorner + 1); + return aHalfCorner; +} + } // namespace mozilla #endif /* MOZILLA_GFX_TYPES_H_ */ diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index c8948862ed..dba65d74e7 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -16,8 +16,6 @@ namespace mozilla { -#define NS_FOR_CSS_HALF_CORNERS(var_) for (int32_t var_ = 0; var_ < 8; ++var_) - // The results of these conversion macros are exhaustively checked in // nsStyleCoord.cpp. // Arguments must not have side effects.