#pragma once
namespace WebCore {
class IntRectExtent {
public:
IntRectExtent() = default;
IntRectExtent(int top, int right, int bottom, int left)
: m_top(top)
, m_right(right)
, m_bottom(bottom)
, m_left(left)
{
}
int top() const { return m_top; }
void setTop(int top) { m_top = top; }
int right() const { return m_right; }
void setRight(int right) { m_right = right; }
int bottom() const { return m_bottom; }
void setBottom(int bottom) { m_bottom = bottom; }
int left() const { return m_left; }
void setLeft(int left) { m_left = left; }
bool isZero() const { return !left() && !right() && !top() && !bottom(); }
private:
int m_top { 0 };
int m_right { 0 };
int m_bottom { 0 };
int m_left { 0 };
};
inline bool operator==(const IntRectExtent& a, const IntRectExtent& b)
{
return a.top() == b.top() && a.right() == b.right() && a.bottom() == b.bottom() && a.left() == b.left();
}
inline bool operator!=(const IntRectExtent& a, const IntRectExtent& b)
{
return !(a == b);
}
template<typename RectType>
inline RectType& operator+=(RectType& rect, const IntRectExtent& extent)
{
rect.move(-extent.left(), -extent.top());
rect.expand(extent.left() + extent.right(), extent.top() + extent.bottom());
return rect;
}
inline IntRectExtent& operator+=(IntRectExtent& a, const IntRectExtent& b)
{
a.setTop(a.top() + b.top());
a.setRight(a.right() + b.right());
a.setBottom(a.bottom() + b.bottom());
a.setLeft(a.left() + b.left());
return a;
}
using IntOutsets = IntRectExtent;
}