Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RenderInline.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, 2008, 2009 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 RenderInline_h
24 #define RenderInline_h
25
26 #include "InlineFlowBox.h"
27 #include "RenderBoxModelObject.h"
28 #include "RenderLineBoxList.h"
29
30 namespace WebCore {
31
32 class Position;
33
34 class RenderInline : public RenderBoxModelObject {
35 public:
36     explicit RenderInline(Node*);
37
38     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
39
40     virtual LayoutUnit marginLeft() const;
41     virtual LayoutUnit marginRight() const;
42     virtual LayoutUnit marginTop() const;
43     virtual LayoutUnit marginBottom() const;
44     virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const;
45     virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const;
46     virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const;
47     virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const;
48
49     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
50     virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const;
51
52     virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
53
54     IntRect linesBoundingBox() const;
55     LayoutRect linesVisualOverflowBoundingBox() const;
56
57     InlineFlowBox* createAndAppendInlineFlowBox();
58
59     void dirtyLineBoxes(bool fullLayout);
60     void deleteLineBoxTree();
61
62     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
63     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
64
65     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
66     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
67     InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
68     InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
69
70     virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
71     RenderInline* inlineElementContinuation() const;
72
73     virtual void updateDragState(bool dragOn);
74     
75     LayoutSize relativePositionedInlineOffset(const RenderBox* child) const;
76
77     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
78     void paintOutline(GraphicsContext*, const LayoutPoint&);
79
80     using RenderBoxModelObject::continuation;
81     using RenderBoxModelObject::setContinuation;
82
83     bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; }
84     void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; }
85     void updateAlwaysCreateLineBoxes(bool fullLayout);
86
87     virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) OVERRIDE;
88
89 protected:
90     virtual void willBeDestroyed();
91
92     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
93
94 private:
95     virtual RenderObjectChildList* virtualChildren() { return children(); }
96     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
97     const RenderObjectChildList* children() const { return &m_children; }
98     RenderObjectChildList* children() { return &m_children; }
99
100     virtual const char* renderName() const;
101
102     virtual bool isRenderInline() const { return true; }
103
104     LayoutRect culledInlineVisualOverflowBoundingBox() const;
105     InlineBox* culledInlineFirstLineBox() const;
106     InlineBox* culledInlineLastLineBox() const;
107
108     template<typename GeneratorContext>
109     void generateLineBoxRects(GeneratorContext& yield) const;
110     template<typename GeneratorContext>
111     void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
112
113     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
114     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
115
116     void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
117                       RenderObject* beforeChild, RenderBoxModelObject* oldCont);
118     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
119                    RenderObject* newChild, RenderBoxModelObject* oldCont);
120
121     virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
122
123     virtual void paint(PaintInfo&, const LayoutPoint&);
124
125     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
126
127     virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasClipPath() || hasMask() || hasFilter(); }
128
129     virtual LayoutUnit offsetLeft() const;
130     virtual LayoutUnit offsetTop() const;
131     virtual LayoutUnit offsetWidth() const { return linesBoundingBox().width(); }
132     virtual LayoutUnit offsetHeight() const { return linesBoundingBox().height(); }
133
134     virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
135     virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
136     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed) const;
137
138     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&, ApplyContainerFlipOrNot = ApplyContainerFlip, bool* wasFixed = 0) const;
139     virtual const RenderObject* pushMappingToContainer(const RenderBoxModelObject* ancestorToStopAt, RenderGeometryMap&) const;
140
141     virtual VisiblePosition positionForPoint(const LayoutPoint&);
142
143     virtual IntRect borderBoundingBox() const
144     {
145         IntRect boundingBox = linesBoundingBox();
146         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
147     }
148
149     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
150
151     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
152
153     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
154     virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
155     
156     virtual void childBecameNonInline(RenderObject* child);
157
158     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
159
160     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
161
162 #if ENABLE(DASHBOARD_SUPPORT)
163     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
164 #endif
165     
166     virtual void updateBoxModelInfoFromStyle();
167     
168     static RenderInline* cloneInline(RenderInline* src);
169
170     void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
171                              const LayoutRect& nextLine, const Color);
172     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
173
174     RenderObjectChildList m_children;
175     RenderLineBoxList m_lineBoxes;   // All of the line boxes created for this inline flow.  For example, <i>Hello<br>world.</i> will have two <i> line boxes.
176
177     bool m_alwaysCreateLineBoxes : 1;
178 };
179
180 inline RenderInline* toRenderInline(RenderObject* object)
181
182     ASSERT(!object || object->isRenderInline());
183     return static_cast<RenderInline*>(object);
184 }
185
186 inline const RenderInline* toRenderInline(const RenderObject* object)
187
188     ASSERT(!object || object->isRenderInline());
189     return static_cast<const RenderInline*>(object);
190 }
191
192 // This will catch anyone doing an unnecessary cast.
193 void toRenderInline(const RenderInline*);
194
195 } // namespace WebCore
196
197 #endif // RenderInline_h