• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "RenderBoxModelObject.h"
27 #include "RenderLineBoxList.h"
28 
29 namespace WebCore {
30 
31 class Position;
32 
33 class RenderInline : public RenderBoxModelObject {
34 public:
35     RenderInline(Node*);
36 
37     virtual void destroy();
38 
39     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
40 
41     virtual int marginLeft() const;
42     virtual int marginRight() const;
43 
44     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
45     virtual void absoluteQuads(Vector<FloatQuad>&);
46 
47     IntRect linesBoundingBox() const;
48 
49     InlineFlowBox* createAndAppendInlineFlowBox();
50 
51     void dirtyLineBoxes(bool fullLayout);
52 
lineBoxes()53     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
lineBoxes()54     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
55 
firstLineBox()56     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
lastLineBox()57     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
58 
continuation()59     RenderBoxModelObject* continuation() const { return m_continuation; }
60 
61     virtual void updateDragState(bool dragOn);
62 
63     IntSize relativePositionedInlineOffset(const RenderBox* child) const;
64 
65     virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
66     void paintOutline(GraphicsContext*, int tx, int ty);
67 
68     int verticalPositionFromCache(bool firstLine) const;
invalidateVerticalPosition()69     void invalidateVerticalPosition() { m_verticalPosition = PositionUndefined; }
70 
71 private:
virtualChildren()72     virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()73     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
children()74     const RenderObjectChildList* children() const { return &m_children; }
children()75     RenderObjectChildList* children() { return &m_children; }
76 
77     virtual const char* renderName() const;
78 
isRenderInline()79     virtual bool isRenderInline() const { return true; }
80 
81     void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
82     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0);
83 
84     void splitInlines(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
85                       RenderObject* beforeChild, RenderBoxModelObject* oldCont);
86     void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
87                    RenderObject* newChild, RenderBoxModelObject* oldCont);
88 
layout()89     virtual void layout() { ASSERT_NOT_REACHED(); } // Do nothing for layout()
90 
91     virtual void paint(PaintInfo&, int tx, int ty);
92 
93     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
94 
requiresLayer()95     virtual bool requiresLayer() const { return isRelPositioned() || isTransparent() || hasMask(); }
96 
97     virtual int offsetLeft() const;
98     virtual int offsetTop() const;
offsetWidth()99     virtual int offsetWidth() const { return linesBoundingBox().width(); }
offsetHeight()100     virtual int offsetHeight() const { return linesBoundingBox().height(); }
101 
102     // Just ignore top/bottom margins on RenderInlines.
marginTop()103     virtual int marginTop() const { return 0; }
marginBottom()104     virtual int marginBottom() const { return 0; }
105     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
106     virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
107     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& rect, bool fixed);
108 
109     virtual VisiblePosition positionForPoint(const IntPoint&);
110 
borderBoundingBox()111     virtual IntRect borderBoundingBox() const
112     {
113         IntRect boundingBox = linesBoundingBox();
114         return IntRect(0, 0, boundingBox.width(), boundingBox.height());
115     }
116 
117     virtual InlineFlowBox* createInlineFlowBox(); // Subclassed by SVG and Ruby
118 
dirtyLinesFromChangedChild(RenderObject * child)119     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
120 
121     virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
122 
123     RenderInline* inlineContinuation() const;
setContinuation(RenderBoxModelObject * c)124     void setContinuation(RenderBoxModelObject* c) { m_continuation = c; }
125 
126     virtual void childBecameNonInline(RenderObject* child);
127 
128     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
129 
130     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
131 
132 #if ENABLE(DASHBOARD_SUPPORT)
133     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
134 #endif
135 
136     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
137     virtual void updateBoxModelInfoFromStyle();
138 
139     static RenderInline* cloneInline(RenderInline* src);
140 
141     void paintOutlineForLine(GraphicsContext*, int tx, int ty, const IntRect& prevLine, const IntRect& thisLine, const IntRect& nextLine);
142     RenderBoxModelObject* continuationBefore(RenderObject* beforeChild);
143 
144     RenderObjectChildList m_children;
145     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.
146 
147     RenderBoxModelObject* m_continuation; // Can be either a block or an inline. <b><i><p>Hello</p></i></b>. In this example the <i> will have a block as its continuation but the
148                                           // <b> will just have an inline as its continuation.
149     mutable int m_lineHeight;
150     mutable int m_verticalPosition;
151 };
152 
toRenderInline(RenderObject * object)153 inline RenderInline* toRenderInline(RenderObject* object)
154 {
155     ASSERT(!object || object->isRenderInline());
156     return static_cast<RenderInline*>(object);
157 }
158 
toRenderInline(const RenderObject * object)159 inline const RenderInline* toRenderInline(const RenderObject* object)
160 {
161     ASSERT(!object || object->isRenderInline());
162     return static_cast<const RenderInline*>(object);
163 }
164 
165 // This will catch anyone doing an unnecessary cast.
166 void toRenderInline(const RenderInline*);
167 
168 } // namespace WebCore
169 
170 #endif // RenderInline_h
171