2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
28 #include "core/rendering/style/BorderValue.h"
29 #include "core/rendering/style/NinePieceImage.h"
30 #include "platform/LengthSize.h"
31 #include "platform/geometry/IntRect.h"
36 friend class RenderStyle;
38 BorderData() : m_topLeft(Length(0, Fixed), Length(0, Fixed))
39 , m_topRight(Length(0, Fixed), Length(0, Fixed))
40 , m_bottomLeft(Length(0, Fixed), Length(0, Fixed))
41 , m_bottomRight(Length(0, Fixed), Length(0, Fixed))
44 bool hasBorder() const
46 bool haveImage = m_image.hasImage();
47 return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_top.nonZero(!haveImage) || m_bottom.nonZero(!haveImage);
50 bool hasBorderRadius() const
52 if (!m_topLeft.width().isZero())
54 if (!m_topRight.width().isZero())
56 if (!m_bottomLeft.width().isZero())
58 if (!m_bottomRight.width().isZero())
63 unsigned borderLeftWidth() const
65 if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
67 return m_left.width();
70 unsigned borderRightWidth() const
72 if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
74 return m_right.width();
77 unsigned borderTopWidth() const
79 if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
84 unsigned borderBottomWidth() const
86 if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
88 return m_bottom.width();
91 bool operator==(const BorderData& o) const
93 return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom && m_image == o.m_image
94 && m_topLeft == o.m_topLeft && m_topRight == o.m_topRight && m_bottomLeft == o.m_bottomLeft && m_bottomRight == o.m_bottomRight;
97 bool visuallyEqual(const BorderData& o) const
99 return m_left.visuallyEqual(o.m_left)
100 && m_right.visuallyEqual(o.m_right)
101 && m_top.visuallyEqual(o.m_top)
102 && m_bottom.visuallyEqual(o.m_bottom)
103 && m_image == o.m_image
104 && m_topLeft == o.m_topLeft
105 && m_topRight == o.m_topRight
106 && m_bottomLeft == o.m_bottomLeft
107 && m_bottomRight == o.m_bottomRight;
110 bool operator!=(const BorderData& o) const
112 return !(*this == o);
115 const BorderValue& left() const { return m_left; }
116 const BorderValue& right() const { return m_right; }
117 const BorderValue& top() const { return m_top; }
118 const BorderValue& bottom() const { return m_bottom; }
120 const NinePieceImage& image() const { return m_image; }
122 const LengthSize& topLeft() const { return m_topLeft; }
123 const LengthSize& topRight() const { return m_topRight; }
124 const LengthSize& bottomLeft() const { return m_bottomLeft; }
125 const LengthSize& bottomRight() const { return m_bottomRight; }
131 BorderValue m_bottom;
133 NinePieceImage m_image;
135 LengthSize m_topLeft;
136 LengthSize m_topRight;
137 LengthSize m_bottomLeft;
138 LengthSize m_bottomRight;
143 #endif // BorderData_h