initial import
[vuplus_webkit] / 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;
45     virtual LayoutUnit marginAfter() const;
46     virtual LayoutUnit marginStart() const;
47     virtual LayoutUnit marginEnd() const;
48
49     virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
50     virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed);
51
52     virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const;
53
54     LayoutRect linesBoundingBox() const;
55     LayoutRect linesVisualOverflowBoundingBox() const;
56
57     InlineFlowBox* createAndAppendInlineFlowBox();
58
59     void dirtyLineBoxes(bool fullLayout);
60
61     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
62     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
63
64     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
65     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
66     InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
67     InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
68
69     virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
70     RenderInline* inlineElementContinuation() const;
71
72     virtual void updateDragState(bool dragOn);
73     
74     LayoutSize relativePositionedInlineOffset(const RenderBox* child) const;
75
76     virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
77     void paintOutline(GraphicsContext*, const LayoutPoint&);
78
79     using RenderBoxModelObject::continuation;
80     using RenderBoxModelObject::setContinuation;
81
82     bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; }
83     void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; }
84     void updateAlwaysCreateLineBoxes(bool fullLayout);
85
86 protected:
87     virtual void willBeDestroyed();
88
89     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
90
91 private:
92     virtual RenderObjectChildList* virtualChildren() { return children(); }
93     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
94     const RenderObjectChildList* children() const { return &m_children; }
95     RenderObjectChildList* children() { return &m_children; }
96
97     virtual const char* renderName() const;
98
99     virtual bool isRenderInline() const { return true; }
100
101     FloatRect culledInlineBoundingBox(const RenderInline* container) const;
102     LayoutRect culledInlineVisualOverflowBoundingBox() const;
103     InlineBox* culledInlineFirstLineBox() const;
104     InlineBox* culledInlineLastLineBox() const;
105     void culledInlineAbsoluteRects(const RenderInline* container, Vector<LayoutRect>&, const LayoutSize&);
106     void culledInlineAbsoluteQuads(const RenderInline* container, Vector<FloatQuad>&);
107
108     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
109     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
110
111     void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
112                       RenderObject* beforeChild, RenderBoxModelObject* oldCont);
113     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
114                    RenderObject* newChild, RenderBoxModelObject* oldCont);
115
116     virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
117
118     virtual void paint(PaintInfo&, const LayoutPoint&);
119
120     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
121
122     virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
123
124     virtual LayoutUnit offsetLeft() const;
125     virtual LayoutUnit offsetTop() const;
126     virtual LayoutUnit offsetWidth() const { return linesBoundingBox().width(); }
127     virtual LayoutUnit offsetHeight() const { return linesBoundingBox().height(); }
128
129     virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
130     virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
131     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed) const;
132
133     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed, bool useTransforms, TransformState&, bool* wasFixed = 0) const;
134     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
135
136     virtual VisiblePosition positionForPoint(const LayoutPoint&);
137
138     virtual LayoutRect borderBoundingBox() const
139     {
140         LayoutRect boundingBox = linesBoundingBox();
141         return LayoutRect(0, 0, boundingBox.width(), boundingBox.height());
142     }
143
144     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
145
146     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
147
148     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
149     virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
150     
151     virtual void childBecameNonInline(RenderObject* child);
152
153     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
154
155     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
156
157 #if ENABLE(DASHBOARD_SUPPORT)
158     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
159 #endif
160     
161     virtual void updateBoxModelInfoFromStyle();
162     
163     static RenderInline* cloneInline(RenderInline* src);
164
165     void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
166                              const LayoutRect& nextLine, const Color);
167     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
168
169     RenderObjectChildList m_children;
170     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.
171
172     mutable LayoutUnit m_lineHeight;
173     bool m_alwaysCreateLineBoxes : 1;
174 };
175
176 inline RenderInline* toRenderInline(RenderObject* object)
177
178     ASSERT(!object || object->isRenderInline());
179     return static_cast<RenderInline*>(object);
180 }
181
182 inline const RenderInline* toRenderInline(const RenderObject* object)
183
184     ASSERT(!object || object->isRenderInline());
185     return static_cast<const RenderInline*>(object);
186 }
187
188 // This will catch anyone doing an unnecessary cast.
189 void toRenderInline(const RenderInline*);
190
191 } // namespace WebCore
192
193 #endif // RenderInline_h