]>
Commit | Line | Data |
---|---|---|
a90939db JF |
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 | // Internet Explorer and Firefox always create a marker for list items, even when the list-style-type is none. We do not make a marker | |
44 | // in the list-style-type: none case, since it is wasteful to do so. However, in order to match other browsers we have to pretend like | |
45 | // an invisible marker exists. The side effect of having an invisible marker is that the quirks mode behavior of shrinking lines with no | |
46 | // text children must not apply. This change also means that gaps will exist between image bullet list items. Even when the list bullet | |
47 | // is an image, the line is still considered to be immune from the quirk. | |
48 | m_hasTextChildren = obj->style()->display() == LIST_ITEM; | |
49 | } | |
50 | ||
51 | #ifndef NDEBUG | |
52 | virtual ~InlineFlowBox(); | |
53 | #endif | |
54 | ||
55 | RenderFlow* flowObject(); | |
56 | ||
57 | virtual bool isInlineFlowBox() { return true; } | |
58 | ||
59 | InlineFlowBox* prevFlowBox() const { return static_cast<InlineFlowBox*>(m_prevLine); } | |
60 | InlineFlowBox* nextFlowBox() const { return static_cast<InlineFlowBox*>(m_nextLine); } | |
61 | ||
62 | InlineBox* firstChild() { checkConsistency(); return m_firstChild; } | |
63 | InlineBox* lastChild() { checkConsistency(); return m_lastChild; } | |
64 | ||
65 | virtual InlineBox* firstLeafChild(); | |
66 | virtual InlineBox* lastLeafChild(); | |
67 | InlineBox* firstLeafChildAfterBox(InlineBox* start = 0); | |
68 | InlineBox* lastLeafChildBeforeBox(InlineBox* start = 0); | |
69 | ||
70 | virtual void setConstructed() | |
71 | { | |
72 | InlineBox::setConstructed(); | |
73 | if (firstChild()) | |
74 | firstChild()->setConstructed(); | |
75 | } | |
76 | ||
77 | void addToLine(InlineBox* child); | |
78 | virtual void deleteLine(RenderArena*); | |
79 | virtual void extractLine(); | |
80 | virtual void attachLine(); | |
81 | virtual void adjustPosition(int dx, int dy); | |
82 | ||
83 | virtual void clearTruncation(); | |
84 | ||
85 | virtual void paintBoxDecorations(RenderObject::PaintInfo&, int tx, int ty); | |
86 | virtual void paintMask(RenderObject::PaintInfo&, int tx, int ty); | |
87 | void paintFillLayers(const RenderObject::PaintInfo&, const Color&, const FillLayer*, | |
88 | int my, int mh, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); | |
89 | void paintFillLayer(const RenderObject::PaintInfo&, const Color&, const FillLayer*, | |
90 | int my, int mh, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver); | |
91 | void paintBoxShadow(GraphicsContext*, RenderStyle*, int tx, int ty, int w, int h); | |
92 | virtual void paintTextDecorations(RenderObject::PaintInfo&, int tx, int ty, bool paintedChildren = false); | |
93 | virtual void paint(RenderObject::PaintInfo&, int tx, int ty); | |
94 | virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty); | |
95 | ||
96 | int marginBorderPaddingLeft(); | |
97 | int marginBorderPaddingRight(); | |
98 | int marginLeft(); | |
99 | int marginRight(); | |
100 | int borderLeft() { if (includeLeftEdge()) return renderBox()->borderLeft(); return 0; } | |
101 | int borderRight() { if (includeRightEdge()) return renderBox()->borderRight(); return 0; } | |
102 | int paddingLeft() { if (includeLeftEdge()) return renderBox()->paddingLeft(); return 0; } | |
103 | int paddingRight() { if (includeRightEdge()) return renderBox()->paddingRight(); return 0; } | |
104 | ||
105 | bool includeLeftEdge() { return m_includeLeftEdge; } | |
106 | bool includeRightEdge() { return m_includeRightEdge; } | |
107 | void setEdges(bool includeLeft, bool includeRight) | |
108 | { | |
109 | m_includeLeftEdge = includeLeft; | |
110 | m_includeRightEdge = includeRight; | |
111 | } | |
112 | ||
113 | // Helper functions used during line construction and placement. | |
114 | void determineSpacingForFlowBoxes(bool lastLine, RenderObject* endObject); | |
115 | int getFlowSpacingWidth(); | |
116 | bool onEndChain(RenderObject* endObject); | |
117 | virtual int placeBoxesHorizontally(int x, int& leftPosition, int& rightPosition, bool& needsWordSpacing); | |
118 | virtual int verticallyAlignBoxes(int heightOfBlock); | |
119 | void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom, | |
120 | int& maxAscent, int& maxDescent, bool strictMode); | |
121 | void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, | |
122 | int maxPositionTop, int maxPositionBottom); | |
123 | void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode, | |
124 | int& topPosition, int& bottomPosition, int& selectionTop, int& selectionBottom); | |
125 | void shrinkBoxesWithNoTextChildren(int topPosition, int bottomPosition); | |
126 | ||
127 | virtual void setVerticalOverflowPositions(int /*top*/, int /*bottom*/) { } | |
128 | virtual void setVerticalSelectionPositions(int /*top*/, int /*bottom*/) { } | |
129 | int maxHorizontalVisualOverflow() const { return m_maxHorizontalVisualOverflow; } | |
130 | ||
131 | void removeChild(InlineBox* child); | |
132 | ||
133 | virtual RenderObject::SelectionState selectionState(); | |
134 | ||
135 | virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth); | |
136 | virtual int placeEllipsisBox(bool ltr, int blockEdge, int ellipsisWidth, bool&); | |
137 | ||
138 | void checkConsistency() const; | |
139 | void setHasBadChildList(); | |
140 | ||
141 | private: | |
142 | InlineBox* m_firstChild; | |
143 | InlineBox* m_lastChild; | |
144 | int m_maxHorizontalVisualOverflow; | |
145 | ||
146 | #ifndef NDEBUG | |
147 | bool m_hasBadChildList; | |
148 | #endif | |
149 | }; | |
150 | ||
151 | #ifdef NDEBUG | |
152 | inline void InlineFlowBox::checkConsistency() const | |
153 | { | |
154 | } | |
155 | #endif | |
156 | ||
157 | inline void InlineFlowBox::setHasBadChildList() | |
158 | { | |
159 | #ifndef NDEBUG | |
160 | m_hasBadChildList = true; | |
161 | #endif | |
162 | } | |
163 | ||
164 | } // namespace WebCore | |
165 | ||
166 | #ifndef NDEBUG | |
167 | // Outside the WebCore namespace for ease of invocation from gdb. | |
168 | void showTree(const WebCore::InlineFlowBox*); | |
169 | #endif | |
170 | ||
171 | #endif // InlineFlowBox_h |