mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
Issue #1925 - Rewrite NS_FOR_CSS_CORNERS to be similar to *_SIDES
- Renames it to NS_CSS_FULL_CORNERS and uses the one macro for all full corners. In preparation for giving half corners the same treatment. - Swaps to prefix operator++
This commit is contained in:
parent
b3a51c2711
commit
0a7f42b452
4 changed files with 18 additions and 21 deletions
|
|
@ -411,26 +411,28 @@ enum Corner {
|
|||
eCornerTopLeft = 0,
|
||||
eCornerTopRight = 1,
|
||||
eCornerBottomRight = 2,
|
||||
eCornerBottomLeft = 3,
|
||||
eNumCorners = 4
|
||||
eCornerBottomLeft = 3
|
||||
};
|
||||
|
||||
#define NS_CORNER_TOP_LEFT mozilla::eCornerTopLeft
|
||||
#define NS_CORNER_TOP_RIGHT mozilla::eCornerTopRight
|
||||
#define NS_CORNER_BOTTOM_RIGHT mozilla::eCornerBottomRight
|
||||
#define NS_CORNER_BOTTOM_LEFT mozilla::eCornerBottomLeft
|
||||
#define NS_NUM_CORNERS mozilla::eNumCorners
|
||||
|
||||
#define NS_FOR_CSS_CORNERS(var_) \
|
||||
for (mozilla::Corner var_ = NS_CORNER_TOP_LEFT; \
|
||||
var_ <= NS_CORNER_BOTTOM_LEFT; \
|
||||
var_++)
|
||||
// Creates a for loop that walks over the four mozilla::Corner values. This
|
||||
// implementation uses the same technique as NS_FOR_CSS_SIDES.
|
||||
#define NS_FOR_CSS_FULL_CORNERS(var_) \
|
||||
int32_t MOZ_CONCAT(var_,__LINE__) = mozilla::eCornerTopLeft; \
|
||||
for (mozilla::Corner var_; \
|
||||
MOZ_CONCAT(var_,__LINE__) <= mozilla::eCornerBottomLeft && \
|
||||
(var_ = mozilla::Corner(MOZ_CONCAT(var_,__LINE__)), true); \
|
||||
++MOZ_CONCAT(var_,__LINE__))
|
||||
|
||||
static inline mozilla::Corner operator++(mozilla::Corner& corner, int) {
|
||||
MOZ_ASSERT(corner >= NS_CORNER_TOP_LEFT &&
|
||||
corner < NS_NUM_CORNERS, "Out of range corner");
|
||||
corner = mozilla::Corner(corner + 1);
|
||||
return corner;
|
||||
static inline mozilla::Corner operator++(mozilla::Corner& aCorner) {
|
||||
MOZ_ASSERT(aCorner >= eCornerTopLeft && aCorner <= eCornerBottomLeft,
|
||||
"Out of range corner!");
|
||||
aCorner = mozilla::Corner(aCorner + 1);
|
||||
return aCorner;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -51,9 +51,6 @@ struct gfxRect :
|
|||
case NS_CORNER_TOP_RIGHT: return TopRight();
|
||||
case NS_CORNER_BOTTOM_RIGHT: return BottomRight();
|
||||
case NS_CORNER_BOTTOM_LEFT: return BottomLeft();
|
||||
default:
|
||||
NS_ERROR("Invalid corner!");
|
||||
break;
|
||||
}
|
||||
return gfxPoint(0.0, 0.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3385,7 +3385,7 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
* a 1.0 unit border all around and no border radius.
|
||||
*/
|
||||
|
||||
NS_FOR_CSS_CORNERS(corner) {
|
||||
NS_FOR_CSS_FULL_CORNERS(corner) {
|
||||
const mozilla::Side sides[2] = { mozilla::Side(corner), PREV_SIDE(corner) };
|
||||
|
||||
if (!IsZeroSize(mBorderRadii[corner]))
|
||||
|
|
@ -3400,7 +3400,7 @@ nsCSSBorderRenderer::DrawBorders()
|
|||
}
|
||||
|
||||
// First, the corners
|
||||
NS_FOR_CSS_CORNERS(corner) {
|
||||
NS_FOR_CSS_FULL_CORNERS(corner) {
|
||||
// if there's no corner, don't do all this work for it
|
||||
if (IsZeroSize(mBorderCornerDimensions[corner]))
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
#define NS_FOR_CSS_FULL_CORNERS(var_) for (int32_t var_ = 0; var_ < 4; ++var_)
|
||||
|
||||
// Indices into "half corner" arrays (nsStyleCorners e.g.)
|
||||
#define NS_CORNER_TOP_LEFT_X 0
|
||||
#define NS_CORNER_TOP_LEFT_Y 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue