Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderInline.h
1 /*
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.
5  *
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.
10  *
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.
15  *
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.
20  *
21  */
22
23 #ifndef RenderInline_h
24 #define RenderInline_h
25
26 #include "core/editing/PositionWithAffinity.h"
27 #include "core/rendering/InlineFlowBox.h"
28 #include "core/rendering/RenderBoxModelObject.h"
29 #include "core/rendering/RenderLineBoxList.h"
30
31 namespace blink {
32
33 class RenderInline : public RenderBoxModelObject {
34 public:
35     explicit RenderInline(Element*);
36     virtual void trace(Visitor*) override;
37
38     static RenderInline* createAnonymous(Document*);
39
40     RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
41     RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
42
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;
46
47     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) override;
48
49     Element* node() const { return toElement(RenderBoxModelObject::node()); }
50
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;
59
60     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override final;
61     virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
62
63     virtual LayoutSize offsetFromContainer(const RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const override final;
64
65     IntRect linesBoundingBox() const;
66     LayoutRect linesVisualOverflowBoundingBox() const;
67
68     InlineFlowBox* createAndAppendInlineFlowBox();
69
70     void dirtyLineBoxes(bool fullLayout);
71
72     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
73     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
74
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(); }
79
80     virtual RenderBoxModelObject* virtualContinuation() const override final { return continuation(); }
81     RenderInline* inlineElementContinuation() const;
82
83     virtual void updateDragState(bool dragOn) override final;
84
85     LayoutSize offsetForInFlowPositionedInline(const RenderBox& child) const;
86
87     virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer) const override final;
88
89     using RenderBoxModelObject::continuation;
90     using RenderBoxModelObject::setContinuation;
91
92     bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); }
93     void setAlwaysCreateLineBoxes(bool alwaysCreateLineBoxes = true) { setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxes); }
94     void updateAlwaysCreateLineBoxes(bool fullLayout);
95
96     virtual LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) override final;
97
98     bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
99
100 protected:
101     virtual void willBeDestroyed() override;
102
103     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
104
105     virtual void computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutPoint& layerOffset) const override;
106
107 private:
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; }
112
113     virtual const char* renderName() const override;
114
115     virtual bool isRenderInline() const override final { return true; }
116
117     LayoutRect culledInlineVisualOverflowBoundingBox() const;
118     InlineBox* culledInlineFirstLineBox() const;
119     InlineBox* culledInlineLastLineBox() const;
120
121     template<typename GeneratorContext>
122     void generateLineBoxRects(GeneratorContext& yield) const;
123     template<typename GeneratorContext>
124     void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
125
126     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
127     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) override final;
128
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);
133
134     virtual void layout() override final { ASSERT_NOT_REACHED(); } // Do nothing for layout()
135
136     virtual void paint(PaintInfo&, const LayoutPoint&) override final;
137
138     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override final;
139
140     virtual LayerType layerTypeRequired() const override { return isRelPositioned() || createsGroup() || hasClipPath() || style()->shouldCompositeForCurrentAnimations() ? NormalLayer : NoLayer; }
141
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(); }
146
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;
150
151     virtual void mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const override;
152
153     virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override final;
154
155     virtual IntRect borderBoundingBox() const override final
156     {
157         IntRect boundingBox = linesBoundingBox();
158         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
159     }
160
161     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
162
163     virtual void dirtyLinesFromChangedChild(RenderObject* child) override final { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
164
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;
167
168     virtual void childBecameNonInline(RenderObject* child) override final;
169
170     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override final;
171
172     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) override final;
173
174     virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&) override final;
175
176     virtual void updateFromStyle() override final;
177
178     RenderInline* clone() const;
179
180     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
181
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.
184 };
185
186 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderInline, isRenderInline());
187
188 } // namespace blink
189
190 #endif // RenderInline_h