Bug 670111 - Add double overloads to NSToCoord(Round|Floor|Ceil|Clamped) to stop numerous build warnings; r=roc
authorEd Morley <bmo@edmorley.co.uk>
Mon, 11 Jul 2011 09:14:12 -0400
changeset 73420 e2139ab441810adbcd96ce5fa125fe0cf6073191
parent 73419 ed3036facfb2e2fdf489c4fa5daec134ef6c21c1
child 73421 a02ef4cdf6b232895c4c334a1535ef8f77ec9586
push id235
push userbzbarsky@mozilla.com
push dateTue, 27 Sep 2011 17:13:04 +0000
treeherdermozilla-beta@2d1e082d176a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs670111
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 670111 - Add double overloads to NSToCoord(Round|Floor|Ceil|Clamped) to stop numerous build warnings; r=roc
gfx/src/nsCoord.h
--- a/gfx/src/nsCoord.h
+++ b/gfx/src/nsCoord.h
@@ -93,16 +93,25 @@ inline nscoord NSToCoordRound(float aVal
 {
 #if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__)
   return NS_lroundup30(aValue);
 #else
   return nscoord(NS_floorf(aValue + 0.5f));
 #endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */
 }
 
+inline nscoord NSToCoordRound(double aValue)
+{
+#if defined(XP_WIN32) && defined(_M_IX86) && !defined(__GNUC__)
+  return NS_lroundup30((float)aValue);
+#else
+  return nscoord(NS_floor(aValue + 0.5f));
+#endif /* XP_WIN32 && _M_IX86 && !__GNUC__ */
+}
+
 inline nscoord NSToCoordRoundWithClamp(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
   NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
                    "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
     return nscoord_MAX;
@@ -349,16 +358,21 @@ inline float NSCoordToFloat(nscoord aCoo
 /*
  * Coord Rounding Functions
  */
 inline nscoord NSToCoordFloor(float aValue)
 {
   return nscoord(NS_floorf(aValue));
 }
 
+inline nscoord NSToCoordFloor(double aValue)
+{
+  return nscoord(NS_floor(aValue));
+}
+
 inline nscoord NSToCoordFloorClamped(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
   NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
                    "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
     return nscoord_MAX;
@@ -372,16 +386,21 @@ inline nscoord NSToCoordFloorClamped(flo
   return NSToCoordFloor(aValue);
 }
 
 inline nscoord NSToCoordCeil(float aValue)
 {
   return nscoord(NS_ceilf(aValue));
 }
 
+inline nscoord NSToCoordCeil(double aValue)
+{
+  return nscoord(NS_ceil(aValue));
+}
+
 inline nscoord NSToCoordCeilClamped(float aValue)
 {
 #ifndef NS_COORD_IS_FLOAT
   // Bounds-check before converting out of float, to avoid overflow
   NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
                    "Overflowed nscoord_MAX in conversion to nscoord");
   if (aValue >= nscoord_MAX) {
     return nscoord_MAX;
@@ -390,16 +409,34 @@ inline nscoord NSToCoordCeilClamped(floa
                    "Overflowed nscoord_MIN in conversion to nscoord");
   if (aValue <= nscoord_MIN) {
     return nscoord_MIN;
   }
 #endif
   return NSToCoordCeil(aValue);
 }
 
+inline nscoord NSToCoordCeilClamped(double aValue)
+{
+#ifndef NS_COORD_IS_FLOAT
+  // Bounds-check before converting out of double, to avoid overflow
+  NS_WARN_IF_FALSE(aValue <= nscoord_MAX,
+                   "Overflowed nscoord_MAX in conversion to nscoord");
+  if (aValue >= nscoord_MAX) {
+    return nscoord_MAX;
+  }
+  NS_WARN_IF_FALSE(aValue >= nscoord_MIN,
+                   "Overflowed nscoord_MIN in conversion to nscoord");
+  if (aValue <= nscoord_MIN) {
+    return nscoord_MIN;
+  }
+#endif
+  return NSToCoordCeil(aValue);
+}
+
 /*
  * Int Rounding Functions
  */
 inline PRInt32 NSToIntFloor(float aValue)
 {
   return PRInt32(NS_floorf(aValue));
 }