Bug 1320014 Part 1 - Move Corner's definition and NS_FOR_CSS_CORNERS to gfx/2d/Types.h. draft
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 04 Jan 2017 16:19:20 +0800
changeset 456790 323ba7a06d7b3ea3ecf45bac044c9b03f7b28ac1
parent 456716 a14094edbad78fc1d16e8d4c57902537cf286fd1
child 456791 61868358194eadaac00480e07ec97b7dfb506d05
push id40602
push userbmo:tlin@mozilla.com
push dateFri, 06 Jan 2017 07:30:30 +0000
bugs1320014
milestone53.0a1
Bug 1320014 Part 1 - Move Corner's definition and NS_FOR_CSS_CORNERS to gfx/2d/Types.h. The only change is that NS_PRECONDITION is replaced by MOZ_ASSERT to prevent Types.h depends on nsDebug.h. MozReview-Commit-ID: FI6LGOedKQ9
gfx/2d/Types.h
gfx/thebes/gfxRect.h
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -411,11 +411,40 @@ enum SideBits {
 
 static inline Side& operator++(Side& side) {
   MOZ_ASSERT(side >= eSideTop && side <= eSideLeft,
              "Out of range side");
   side = Side(side + 1);
   return side;
 }
 
+namespace css {
+enum Corner {
+  // This order is important!
+  eCornerTopLeft = 0,
+  eCornerTopRight = 1,
+  eCornerBottomRight = 2,
+  eCornerBottomLeft = 3,
+  eNumCorners = 4
+};
+} // namespace css
+
+#define NS_CORNER_TOP_LEFT mozilla::css::eCornerTopLeft
+#define NS_CORNER_TOP_RIGHT mozilla::css::eCornerTopRight
+#define NS_CORNER_BOTTOM_RIGHT mozilla::css::eCornerBottomRight
+#define NS_CORNER_BOTTOM_LEFT mozilla::css::eCornerBottomLeft
+#define NS_NUM_CORNERS mozilla::css::eNumCorners
+
+#define NS_FOR_CSS_CORNERS(var_)                       \
+  for (mozilla::css::Corner var_ = NS_CORNER_TOP_LEFT; \
+       var_ <= NS_CORNER_BOTTOM_LEFT;                  \
+       var_++)
+
+static inline mozilla::css::Corner operator++(mozilla::css::Corner& corner, int) {
+  MOZ_ASSERT(corner >= NS_CORNER_TOP_LEFT &&
+             corner < NS_NUM_CORNERS, "Out of range corner");
+  corner = mozilla::css::Corner(corner + 1);
+  return corner;
+}
+
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_TYPES_H_ */
--- a/gfx/thebes/gfxRect.h
+++ b/gfx/thebes/gfxRect.h
@@ -22,46 +22,16 @@ struct gfxMargin : public mozilla::gfx::
 
   // Constructors
   gfxMargin() : Super() {}
   gfxMargin(const gfxMargin& aMargin) : Super(aMargin) {}
   gfxMargin(gfxFloat aTop, gfxFloat aRight, gfxFloat aBottom, gfxFloat aLeft)
     : Super(aTop, aRight, aBottom, aLeft) {}
 };
 
-namespace mozilla {
-    namespace css {
-        enum Corner {
-            // this order is important!
-            eCornerTopLeft = 0,
-            eCornerTopRight = 1,
-            eCornerBottomRight = 2,
-            eCornerBottomLeft = 3,
-            eNumCorners = 4
-        };
-    } // namespace css
-} // namespace mozilla
-#define NS_CORNER_TOP_LEFT mozilla::css::eCornerTopLeft
-#define NS_CORNER_TOP_RIGHT mozilla::css::eCornerTopRight
-#define NS_CORNER_BOTTOM_RIGHT mozilla::css::eCornerBottomRight
-#define NS_CORNER_BOTTOM_LEFT mozilla::css::eCornerBottomLeft
-#define NS_NUM_CORNERS mozilla::css::eNumCorners
-
-#define NS_FOR_CSS_CORNERS(var_)                         \
-    for (mozilla::css::Corner var_ = NS_CORNER_TOP_LEFT; \
-         var_ <= NS_CORNER_BOTTOM_LEFT;                  \
-         var_++)
-
-static inline mozilla::css::Corner operator++(mozilla::css::Corner& corner, int) {
-    NS_PRECONDITION(corner >= NS_CORNER_TOP_LEFT &&
-                    corner < NS_NUM_CORNERS, "Out of range corner");
-    corner = mozilla::css::Corner(corner + 1);
-    return corner;
-}
-
 struct gfxRect :
     public mozilla::gfx::BaseRect<gfxFloat, gfxRect, gfxPoint, gfxSize, gfxMargin> {
     typedef mozilla::gfx::BaseRect<gfxFloat, gfxRect, gfxPoint, gfxSize, gfxMargin> Super;
 
     gfxRect() : Super() {}
     gfxRect(const gfxPoint& aPos, const gfxSize& aSize) :
         Super(aPos, aSize) {}
     gfxRect(gfxFloat aX, gfxFloat aY, gfxFloat aWidth, gfxFloat aHeight) :