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.
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.
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.
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.
26 #include "RenderContainer.h"
32 NOT_SET
= 0, NO_LINE
= 1, ONE_LINE
= 2, MULTI_LINE
= 3
36 * all geometry managing stuff is only in the block elements.
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.
44 class RenderFlow
: public RenderContainer
{
46 RenderFlow(Node
* node
)
47 : RenderContainer(node
)
52 , m_childrenInline(true)
54 , m_topMarginQuirk(false)
55 , m_bottomMarginQuirk(false)
56 , m_hasMarkupTruncation(false)
57 , m_selectionState(SelectionNone
)
59 , m_lineCountForTextAutosizing(NOT_SET
)
60 , m_isContinuation(false)
61 , m_cellWidthChanged(false)
65 virtual ~RenderFlow();
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
);
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);
77 static RenderFlow
* createAnonymousFlow(Document
*, PassRefPtr
<RenderStyle
>);
79 void extractLineBox(InlineFlowBox
*);
80 void attachLineBox(InlineFlowBox
*);
81 void removeLineBox(InlineFlowBox
*);
82 void deleteLineBoxes();
83 virtual void destroy();
85 virtual void dirtyLinesFromChangedChild(RenderObject
* child
);
87 virtual int lineHeight(bool firstLine
, bool isRootLineBox
= false) const;
89 InlineFlowBox
* firstLineBox() const { return m_firstLineBox
; }
90 InlineFlowBox
* lastLineBox() const { return m_lastLineBox
; }
92 virtual InlineBox
* createInlineBox(bool makePlaceHolderBox
, bool isRootLineBox
, bool isOnlyRun
=false);
93 virtual void dirtyLineBoxes(bool fullLayout
, bool isRootLineBox
= false);
95 void paintLines(PaintInfo
&, int tx
, int ty
);
96 bool hitTestLines(const HitTestRequest
&, HitTestResult
&, int x
, int y
, int tx
, int ty
, HitTestAction
);
98 virtual IntRect
localCaretRect(InlineBox
*, int caretOffset
, int* extraWidthToEndOfLine
= 0);
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
);
104 virtual bool hasColumns() const { return m_hasColumns
; }
106 void calcMargins(int containerWidth
);
108 void checkConsistency() const;
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
;
118 // For block flows, each box represents the root inline box for a line in the
120 // For inline flows, each box represents a portion of that inline.
121 InlineFlowBox
* m_firstLineBox
;
122 InlineFlowBox
* m_lastLineBox
;
124 mutable int m_lineHeight
;
126 // These bitfields are moved here from subclasses to pack them together
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;
138 bool m_isContinuation
: 1; // Whether or not we're a continuation of an inline.
140 // from RenderTableCell
141 bool m_cellWidthChanged
: 1;
145 inline void RenderFlow::checkConsistency() const
150 } // namespace WebCore
152 #endif // RenderFlow_h