Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RootInlineBox.h
1 /*
2  * Copyright (C) 2003, 2006, 2007, 2008 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 RootInlineBox_h
22 #define RootInlineBox_h
23
24 #include "BidiContext.h"
25 #include "InlineFlowBox.h"
26
27 namespace WebCore {
28
29 class EllipsisBox;
30 class HitTestResult;
31
32 struct BidiStatus;
33 struct GapRects;
34
35 class RootInlineBox : public InlineFlowBox {
36 public:
37     RootInlineBox(RenderBlock* block);
38
39     virtual void destroy(RenderArena*);
40
41     virtual bool isRootInlineBox() const { return true; }
42
43     void detachEllipsisBox(RenderArena*);
44
45     RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLineBox); }
46     RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLineBox); }
47
48     virtual void adjustPosition(float dx, float dy);
49
50     LayoutUnit lineTop() const { return m_lineTop; }
51     LayoutUnit lineBottom() const { return m_lineBottom; }
52
53     LayoutUnit lineTopWithLeading() const { return m_lineTopWithLeading; }
54     LayoutUnit lineBottomWithLeading() const { return m_lineBottomWithLeading; }
55     
56     LayoutUnit paginationStrut() const { return m_paginationStrut; }
57     void setPaginationStrut(LayoutUnit s) { m_paginationStrut = s; }
58
59     bool isFirstAfterPageBreak() const { return m_isFirstAfterPageBreak; }
60     void setIsFirstAfterPageBreak(bool isFirstAfterPageBreak) { m_isFirstAfterPageBreak = isFirstAfterPageBreak; }
61
62     LayoutUnit paginatedLineWidth() const { return m_paginatedLineWidth; }
63     void setPaginatedLineWidth(LayoutUnit width) { m_paginatedLineWidth = width; }
64
65     LayoutUnit selectionTop() const;
66     LayoutUnit selectionBottom() const;
67     LayoutUnit selectionHeight() const { return max<LayoutUnit>(0, selectionBottom() - selectionTop()); }
68
69     LayoutUnit selectionTopAdjustedForPrecedingBlock() const;
70     LayoutUnit selectionHeightAdjustedForPrecedingBlock() const { return max<LayoutUnit>(0, selectionBottom() - selectionTopAdjustedForPrecedingBlock()); }
71
72     int blockDirectionPointInLine() const;
73
74     LayoutUnit alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
75     void setLineTopBottomPositions(LayoutUnit top, LayoutUnit bottom, LayoutUnit topWithLeading, LayoutUnit bottomWithLeading)
76     { 
77         m_lineTop = top; 
78         m_lineBottom = bottom;
79         m_lineTopWithLeading = topWithLeading;
80         m_lineBottomWithLeading = bottomWithLeading;
81     }
82
83     virtual RenderLineBoxList* rendererLineBoxes() const;
84
85     RenderObject* lineBreakObj() const { return m_lineBreakObj; }
86     BidiStatus lineBreakBidiStatus() const;
87     void setLineBreakInfo(RenderObject*, unsigned breakPos, const BidiStatus&);
88
89     unsigned lineBreakPos() const { return m_lineBreakPos; }
90     void setLineBreakPos(unsigned p) { m_lineBreakPos = p; }
91
92     using InlineBox::endsWithBreak;
93     using InlineBox::setEndsWithBreak;
94
95     void childRemoved(InlineBox* box);
96
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;
102
103     using InlineBox::hasEllipsisBox;
104     EllipsisBox* ellipsisBox() const;
105
106     void paintEllipsisBox(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) const;
107
108     virtual void clearTruncation() OVERRIDE;
109
110     bool isHyphenated() const;
111
112     virtual LayoutUnit baselinePosition(FontBaseline baselineType) const;
113     virtual LayoutUnit lineHeight() const;
114
115 #if PLATFORM(MAC)
116     void addHighlightOverflow();
117     void paintCustomHighlight(PaintInfo&, const LayoutPoint&, const AtomicString& highlightType);
118 #endif
119
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;
122
123     using InlineBox::hasSelectedChildren;
124     using InlineBox::setHasSelectedChildren;
125
126     virtual RenderObject::SelectionState selectionState();
127     InlineBox* firstSelectedBox();
128     InlineBox* lastSelectedBox();
129
130     GapRects lineSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, LayoutUnit selTop, LayoutUnit selHeight, const PaintInfo*);
131
132     RenderBlock* block() const;
133
134     InlineBox* closestLeafChildForPoint(const IntPoint&, bool onlyEditableLeaves);
135     InlineBox* closestLeafChildForLogicalLeftPosition(int, bool onlyEditableLeaves = false);
136
137     void appendFloat(RenderBox* floatingBox)
138     {
139         ASSERT(!isDirty());
140         if (m_floats)
141             m_floats->append(floatingBox);
142         else
143             m_floats= adoptPtr(new Vector<RenderBox*>(1, floatingBox));
144     }
145
146     Vector<RenderBox*>* floatsPtr() { ASSERT(!isDirty()); return m_floats.get(); }
147
148     virtual void extractLineBoxFromRenderObject();
149     virtual void attachLineBoxToRenderObject();
150     virtual void removeLineBoxFromRenderObject();
151     
152     FontBaseline baselineType() const { return static_cast<FontBaseline>(m_baselineType); }
153
154     bool hasAnnotationsBefore() const { return m_hasAnnotationsBefore; }
155     bool hasAnnotationsAfter() const { return m_hasAnnotationsAfter; }
156
157     LayoutRect paddedLayoutOverflowRect(LayoutUnit endPadding) const;
158
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;
167     
168     LayoutUnit logicalTopVisualOverflow() const
169     {
170         return InlineFlowBox::logicalTopVisualOverflow(lineTop());
171     }
172     LayoutUnit logicalBottomVisualOverflow() const
173     {
174         return InlineFlowBox::logicalBottomVisualOverflow(lineBottom());
175     }
176     LayoutUnit logicalTopLayoutOverflow() const
177     {
178         return InlineFlowBox::logicalTopLayoutOverflow(lineTop());
179     }
180     LayoutUnit logicalBottomLayoutOverflow() const
181     {
182         return InlineFlowBox::logicalBottomLayoutOverflow(lineBottom());
183     }
184
185     Node* getLogicalStartBoxWithNode(InlineBox*&) const;
186     Node* getLogicalEndBoxWithNode(InlineBox*&) const;
187
188 #ifndef NDEBUG
189     virtual const char* boxName() const;
190 #endif
191 private:
192     LayoutUnit lineSnapAdjustment(LayoutUnit delta = 0) const;
193
194     LayoutUnit beforeAnnotationsAdjustment() const;
195
196     // This folds into the padding at the end of InlineFlowBox on 64-bit.
197     unsigned m_lineBreakPos;
198
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;
203
204     LayoutUnit m_lineTop;
205     LayoutUnit m_lineBottom;
206
207     LayoutUnit m_lineTopWithLeading;
208     LayoutUnit m_lineBottomWithLeading;
209
210     LayoutUnit m_paginationStrut;
211     LayoutUnit m_paginatedLineWidth;
212
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;
216 };
217
218 } // namespace WebCore
219
220 #endif // RootInlineBox_h