Bug 1317588 Part 1 - Move NS_FOR_CSS_SIDES and operator++ to gfx/2d/Types.h. r=mats
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 18 Nov 2016 15:25:33 +0800
changeset 324061 aceab4673889e2575c25bb5910a9784b2a8e1d1d
parent 324060 d9b26b438895944ea6764976577436383de9e23d
child 324062 60506dc6f798fde3715897564930ce5b2dcf5ed8
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmats
bugs1317588
milestone53.0a1
Bug 1317588 Part 1 - Move NS_FOR_CSS_SIDES and operator++ to gfx/2d/Types.h. r=mats Make them live with the definition of enum Side. MozReview-Commit-ID: 5uJPxFPOj79
gfx/2d/Types.h
layout/style/nsStyleConsts.h
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -2,16 +2,18 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_TYPES_H_
 #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>
 
 namespace mozilla {
 namespace gfx {
 
 typedef float Float;
@@ -392,16 +394,38 @@ enum SideBits {
   eSideBitsRight  = 1 << eSideRight,
   eSideBitsBottom = 1 << eSideBottom,
   eSideBitsLeft   = 1 << eSideLeft,
   eSideBitsTopBottom = eSideBitsTop  | eSideBitsBottom,
   eSideBitsLeftRight = eSideBitsLeft | eSideBitsRight,
   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_ */
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -5,43 +5,21 @@
 
 /* constants used in the style struct data provided by nsStyleContext */
 
 #ifndef nsStyleConsts_h___
 #define nsStyleConsts_h___
 
 #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_)
 
 // Indices into "half corner" arrays (nsStyleCorners e.g.)
 #define NS_CORNER_TOP_LEFT_X      0
 #define NS_CORNER_TOP_LEFT_Y      1
 #define NS_CORNER_TOP_RIGHT_X     2
 #define NS_CORNER_TOP_RIGHT_Y     3