2 * Copyright (C) 2003, 2006, 2007, 2008 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 RootInlineBox_h
22 #define RootInlineBox_h
24 #include "BidiContext.h"
25 #include "InlineFlowBox.h"
35 class RootInlineBox : public InlineFlowBox {
37 RootInlineBox(RenderBlock* block);
39 virtual void destroy(RenderArena*);
41 virtual bool isRootInlineBox() const { return true; }
43 void detachEllipsisBox(RenderArena*);
45 RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLineBox); }
46 RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLineBox); }
48 virtual void adjustPosition(float dx, float dy);
50 LayoutUnit lineTop() const { return m_lineTop; }
51 LayoutUnit lineBottom() const { return m_lineBottom; }
53 LayoutUnit lineTopWithLeading() const { return m_lineTopWithLeading; }
54 LayoutUnit lineBottomWithLeading() const { return m_lineBottomWithLeading; }
56 int paginationStrut() const { return m_paginationStrut; }
57 void setPaginationStrut(int s) { m_paginationStrut = s; }
59 LayoutUnit selectionTop() const;
60 LayoutUnit selectionBottom() const;
61 LayoutUnit selectionHeight() const { return max<LayoutUnit>(0, selectionBottom() - selectionTop()); }
63 int blockDirectionPointInLine() const { return max(lineTop(), selectionTop()); }
65 LayoutUnit alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
66 void setLineTopBottomPositions(LayoutUnit top, LayoutUnit bottom, LayoutUnit topWithLeading, LayoutUnit bottomWithLeading)
69 m_lineBottom = bottom;
70 m_lineTopWithLeading = topWithLeading;
71 m_lineBottomWithLeading = bottomWithLeading;
74 virtual RenderLineBoxList* rendererLineBoxes() const;
76 RenderObject* lineBreakObj() const { return m_lineBreakObj; }
77 BidiStatus lineBreakBidiStatus() const;
78 void setLineBreakInfo(RenderObject*, unsigned breakPos, const BidiStatus&);
80 unsigned lineBreakPos() const { return m_lineBreakPos; }
81 void setLineBreakPos(unsigned p) { m_lineBreakPos = p; }
83 bool endsWithBreak() const { return m_endsWithBreak; }
84 void setEndsWithBreak(bool b) { m_endsWithBreak = b; }
86 void childRemoved(InlineBox* box);
88 bool lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth);
89 void placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0);
90 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, bool& foundBox);
92 bool hasEllipsisBox() const { return m_hasEllipsisBoxOrHyphen; }
93 EllipsisBox* ellipsisBox() const;
95 void paintEllipsisBox(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) const;
97 virtual void clearTruncation();
99 bool isHyphenated() const;
101 virtual int baselinePosition(FontBaseline baselineType) const { return boxModelObject()->baselinePosition(baselineType, m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); }
102 virtual int lineHeight() const { return boxModelObject()->lineHeight(m_firstLine, isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); }
105 void addHighlightOverflow();
106 void paintCustomHighlight(PaintInfo&, const LayoutPoint&, const AtomicString& highlightType);
109 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
110 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom);
112 bool hasSelectedChildren() const { return m_hasSelectedChildrenOrCanHaveLeadingExpansion; }
113 void setHasSelectedChildren(bool hasSelectedChildren) { m_hasSelectedChildrenOrCanHaveLeadingExpansion = hasSelectedChildren; }
115 virtual RenderObject::SelectionState selectionState();
116 InlineBox* firstSelectedBox();
117 InlineBox* lastSelectedBox();
119 GapRects lineSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, LayoutUnit selTop, LayoutUnit selHeight, const PaintInfo*);
121 RenderBlock* block() const;
123 InlineBox* closestLeafChildForPoint(const IntPoint&, bool onlyEditableLeaves);
124 InlineBox* closestLeafChildForLogicalLeftPosition(int, bool onlyEditableLeaves = false);
126 void appendFloat(RenderBox* floatingBox)
130 m_floats->append(floatingBox);
132 m_floats= adoptPtr(new Vector<RenderBox*>(1, floatingBox));
135 Vector<RenderBox*>* floatsPtr() { ASSERT(!isDirty()); return m_floats.get(); }
137 virtual void extractLineBoxFromRenderObject();
138 virtual void attachLineBoxToRenderObject();
139 virtual void removeLineBoxFromRenderObject();
141 FontBaseline baselineType() const { return static_cast<FontBaseline>(m_baselineType); }
143 bool hasAnnotationsBefore() const { return m_hasAnnotationsBefore; }
144 bool hasAnnotationsAfter() const { return m_hasAnnotationsAfter; }
146 LayoutRect paddedLayoutOverflowRect(LayoutUnit endPadding) const;
148 void ascentAndDescentForBox(InlineBox*, GlyphOverflowAndFallbackFontsMap&, LayoutUnit& ascent, LayoutUnit& descent, bool& affectsAscent, bool& affectsDescent) const;
149 LayoutUnit verticalPositionForBox(InlineBox*, VerticalPositionCache&);
150 bool includeLeadingForBox(InlineBox*) const;
151 bool includeFontForBox(InlineBox*) const;
152 bool includeGlyphsForBox(InlineBox*) const;
153 bool includeMarginForBox(InlineBox*) const;
154 bool fitsToGlyphs() const;
155 bool includesRootLineBoxFontOrLeading() const;
157 LayoutUnit logicalTopVisualOverflow() const
159 return InlineFlowBox::logicalTopVisualOverflow(lineTop());
161 LayoutUnit logicalBottomVisualOverflow() const
163 return InlineFlowBox::logicalBottomVisualOverflow(lineBottom());
165 LayoutUnit logicalTopLayoutOverflow() const
167 return InlineFlowBox::logicalTopLayoutOverflow(lineTop());
169 LayoutUnit logicalBottomLayoutOverflow() const
171 return InlineFlowBox::logicalBottomLayoutOverflow(lineBottom());
174 Node* getLogicalStartBoxWithNode(InlineBox*&) const;
175 Node* getLogicalEndBoxWithNode(InlineBox*&) const;
177 virtual const char* boxName() const;
180 void setHasEllipsisBox(bool hasEllipsisBox) { m_hasEllipsisBoxOrHyphen = hasEllipsisBox; }
182 int beforeAnnotationsAdjustment() const;
184 // Where this line ended. The exact object and the position within that object are stored so that
185 // we can create an InlineIterator beginning just after the end of this line.
186 RenderObject* m_lineBreakObj;
187 unsigned m_lineBreakPos;
188 RefPtr<BidiContext> m_lineBreakContext;
190 LayoutUnit m_lineTop;
191 LayoutUnit m_lineBottom;
193 LayoutUnit m_lineTopWithLeading;
194 LayoutUnit m_lineBottomWithLeading;
196 int m_paginationStrut;
198 // Floats hanging off the line are pushed into this vector during layout. It is only
199 // good for as long as the line has not been marked dirty.
200 OwnPtr<Vector<RenderBox*> > m_floats;
202 // Whether or not this line uses alphabetic or ideographic baselines by default.
203 unsigned m_baselineType : 1; // FontBaseline
205 // If the line contains any ruby runs, then this will be true.
206 bool m_hasAnnotationsBefore : 1;
207 bool m_hasAnnotationsAfter : 1;
209 WTF::Unicode::Direction m_lineBreakBidiStatusEor : 5;
210 WTF::Unicode::Direction m_lineBreakBidiStatusLastStrong : 5;
211 WTF::Unicode::Direction m_lineBreakBidiStatusLast : 5;
214 } // namespace WebCore
216 #endif // RootInlineBox_h