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.
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.
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.
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.
23 #ifndef RenderInline_h
24 #define RenderInline_h
26 #include "InlineFlowBox.h"
27 #include "RenderBoxModelObject.h"
28 #include "RenderLineBoxList.h"
34 class RenderInline : public RenderBoxModelObject {
36 explicit RenderInline(Node*);
38 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
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;
49 virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
50 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed);
52 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&) const;
54 LayoutRect linesBoundingBox() const;
55 LayoutRect linesVisualOverflowBoundingBox() const;
57 InlineFlowBox* createAndAppendInlineFlowBox();
59 void dirtyLineBoxes(bool fullLayout);
61 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
62 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
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(); }
69 virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
70 RenderInline* inlineElementContinuation() const;
72 virtual void updateDragState(bool dragOn);
74 LayoutSize relativePositionedInlineOffset(const RenderBox* child) const;
76 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
77 void paintOutline(GraphicsContext*, const LayoutPoint&);
79 using RenderBoxModelObject::continuation;
80 using RenderBoxModelObject::setContinuation;
82 bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; }
83 void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; }
84 void updateAlwaysCreateLineBoxes(bool fullLayout);
87 virtual void willBeDestroyed();
89 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
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; }
97 virtual const char* renderName() const;
99 virtual bool isRenderInline() const { return true; }
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>&);
108 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
109 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
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);
116 virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
118 virtual void paint(PaintInfo&, const LayoutPoint&);
120 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
122 virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
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(); }
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;
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;
136 virtual VisiblePosition positionForPoint(const LayoutPoint&);
138 virtual LayoutRect borderBoundingBox() const
140 LayoutRect boundingBox = linesBoundingBox();
141 return LayoutRect(0, 0, boundingBox.width(), boundingBox.height());
144 virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
146 virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
148 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
149 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
151 virtual void childBecameNonInline(RenderObject* child);
153 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
155 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
157 #if ENABLE(DASHBOARD_SUPPORT)
158 virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
161 virtual void updateBoxModelInfoFromStyle();
163 static RenderInline* cloneInline(RenderInline* src);
165 void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
166 const LayoutRect& nextLine, const Color);
167 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
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.
172 mutable LayoutUnit m_lineHeight;
173 bool m_alwaysCreateLineBoxes : 1;
176 inline RenderInline* toRenderInline(RenderObject* object)
178 ASSERT(!object || object->isRenderInline());
179 return static_cast<RenderInline*>(object);
182 inline const RenderInline* toRenderInline(const RenderObject* object)
184 ASSERT(!object || object->isRenderInline());
185 return static_cast<const RenderInline*>(object);
188 // This will catch anyone doing an unnecessary cast.
189 void toRenderInline(const RenderInline*);
191 } // namespace WebCore
193 #endif // RenderInline_h