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 "core/editing/PositionWithAffinity.h"
27 #include "core/rendering/InlineFlowBox.h"
28 #include "core/rendering/RenderBoxModelObject.h"
29 #include "core/rendering/RenderLineBoxList.h"
33 class RenderInline : public RenderBoxModelObject {
35 explicit RenderInline(Element*);
36 virtual void trace(Visitor*) OVERRIDE;
38 static RenderInline* createAnonymous(Document*);
40 RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
41 RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
43 // If you have a RenderInline, use firstChild or lastChild instead.
44 void slowFirstChild() const WTF_DELETED_FUNCTION;
45 void slowLastChild() const WTF_DELETED_FUNCTION;
47 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE;
49 Element* node() const { return toElement(RenderBoxModelObject::node()); }
51 virtual LayoutUnit marginLeft() const OVERRIDE FINAL;
52 virtual LayoutUnit marginRight() const OVERRIDE FINAL;
53 virtual LayoutUnit marginTop() const OVERRIDE FINAL;
54 virtual LayoutUnit marginBottom() const OVERRIDE FINAL;
55 virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL;
56 virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL;
57 virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL;
58 virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const OVERRIDE FINAL;
60 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const OVERRIDE FINAL;
61 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const OVERRIDE;
63 virtual LayoutSize offsetFromContainer(const RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const OVERRIDE FINAL;
65 IntRect linesBoundingBox() const;
66 LayoutRect linesVisualOverflowBoundingBox() const;
68 InlineFlowBox* createAndAppendInlineFlowBox();
70 void dirtyLineBoxes(bool fullLayout);
71 void deleteLineBoxTree();
73 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
74 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
76 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
77 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
78 InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
79 InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
81 virtual RenderBoxModelObject* virtualContinuation() const OVERRIDE FINAL { return continuation(); }
82 RenderInline* inlineElementContinuation() const;
84 virtual void updateDragState(bool dragOn) OVERRIDE FINAL;
86 LayoutSize offsetForInFlowPositionedInline(const RenderBox& child) const;
88 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) const OVERRIDE FINAL;
89 void paintOutline(PaintInfo&, const LayoutPoint&);
91 using RenderBoxModelObject::continuation;
92 using RenderBoxModelObject::setContinuation;
94 bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); }
95 void setAlwaysCreateLineBoxes(bool alwaysCreateLineBoxes = true) { setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes); }
96 void updateAlwaysCreateLineBoxes(bool fullLayout);
98 virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) OVERRIDE FINAL;
100 bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
103 virtual void willBeDestroyed() OVERRIDE;
105 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
107 virtual void computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const OVERRIDE;
110 virtual RenderObjectChildList* virtualChildren() OVERRIDE FINAL { return children(); }
111 virtual const RenderObjectChildList* virtualChildren() const OVERRIDE FINAL { return children(); }
112 const RenderObjectChildList* children() const { return &m_children; }
113 RenderObjectChildList* children() { return &m_children; }
115 virtual const char* renderName() const OVERRIDE;
117 virtual bool isRenderInline() const OVERRIDE FINAL { return true; }
119 LayoutRect culledInlineVisualOverflowBoundingBox() const;
120 InlineBox* culledInlineFirstLineBox() const;
121 InlineBox* culledInlineLastLineBox() const;
123 template<typename GeneratorContext>
124 void generateLineBoxRects(GeneratorContext& yield) const;
125 template<typename GeneratorContext>
126 void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
128 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
129 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) OVERRIDE FINAL;
131 void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
132 RenderObject* beforeChild, RenderBoxModelObject* oldCont);
133 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
134 RenderObject* newChild, RenderBoxModelObject* oldCont);
136 virtual void layout() OVERRIDE FINAL { ASSERT_NOT_REACHED(); } // Do nothing for layout()
138 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL;
140 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE FINAL;
142 virtual LayerType layerTypeRequired() const OVERRIDE { return isRelPositioned() || createsGroup() || hasClipPath() || style()->shouldCompositeForCurrentAnimations() ? NormalLayer : NoLayer; }
144 virtual LayoutUnit offsetLeft() const OVERRIDE FINAL;
145 virtual LayoutUnit offsetTop() const OVERRIDE FINAL;
146 virtual LayoutUnit offsetWidth() const OVERRIDE FINAL { return linesBoundingBox().width(); }
147 virtual LayoutUnit offsetHeight() const OVERRIDE FINAL { return linesBoundingBox().height(); }
149 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const OVERRIDE;
150 virtual LayoutRect rectWithOutlineForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalidationState* = 0) const OVERRIDE FINAL;
151 virtual void mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect&, ViewportConstrainedPosition, const PaintInvalidationState*) const OVERRIDE FINAL;
153 virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const OVERRIDE;
155 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) OVERRIDE FINAL;
157 virtual IntRect borderBoundingBox() const OVERRIDE FINAL
159 IntRect boundingBox = linesBoundingBox();
160 return IntRect(0, 0, boundingBox.width(), boundingBox.height());
163 virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
165 virtual void dirtyLinesFromChangedChild(RenderObject* child) OVERRIDE FINAL { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
167 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL;
168 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE FINAL;
170 virtual void childBecameNonInline(RenderObject* child) OVERRIDE FINAL;
172 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) OVERRIDE FINAL;
174 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE FINAL;
176 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&) OVERRIDE FINAL;
178 virtual void updateFromStyle() OVERRIDE FINAL;
180 RenderInline* clone() const;
182 void paintOutlineForLine(GraphicsContext*, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
183 const LayoutRect& nextLine, const Color);
184 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
186 RenderObjectChildList m_children;
187 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.
190 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline());
194 #endif // RenderInline_h