|
1 /* |
|
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
|
3 * |
|
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. |
|
8 * |
|
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. |
|
13 * |
|
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. |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef InlineFlowBox_h |
|
22 #define InlineFlowBox_h |
|
23 |
|
24 #include "InlineRunBox.h" |
|
25 |
|
26 namespace WebCore { |
|
27 |
|
28 class HitTestResult; |
|
29 |
|
30 struct HitTestRequest; |
|
31 |
|
32 class InlineFlowBox : public InlineRunBox { |
|
33 public: |
|
34 InlineFlowBox(RenderObject* obj) |
|
35 : InlineRunBox(obj) |
|
36 , m_firstChild(0) |
|
37 , m_lastChild(0) |
|
38 , m_maxHorizontalVisualOverflow(0) |
|
39 #ifndef NDEBUG |
|
40 , m_hasBadChildList(false) |
|
41 #endif |
|
42 { |
|
43 m_hasTextChildren = false; |
|
44 } |
|
45 |
|
46 #ifndef NDEBUG |
|
47 virtual ~InlineFlowBox(); |
|
48 #endif |
|
49 |
|
50 RenderFlow* flowObject(); |
|
51 |
|
52 virtual bool isInlineFlowBox() { return true; } |
|
53 |
|
54 InlineFlowBox* prevFlowBox() const { return static_cast<InlineFlowBox*>(m_prevLine); } |
|
55 InlineFlowBox* nextFlowBox() const { return static_cast<InlineFlowBox*>(m_nextLine); } |
|
56 |
|
57 InlineBox* firstChild() { checkConsistency(); return m_firstChild; } |
|
58 InlineBox* lastChild() { checkConsistency(); return m_lastChild; } |
|
59 |
|
60 virtual InlineBox* firstLeafChild(); |
|
61 virtual InlineBox* lastLeafChild(); |
|
62 InlineBox* firstLeafChildAfterBox(InlineBox* start = 0); |
|
63 InlineBox* lastLeafChildBeforeBox(InlineBox* start = 0); |
|
64 |
|
65 virtual void setConstructed() |
|
66 { |
|
67 InlineBox::setConstructed(); |
|
68 if (firstChild()) |
|
69 firstChild()->setConstructed(); |
|
70 } |
|
71 |
|
72 void addToLine(InlineBox* child); |
|
73 virtual void deleteLine(RenderArena*); |
|
74 virtual void extractLine(); |
|
75 virtual void attachLine(); |
|
76 virtual void adjustPosition(int dx, int dy); |
|
77 |
|
78 virtual void clearTruncation(); |
|
79 |
|
80 virtual void paintBoxDecorations(RenderObject::PaintInfo&, int tx, int ty); |
|
81 void paintBackgrounds(GraphicsContext*, const Color&, const BackgroundLayer*, |
|
82 int my, int mh, int tx, int ty, int w, int h); |
|
83 void paintBackground(GraphicsContext*, const Color&, const BackgroundLayer*, |
|
84 int my, int mh, int tx, int ty, int w, int h); |
|
85 void paintBoxShadow(GraphicsContext*, RenderStyle*, int tx, int ty, int w, int h); |
|
86 virtual void paintTextDecorations(RenderObject::PaintInfo&, int tx, int ty, bool paintedChildren = false); |
|
87 virtual void paint(RenderObject::PaintInfo&, int tx, int ty); |
|
88 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); |
|
89 |
|
90 int marginBorderPaddingLeft(); |
|
91 int marginBorderPaddingRight(); |
|
92 int marginLeft(); |
|
93 int marginRight(); |
|
94 int borderLeft() { if (includeLeftEdge()) return object()->borderLeft(); return 0; } |
|
95 int borderRight() { if (includeRightEdge()) return object()->borderRight(); return 0; } |
|
96 int paddingLeft() { if (includeLeftEdge()) return object()->paddingLeft(); return 0; } |
|
97 int paddingRight() { if (includeRightEdge()) return object()->paddingRight(); return 0; } |
|
98 |
|
99 bool includeLeftEdge() { return m_includeLeftEdge; } |
|
100 bool includeRightEdge() { return m_includeRightEdge; } |
|
101 void setEdges(bool includeLeft, bool includeRight) |
|
102 { |
|
103 m_includeLeftEdge = includeLeft; |
|
104 m_includeRightEdge = includeRight; |
|
105 } |
|
106 |
|
107 // Helper functions used during line construction and placement. |
|
108 void determineSpacingForFlowBoxes(bool lastLine, RenderObject* endObject); |
|
109 int getFlowSpacingWidth(); |
|
110 bool onEndChain(RenderObject* endObject); |
|
111 virtual int placeBoxesHorizontally(int x, int& leftPosition, int& rightPosition, bool& needsWordSpacing); |
|
112 virtual void verticallyAlignBoxes(int& heightOfBlock); |
|
113 void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, |
|
114 int& maxAscent, int& maxDescent, bool strictMode); |
|
115 void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, |
|
116 int maxPositionTop, int maxPositionBottom); |
|
117 void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode, |
|
118 int& topPosition, int& bottomPosition, int& selectionTop, int& selectionBottom); |
|
119 void shrinkBoxesWithNoTextChildren(int topPosition, int bottomPosition); |
|
120 |
|
121 virtual void setVerticalOverflowPositions(int top, int bottom) { } |
|
122 virtual void setVerticalSelectionPositions(int top, int bottom) { } |
|
123 int maxHorizontalVisualOverflow() const { return m_maxHorizontalVisualOverflow; } |
|
124 |
|
125 void removeChild(InlineBox* child); |
|
126 |
|
127 virtual RenderObject::SelectionState selectionState(); |
|
128 |
|
129 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth); |
|
130 virtual int placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool&); |
|
131 |
|
132 void checkConsistency() const; |
|
133 void setHasBadChildList(); |
|
134 |
|
135 private: |
|
136 InlineBox* m_firstChild; |
|
137 InlineBox* m_lastChild; |
|
138 int m_maxHorizontalVisualOverflow; |
|
139 |
|
140 #ifndef NDEBUG |
|
141 bool m_hasBadChildList; |
|
142 #endif |
|
143 }; |
|
144 |
|
145 #ifdef NDEBUG |
|
146 inline void InlineFlowBox::checkConsistency() const |
|
147 { |
|
148 } |
|
149 #endif |
|
150 |
|
151 inline void InlineFlowBox::setHasBadChildList() |
|
152 { |
|
153 #ifndef NDEBUG |
|
154 m_hasBadChildList = true; |
|
155 #endif |
|
156 } |
|
157 |
|
158 } // namespace WebCore |
|
159 |
|
160 #ifndef NDEBUG |
|
161 // Outside the WebCore namespace for ease of invocation from gdb. |
|
162 void showTree(const WebCore::InlineBox*); |
|
163 #endif |
|
164 |
|
165 #endif // InlineFlowBox_h |