2
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
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.
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.
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.
21
#ifndef RenderOverflow_h
22
#define RenderOverflow_h
28
// RenderOverflow is a class for tracking content that spills out of a box. This class is used by RenderBox and
31
// There are two types of overflow: layout overflow (which is expected to be reachable via scrolling mechanisms) and
32
// visual overflow (which is not expected to be reachable via scrolling mechanisms).
34
// Layout overflow examples include other boxes that spill out of our box, For example, in the inline case a tall image
35
// could spill out of a line box.
37
// Examples of visual overflow are shadows, text stroke (and eventually outline and border-image).
39
// This object is allocated only when some of these fields have non-default values in the owning box.
40
class RenderOverflow {
42
RenderOverflow(const IntRect& defaultRect = IntRect())
43
: m_topLayoutOverflow(defaultRect.y())
44
, m_bottomLayoutOverflow(defaultRect.bottom())
45
, m_leftLayoutOverflow(defaultRect.x())
46
, m_rightLayoutOverflow(defaultRect.right())
47
, m_topVisualOverflow(defaultRect.y())
48
, m_bottomVisualOverflow(defaultRect.bottom())
49
, m_leftVisualOverflow(defaultRect.x())
50
, m_rightVisualOverflow(defaultRect.right())
54
int topLayoutOverflow() const { return m_topLayoutOverflow; }
55
int bottomLayoutOverflow() const { return m_bottomLayoutOverflow; }
56
int leftLayoutOverflow() const { return m_leftLayoutOverflow; }
57
int rightLayoutOverflow() const { return m_rightLayoutOverflow; }
58
IntRect layoutOverflowRect() const;
60
int topVisualOverflow() const { return m_topVisualOverflow; }
61
int bottomVisualOverflow() const { return m_bottomVisualOverflow; }
62
int leftVisualOverflow() const { return m_leftVisualOverflow; }
63
int rightVisualOverflow() const { return m_rightVisualOverflow; }
64
IntRect visualOverflowRect() const;
66
IntRect visibleOverflowRect() const;
68
void setTopLayoutOverflow(int overflow) { m_topLayoutOverflow = overflow; }
69
void setBottomLayoutOverflow(int overflow) { m_bottomLayoutOverflow = overflow; }
70
void setLeftLayoutOverflow(int overflow) { m_leftLayoutOverflow = overflow; }
71
void setRightLayoutOverflow(int overflow) { m_rightLayoutOverflow = overflow; }
73
void setTopVisualOverflow(int overflow) { m_topVisualOverflow = overflow; }
74
void setBottomVisualOverflow(int overflow) { m_bottomVisualOverflow = overflow; }
75
void setLeftVisualOverflow(int overflow) { m_leftVisualOverflow = overflow; }
76
void setRightVisualOverflow(int overflow) { m_rightVisualOverflow = overflow; }
78
void move(int dx, int dy);
80
void addLayoutOverflow(const IntRect&);
81
void addVisualOverflow(const IntRect&);
83
void resetLayoutOverflow(const IntRect& defaultRect);
86
int m_topLayoutOverflow;
87
int m_bottomLayoutOverflow;
88
int m_leftLayoutOverflow;
89
int m_rightLayoutOverflow;
91
int m_topVisualOverflow;
92
int m_bottomVisualOverflow;
93
int m_leftVisualOverflow;
94
int m_rightVisualOverflow;
97
inline IntRect RenderOverflow::layoutOverflowRect() const
99
return IntRect(m_leftLayoutOverflow, m_topLayoutOverflow, m_rightLayoutOverflow - m_leftLayoutOverflow, m_bottomLayoutOverflow - m_topLayoutOverflow);
102
inline IntRect RenderOverflow::visualOverflowRect() const
104
return IntRect(m_leftVisualOverflow, m_topVisualOverflow, m_rightVisualOverflow - m_leftVisualOverflow, m_bottomVisualOverflow - m_topVisualOverflow);
107
inline IntRect RenderOverflow::visibleOverflowRect() const
109
IntRect combinedRect(layoutOverflowRect());
110
combinedRect.unite(visualOverflowRect());
114
inline void RenderOverflow::move(int dx, int dy)
116
m_topLayoutOverflow += dy;
117
m_bottomLayoutOverflow += dy;
118
m_leftLayoutOverflow += dx;
119
m_rightLayoutOverflow += dx;
121
m_topVisualOverflow += dy;
122
m_bottomVisualOverflow += dy;
123
m_leftVisualOverflow += dx;
124
m_rightVisualOverflow += dx;
127
inline void RenderOverflow::addLayoutOverflow(const IntRect& rect)
129
m_topLayoutOverflow = std::min(rect.y(), m_topLayoutOverflow);
130
m_bottomLayoutOverflow = std::max(rect.bottom(), m_bottomLayoutOverflow);
131
m_leftLayoutOverflow = std::min(rect.x(), m_leftLayoutOverflow);
132
m_rightLayoutOverflow = std::max(rect.right(), m_rightLayoutOverflow);
135
inline void RenderOverflow::addVisualOverflow(const IntRect& rect)
137
m_topVisualOverflow = std::min(rect.y(), m_topVisualOverflow);
138
m_bottomVisualOverflow = std::max(rect.bottom(), m_bottomVisualOverflow);
139
m_leftVisualOverflow = std::min(rect.x(), m_leftVisualOverflow);
140
m_rightVisualOverflow = std::max(rect.right(), m_rightVisualOverflow);
143
inline void RenderOverflow::resetLayoutOverflow(const IntRect& rect)
145
m_topLayoutOverflow = rect.y();
146
m_bottomLayoutOverflow = rect.bottom();
147
m_leftLayoutOverflow = rect.x();
148
m_rightLayoutOverflow = rect.right();
151
} // namespace WebCore
153
#endif // RenderOverflow_h