| 1 | /* |
| 2 | Copyright (C) 2005, 2006 Apple Inc. All rights reserved. |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Library General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Library General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Library General Public License |
| 15 | along with this library; see the file COPYING.LIB. If not, write to |
| 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | Boston, MA 02110-1301, USA. |
| 18 | |
| 19 | |
| 20 | Some useful definitions needed for laying out elements |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include "LayoutRect.h" |
| 26 | |
| 27 | namespace WebCore { |
| 28 | |
| 29 | struct GapRects { |
| 30 | const LayoutRect& left() const { return m_left; } |
| 31 | const LayoutRect& center() const { return m_center; } |
| 32 | const LayoutRect& right() const { return m_right; } |
| 33 | |
| 34 | void uniteLeft(const LayoutRect& r) { m_left.unite(r); } |
| 35 | void uniteCenter(const LayoutRect& r) { m_center.unite(r); } |
| 36 | void uniteRight(const LayoutRect& r) { m_right.unite(r); } |
| 37 | void unite(const GapRects& o) { uniteLeft(o.left()); uniteCenter(o.center()); uniteRight(o.right()); } |
| 38 | |
| 39 | operator LayoutRect() const |
| 40 | { |
| 41 | LayoutRect result = m_left; |
| 42 | result.unite(m_center); |
| 43 | result.unite(m_right); |
| 44 | return result; |
| 45 | } |
| 46 | |
| 47 | bool operator==(const GapRects& other) |
| 48 | { |
| 49 | return m_left == other.left() && m_center == other.center() && m_right == other.right(); |
| 50 | } |
| 51 | bool operator!=(const GapRects& other) { return !(*this == other); } |
| 52 | |
| 53 | private: |
| 54 | LayoutRect m_left; |
| 55 | LayoutRect m_center; |
| 56 | LayoutRect m_right; |
| 57 | }; |
| 58 | |
| 59 | } // namespace WebCore |
| 60 | |