• 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  *           (C) 2007 David Smith (catfish.man@gmail.com)
5  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef RenderBlock_h
24 #define RenderBlock_h
25 
26 #include "DeprecatedPtrList.h"
27 #include "GapRects.h"
28 #include "RenderBox.h"
29 #include "RenderLineBoxList.h"
30 #include "RootInlineBox.h"
31 #include <wtf/ListHashSet.h>
32 
33 namespace WebCore {
34 
35 class InlineIterator;
36 class RenderInline;
37 class RootInlineBox;
38 
39 struct BidiRun;
40 
41 template <class Iterator, class Run> class BidiResolver;
42 template <class Iterator> class MidpointState;
43 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
44 typedef MidpointState<InlineIterator> LineMidpointState;
45 
46 enum CaretType { CursorCaret, DragCaret };
47 
48 class RenderBlock : public RenderBox {
49 public:
50     RenderBlock(Node*);
51     virtual ~RenderBlock();
52 
children()53     const RenderObjectChildList* children() const { return &m_children; }
children()54     RenderObjectChildList* children() { return &m_children; }
55 
56     virtual void destroy();
57 
58     // These two functions are overridden for inline-block.
59     virtual int lineHeight(bool firstLine, bool isRootLineBox = false) const;
60     virtual int baselinePosition(bool firstLine, bool isRootLineBox = false) const;
61 
lineBoxes()62     RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
lineBoxes()63     const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
64 
firstLineBox()65     InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
lastLineBox()66     InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
67 
68     void deleteLineBoxTree();
69 
70     // The height (and width) of a block when you include overflow spillage out of the bottom
71     // of the block (e.g., a <div style="height:25px"> that has a 100px tall image inside
72     // it would have an overflow height of borderTop() + paddingTop() + 100px.
73     virtual int overflowHeight(bool includeInterior = true) const;
74     virtual int overflowWidth(bool includeInterior = true) const;
75     virtual int overflowLeft(bool includeInterior = true) const;
76     virtual int overflowTop(bool includeInterior = true) const;
77     virtual IntRect overflowRect(bool includeInterior = true) const;
78 
79     void addVisualOverflow(const IntRect&);
80 
81     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
82     virtual void removeChild(RenderObject*);
83 
84     virtual void layoutBlock(bool relayoutChildren);
85 
86     void insertPositionedObject(RenderBox*);
87     void removePositionedObject(RenderBox*);
88     void removePositionedObjects(RenderBlock*);
89 
90     void addPercentHeightDescendant(RenderBox*);
91     static void removePercentHeightDescendant(RenderBox*);
92     HashSet<RenderBox*>* percentHeightDescendants() const;
93 
94     RootInlineBox* createAndAppendRootInlineBox();
95 
96     bool generatesLineBoxesForInlineChild(RenderObject*, bool isLineEmpty = true, bool previousLineBrokeCleanly = true);
97 
98     void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true);
99     void markPositionedObjectsForLayout();
100 
containsFloats()101     bool containsFloats() { return m_floatingObjects && !m_floatingObjects->isEmpty(); }
102     bool containsFloat(RenderObject*);
103 
104     IntRect floatRect() const;
105 
106     int lineWidth(int y, bool firstLine) const;
107     virtual int lowestPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
108     virtual int rightmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
109     virtual int leftmostPosition(bool includeOverflowInterior = true, bool includeSelf = true) const;
110 
rightOffset(int y,bool firstLine)111     int rightOffset(int y, bool firstLine) const { return rightRelOffset(y, rightOffset(), firstLine); }
leftOffset(int y,bool firstLine)112     int leftOffset(int y, bool firstLine) const { return leftRelOffset(y, leftOffset(), firstLine); }
113 
114     virtual VisiblePosition positionForPoint(const IntPoint&);
115 
116     // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
117     virtual int availableWidth() const;
118 
firstRootBox()119     RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
lastRootBox()120     RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
121 
122     bool containsNonZeroBidiLevel() const;
123 
124     virtual void setSelectionState(SelectionState s);
125 
126     GapRects selectionGapRectsForRepaint(RenderBoxModelObject* repaintContainer);
127     IntRect fillLeftSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,
128                                  int blockX, int blockY, int tx, int ty, const PaintInfo*);
129     IntRect fillRightSelectionGap(RenderObject* selObj, int xPos, int yPos, int height, RenderBlock* rootBlock,
130                                   int blockX, int blockY, int tx, int ty, const PaintInfo*);
131     IntRect fillHorizontalSelectionGap(RenderObject* selObj, int xPos, int yPos, int width, int height, const PaintInfo*);
132 
133     void getHorizontalSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);
134 
135     // Helper methods for computing line counts and heights for line counts.
136     RootInlineBox* lineAtIndex(int);
137     int lineCount();
138     int heightForLineCount(int);
139     void clearTruncation();
140 
141     void adjustRectForColumns(IntRect&) const;
142 
143     void addContinuationWithOutline(RenderInline*);
144 
inlineContinuation()145     RenderInline* inlineContinuation() const { return m_inlineContinuation; }
setInlineContinuation(RenderInline * c)146     void setInlineContinuation(RenderInline* c) { m_inlineContinuation = c; }
147 
148     // This function is a convenience helper for creating an anonymous block that inherits its
149     // style from this RenderBlock.
150     RenderBlock* createAnonymousBlock() const;
151 
152     Vector<IntRect>* columnRects() const;
153     int columnGap() const;
154 
155 protected:
setOverflowHeight(int h)156     virtual void setOverflowHeight(int h) { m_overflowHeight = h; }
setOverflowWidth(int w)157     virtual void setOverflowWidth(int w) { m_overflowWidth = w; }
158 
maxTopPosMargin()159     int maxTopPosMargin() const { return m_maxMargin ? m_maxMargin->m_topPos : MaxMargin::topPosDefault(this); }
maxTopNegMargin()160     int maxTopNegMargin() const { return m_maxMargin ? m_maxMargin->m_topNeg : MaxMargin::topNegDefault(this); }
maxBottomPosMargin()161     int maxBottomPosMargin() const { return m_maxMargin ? m_maxMargin->m_bottomPos : MaxMargin::bottomPosDefault(this); }
maxBottomNegMargin()162     int maxBottomNegMargin() const { return m_maxMargin ? m_maxMargin->m_bottomNeg : MaxMargin::bottomNegDefault(this); }
163     void setMaxTopMargins(int pos, int neg);
164     void setMaxBottomMargins(int pos, int neg);
165 
initMaxMarginValues()166     void initMaxMarginValues()
167     {
168         if (m_maxMargin) {
169             m_maxMargin->m_topPos = MaxMargin::topPosDefault(this);
170             m_maxMargin->m_topNeg = MaxMargin::topNegDefault(this);
171             m_maxMargin->m_bottomPos = MaxMargin::bottomPosDefault(this);
172             m_maxMargin->m_bottomNeg = MaxMargin::bottomNegDefault(this);
173         }
174     }
175 
176     virtual void layout();
177 
178     void layoutPositionedObjects(bool relayoutChildren);
179 
180     virtual void paint(PaintInfo&, int tx, int ty);
181     virtual void paintObject(PaintInfo&, int tx, int ty);
182 
183     int rightRelOffset(int y, int fixedOffset, bool applyTextIndent = true, int* heightRemaining = 0) const;
184     int leftRelOffset(int y, int fixedOffset, bool applyTextIndent = true, int* heightRemaining = 0) const;
185 
186     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
187 
188     virtual void calcPrefWidths();
189 
190     virtual int firstLineBoxBaseline() const;
191     virtual int lastLineBoxBaseline() const;
192 
193     virtual void updateFirstLetter();
194 
195     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
196 
197     // Delay update scrollbar until finishDelayRepaint() will be
198     // called. This function is used when a flexbox is laying out its
199     // descendant. If multiple calls are made to startDelayRepaint(),
200     // finishDelayRepaint() will do nothing until finishDelayRepaint()
201     // is called the same number of times.
202     static void startDelayUpdateScrollInfo();
203     static void finishDelayUpdateScrollInfo();
204 
205     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
206     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
207 
208     virtual bool hasLineIfEmpty() const;
209     bool layoutOnlyPositionedObjects();
210 
211 private:
virtualChildren()212     virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()213     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
214 
215     virtual const char* renderName() const;
216 
isRenderBlock()217     virtual bool isRenderBlock() const { return true; }
isBlockFlow()218     virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && !isTable(); }
isInlineBlockOrInlineTable()219     virtual bool isInlineBlockOrInlineTable() const { return isInline() && isReplaced(); }
220 
221     void makeChildrenNonInline(RenderObject* insertionPoint = 0);
222     virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
223 
dirtyLinesFromChangedChild(RenderObject * child)224     virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
225 
226     virtual bool isSelfCollapsingBlock() const;
227 
maxTopMargin(bool positive)228     virtual int maxTopMargin(bool positive) const { return positive ? maxTopPosMargin() : maxTopNegMargin(); }
maxBottomMargin(bool positive)229     virtual int maxBottomMargin(bool positive) const { return positive ? maxBottomPosMargin() : maxBottomNegMargin(); }
230 
231     virtual void repaintOverhangingFloats(bool paintAllDescendants);
232 
233     void layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom);
234     void layoutInlineChildren(bool relayoutChildren, int& repaintTop, int& repaintBottom);
235 
positionListMarker()236     virtual void positionListMarker() { }
237 
238     virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set.
239 
240     virtual void updateBeforeAfterContent(PseudoId);
241 
242     virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG and Ruby.
243 
244     // Called to lay out the legend for a fieldset.
layoutLegend(bool)245     virtual RenderObject* layoutLegend(bool /*relayoutChildren*/) { return 0; }
246 
247     struct FloatWithRect {
FloatWithRectFloatWithRect248         FloatWithRect(RenderBox* f)
249             : object(f)
250             , rect(IntRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom()))
251             , everHadLayout(f->m_everHadLayout)
252         {
253         }
254 
255         RenderBox* object;
256         IntRect rect;
257         bool everHadLayout;
258     };
259 
260     // The following functions' implementations are in RenderBlockLineLayout.cpp.
261     void bidiReorderLine(InlineBidiResolver&, const InlineIterator& end, bool previousLineBrokeCleanly);
262     RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly,
263                                           InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats);
264     RootInlineBox* determineEndPosition(RootInlineBox* startBox, InlineIterator& cleanLineStart,
265                                         BidiStatus& cleanLineBidiStatus,
266                                         int& yPos);
267     bool matchedEndLine(const InlineBidiResolver&, const InlineIterator& endLineStart, const BidiStatus& endLineStatus,
268                         RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop);
269 
270     void skipTrailingWhitespace(InlineIterator&, bool isLineEmpty, bool previousLineBrokeCleanly);
271     int skipLeadingWhitespace(InlineBidiResolver&, bool firstLine, bool isLineEmpty, bool previousLineBrokeCleanly);
272     void fitBelowFloats(int widthToFit, bool firstLine, int& availableWidth);
273     InlineIterator findNextLineBreak(InlineBidiResolver&, bool firstLine, bool& isLineEmpty, bool& previousLineBrokeCleanly, EClear* clear = 0);
274     RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool firstLine, bool lastLine, RenderObject* endObject);
275     InlineFlowBox* createLineBoxes(RenderObject*, bool firstLine);
276     void computeHorizontalPositionsForLine(RootInlineBox*, bool firstLine, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd);
277     void computeVerticalPositionsForLine(RootInlineBox*, BidiRun*);
278     void checkLinesForOverflow();
279     void deleteEllipsisLineBoxes();
280     void checkLinesForTextOverflow();
281     // End of functions defined in RenderBlockLineLayout.cpp.
282 
283     void paintFloats(PaintInfo&, int tx, int ty, bool preservePhase = false);
284     void paintContents(PaintInfo&, int tx, int ty);
285     void paintColumnContents(PaintInfo&, int tx, int ty, bool paintFloats = false);
286     void paintColumnRules(PaintInfo&, int tx, int ty);
287     void paintChildren(PaintInfo&, int tx, int ty);
288     void paintEllipsisBoxes(PaintInfo&, int tx, int ty);
289     void paintSelection(PaintInfo&, int tx, int ty);
290     void paintCaret(PaintInfo&, int tx, int ty, CaretType);
291 
292     void insertFloatingObject(RenderBox*);
293     void removeFloatingObject(RenderBox*);
294 
295     // Called from lineWidth, to position the floats added in the last line.
296     // Returns ture if and only if it has positioned any floats.
297     bool positionNewFloats();
298     void clearFloats();
299     int getClearDelta(RenderBox* child, int yPos);
300 
301     virtual bool avoidsFloats() const;
302 
hasOverhangingFloats()303     bool hasOverhangingFloats() { return parent() && !hasColumns() && floatBottom() > height(); }
304     void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset);
305     int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats);
306 
307     int nextFloatBottomBelow(int) const;
308     int floatBottom() const;
309     inline int leftBottom();
310     inline int rightBottom();
311 
312     int rightOffset() const;
313     int leftOffset() const;
314     virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
315     virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
316 
317     virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
318 
319     void calcInlinePrefWidths();
320     void calcBlockPrefWidths();
321 
322     // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
323     // children.
324     virtual RenderBlock* firstLineBlock() const;
325     bool inRootBlockContext() const;
326 
327     virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
328     virtual RenderStyle* outlineStyleForRepaint() const;
329 
330     virtual RenderObject* hoverAncestor() const;
331     virtual void updateDragState(bool dragOn);
332     virtual void childBecameNonInline(RenderObject* child);
333 
selectionRectForRepaint(RenderBoxModelObject * repaintContainer,bool)334     virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/)
335     {
336         return selectionGapRectsForRepaint(repaintContainer);
337     }
338     virtual bool shouldPaintSelectionGaps() const;
339     bool isSelectionRoot() const;
340     GapRects fillSelectionGaps(RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty,
341                                int& lastTop, int& lastLeft, int& lastRight, const PaintInfo* = 0);
342     GapRects fillInlineSelectionGaps(RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty,
343                                      int& lastTop, int& lastLeft, int& lastRight, const PaintInfo*);
344     GapRects fillBlockSelectionGaps(RenderBlock* rootBlock, int blockX, int blockY, int tx, int ty,
345                                     int& lastTop, int& lastLeft, int& lastRight, const PaintInfo*);
346     IntRect fillVerticalSelectionGap(int lastTop, int lastLeft, int lastRight, int bottomY, RenderBlock* rootBlock,
347                                      int blockX, int blockY, const PaintInfo*);
348     int leftSelectionOffset(RenderBlock* rootBlock, int y);
349     int rightSelectionOffset(RenderBlock* rootBlock, int y);
350 
351     virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
352     virtual void absoluteQuads(Vector<FloatQuad>&);
353 
354     int desiredColumnWidth() const;
355     unsigned desiredColumnCount() const;
356     void setDesiredColumnCountAndWidth(int count, int width);
357 
358     void paintContinuationOutlines(PaintInfo&, int tx, int ty);
359 
360     virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
361 
362     virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
363 
364     void adjustPointToColumnContents(IntPoint&) const;
365     void adjustForBorderFit(int x, int& left, int& right) const; // Helper function for borderFitAdjust
366 
367     void markLinesDirtyInVerticalRange(int top, int bottom);
368 
369     void newLine(EClear);
370 
371     Position positionForBox(InlineBox*, bool start = true) const;
372     Position positionForRenderer(RenderObject*, bool start = true) const;
373     VisiblePosition positionForPointWithInlineChildren(const IntPoint&);
374 
375     // Adjust tx and ty from painting offsets to the local coords of this renderer
376     void offsetForContents(int& tx, int& ty) const;
377 
378     void calcColumnWidth();
379     int layoutColumns(int endOfContent = -1);
380 
381     bool expandsToEncloseOverhangingFloats() const;
382 
383     void updateScrollInfoAfterLayout();
384 
385     struct FloatingObject {
386         enum Type {
387             FloatLeft,
388             FloatRight
389         };
390 
FloatingObjectFloatingObject391         FloatingObject(Type type)
392             : m_renderer(0)
393             , m_top(0)
394             , m_bottom(0)
395             , m_left(0)
396             , m_width(0)
397             , m_type(type)
398             , m_shouldPaint(true)
399             , m_isDescendant(false)
400         {
401         }
402 
typeFloatingObject403         Type type() { return static_cast<Type>(m_type); }
404 
405         RenderBox* m_renderer;
406         int m_top;
407         int m_bottom;
408         int m_left;
409         int m_width;
410         unsigned m_type : 1; // Type (left or right aligned)
411         bool m_shouldPaint : 1;
412         bool m_isDescendant : 1;
413     };
414 
415     class MarginInfo {
416         // Collapsing flags for whether we can collapse our margins with our children's margins.
417         bool m_canCollapseWithChildren : 1;
418         bool m_canCollapseTopWithChildren : 1;
419         bool m_canCollapseBottomWithChildren : 1;
420 
421         // Whether or not we are a quirky container, i.e., do we collapse away top and bottom
422         // margins in our container.  Table cells and the body are the common examples. We
423         // also have a custom style property for Safari RSS to deal with TypePad blog articles.
424         bool m_quirkContainer : 1;
425 
426         // This flag tracks whether we are still looking at child margins that can all collapse together at the beginning of a block.
427         // They may or may not collapse with the top margin of the block (|m_canCollapseTopWithChildren| tells us that), but they will
428         // always be collapsing with one another.  This variable can remain set to true through multiple iterations
429         // as long as we keep encountering self-collapsing blocks.
430         bool m_atTopOfBlock : 1;
431 
432         // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block.
433         bool m_atBottomOfBlock : 1;
434 
435         // If our last normal flow child was a self-collapsing block that cleared a float,
436         // we track it in this variable.
437         bool m_selfCollapsingBlockClearedFloat : 1;
438 
439         // These variables are used to detect quirky margins that we need to collapse away (in table cells
440         // and in the body element).
441         bool m_topQuirk : 1;
442         bool m_bottomQuirk : 1;
443         bool m_determinedTopQuirk : 1;
444 
445         // These flags track the previous maximal positive and negative margins.
446         int m_posMargin;
447         int m_negMargin;
448 
449     public:
450         MarginInfo(RenderBlock* b, int top, int bottom);
451 
setAtTopOfBlock(bool b)452         void setAtTopOfBlock(bool b) { m_atTopOfBlock = b; }
setAtBottomOfBlock(bool b)453         void setAtBottomOfBlock(bool b) { m_atBottomOfBlock = b; }
clearMargin()454         void clearMargin() { m_posMargin = m_negMargin = 0; }
setSelfCollapsingBlockClearedFloat(bool b)455         void setSelfCollapsingBlockClearedFloat(bool b) { m_selfCollapsingBlockClearedFloat = b; }
setTopQuirk(bool b)456         void setTopQuirk(bool b) { m_topQuirk = b; }
setBottomQuirk(bool b)457         void setBottomQuirk(bool b) { m_bottomQuirk = b; }
setDeterminedTopQuirk(bool b)458         void setDeterminedTopQuirk(bool b) { m_determinedTopQuirk = b; }
setPosMargin(int p)459         void setPosMargin(int p) { m_posMargin = p; }
setNegMargin(int n)460         void setNegMargin(int n) { m_negMargin = n; }
setPosMarginIfLarger(int p)461         void setPosMarginIfLarger(int p) { if (p > m_posMargin) m_posMargin = p; }
setNegMarginIfLarger(int n)462         void setNegMarginIfLarger(int n) { if (n > m_negMargin) m_negMargin = n; }
463 
setMargin(int p,int n)464         void setMargin(int p, int n) { m_posMargin = p; m_negMargin = n; }
465 
atTopOfBlock()466         bool atTopOfBlock() const { return m_atTopOfBlock; }
canCollapseWithTop()467         bool canCollapseWithTop() const { return m_atTopOfBlock && m_canCollapseTopWithChildren; }
canCollapseWithBottom()468         bool canCollapseWithBottom() const { return m_atBottomOfBlock && m_canCollapseBottomWithChildren; }
canCollapseTopWithChildren()469         bool canCollapseTopWithChildren() const { return m_canCollapseTopWithChildren; }
canCollapseBottomWithChildren()470         bool canCollapseBottomWithChildren() const { return m_canCollapseBottomWithChildren; }
selfCollapsingBlockClearedFloat()471         bool selfCollapsingBlockClearedFloat() const { return m_selfCollapsingBlockClearedFloat; }
quirkContainer()472         bool quirkContainer() const { return m_quirkContainer; }
determinedTopQuirk()473         bool determinedTopQuirk() const { return m_determinedTopQuirk; }
topQuirk()474         bool topQuirk() const { return m_topQuirk; }
bottomQuirk()475         bool bottomQuirk() const { return m_bottomQuirk; }
posMargin()476         int posMargin() const { return m_posMargin; }
negMargin()477         int negMargin() const { return m_negMargin; }
margin()478         int margin() const { return m_posMargin - m_negMargin; }
479     };
480 
481     void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
482     void adjustFloatingBlock(const MarginInfo&);
483     bool handleSpecialChild(RenderBox* child, const MarginInfo&);
484     bool handleFloatingChild(RenderBox* child, const MarginInfo&);
485     bool handlePositionedChild(RenderBox* child, const MarginInfo&);
486     bool handleRunInChild(RenderBox* child);
487     int collapseMargins(RenderBox* child, MarginInfo&);
488     int clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);
489     int estimateVerticalPosition(RenderBox* child, const MarginInfo&);
490     void determineHorizontalPosition(RenderBox* child);
491     void handleBottomOfBlock(int top, int bottom, MarginInfo&);
492     void setCollapsedBottomMargin(const MarginInfo&);
493     // End helper functions and structs used by layoutBlockChildren.
494 
495     typedef ListHashSet<RenderBox*>::const_iterator Iterator;
496     DeprecatedPtrList<FloatingObject>* m_floatingObjects;
497     ListHashSet<RenderBox*>* m_positionedObjects;
498 
499     // An inline can be split with blocks occurring in between the inline content.
500     // When this occurs we need a pointer to our next object.  We can basically be
501     // split into a sequence of inlines and blocks.  The continuation will either be
502     // an anonymous block (that houses other blocks) or it will be an inline flow.
503     RenderInline* m_inlineContinuation;
504 
505     // Allocated only when some of these fields have non-default values
506     struct MaxMargin {
MaxMarginMaxMargin507         MaxMargin(const RenderBlock* o)
508             : m_topPos(topPosDefault(o))
509             , m_topNeg(topNegDefault(o))
510             , m_bottomPos(bottomPosDefault(o))
511             , m_bottomNeg(bottomNegDefault(o))
512         {
513         }
514 
topPosDefaultMaxMargin515         static int topPosDefault(const RenderBlock* o) { return o->marginTop() > 0 ? o->marginTop() : 0; }
topNegDefaultMaxMargin516         static int topNegDefault(const RenderBlock* o) { return o->marginTop() < 0 ? -o->marginTop() : 0; }
bottomPosDefaultMaxMargin517         static int bottomPosDefault(const RenderBlock* o) { return o->marginBottom() > 0 ? o->marginBottom() : 0; }
bottomNegDefaultMaxMargin518         static int bottomNegDefault(const RenderBlock* o) { return o->marginBottom() < 0 ? -o->marginBottom() : 0; }
519 
520         int m_topPos;
521         int m_topNeg;
522         int m_bottomPos;
523         int m_bottomNeg;
524      };
525 
526     MaxMargin* m_maxMargin;
527 
528     RenderObjectChildList m_children;
529     RenderLineBoxList m_lineBoxes;   // All of the root line boxes created for this block flow.  For example, <div>Hello<br>world.</div> will have two total lines for the <div>.
530 
531 protected:
532     // How much content overflows out of our block vertically or horizontally.
533     int m_overflowHeight;
534     int m_overflowWidth;
535     int m_overflowLeft;
536     int m_overflowTop;
537 
538 private:
539     mutable int m_lineHeight;
540 };
541 
toRenderBlock(RenderObject * object)542 inline RenderBlock* toRenderBlock(RenderObject* object)
543 {
544     ASSERT(!object || object->isRenderBlock());
545     return static_cast<RenderBlock*>(object);
546 }
547 
toRenderBlock(const RenderObject * object)548 inline const RenderBlock* toRenderBlock(const RenderObject* object)
549 {
550     ASSERT(!object || object->isRenderBlock());
551     return static_cast<const RenderBlock*>(object);
552 }
553 
554 // This will catch anyone doing an unnecessary cast.
555 void toRenderBlock(const RenderBlock*);
556 
557 } // namespace WebCore
558 
559 #endif // RenderBlock_h
560