• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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)
7  *
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.
12  *
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.
17  *
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.
22  *
23  */
24 
25 #ifndef BorderData_h
26 #define BorderData_h
27 
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"
32 
33 namespace WebCore {
34 
35 class BorderData {
36 friend class RenderStyle;
37 public:
BorderData()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))
42     {
43     }
hasBorder()44     bool hasBorder() const
45     {
46         bool haveImage = m_image.hasImage();
47         return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_top.nonZero(!haveImage) || m_bottom.nonZero(!haveImage);
48     }
49 
hasBorderRadius()50     bool hasBorderRadius() const
51     {
52         if (!m_topLeft.width().isZero())
53             return true;
54         if (!m_topRight.width().isZero())
55             return true;
56         if (!m_bottomLeft.width().isZero())
57             return true;
58         if (!m_bottomRight.width().isZero())
59             return true;
60         return false;
61     }
62 
borderLeftWidth()63     unsigned borderLeftWidth() const
64     {
65         if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
66             return 0;
67         return m_left.width();
68     }
69 
borderRightWidth()70     unsigned borderRightWidth() const
71     {
72         if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
73             return 0;
74         return m_right.width();
75     }
76 
borderTopWidth()77     unsigned borderTopWidth() const
78     {
79         if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
80             return 0;
81         return m_top.width();
82     }
83 
borderBottomWidth()84     unsigned borderBottomWidth() const
85     {
86         if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
87             return 0;
88         return m_bottom.width();
89     }
90 
91     bool operator==(const BorderData& o) const
92     {
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;
95     }
96 
97     bool operator!=(const BorderData& o) const
98     {
99         return !(*this == o);
100     }
101 
left()102     const BorderValue& left() const { return m_left; }
right()103     const BorderValue& right() const { return m_right; }
top()104     const BorderValue& top() const { return m_top; }
bottom()105     const BorderValue& bottom() const { return m_bottom; }
106 
image()107     const NinePieceImage& image() const { return m_image; }
108 
topLeft()109     const LengthSize& topLeft() const { return m_topLeft; }
topRight()110     const LengthSize& topRight() const { return m_topRight; }
bottomLeft()111     const LengthSize& bottomLeft() const { return m_bottomLeft; }
bottomRight()112     const LengthSize& bottomRight() const { return m_bottomRight; }
113 
114 private:
115     BorderValue m_left;
116     BorderValue m_right;
117     BorderValue m_top;
118     BorderValue m_bottom;
119 
120     NinePieceImage m_image;
121 
122     LengthSize m_topLeft;
123     LengthSize m_topRight;
124     LengthSize m_bottomLeft;
125     LengthSize m_bottomRight;
126 };
127 
128 } // namespace WebCore
129 
130 #endif // BorderData_h
131