2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "LayoutTypes.h"
40 Radii(const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight)
42 , m_topRight(topRight)
43 , m_bottomLeft(bottomLeft)
44 , m_bottomRight(bottomRight)
48 void setTopLeft(const LayoutSize& size) { m_topLeft = size; }
49 void setTopRight(const LayoutSize& size) { m_topRight = size; }
50 void setBottomLeft(const LayoutSize& size) { m_bottomLeft = size; }
51 void setBottomRight(const LayoutSize& size) { m_bottomRight = size; }
52 const LayoutSize& topLeft() const { return m_topLeft; }
53 const LayoutSize& topRight() const { return m_topRight; }
54 const LayoutSize& bottomLeft() const { return m_bottomLeft; }
55 const LayoutSize& bottomRight() const { return m_bottomRight; }
59 void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
60 void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
62 void scale(float factor);
63 void expand(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth);
64 void expand(LayoutUnit size) { expand(size, size, size, size); }
65 void shrink(LayoutUnit topWidth, LayoutUnit bottomWidth, LayoutUnit leftWidth, LayoutUnit rightWidth) { expand(-topWidth, -bottomWidth, -leftWidth, -rightWidth); }
66 void shrink(LayoutUnit size) { shrink(size, size, size, size); }
70 LayoutSize m_topRight;
71 LayoutSize m_bottomLeft;
72 LayoutSize m_bottomRight;
75 explicit RoundedRect(const LayoutRect&, const Radii& = Radii());
76 RoundedRect(LayoutUnit x, LayoutUnit y, LayoutUnit width, LayoutUnit height);
77 RoundedRect(const LayoutRect&, const LayoutSize& topLeft, const LayoutSize& topRight, const LayoutSize& bottomLeft, const LayoutSize& bottomRight);
79 const LayoutRect& rect() const { return m_rect; }
80 const Radii& radii() const { return m_radii; }
81 bool isRounded() const { return !m_radii.isZero(); }
82 bool isEmpty() const { return m_rect.isEmpty(); }
84 void setRect(const LayoutRect& rect) { m_rect = rect; }
85 void setRadii(const Radii& radii) { m_radii = radii; }
87 void move(const LayoutSize& size) { m_rect.move(size); }
88 void inflate(LayoutUnit size) { m_rect.inflate(size); }
89 void inflateWithRadii(LayoutUnit size);
90 void expandRadii(LayoutUnit size) { m_radii.expand(size); }
91 void shrinkRadii(LayoutUnit size) { m_radii.shrink(size); }
93 void includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
94 void excludeLogicalEdges(bool isHorizontal, bool excludeLogicalLeftEdge, bool excludeLogicalRightEdge);
96 bool isRenderable() const;
103 inline bool operator==(const RoundedRect::Radii& a, const RoundedRect::Radii& b)
105 return a.topLeft() == b.topLeft() && a.topRight() == b.topRight() && a.bottomLeft() == b.bottomLeft() && a.bottomRight() == b.bottomRight();
108 inline bool operator==(const RoundedRect& a, const RoundedRect& b)
110 return a.rect() == b.rect() && a.radii() == b.radii();
114 } // namespace WebCore
116 #endif // RoundedRect_h