From 5fdbf7170f9b2dcac3088461ef75fae39d6c364b Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 23 May 2011 22:33:39 +0000 Subject: 2011-05-23 Matthew Delaney 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 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87103 268f45cc-cd09-0410-ab3c-d52691b4dbfc Signed-off-by: Alexis Menard --- .../webkit/Source/JavaScriptCore/ChangeLog | 11 ++++++++++ .../webkit/Source/JavaScriptCore/wtf/MathExtras.h | 24 +++++++++++++++------- src/3rdparty/webkit/Source/WebCore/ChangeLog | 12 +++++++++++ .../Source/WebCore/platform/graphics/FloatRect.cpp | 16 ++------------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/Source/JavaScriptCore/ChangeLog index 4ad4131..ae7ef60 100644 --- a/src/3rdparty/webkit/Source/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,14 @@ +2011-05-23 Matthew Delaney + + 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-06-20 Oliver Hunt Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h index fac187c..f1b13a5 100644 --- a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h +++ b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/MathExtras.h @@ -220,17 +220,27 @@ inline int clampToPositiveInteger(double d) return static_cast(std::max(std::min(d, maxIntAsDouble), 0)); } -inline int clampToInteger(float d) +inline int clampToInteger(float x) { - const float minIntAsFloat = static_cast(std::numeric_limits::min()); - const float maxIntAsFloat = static_cast(std::numeric_limits::max()); - return static_cast(std::max(std::min(d, maxIntAsFloat), minIntAsFloat)); + static const int s_intMax = std::numeric_limits::max(); + static const int s_intMin = std::numeric_limits::min(); + + if (x >= static_cast(s_intMax)) + return s_intMax; + if (x < static_cast(s_intMin)) + return s_intMin; + return static_cast(x); } -inline int clampToPositiveInteger(float d) +inline int clampToPositiveInteger(float x) { - const float maxIntAsFloat = static_cast(std::numeric_limits::max()); - return static_cast(std::max(std::min(d, maxIntAsFloat), 0)); + static const int s_intMax = std::numeric_limits::max(); + + if (x >= static_cast(s_intMax)) + return s_intMax; + if (x < 0) + return 0; + return static_cast(x); } inline int clampToInteger(unsigned value) diff --git a/src/3rdparty/webkit/Source/WebCore/ChangeLog b/src/3rdparty/webkit/Source/WebCore/ChangeLog index 86a1d8c..ea77d39 100644 --- a/src/3rdparty/webkit/Source/WebCore/ChangeLog +++ b/src/3rdparty/webkit/Source/WebCore/ChangeLog @@ -1,3 +1,15 @@ +2011-05-23 Matthew Delaney + + 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-06-27 Joe Wild Reviewed by Simon Fraser. diff --git a/src/3rdparty/webkit/Source/WebCore/platform/graphics/FloatRect.cpp b/src/3rdparty/webkit/Source/WebCore/platform/graphics/FloatRect.cpp index 165ef76..7afc92b 100644 --- a/src/3rdparty/webkit/Source/WebCore/platform/graphics/FloatRect.cpp +++ b/src/3rdparty/webkit/Source/WebCore/platform/graphics/FloatRect.cpp @@ -182,18 +182,6 @@ void FloatRect::fitToPoints(const FloatPoint& p0, const FloatPoint& p1, const Fl setLocationAndSizeFromEdges(left, top, right, bottom); } -static inline int safeFloatToInt(float x) -{ - static const int s_intMax = std::numeric_limits::max(); - static const int s_intMin = std::numeric_limits::min(); - - if (x >= static_cast(s_intMax)) - return s_intMax; - if (x < static_cast(s_intMin)) - return s_intMin; - return static_cast(x); -} - IntRect enclosingIntRect(const FloatRect& rect) { float left = floorf(rect.x()); @@ -201,8 +189,8 @@ IntRect enclosingIntRect(const FloatRect& rect) 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) -- cgit v0.12