]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderFlow.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderFlow.h
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifndef RenderFlow_h
24 #define RenderFlow_h
25
26 #include "RenderContainer.h"
27
28 namespace WebCore {
29
30 enum LineCount
31 {
32 NOT_SET = 0, NO_LINE = 1, ONE_LINE = 2, MULTI_LINE = 3
33 };
34
35 /**
36 * all geometry managing stuff is only in the block elements.
37 *
38 * Inline elements don't layout themselves, but the whole paragraph
39 * gets flowed by the surrounding block element. This is, because
40 * one needs to know the whole paragraph to calculate bidirectional
41 * behaviour of text, so putting the layouting routines in the inline
42 * elements is impossible.
43 */
44 class RenderFlow : public RenderContainer {
45 public:
46 RenderFlow(Node* node)
47 : RenderContainer(node)
48 , m_continuation(0)
49 , m_firstLineBox(0)
50 , m_lastLineBox(0)
51 , m_lineHeight(-1)
52 , m_childrenInline(true)
53 , m_firstLine(false)
54 , m_topMarginQuirk(false)
55 , m_bottomMarginQuirk(false)
56 , m_hasMarkupTruncation(false)
57 , m_selectionState(SelectionNone)
58 , m_hasColumns(false)
59 , m_lineCountForTextAutosizing(NOT_SET)
60 , m_isContinuation(false)
61 , m_cellWidthChanged(false)
62 {
63 }
64 #ifndef NDEBUG
65 virtual ~RenderFlow();
66 #endif
67
68 virtual RenderFlow* virtualContinuation() const { return continuation(); }
69 RenderFlow* continuation() const { return m_continuation; }
70 void setContinuation(RenderFlow* c) { m_continuation = c; }
71 RenderFlow* continuationBefore(RenderObject* beforeChild);
72
73 void addChildWithContinuation(RenderObject* newChild, RenderObject* beforeChild);
74 virtual void addChildToFlow(RenderObject* newChild, RenderObject* beforeChild) = 0;
75 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
76
77 static RenderFlow* createAnonymousFlow(Document*, PassRefPtr<RenderStyle>);
78
79 void extractLineBox(InlineFlowBox*);
80 void attachLineBox(InlineFlowBox*);
81 void removeLineBox(InlineFlowBox*);
82 void deleteLineBoxes();
83 virtual void destroy();
84
85 virtual void dirtyLinesFromChangedChild(RenderObject* child);
86
87 virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
88
89 InlineFlowBox* firstLineBox() const { return m_firstLineBox; }
90 InlineFlowBox* lastLineBox() const { return m_lastLineBox; }
91
92 virtual InlineBox* createInlineBox(bool makePlaceHolderBox, bool isRootLineBox, bool isOnlyRun=false);
93 virtual void dirtyLineBoxes(bool fullLayout, bool isRootLineBox = false);
94
95 void paintLines(PaintInfo&, int tx, int ty);
96 bool hitTestLines(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
97
98 virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
99
100 virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
101 void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect& prevLine, const IntRect& thisLine, const IntRect& nextLine);
102 void paintOutline(GraphicsContext*, int tx, int ty);
103
104 virtual bool hasColumns() const { return m_hasColumns; }
105
106 void calcMargins(int containerWidth);
107
108 void checkConsistency() const;
109
110 private:
111 // An inline can be split with blocks occurring in between the inline content.
112 // When this occurs we need a pointer to our next object. We can basically be
113 // split into a sequence of inlines and blocks. The continuation will either be
114 // an anonymous block (that houses other blocks) or it will be an inline flow.
115 RenderFlow* m_continuation;
116
117 protected:
118 // For block flows, each box represents the root inline box for a line in the
119 // paragraph.
120 // For inline flows, each box represents a portion of that inline.
121 InlineFlowBox* m_firstLineBox;
122 InlineFlowBox* m_lastLineBox;
123
124 mutable int m_lineHeight;
125
126 // These bitfields are moved here from subclasses to pack them together
127 // from RenderBlock
128 bool m_childrenInline : 1;
129 bool m_firstLine : 1;
130 bool m_topMarginQuirk : 1;
131 bool m_bottomMarginQuirk : 1;
132 bool m_hasMarkupTruncation : 1;
133 unsigned m_selectionState : 3; // SelectionState
134 bool m_hasColumns : 1;
135 unsigned m_lineCountForTextAutosizing : 2;
136
137 // from RenderInline
138 bool m_isContinuation : 1; // Whether or not we're a continuation of an inline.
139
140 // from RenderTableCell
141 bool m_cellWidthChanged : 1;
142 };
143
144 #ifdef NDEBUG
145 inline void RenderFlow::checkConsistency() const
146 {
147 }
148 #endif
149
150 } // namespace WebCore
151
152 #endif // RenderFlow_h