diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/graphics/FloatRect.cpp | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/graphics/FloatRect.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/FloatRect.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/FloatRect.cpp b/Source/WebCore/platform/graphics/FloatRect.cpp index 36f3d3a..165ef76 100644 --- a/Source/WebCore/platform/graphics/FloatRect.cpp +++ b/Source/WebCore/platform/graphics/FloatRect.cpp @@ -30,8 +30,8 @@ #include "FloatConversion.h" #include "IntRect.h" #include <algorithm> -#include <limits> #include <math.h> +#include <wtf/MathExtras.h> using std::max; using std::min; @@ -97,6 +97,24 @@ void FloatRect::unite(const FloatRect& other) setLocationAndSizeFromEdges(l, t, r, b); } +void FloatRect::uniteIfNonZero(const FloatRect& other) +{ + // Handle empty special cases first. + if (!other.width() && !other.height()) + return; + if (!width() && !height()) { + *this = other; + return; + } + + float left = min(x(), other.x()); + float top = min(y(), other.y()); + float right = max(maxX(), other.maxX()); + float bottom = max(maxY(), other.maxY()); + + setLocationAndSizeFromEdges(left, top, right, bottom); +} + void FloatRect::scale(float sx, float sy) { m_location.setX(x() * sx); @@ -182,6 +200,7 @@ IntRect enclosingIntRect(const FloatRect& rect) float top = floorf(rect.y()); float width = ceilf(rect.maxX()) - left; float height = ceilf(rect.maxY()) - top; + return IntRect(safeFloatToInt(left), safeFloatToInt(top), safeFloatToInt(width), safeFloatToInt(height)); } |