Index: Source/platform/geometry/FloatBoxExtent.h |
diff --git a/Source/platform/geometry/IntRectExtent.h b/Source/platform/geometry/FloatBoxExtent.h |
similarity index 60% |
copy from Source/platform/geometry/IntRectExtent.h |
copy to Source/platform/geometry/FloatBoxExtent.h |
index 76961d19de2ac982660abf72da2fbb35ebb7cdde..309a80e88abf0da8a1ec8e7bd26b814a6f289702 100644 |
--- a/Source/platform/geometry/IntRectExtent.h |
+++ b/Source/platform/geometry/FloatBoxExtent.h |
@@ -27,16 +27,16 @@ |
* SUCH DAMAGE. |
*/ |
-#ifndef IntRectExtent_h |
-#define IntRectExtent_h |
+#ifndef FloatBoxExtent_h |
+#define FloatBoxExtent_h |
-#include "platform/geometry/LayoutRect.h" |
+#include "platform/geometry/FloatRect.h" |
namespace WebCore { |
-class IntRectExtent { |
+class FloatBoxExtent { |
public: |
- IntRectExtent() |
+ FloatBoxExtent() |
: m_top(0) |
, m_right(0) |
, m_bottom(0) |
@@ -44,7 +44,7 @@ public: |
{ |
} |
- IntRectExtent(int top, int right, int bottom, int left) |
+ FloatBoxExtent(float top, float right, float bottom, float left) |
: m_top(top) |
, m_right(right) |
, m_bottom(bottom) |
@@ -52,21 +52,21 @@ public: |
{ |
} |
- int top() const { return m_top; } |
- void setTop(int top) { m_top = top; } |
+ float top() const { return m_top; } |
+ void setTop(float top) { m_top = top; } |
- int right() const { return m_right; } |
- void setRight(int right) { m_right = right; } |
+ float right() const { return m_right; } |
+ void setRight(float right) { m_right = right; } |
- int bottom() const { return m_bottom; } |
- void setBottom(int bottom) { m_bottom = bottom; } |
+ float bottom() const { return m_bottom; } |
+ void setBottom(float bottom) { m_bottom = bottom; } |
- int left() const { return m_left; } |
- void setLeft(int left) { m_left = left; } |
+ float left() const { return m_left; } |
+ void setLeft(float left) { m_left = left; } |
bool isZero() const { return !left() && !right() && !top() && !bottom(); } |
- void expandRect(LayoutRect& rect) const |
+ void expandRect(FloatRect& rect) const |
{ |
if (isZero()) |
return; |
@@ -75,14 +75,30 @@ public: |
rect.expand(left() + right(), top() + bottom()); |
} |
+ void unite(const FloatBoxExtent& other) |
+ { |
+ m_top = std::min(m_top, other.top()); |
+ m_right = std::max(m_right, other.right()); |
+ m_bottom = std::max(m_bottom, other.bottom()); |
+ m_left = std::min(m_left, other.left()); |
+ } |
+ |
+ void unite(const FloatRect& rect) |
+ { |
+ m_top = std::min(m_top, rect.y()); |
+ m_right = std::max(m_right, rect.maxX()); |
+ m_bottom = std::max(m_bottom, rect.maxY()); |
+ m_left = std::min(m_left, rect.x()); |
+ } |
+ |
private: |
- int m_top; |
- int m_right; |
- int m_bottom; |
- int m_left; |
+ float m_top; |
+ float m_right; |
+ float m_bottom; |
+ float m_left; |
}; |
-inline bool operator==(const IntRectExtent& a, const IntRectExtent& b) |
+inline bool operator==(const FloatBoxExtent& a, const FloatBoxExtent& b) |
{ |
return a.top() == b.top() |
&& a.right() == b.right() |
@@ -90,12 +106,12 @@ inline bool operator==(const IntRectExtent& a, const IntRectExtent& b) |
&& a.left() == b.left(); |
} |
-inline bool operator!=(const IntRectExtent& a, const IntRectExtent& b) |
+inline bool operator!=(const FloatBoxExtent& a, const FloatBoxExtent& b) |
{ |
return !(a == b); |
} |
-inline void operator+=(IntRectExtent& a, const IntRectExtent& b) |
+inline void operator+=(FloatBoxExtent& a, const FloatBoxExtent& b) |
{ |
a.setTop(a.top() + b.top()); |
a.setRight(a.right() + b.right()); |
@@ -106,4 +122,4 @@ inline void operator+=(IntRectExtent& a, const IntRectExtent& b) |
} // namespace WebCore |
-#endif // IntRectExtent_h |
+#endif // FloatBoxExtent_h |