• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef InlineFlowBox_h
22 #define InlineFlowBox_h
23 
24 #include "InlineRunBox.h"
25 
26 namespace WebCore {
27 
28 class HitTestRequest;
29 class HitTestResult;
30 class RenderLineBoxList;
31 
32 class InlineFlowBox : public InlineRunBox {
33 public:
InlineFlowBox(RenderObject * obj)34     InlineFlowBox(RenderObject* obj)
35         : InlineRunBox(obj)
36         , m_firstChild(0)
37         , m_lastChild(0)
38         , m_maxHorizontalVisualOverflow(0)
39         , m_includeLeftEdge(false)
40         , m_includeRightEdge(false)
41         , m_hasTextChildren(true)
42 #ifndef NDEBUG
43         , m_hasBadChildList(false)
44 #endif
45     {
46         // Internet Explorer and Firefox always create a marker for list items, even when the list-style-type is none.  We do not make a marker
47         // in the list-style-type: none case, since it is wasteful to do so.  However, in order to match other browsers we have to pretend like
48         // an invisible marker exists.  The side effect of having an invisible marker is that the quirks mode behavior of shrinking lines with no
49         // text children must not apply.  This change also means that gaps will exist between image bullet list items.  Even when the list bullet
50         // is an image, the line is still considered to be immune from the quirk.
51         m_hasTextChildren = obj->style()->display() == LIST_ITEM;
52     }
53 
54 #ifndef NDEBUG
55     virtual ~InlineFlowBox();
56 #endif
57 
prevFlowBox()58     InlineFlowBox* prevFlowBox() const { return static_cast<InlineFlowBox*>(m_prevLine); }
nextFlowBox()59     InlineFlowBox* nextFlowBox() const { return static_cast<InlineFlowBox*>(m_nextLine); }
60 
firstChild()61     InlineBox* firstChild() const { checkConsistency(); return m_firstChild; }
lastChild()62     InlineBox* lastChild() const { checkConsistency(); return m_lastChild; }
63 
isLeaf()64     virtual bool isLeaf() const { return false; }
65 
66     InlineBox* firstLeafChild() const;
67     InlineBox* lastLeafChild() const;
68 
setConstructed()69     virtual void setConstructed()
70     {
71         InlineBox::setConstructed();
72         if (firstChild())
73             firstChild()->setConstructed();
74     }
75 
76     void addToLine(InlineBox* child);
77     virtual void deleteLine(RenderArena*);
78     virtual void extractLine();
79     virtual void attachLine();
80     virtual void adjustPosition(int dx, int dy);
81 
82     virtual void extractLineBoxFromRenderObject();
83     virtual void attachLineBoxToRenderObject();
84     virtual void removeLineBoxFromRenderObject();
85 
86     virtual void clearTruncation();
87 
88     virtual void paintBoxDecorations(RenderObject::PaintInfo&, int tx, int ty);
89     virtual void paintMask(RenderObject::PaintInfo&, int tx, int ty);
90     void paintFillLayers(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
91     void paintFillLayer(const RenderObject::PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
92     void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h);
93     virtual void paintTextDecorations(RenderObject::PaintInfo&, int tx, int ty, bool paintedChildren = false);
94     virtual void paint(RenderObject::PaintInfo&, int tx, int ty);
95     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
96 
97     virtual RenderLineBoxList* rendererLineBoxes() const;
98 
marginBorderPaddingLeft()99     int marginBorderPaddingLeft() const { return marginLeft() + borderLeft() + paddingLeft(); }
marginBorderPaddingRight()100     int marginBorderPaddingRight() const { return marginRight() + borderRight() + paddingRight(); }
marginLeft()101     int marginLeft() const { if (includeLeftEdge()) return boxModelObject()->marginLeft(); return 0; }
marginRight()102     int marginRight() const { if (includeRightEdge()) return boxModelObject()->marginRight(); return 0; }
borderLeft()103     int borderLeft() const { if (includeLeftEdge()) return renderer()->style()->borderLeftWidth(); return 0; }
borderRight()104     int borderRight() const { if (includeRightEdge()) return renderer()->style()->borderRightWidth(); return 0; }
borderTop()105     int borderTop() const { return renderer()->style()->borderTopWidth(); }
borderBottom()106     int borderBottom() const { return renderer()->style()->borderBottomWidth(); }
paddingLeft()107     int paddingLeft() const { if (includeLeftEdge()) return boxModelObject()->paddingLeft(); return 0; }
paddingRight()108     int paddingRight() const { if (includeRightEdge()) return boxModelObject()->paddingRight(); return 0; }
paddingTop()109     int paddingTop() const { return boxModelObject()->paddingTop(); }
paddingBottom()110     int paddingBottom() const { return boxModelObject()->paddingBottom(); }
111 
includeLeftEdge()112     bool includeLeftEdge() const { return m_includeLeftEdge; }
includeRightEdge()113     bool includeRightEdge() const { return m_includeRightEdge; }
setEdges(bool includeLeft,bool includeRight)114     void setEdges(bool includeLeft, bool includeRight)
115     {
116         m_includeLeftEdge = includeLeft;
117         m_includeRightEdge = includeRight;
118     }
119 
120     // Helper functions used during line construction and placement.
121     void determineSpacingForFlowBoxes(bool lastLine, RenderObject* endObject);
122     int getFlowSpacingWidth();
123     bool onEndChain(RenderObject* endObject);
124     virtual int placeBoxesHorizontally(int x, int& leftPosition, int& rightPosition, bool& needsWordSpacing);
125     virtual int verticallyAlignBoxes(int heightOfBlock);
126     void computeLogicalBoxHeights(int& maxPositionTop, int& maxPositionBottom,
127                                   int& maxAscent, int& maxDescent, bool strictMode);
128     void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
129                                    int maxPositionTop, int maxPositionBottom);
130     void placeBoxesVertically(int y, int maxHeight, int maxAscent, bool strictMode,
131                               int& topPosition, int& bottomPosition, int& selectionTop, int& selectionBottom);
132 
setVerticalOverflowPositions(int,int)133     virtual void setVerticalOverflowPositions(int /*top*/, int /*bottom*/) { }
setVerticalSelectionPositions(int,int)134     virtual void setVerticalSelectionPositions(int /*top*/, int /*bottom*/) { }
maxHorizontalVisualOverflow()135     short maxHorizontalVisualOverflow() const { return m_maxHorizontalVisualOverflow; }
136 
137     void removeChild(InlineBox* child);
138 
139     virtual RenderObject::SelectionState selectionState();
140 
141     virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth);
142     virtual int placeEllipsisBox(bool ltr, int blockLeftEdge, int blockRightEdge, int ellipsisWidth, bool&);
143 
hasTextChildren()144     bool hasTextChildren() const { return m_hasTextChildren; }
145 
146     void checkConsistency() const;
147     void setHasBadChildList();
148 
149 private:
isInlineFlowBox()150     virtual bool isInlineFlowBox() const { return true; }
151 
152     InlineBox* m_firstChild;
153     InlineBox* m_lastChild;
154     short m_maxHorizontalVisualOverflow;
155 
156     bool m_includeLeftEdge : 1;
157     bool m_includeRightEdge : 1;
158     bool m_hasTextChildren : 1;
159 
160 #ifndef NDEBUG
161     bool m_hasBadChildList;
162 #endif
163 };
164 
165 #ifdef NDEBUG
checkConsistency()166 inline void InlineFlowBox::checkConsistency() const
167 {
168 }
169 #endif
170 
setHasBadChildList()171 inline void InlineFlowBox::setHasBadChildList()
172 {
173 #ifndef NDEBUG
174     m_hasBadChildList = true;
175 #endif
176 }
177 
178 } // namespace WebCore
179 
180 #ifndef NDEBUG
181 // Outside the WebCore namespace for ease of invocation from gdb.
182 void showTree(const WebCore::InlineFlowBox*);
183 #endif
184 
185 #endif // InlineFlowBox_h
186