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 LayoutUnit paginationStrut() const { return m_paginationStrut; }
57 void setPaginationStrut(LayoutUnit s) { m_paginationStrut = s; }
59 bool isFirstAfterPageBreak() const { return m_isFirstAfterPageBreak; }
60 void setIsFirstAfterPageBreak(bool isFirstAfterPageBreak) { m_isFirstAfterPageBreak = isFirstAfterPageBreak; }
62 LayoutUnit paginatedLineWidth() const { return m_paginatedLineWidth; }
63 void setPaginatedLineWidth(LayoutUnit width) { m_paginatedLineWidth = width; }
65 LayoutUnit selectionTop() const;
66 LayoutUnit selectionBottom() const;
67 LayoutUnit selectionHeight() const { return max<LayoutUnit>(0, selectionBottom() - selectionTop()); }
69 LayoutUnit selectionTopAdjustedForPrecedingBlock() const;
70 LayoutUnit selectionHeightAdjustedForPrecedingBlock() const { return max<LayoutUnit>(0, selectionBottom() - selectionTopAdjustedForPrecedingBlock()); }
72 int blockDirectionPointInLine() const;
74 LayoutUnit alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
75 void setLineTopBottomPositions(LayoutUnit top, LayoutUnit bottom, LayoutUnit topWithLeading, LayoutUnit bottomWithLeading)
78 m_lineBottom = bottom;
79 m_lineTopWithLeading = topWithLeading;
80 m_lineBottomWithLeading = bottomWithLeading;
83 virtual RenderLineBoxList* rendererLineBoxes() const;
85 RenderObject* lineBreakObj() const { return m_lineBreakObj; }
86 BidiStatus lineBreakBidiStatus() const;
87 void setLineBreakInfo(RenderObject*, unsigned breakPos, const BidiStatus&);
89 unsigned lineBreakPos() const { return m_lineBreakPos; }
90 void setLineBreakPos(unsigned p) { m_lineBreakPos = p; }
92 using InlineBox::endsWithBreak;
93 using InlineBox::setEndsWithBreak;
95 void childRemoved(InlineBox* box);
97 bool lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth);
98 // Return the truncatedWidth, the width of the truncated text + ellipsis.
99 float placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0);
100 // Return the position of the EllipsisBox or -1.
101 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) OVERRIDE;
103 using InlineBox::hasEllipsisBox;
104 EllipsisBox* ellipsisBox() const;
106 void paintEllipsisBox(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) const;
108 virtual void clearTruncation() OVERRIDE;
110 bool isHyphenated() const;
112 virtual LayoutUnit baselinePosition(FontBaseline baselineType) const;
113 virtual LayoutUnit lineHeight() const;
116 void addHighlightOverflow();
117 void paintCustomHighlight(PaintInfo&, const LayoutPoint&, const AtomicString& highlightType);
120 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
121 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
123 using InlineBox::hasSelectedChildren;
124 using InlineBox::setHasSelectedChildren;
126 virtual RenderObject::SelectionState selectionState();
127 InlineBox* firstSelectedBox();
128 InlineBox* lastSelectedBox();
130 GapRects lineSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, LayoutUnit selTop, LayoutUnit selHeight, const PaintInfo*);
132 RenderBlock* block() const;
134 InlineBox* closestLeafChildForPoint(const IntPoint&, bool onlyEditableLeaves);
135 InlineBox* closestLeafChildForLogicalLeftPosition(int, bool onlyEditableLeaves = false);
137 void appendFloat(RenderBox* floatingBox)
141 m_floats->append(floatingBox);
143 m_floats= adoptPtr(new Vector<RenderBox*>(1, floatingBox));
146 Vector<RenderBox*>* floatsPtr() { ASSERT(!isDirty()); return m_floats.get(); }
148 virtual void extractLineBoxFromRenderObject();
149 virtual void attachLineBoxToRenderObject();
150 virtual void removeLineBoxFromRenderObject();
152 FontBaseline baselineType() const { return static_cast<FontBaseline>(m_baselineType); }
154 bool hasAnnotationsBefore() const { return m_hasAnnotationsBefore; }
155 bool hasAnnotationsAfter() const { return m_hasAnnotationsAfter; }
157 LayoutRect paddedLayoutOverflowRect(LayoutUnit endPadding) const;
159 void ascentAndDescentForBox(InlineBox*, GlyphOverflowAndFallbackFontsMap&, int& ascent, int& descent, bool& affectsAscent, bool& affectsDescent) const;
160 LayoutUnit verticalPositionForBox(InlineBox*, VerticalPositionCache&);
161 bool includeLeadingForBox(InlineBox*) const;
162 bool includeFontForBox(InlineBox*) const;
163 bool includeGlyphsForBox(InlineBox*) const;
164 bool includeMarginForBox(InlineBox*) const;
165 bool fitsToGlyphs() const;
166 bool includesRootLineBoxFontOrLeading() const;
168 LayoutUnit logicalTopVisualOverflow() const
170 return InlineFlowBox::logicalTopVisualOverflow(lineTop());
172 LayoutUnit logicalBottomVisualOverflow() const
174 return InlineFlowBox::logicalBottomVisualOverflow(lineBottom());
176 LayoutUnit logicalTopLayoutOverflow() const
178 return InlineFlowBox::logicalTopLayoutOverflow(lineTop());
180 LayoutUnit logicalBottomLayoutOverflow() const
182 return InlineFlowBox::logicalBottomLayoutOverflow(lineBottom());
185 Node* getLogicalStartBoxWithNode(InlineBox*&) const;
186 Node* getLogicalEndBoxWithNode(InlineBox*&) const;
189 virtual const char* boxName() const;
192 LayoutUnit lineSnapAdjustment(LayoutUnit delta = 0) const;
194 LayoutUnit beforeAnnotationsAdjustment() const;
196 // This folds into the padding at the end of InlineFlowBox on 64-bit.
197 unsigned m_lineBreakPos;
199 // Where this line ended. The exact object and the position within that object are stored so that
200 // we can create an InlineIterator beginning just after the end of this line.
201 RenderObject* m_lineBreakObj;
202 RefPtr<BidiContext> m_lineBreakContext;
204 LayoutUnit m_lineTop;
205 LayoutUnit m_lineBottom;
207 LayoutUnit m_lineTopWithLeading;
208 LayoutUnit m_lineBottomWithLeading;
210 LayoutUnit m_paginationStrut;
211 LayoutUnit m_paginatedLineWidth;
213 // Floats hanging off the line are pushed into this vector during layout. It is only
214 // good for as long as the line has not been marked dirty.
215 OwnPtr<Vector<RenderBox*> > m_floats;
218 } // namespace WebCore
220 #endif // RootInlineBox_h