Title: [87103] trunk/Source
Revision
87103
Author
[email protected]
Date
2011-05-23 15:33:39 -0700 (Mon, 23 May 2011)

Log Message

2011-05-23  Matthew Delaney  <[email protected]>

        Reviewed by Simon Fraser.

        Remove safeFloatToInt() in FloatRect.cpp and replace with working version of clampToInteger()
        https://bugs.webkit.org/show_bug.cgi?id=58216

        * wtf/MathExtras.h:
        (clampToInteger):
        (clampToPositiveInteger):
2011-05-23  Matthew Delaney  <[email protected]>

        Reviewed by Simon Fraser.

        Remove safeFloatToInt() in FloatRect.cpp and replace with working version of clampToInteger()
        https://bugs.webkit.org/show_bug.cgi?id=58216

        No new tests. The SVG tests mask-excessive-malloc.svg and pattern-excessive-malloc.svg exercise this code path.

        * platform/graphics/FloatRect.cpp:
        (WebCore::enclosingIntRect):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (87102 => 87103)


--- trunk/Source/_javascript_Core/ChangeLog	2011-05-23 22:22:27 UTC (rev 87102)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-05-23 22:33:39 UTC (rev 87103)
@@ -1,3 +1,14 @@
+2011-05-23  Matthew Delaney  <[email protected]>
+
+        Reviewed by Simon Fraser.
+
+        Remove safeFloatToInt() in FloatRect.cpp and replace with working version of clampToInteger()
+        https://bugs.webkit.org/show_bug.cgi?id=58216
+
+        * wtf/MathExtras.h:
+        (clampToInteger):
+        (clampToPositiveInteger):
+
 2011-05-23  Ruben  <[email protected]>
 
         Reviewed by Tony Chang.

Modified: trunk/Source/_javascript_Core/wtf/MathExtras.h (87102 => 87103)


--- trunk/Source/_javascript_Core/wtf/MathExtras.h	2011-05-23 22:22:27 UTC (rev 87102)
+++ trunk/Source/_javascript_Core/wtf/MathExtras.h	2011-05-23 22:33:39 UTC (rev 87103)
@@ -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: trunk/Source/WebCore/ChangeLog (87102 => 87103)


--- trunk/Source/WebCore/ChangeLog	2011-05-23 22:22:27 UTC (rev 87102)
+++ trunk/Source/WebCore/ChangeLog	2011-05-23 22:33:39 UTC (rev 87103)
@@ -1,3 +1,15 @@
+2011-05-23  Matthew Delaney  <[email protected]>
+
+        Reviewed by Simon Fraser.
+
+        Remove safeFloatToInt() in FloatRect.cpp and replace with working version of clampToInteger()
+        https://bugs.webkit.org/show_bug.cgi?id=58216
+
+        No new tests. The SVG tests mask-excessive-malloc.svg and pattern-excessive-malloc.svg exercise this code path.
+
+        * platform/graphics/FloatRect.cpp:
+        (WebCore::enclosingIntRect):
+
 2011-05-20  Jeremy Noble  <[email protected]>
 
         Reviewed by Darin Adler.

Modified: trunk/Source/WebCore/platform/graphics/FloatRect.cpp (87102 => 87103)


--- trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2011-05-23 22:22:27 UTC (rev 87102)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.cpp	2011-05-23 22:33:39 UTC (rev 87103)
@@ -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