2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
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.
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.
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.
21 #ifndef InlineFlowBox_h
22 #define InlineFlowBox_h
24 #include "InlineRunBox.h"
30 struct HitTestRequest
;
32 class InlineFlowBox
: public InlineRunBox
{
34 InlineFlowBox(RenderObject
* obj
)
38 , m_maxHorizontalVisualOverflow(0)
40 , m_hasBadChildList(false)
43 // 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
44 // 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
45 // an invisible marker exists. The side effect of having an invisible marker is that the quirks mode behavior of shrinking lines with no
46 // text children must not apply. This change also means that gaps will exist between image bullet list items. Even when the list bullet
47 // is an image, the line is still considered to be immune from the quirk.
48 m_hasTextChildren
= obj
->style()->display() == LIST_ITEM
;
52 virtual ~InlineFlowBox();
55 RenderFlow
* flowObject();
57 virtual bool isInlineFlowBox() { return true; }
59 InlineFlowBox
* prevFlowBox() const { return static_cast<InlineFlowBox
*>(m_prevLine
); }
60 InlineFlowBox
* nextFlowBox() const { return static_cast<InlineFlowBox
*>(m_nextLine
); }
62 InlineBox
* firstChild() { checkConsistency(); return m_firstChild
; }
63 InlineBox
* lastChild() { checkConsistency(); return m_lastChild
; }
65 virtual InlineBox
* firstLeafChild();
66 virtual InlineBox
* lastLeafChild();
67 InlineBox
* firstLeafChildAfterBox(InlineBox
* start
= 0);
68 InlineBox
* lastLeafChildBeforeBox(InlineBox
* start
= 0);
70 virtual void setConstructed()
72 InlineBox::setConstructed();
74 firstChild()->setConstructed();
77 void addToLine(InlineBox
* child
);
78 virtual void deleteLine(RenderArena
*);
79 virtual void extractLine();
80 virtual void attachLine();
81 virtual void adjustPosition(int dx
, int dy
);
83 virtual void clearTruncation();
85 virtual void paintBoxDecorations(RenderObject::PaintInfo
&, int tx
, int ty
);
86 virtual void paintMask(RenderObject::PaintInfo
&, int tx
, int ty
);
87 void paintFillLayers(const RenderObject::PaintInfo
&, const Color
&, const FillLayer
*,
88 int my
, int mh
, int tx
, int ty
, int w
, int h
, CompositeOperator
= CompositeSourceOver
);
89 void paintFillLayer(const RenderObject::PaintInfo
&, const Color
&, const FillLayer
*,
90 int my
, int mh
, int tx
, int ty
, int w
, int h
, CompositeOperator
= CompositeSourceOver
);
91 void paintBoxShadow(GraphicsContext
*, RenderStyle
*, int tx
, int ty
, int w
, int h
);
92 virtual void paintTextDecorations(RenderObject::PaintInfo
&, int tx
, int ty
, bool paintedChildren
= false);
93 virtual void paint(RenderObject::PaintInfo
&, int tx
, int ty
);
94 virtual bool nodeAtPoint(const HitTestRequest
&, HitTestResult
&, int x
, int y
, int tx
, int ty
);
96 int marginBorderPaddingLeft();
97 int marginBorderPaddingRight();
100 int borderLeft() { if (includeLeftEdge()) return renderBox()->borderLeft(); return 0; }
101 int borderRight() { if (includeRightEdge()) return renderBox()->borderRight(); return 0; }
102 int paddingLeft() { if (includeLeftEdge()) return renderBox()->paddingLeft(); return 0; }
103 int paddingRight() { if (includeRightEdge()) return renderBox()->paddingRight(); return 0; }
105 bool includeLeftEdge() { return m_includeLeftEdge
; }
106 bool includeRightEdge() { return m_includeRightEdge
; }
107 void setEdges(bool includeLeft
, bool includeRight
)
109 m_includeLeftEdge
= includeLeft
;
110 m_includeRightEdge
= includeRight
;
113 // Helper functions used during line construction and placement.
114 void determineSpacingForFlowBoxes(bool lastLine
, RenderObject
* endObject
);
115 int getFlowSpacingWidth();
116 bool onEndChain(RenderObject
* endObject
);
117 virtual int placeBoxesHorizontally(int x
, int& leftPosition
, int& rightPosition
, bool& needsWordSpacing
);
118 virtual int verticallyAlignBoxes(int heightOfBlock
);
119 void computeLogicalBoxHeights(int& maxPositionTop
, int& maxPositionBottom
,
120 int& maxAscent
, int& maxDescent
, bool strictMode
);
121 void adjustMaxAscentAndDescent(int& maxAscent
, int& maxDescent
,
122 int maxPositionTop
, int maxPositionBottom
);
123 void placeBoxesVertically(int y
, int maxHeight
, int maxAscent
, bool strictMode
,
124 int& topPosition
, int& bottomPosition
, int& selectionTop
, int& selectionBottom
);
125 void shrinkBoxesWithNoTextChildren(int topPosition
, int bottomPosition
);
127 virtual void setVerticalOverflowPositions(int /*top*/, int /*bottom*/) { }
128 virtual void setVerticalSelectionPositions(int /*top*/, int /*bottom*/) { }
129 int maxHorizontalVisualOverflow() const { return m_maxHorizontalVisualOverflow
; }
131 void removeChild(InlineBox
* child
);
133 virtual RenderObject::SelectionState
selectionState();
135 virtual bool canAccommodateEllipsis(bool ltr
, int blockEdge
, int ellipsisWidth
);
136 virtual int placeEllipsisBox(bool ltr
, int blockEdge
, int ellipsisWidth
, bool&);
138 void checkConsistency() const;
139 void setHasBadChildList();
142 InlineBox
* m_firstChild
;
143 InlineBox
* m_lastChild
;
144 int m_maxHorizontalVisualOverflow
;
147 bool m_hasBadChildList
;
152 inline void InlineFlowBox::checkConsistency() const
157 inline void InlineFlowBox::setHasBadChildList()
160 m_hasBadChildList
= true;
164 } // namespace WebCore
167 // Outside the WebCore namespace for ease of invocation from gdb.
168 void showTree(const WebCore::InlineFlowBox
*);
171 #endif // InlineFlowBox_h