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 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;
49 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
50 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const;
52 virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
54 IntRect linesBoundingBox() const;
55 LayoutRect linesVisualOverflowBoundingBox() const;
57 InlineFlowBox* createAndAppendInlineFlowBox();
59 void dirtyLineBoxes(bool fullLayout);
60 void deleteLineBoxTree();
62 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
63 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
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(); }
70 virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
71 RenderInline* inlineElementContinuation() const;
73 virtual void updateDragState(bool dragOn);
75 LayoutSize relativePositionedInlineOffset(const RenderBox* child) const;
77 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&);
78 void paintOutline(GraphicsContext*, const LayoutPoint&);
80 using RenderBoxModelObject::continuation;
81 using RenderBoxModelObject::setContinuation;
83 bool alwaysCreateLineBoxes() const { return m_alwaysCreateLineBoxes; }
84 void setAlwaysCreateLineBoxes() { m_alwaysCreateLineBoxes = true; }
85 void updateAlwaysCreateLineBoxes(bool fullLayout);
87 virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) OVERRIDE;
90 virtual void willBeDestroyed();
92 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
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; }
100 virtual const char* renderName() const;
102 virtual bool isRenderInline() const { return true; }
104 LayoutRect culledInlineVisualOverflowBoundingBox() const;
105 InlineBox* culledInlineFirstLineBox() const;
106 InlineBox* culledInlineLastLineBox() const;
108 template<typename GeneratorContext>
109 void generateLineBoxRects(GeneratorContext& yield) const;
110 template<typename GeneratorContext>
111 void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
113 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
114 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
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);
121 virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
123 virtual void paint(PaintInfo&, const LayoutPoint&);
125 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
127 virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasClipPath() || hasMask() || hasFilter(); }
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(); }
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;
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;
141 virtual VisiblePosition positionForPoint(const LayoutPoint&);
143 virtual IntRect borderBoundingBox() const
145 IntRect boundingBox = linesBoundingBox();
146 return IntRect(0, 0, boundingBox.width(), boundingBox.height());
149 virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
151 virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
153 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
154 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
156 virtual void childBecameNonInline(RenderObject* child);
158 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
160 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
162 #if ENABLE(DASHBOARD_SUPPORT)
163 virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
166 virtual void updateBoxModelInfoFromStyle();
168 static RenderInline* cloneInline(RenderInline* src);
170 void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
171 const LayoutRect& nextLine, const Color);
172 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
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.
177 bool m_alwaysCreateLineBoxes : 1;
180 inline RenderInline* toRenderInline(RenderObject* object)
182 ASSERT(!object || object->isRenderInline());
183 return static_cast<RenderInline*>(object);
186 inline const RenderInline* toRenderInline(const RenderObject* object)
188 ASSERT(!object || object->isRenderInline());
189 return static_cast<const RenderInline*>(object);
192 // This will catch anyone doing an unnecessary cast.
193 void toRenderInline(const RenderInline*);
195 } // namespace WebCore
197 #endif // RenderInline_h