Title: [88845] branches/chromium/742/Source
Revision
88845
Author
[email protected]
Date
2011-06-14 13:09:49 -0700 (Tue, 14 Jun 2011)

Log Message

Merge 87103
BUG=83270
Review URL: http://codereview.chromium.org/7155005

Modified Paths

Diff

Modified: branches/chromium/742/Source/_javascript_Core/wtf/MathExtras.h (88844 => 88845)


--- branches/chromium/742/Source/_javascript_Core/wtf/MathExtras.h	2011-06-14 20:01:19 UTC (rev 88844)
+++ branches/chromium/742/Source/_javascript_Core/wtf/MathExtras.h	2011-06-14 20:09:49 UTC (rev 88845)
@@ -220,17 +220,27 @@
     return static_cast<int>(std::max<double>(std::min(d, maxIntAsDouble), 0));
 }
 
-inline int clampToInteger(float d)
+inline int clampToInteger(float x)
 {
-    const float minIntAsFloat = static_cast<float>(std::numeric_limits<int>::min());
-    const float maxIntAsFloat = static_cast<float>(std::numeric_limits<int>::max());
-    return static_cast<int>(std::max(std::min(d, maxIntAsFloat), minIntAsFloat));
+    static const int s_intMax = std::numeric_limits<int>::max();
+    static const int s_intMin = std::numeric_limits<int>::min();
+    
+    if (x >= static_cast<float>(s_intMax))
+        return s_intMax;
+    if (x < static_cast<float>(s_intMin))
+        return s_intMin;
+    return static_cast<int>(x);
 }
 
-inline int clampToPositiveInteger(float d)
+inline int clampToPositiveInteger(float x)
 {
-    const float maxIntAsFloat = static_cast<float>(std::numeric_limits<int>::max());
-    return static_cast<int>(std::max<float>(std::min(d, maxIntAsFloat), 0));
+    static const int s_intMax = std::numeric_limits<int>::max();
+    
+    if (x >= static_cast<float>(s_intMax))
+        return s_intMax;
+    if (x < 0)
+        return 0;
+    return static_cast<int>(x);
 }
 
 inline int clampToInteger(unsigned value)

Modified: branches/chromium/742/Source/WebCore/platform/graphics/FloatRect.cpp (88844 => 88845)


--- branches/chromium/742/Source/WebCore/platform/graphics/FloatRect.cpp	2011-06-14 20:01:19 UTC (rev 88844)
+++ branches/chromium/742/Source/WebCore/platform/graphics/FloatRect.cpp	2011-06-14 20:09:49 UTC (rev 88845)
@@ -182,18 +182,6 @@
     setLocationAndSizeFromEdges(left, top, right, bottom);
 }
 
-static inline int safeFloatToInt(float x)
-{
-    static const int s_intMax = std::numeric_limits<int>::max();
-    static const int s_intMin = std::numeric_limits<int>::min();
-
-    if (x >= static_cast<float>(s_intMax))
-        return s_intMax;
-    if (x < static_cast<float>(s_intMin))
-        return s_intMin;
-    return static_cast<int>(x);
-}
-
 IntRect enclosingIntRect(const FloatRect& rect)
 {
     float left = floorf(rect.x());
@@ -201,8 +189,8 @@
     float width = ceilf(rect.maxX()) - left;
     float height = ceilf(rect.maxY()) - top;
     
-    return IntRect(safeFloatToInt(left), safeFloatToInt(top), 
-                   safeFloatToInt(width), safeFloatToInt(height));
+    return IntRect(clampToInteger(left), clampToInteger(top), 
+                   clampToInteger(width), clampToInteger(height));
 }
 
 FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to