mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #1925 - Move NS_FOR_CSS_SIDES and operator++ to gfx/2d/Types.h
This commit is contained in:
parent
1fe474cf7b
commit
5b0921df6e
2 changed files with 26 additions and 24 deletions
|
|
@ -7,6 +7,8 @@
|
|||
#define MOZILLA_GFX_TYPES_H_
|
||||
|
||||
#include "mozilla/EndianUtils.h"
|
||||
#include "mozilla/MacroArgs.h" // for MOZ_CONCAT
|
||||
#include "nsDebug.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -387,11 +389,33 @@ enum SideBits {
|
|||
eSideBitsAll = eSideBitsTopBottom | eSideBitsLeftRight
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_SIDE_TOP mozilla::eSideTop
|
||||
#define NS_SIDE_RIGHT mozilla::eSideRight
|
||||
#define NS_SIDE_BOTTOM mozilla::eSideBottom
|
||||
#define NS_SIDE_LEFT mozilla::eSideLeft
|
||||
|
||||
namespace css {
|
||||
typedef mozilla::Side Side;
|
||||
} // namespace css
|
||||
|
||||
// Creates a for loop that walks over the four mozilla::css::Side values.
|
||||
// We use an int32_t helper variable (instead of a Side) for our loop counter,
|
||||
// to avoid triggering undefined behavior just before we exit the loop (at
|
||||
// which point the counter is incremented beyond the largest valid Side value).
|
||||
#define NS_FOR_CSS_SIDES(var_) \
|
||||
int32_t MOZ_CONCAT(var_,__LINE__) = NS_SIDE_TOP; \
|
||||
for (mozilla::css::Side var_; \
|
||||
MOZ_CONCAT(var_,__LINE__) <= NS_SIDE_LEFT && \
|
||||
((var_ = mozilla::css::Side(MOZ_CONCAT(var_,__LINE__))), true); \
|
||||
MOZ_CONCAT(var_,__LINE__)++)
|
||||
|
||||
static inline css::Side operator++(css::Side& side, int) {
|
||||
NS_PRECONDITION(side >= NS_SIDE_TOP &&
|
||||
side <= NS_SIDE_LEFT, "Out of range side");
|
||||
side = css::Side(side + 1);
|
||||
return side;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* MOZILLA_GFX_TYPES_H_ */
|
||||
|
|
|
|||
|
|
@ -10,33 +10,11 @@
|
|||
|
||||
#include "gfxRect.h"
|
||||
#include "nsFont.h"
|
||||
#include "mozilla/MacroArgs.h" // for MOZ_CONCAT
|
||||
#include "X11UndefineNone.h"
|
||||
|
||||
// XXX fold this into nsStyleContext and group by nsStyleXXX struct
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
typedef mozilla::Side Side;
|
||||
} // namespace css
|
||||
|
||||
// Creates a for loop that walks over the four mozilla::css::Side values.
|
||||
// We use an int32_t helper variable (instead of a Side) for our loop counter,
|
||||
// to avoid triggering undefined behavior just before we exit the loop (at
|
||||
// which point the counter is incremented beyond the largest valid Side value).
|
||||
#define NS_FOR_CSS_SIDES(var_) \
|
||||
int32_t MOZ_CONCAT(var_,__LINE__) = NS_SIDE_TOP; \
|
||||
for (mozilla::css::Side var_; \
|
||||
MOZ_CONCAT(var_,__LINE__) <= NS_SIDE_LEFT && \
|
||||
((var_ = mozilla::css::Side(MOZ_CONCAT(var_,__LINE__))), true); \
|
||||
MOZ_CONCAT(var_,__LINE__)++)
|
||||
|
||||
static inline css::Side operator++(css::Side& side, int) {
|
||||
NS_PRECONDITION(side >= NS_SIDE_TOP &&
|
||||
side <= NS_SIDE_LEFT, "Out of range side");
|
||||
side = css::Side(side + 1);
|
||||
return side;
|
||||
}
|
||||
|
||||
#define NS_FOR_CSS_FULL_CORNERS(var_) for (int32_t var_ = 0; var_ < 4; ++var_)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue