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);
72 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
73 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
75 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
76 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
77 InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
78 InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
80 virtual RenderBoxModelObject* virtualContinuation() const override final { return continuation(); }
81 RenderInline* inlineElementContinuation() const;
83 virtual void updateDragState(bool dragOn) override final;
85 LayoutSize offsetForInFlowPositionedInline(const RenderBox& child) const;
87 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const override final;
89 using RenderBoxModelObject::continuation;
90 using RenderBoxModelObject::setContinuation;
92 bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); }
93 void setAlwaysCreateLineBoxes(bool alwaysCreateLineBoxes = true) { setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes); }
94 void updateAlwaysCreateLineBoxes(bool fullLayout);
96 virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) override final;
98 bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
101 virtual void willBeDestroyed() override;
103 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
105 virtual void computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const override;
108 virtual RenderObjectChildList* virtualChildren() override final { return children(); }
109 virtual const RenderObjectChildList* virtualChildren() const override final { return children(); }
110 const RenderObjectChildList* children() const { return &m_children; }
111 RenderObjectChildList* children() { return &m_children; }
113 virtual const char* renderName() const override;
115 virtual bool isRenderInline() const override final { return true; }
117 LayoutRect culledInlineVisualOverflowBoundingBox() const;
118 InlineBox* culledInlineFirstLineBox() const;
119 InlineBox* culledInlineLastLineBox() const;
121 template<typename GeneratorContext>
122 void generateLineBoxRects(GeneratorContext& yield) const;
123 template<typename GeneratorContext>
124 void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
126 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
127 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) override final;
129 void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
130 RenderObject* beforeChild, RenderBoxModelObject* oldCont);
131 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
132 RenderObject* newChild, RenderBoxModelObject* oldCont);
134 virtual void layout() override final { ASSERT_NOT_REACHED(); } // Do nothing for layout()
136 virtual void paint(PaintInfo&, const LayoutPoint&) override final;
138 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override final;
140 virtual LayerType layerTypeRequired() const override { return isRelPositioned() || createsGroup() || hasClipPath() || style()->shouldCompositeForCurrentAnimations() ? NormalLayer : NoLayer; }
142 virtual LayoutUnit offsetLeft() const override final;
143 virtual LayoutUnit offsetTop() const override final;
144 virtual LayoutUnit offsetWidth() const override final { return linesBoundingBox().width(); }
145 virtual LayoutUnit offsetHeight() const override final { return linesBoundingBox().height(); }
147 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const override;
148 virtual LayoutRect rectWithOutlineForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalidationState* = 0) const override final;
149 virtual void mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const override final;
151 virtual void mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const override;
153 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override final;
155 virtual IntRect borderBoundingBox() const override final
157 IntRect boundingBox = linesBoundingBox();
158 return IntRect(0, 0, boundingBox.width(), boundingBox.height());
161 virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
163 virtual void dirtyLinesFromChangedChild(RenderObject* child) override final { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
165 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
166 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override final;
168 virtual void childBecameNonInline(RenderObject* child) override final;
170 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override final;
172 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) override final;
174 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&) override final;
176 virtual void updateFromStyle() override final;
178 RenderInline* clone() const;
180 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
182 RenderObjectChildList m_children;
183 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.
186 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline());
190 #endif // RenderInline_h