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"
35 class RenderInline : public RenderBoxModelObject {
37 RenderInline(Element&, RenderStyle&&);
38 RenderInline(Document&, RenderStyle&&);
40 void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
42 LayoutUnit marginLeft() const final;
43 LayoutUnit marginRight() const final;
44 LayoutUnit marginTop() const final;
45 LayoutUnit marginBottom() const final;
46 LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const final;
47 LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const final;
48 LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const final;
49 LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const final;
51 void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const final;
52 void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
54 LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const final;
56 LayoutRect borderBoundingBox() const final
58 return LayoutRect(LayoutPoint(), linesBoundingBox().size());
61 WEBCORE_EXPORT IntRect linesBoundingBox() const;
62 LayoutRect linesVisualOverflowBoundingBox() const;
63 LayoutRect linesVisualOverflowBoundingBoxInRegion(const RenderRegion*) const;
65 InlineFlowBox* createAndAppendInlineFlowBox();
67 void dirtyLineBoxes(bool fullLayout);
70 RenderLineBoxList& lineBoxes() { return m_lineBoxes; }
71 const RenderLineBoxList& lineBoxes() const { return m_lineBoxes; }
73 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
74 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
75 InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
76 InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
79 void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const override;
82 RenderBoxModelObject* virtualContinuation() const final { return continuation(); }
83 RenderInline* inlineElementContinuation() const;
85 void updateDragState(bool dragOn) final;
87 LayoutSize offsetForInFlowPositionedInline(const RenderBox* child) const;
89 void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;
90 void paintOutline(PaintInfo&, const LayoutPoint&);
92 using RenderBoxModelObject::continuation;
93 using RenderBoxModelObject::setContinuation;
95 bool alwaysCreateLineBoxes() const { return renderInlineAlwaysCreatesLineBoxes(); }
96 void setAlwaysCreateLineBoxes() { setRenderInlineAlwaysCreatesLineBoxes(true); }
97 void updateAlwaysCreateLineBoxes(bool fullLayout);
99 LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) final;
101 bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
104 void willBeDestroyed() override;
106 void styleWillChange(StyleDifference, const RenderStyle& newStyle) override;
107 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
109 void updateFromStyle() override;
112 const char* renderName() const override;
114 bool canHaveChildren() const final { return true; }
116 LayoutRect culledInlineVisualOverflowBoundingBox() const;
117 InlineBox* culledInlineFirstLineBox() const;
118 InlineBox* culledInlineLastLineBox() const;
120 template<typename GeneratorContext>
121 void generateLineBoxRects(GeneratorContext& yield) const;
122 template<typename GeneratorContext>
123 void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
125 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
126 void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = nullptr) final;
128 void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
129 RenderObject* beforeChild, RenderBoxModelObject* oldCont);
130 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
131 RenderObject* newChild, RenderBoxModelObject* oldCont);
133 void layout() final { ASSERT_NOT_REACHED(); } // Do nothing for layout()
135 void paint(PaintInfo&, const LayoutPoint&) final;
137 bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
139 bool requiresLayer() const override { return isInFlowPositioned() || createsGroup() || hasClipPath() || willChangeCreatesStackingContext(); }
141 LayoutUnit offsetLeft() const final;
142 LayoutUnit offsetTop() const final;
143 LayoutUnit offsetWidth() const final { return linesBoundingBox().width(); }
144 LayoutUnit offsetHeight() const final { return linesBoundingBox().height(); }
146 LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override;
147 LayoutRect rectWithOutlineForRepaint(const RenderLayerModelObject* repaintContainer, LayoutUnit outlineWidth) const final;
148 LayoutRect computeRectForRepaint(const LayoutRect&, const RenderLayerModelObject* repaintContainer, RepaintContext = { false, false }) const final;
150 void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override;
151 const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
153 VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) final;
155 LayoutRect frameRectForStickyPositioning() const final { return linesBoundingBox(); }
157 virtual std::unique_ptr<InlineFlowBox> createInlineFlowBox(); // Subclassed by RenderSVGInline
159 void dirtyLinesFromChangedChild(RenderObject& child) final { m_lineBoxes.dirtyLinesFromChangedChild(*this, child); }
161 LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
162 int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const final;
164 void childBecameNonInline(RenderElement&) final;
166 void updateHitTestResult(HitTestResult&, const LayoutPoint&) final;
168 void imageChanged(WrappedImagePtr, const IntRect* = 0) final;
170 #if ENABLE(DASHBOARD_SUPPORT)
171 void addAnnotatedRegions(Vector<AnnotatedRegionValue>&) final;
174 RenderPtr<RenderInline> clone() const;
176 void paintOutlineForLine(GraphicsContext&, const LayoutPoint&, const LayoutRect& prevLine, const LayoutRect& thisLine,
177 const LayoutRect& nextLine, const Color);
178 RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
180 bool willChangeCreatesStackingContext() const
182 return style().willChange() && style().willChange()->canCreateStackingContext();
185 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.
188 } // namespace WebCore
190 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderInline, isRenderInline())
192 #endif // RenderInline_h