1/* 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following 13 * disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#ifndef IntRectExtent_h 31#define IntRectExtent_h 32 33#if ENABLE(CSS_FILTERS) 34 35#include "LayoutRect.h" 36 37namespace WebCore { 38 39class IntRectExtent { 40public: 41 IntRectExtent() 42 : m_top(0) 43 , m_right(0) 44 , m_bottom(0) 45 , m_left(0) 46 { 47 } 48 49 IntRectExtent(int top, int right, int bottom, int left) 50 : m_top(top) 51 , m_right(right) 52 , m_bottom(bottom) 53 , m_left(left) 54 { 55 } 56 57 int top() const { return m_top; } 58 void setTop(int top) { m_top = top; } 59 60 int right() const { return m_right; } 61 void setRight(int right) { m_right = right; } 62 63 int bottom() const { return m_bottom; } 64 void setBottom(int bottom) { m_bottom = bottom; } 65 66 int left() const { return m_left; } 67 void setLeft(int left) { m_left = left; } 68 69 void expandRect(LayoutRect& rect) const 70 { 71 if (isZero()) 72 return; 73 74 rect.move(-left(), -top()); 75 rect.expand(left() + right(), top() + bottom()); 76 } 77 78private: 79 bool isZero() const { return !left() && !right() && !top() && !bottom(); } 80 81 int m_top; 82 int m_right; 83 int m_bottom; 84 int m_left; 85}; 86 87inline bool operator==(const IntRectExtent& a, const IntRectExtent& b) 88{ 89 return a.top() == b.top() 90 && a.right() == b.right() 91 && a.bottom() == b.bottom() 92 && a.left() == b.left(); 93} 94 95inline bool operator!=(const IntRectExtent& a, const IntRectExtent& b) 96{ 97 return !(a == b); 98} 99 100inline void operator+=(IntRectExtent& a, const IntRectExtent& b) 101{ 102 a.setTop(a.top() + b.top()); 103 a.setRight(a.right() + b.right()); 104 a.setBottom(a.bottom() + b.bottom()); 105 a.setLeft(a.left() + b.left()); 106} 107 108} // namespace WebCore 109 110#endif // ENABLE(CSS_FILTERS) 111 112#endif // IntRectExtent_h 113