-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
BorderData.h
151 lines (125 loc) · 5.25 KB
/
BorderData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#pragma once
#include "BorderValue.h"
#include "LengthSize.h"
#include "NinePieceImage.h"
namespace WebCore {
class OutlineValue;
class BorderData {
friend class RenderStyle;
public:
struct Radii {
LengthSize topLeft { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize topRight { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize bottomLeft { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
LengthSize bottomRight { { 0, LengthType::Fixed }, { 0, LengthType::Fixed } };
};
bool hasBorder() const
{
return m_left.nonZero() || m_right.nonZero() || m_top.nonZero() || m_bottom.nonZero();
}
bool hasVisibleBorder() const
{
return m_left.isVisible() || m_right.isVisible() || m_top.isVisible() || m_bottom.isVisible();
}
bool hasBorderImage() const
{
return m_image.hasImage();
}
bool hasBorderRadius() const
{
return !m_radii.topLeft.width.isZero()
|| !m_radii.topRight.width.isZero()
|| !m_radii.bottomLeft.width.isZero()
|| !m_radii.bottomRight.width.isZero();
}
float borderLeftWidth() const
{
if (m_left.style() == BorderStyle::None || m_left.style() == BorderStyle::Hidden)
return 0;
if (m_image.overridesBorderWidths() && m_image.borderSlices().left().isFixed())
return m_image.borderSlices().left().value();
return m_left.width();
}
float borderRightWidth() const
{
if (m_right.style() == BorderStyle::None || m_right.style() == BorderStyle::Hidden)
return 0;
if (m_image.overridesBorderWidths() && m_image.borderSlices().right().isFixed())
return m_image.borderSlices().right().value();
return m_right.width();
}
float borderTopWidth() const
{
if (m_top.style() == BorderStyle::None || m_top.style() == BorderStyle::Hidden)
return 0;
if (m_image.overridesBorderWidths() && m_image.borderSlices().top().isFixed())
return m_image.borderSlices().top().value();
return m_top.width();
}
float borderBottomWidth() const
{
if (m_bottom.style() == BorderStyle::None || m_bottom.style() == BorderStyle::Hidden)
return 0;
if (m_image.overridesBorderWidths() && m_image.borderSlices().bottom().isFixed())
return m_image.borderSlices().bottom().value();
return m_bottom.width();
}
FloatBoxExtent borderWidth() const
{
return FloatBoxExtent(borderTopWidth(), borderRightWidth(), borderBottomWidth(), borderLeftWidth());
}
bool isEquivalentForPainting(const BorderData& other, bool currentColorDiffers) const;
bool operator==(const BorderData& o) const
{
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
&& m_radii.topLeft == o.m_radii.topLeft && m_radii.topRight == o.m_radii.topRight && m_radii.bottomLeft == o.m_radii.bottomLeft && m_radii.bottomRight == o.m_radii.bottomRight;
}
bool operator!=(const BorderData& o) const
{
return !(*this == o);
}
const BorderValue& left() const { return m_left; }
const BorderValue& right() const { return m_right; }
const BorderValue& top() const { return m_top; }
const BorderValue& bottom() const { return m_bottom; }
const NinePieceImage& image() const { return m_image; }
const LengthSize& topLeftRadius() const { return m_radii.topLeft; }
const LengthSize& topRightRadius() const { return m_radii.topRight; }
const LengthSize& bottomLeftRadius() const { return m_radii.bottomLeft; }
const LengthSize& bottomRightRadius() const { return m_radii.bottomRight; }
void dump(TextStream&, DumpStyleValues = DumpStyleValues::All) const;
private:
BorderValue m_left;
BorderValue m_right;
BorderValue m_top;
BorderValue m_bottom;
NinePieceImage m_image;
Radii m_radii;
};
WTF::TextStream& operator<<(WTF::TextStream&, const BorderValue&);
WTF::TextStream& operator<<(WTF::TextStream&, const OutlineValue&);
WTF::TextStream& operator<<(WTF::TextStream&, const BorderData&);
} // namespace WebCore