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, 2010 Apple Inc. All rights reserved.
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.
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.
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.
27 #include "PODIntervalTree.h"
28 #include "RenderBox.h"
29 #include "RenderLineBoxList.h"
30 #include "RootInlineBox.h"
32 #include <wtf/OwnPtr.h>
33 #include <wtf/ListHashSet.h>
40 class LayoutStateMaintainer;
41 class LazyLineBreakIterator;
42 class LineLayoutState;
52 template <class Iterator, class Run> class BidiResolver;
53 template <class Run> class BidiRunList;
54 template <class Iterator> struct MidpointState;
55 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
56 typedef MidpointState<InlineIterator> LineMidpointState;
58 enum CaretType { CursorCaret, DragCaret };
61 DefaultTextRunFlags = 0,
62 RespectDirection = 1 << 0,
63 RespectDirectionOverride = 1 << 1
66 typedef unsigned TextRunFlags;
68 class RenderBlock : public RenderBox {
70 friend class LineLayoutState;
72 // Used by the PODIntervalTree for debugging the FloatingObject.
73 template <class> friend struct ValueToString;
77 virtual ~RenderBlock();
79 const RenderObjectChildList* children() const { return &m_children; }
80 RenderObjectChildList* children() { return &m_children; }
82 bool beingDestroyed() const { return m_beingDestroyed; }
84 // These two functions are overridden for inline-block.
85 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
86 virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
88 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
89 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
91 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
92 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
94 void deleteLineBoxTree();
96 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
97 virtual void removeChild(RenderObject*);
99 enum BlockLayoutPass { NormalLayoutPass, PositionedFloatLayoutPass };
100 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0, BlockLayoutPass = NormalLayoutPass);
102 void insertPositionedObject(RenderBox*);
103 void removePositionedObject(RenderBox*);
104 void removePositionedObjects(RenderBlock*);
106 typedef ListHashSet<RenderBox*, 4> PositionedObjectsListHashSet;
107 PositionedObjectsListHashSet* positionedObjects() const { return m_positionedObjects.get(); }
109 void addPercentHeightDescendant(RenderBox*);
110 static void removePercentHeightDescendant(RenderBox*);
111 HashSet<RenderBox*>* percentHeightDescendants() const;
113 static bool hasPercentHeightDescendant(RenderBox*);
116 RootInlineBox* createAndAppendRootInlineBox();
118 bool generatesLineBoxesForInlineChild(RenderObject*);
120 void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true);
121 void markSiblingsWithFloatsForLayout();
122 void markPositionedObjectsForLayout();
123 virtual void markForPaginationRelayoutIfNeeded();
125 bool containsFloats() { return m_floatingObjects && !m_floatingObjects->set().isEmpty(); }
126 bool containsFloat(RenderBox*);
128 LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool firstLine) const;
129 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool firstLine) const { return logicalRightOffsetForLine(position, logicalRightOffsetForContent(), firstLine); }
130 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool firstLine) const { return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(), firstLine); }
131 LayoutUnit startOffsetForLine(LayoutUnit position, bool firstLine) const { return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine) : logicalRightOffsetForLine(position, firstLine); }
132 LayoutUnit startAlignedOffsetForLine(RenderBox* child, LayoutUnit position, bool firstLine);
133 LayoutUnit textIndentOffset() const;
135 virtual VisiblePosition positionForPoint(const LayoutPoint&);
137 // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
138 virtual LayoutUnit availableLogicalWidth() const;
140 LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
141 void adjustStartEdgeForWritingModeIncludingColumns(LayoutRect&) const;
143 RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
144 RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
146 bool containsNonZeroBidiLevel() const;
148 GapRects selectionGapRectsForRepaint(RenderBoxModelObject* repaintContainer);
149 LayoutRect logicalLeftSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
150 RenderObject* selObj, LayoutUnit logicalLeft, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*);
151 LayoutRect logicalRightSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
152 RenderObject* selObj, LayoutUnit logicalRight, LayoutUnit logicalTop, LayoutUnit logicalHeight, const PaintInfo*);
153 void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);
154 LayoutRect logicalRectToPhysicalRect(const LayoutPoint& physicalPosition, const LayoutRect& logicalRect);
156 // Helper methods for computing line counts and heights for line counts.
157 RootInlineBox* lineAtIndex(int);
159 int heightForLineCount(int);
160 void clearTruncation();
162 void adjustRectForColumns(LayoutRect&) const;
163 virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const;
165 void addContinuationWithOutline(RenderInline*);
166 bool paintsContinuationOutline(RenderInline*);
168 virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
169 bool isAnonymousBlockContinuation() const { return continuation() && isAnonymousBlock(); }
170 RenderInline* inlineElementContinuation() const;
171 RenderBlock* blockElementContinuation() const;
173 using RenderBoxModelObject::continuation;
174 using RenderBoxModelObject::setContinuation;
176 // This function is a convenience helper for creating an anonymous block that inherits its
177 // style from this RenderBlock.
178 RenderBlock* createAnonymousBlock(bool isFlexibleBox = false) const;
179 RenderBlock* createAnonymousColumnsBlock() const;
180 RenderBlock* createAnonymousColumnSpanBlock() const;
181 RenderBlock* createAnonymousBlockWithSameTypeAs(RenderBlock* otherAnonymousBlock) const;
183 static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&);
185 static TextRun constructTextRun(RenderObject* context, const Font&, const String&, RenderStyle*,
186 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
188 static TextRun constructTextRun(RenderObject* context, const Font&, const UChar*, int length, RenderStyle*,
189 TextRun::ExpansionBehavior = TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, TextRunFlags = DefaultTextRunFlags);
191 ColumnInfo* columnInfo() const;
192 int columnGap() const;
194 // These two functions take the ColumnInfo* to avoid repeated lookups of the info in the global HashMap.
195 unsigned columnCount(ColumnInfo*) const;
196 LayoutRect columnRectAt(ColumnInfo*, unsigned) const;
198 int paginationStrut() const { return m_rareData ? m_rareData->m_paginationStrut : 0; }
199 void setPaginationStrut(int);
201 // The page logical offset is the object's offset from the top of the page in the page progression
202 // direction (so an x-offset in vertical text and a y-offset for horizontal text).
203 int pageLogicalOffset() const { return m_rareData ? m_rareData->m_pageLogicalOffset : 0; }
204 void setPageLogicalOffset(int);
206 // Accessors for logical width/height and margins in the containing block's block-flow direction.
207 enum ApplyLayoutDeltaMode { ApplyLayoutDelta, DoNotApplyLayoutDelta };
208 LayoutUnit logicalWidthForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->width() : child->height(); }
209 LayoutUnit logicalHeightForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->height() : child->width(); }
210 LayoutUnit logicalTopForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->y() : child->x(); }
211 LayoutUnit logicalLeftForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->x() : child->y(); }
212 void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
213 void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
214 LayoutUnit marginBeforeForChild(RenderBoxModelObject* child) const;
215 LayoutUnit marginAfterForChild(RenderBoxModelObject* child) const;
216 LayoutUnit marginStartForChild(RenderBoxModelObject* child) const;
217 LayoutUnit marginEndForChild(RenderBoxModelObject* child) const;
218 LayoutUnit marginLogicalLeftForChild(RenderBoxModelObject* child) const;
219 LayoutUnit marginLogicalRightForChild(RenderBoxModelObject* child) const;
220 void setMarginStartForChild(RenderBox* child, LayoutUnit);
221 void setMarginEndForChild(RenderBox* child, LayoutUnit);
222 void setMarginBeforeForChild(RenderBox* child, LayoutUnit);
223 void setMarginAfterForChild(RenderBox* child, LayoutUnit);
224 LayoutUnit collapsedMarginBeforeForChild(RenderBox* child) const;
225 LayoutUnit collapsedMarginAfterForChild(RenderBox* child) const;
227 void updateLogicalWidthForAlignment(const ETextAlign&, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
229 virtual void updateFirstLetter();
233 MarginValues(LayoutUnit beforePos, LayoutUnit beforeNeg, LayoutUnit afterPos, LayoutUnit afterNeg)
234 : m_positiveMarginBefore(beforePos)
235 , m_negativeMarginBefore(beforeNeg)
236 , m_positiveMarginAfter(afterPos)
237 , m_negativeMarginAfter(afterNeg)
240 LayoutUnit positiveMarginBefore() const { return m_positiveMarginBefore; }
241 LayoutUnit negativeMarginBefore() const { return m_negativeMarginBefore; }
242 LayoutUnit positiveMarginAfter() const { return m_positiveMarginAfter; }
243 LayoutUnit negativeMarginAfter() const { return m_negativeMarginAfter; }
245 void setPositiveMarginBefore(LayoutUnit pos) { m_positiveMarginBefore = pos; }
246 void setNegativeMarginBefore(LayoutUnit neg) { m_negativeMarginBefore = neg; }
247 void setPositiveMarginAfter(LayoutUnit pos) { m_positiveMarginAfter = pos; }
248 void setNegativeMarginAfter(LayoutUnit neg) { m_negativeMarginAfter = neg; }
251 LayoutUnit m_positiveMarginBefore;
252 LayoutUnit m_negativeMarginBefore;
253 LayoutUnit m_positiveMarginAfter;
254 LayoutUnit m_negativeMarginAfter;
256 MarginValues marginValuesForChild(RenderBox* child);
258 virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { };
260 int logicalRightOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() + availableLogicalWidth() : borderTop() + paddingTop() + availableLogicalWidth(); }
261 int logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
264 void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
268 virtual void willBeDestroyed();
270 // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode.
271 // Since they are typically called only to move objects around within anonymous blocks (which only have layers in
272 // the case of column spans), the default for fullRemoveInsert is false rather than true.
273 void moveChildTo(RenderBlock* to, RenderObject* child, bool fullRemoveInsert = false)
275 return moveChildTo(to, child, 0, fullRemoveInsert);
277 void moveChildTo(RenderBlock* to, RenderObject* child, RenderObject* beforeChild, bool fullRemoveInsert = false);
278 void moveAllChildrenTo(RenderBlock* to, bool fullRemoveInsert = false)
280 return moveAllChildrenTo(to, 0, fullRemoveInsert);
282 void moveAllChildrenTo(RenderBlock* to, RenderObject* beforeChild, bool fullRemoveInsert = false)
284 return moveChildrenTo(to, firstChild(), 0, beforeChild, fullRemoveInsert);
286 // Move all of the kids from |startChild| up to but excluding |endChild|. 0 can be passed as the endChild to denote
287 // that all the kids from |startChild| onwards should be added.
288 void moveChildrenTo(RenderBlock* to, RenderObject* startChild, RenderObject* endChild, bool fullRemoveInsert = false)
290 return moveChildrenTo(to, startChild, endChild, 0, fullRemoveInsert);
292 void moveChildrenTo(RenderBlock* to, RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRemoveInsert = false);
294 LayoutUnit maxPositiveMarginBefore() const { return m_rareData ? m_rareData->m_margins.positiveMarginBefore() : RenderBlockRareData::positiveMarginBeforeDefault(this); }
295 LayoutUnit maxNegativeMarginBefore() const { return m_rareData ? m_rareData->m_margins.negativeMarginBefore() : RenderBlockRareData::negativeMarginBeforeDefault(this); }
296 LayoutUnit maxPositiveMarginAfter() const { return m_rareData ? m_rareData->m_margins.positiveMarginAfter() : RenderBlockRareData::positiveMarginAfterDefault(this); }
297 LayoutUnit maxNegativeMarginAfter() const { return m_rareData ? m_rareData->m_margins.negativeMarginAfter() : RenderBlockRareData::negativeMarginAfterDefault(this); }
299 void setMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg);
300 void setMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg);
302 void initMaxMarginValues()
305 m_rareData->m_margins = MarginValues(RenderBlockRareData::positiveMarginBeforeDefault(this) , RenderBlockRareData::negativeMarginBeforeDefault(this),
306 RenderBlockRareData::positiveMarginAfterDefault(this), RenderBlockRareData::negativeMarginAfterDefault(this));
307 m_rareData->m_paginationStrut = 0;
311 virtual void layout();
313 bool layoutPositionedObjects(bool relayoutChildren);
315 virtual void paint(PaintInfo&, const LayoutPoint&);
316 virtual void paintObject(PaintInfo&, const LayoutPoint&);
318 void adjustForRegionFittingIfNeeded(LayoutUnit logicalTop, LayoutUnit& rightOffset) const;
320 LayoutUnit logicalRightOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, LayoutUnit* logicalHeightRemaining = 0) const;
321 LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, LayoutUnit fixedOffset, bool applyTextIndent = true, LayoutUnit* logicalHeightRemaining = 0) const;
323 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
324 virtual void adjustInlineDirectionLineBounds(int /* expansionOpportunityCount */, float& /* logicalLeft */, float& /* logicalWidth */) const { }
326 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
328 virtual void computePreferredLogicalWidths();
330 virtual LayoutUnit firstLineBoxBaseline() const;
331 virtual LayoutUnit lastLineBoxBaseline() const;
333 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
335 // Delay update scrollbar until finishDelayRepaint() will be
336 // called. This function is used when a flexbox is laying out its
337 // descendant. If multiple calls are made to startDelayRepaint(),
338 // finishDelayRepaint() will do nothing until finishDelayRepaint()
339 // is called the same number of times.
340 static void startDelayUpdateScrollInfo();
341 static void finishDelayUpdateScrollInfo();
343 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
344 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
346 virtual bool hasLineIfEmpty() const;
348 bool simplifiedLayout();
349 void simplifiedNormalFlowLayout();
351 void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
352 virtual void addOverflowFromChildren();
353 void addOverflowFromFloats();
354 void addOverflowFromPositionedObjects();
355 void addOverflowFromBlockChildren();
356 void addOverflowFromInlineChildren();
358 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint&);
361 // Only used by RenderSVGText, which explicitely overrides RenderBlock::layoutBlock(), do NOT use for anything else.
362 void forceLayoutInlineChildren()
364 LayoutUnit repaintLogicalTop = 0;
365 LayoutUnit repaintLogicalBottom = 0;
366 layoutInlineChildren(true, repaintLogicalTop, repaintLogicalBottom);
371 virtual RenderObjectChildList* virtualChildren() { return children(); }
372 virtual const RenderObjectChildList* virtualChildren() const { return children(); }
374 virtual const char* renderName() const;
376 virtual bool isRenderBlock() const { return true; }
377 virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && !isTable(); }
378 virtual bool isInlineBlockOrInlineTable() const { return isInline() && isReplaced(); }
380 void makeChildrenNonInline(RenderObject* insertionPoint = 0);
381 virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
383 virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
385 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
386 void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild);
387 void addChildToAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild);
388 virtual void addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild = 0);
390 virtual bool isSelfCollapsingBlock() const;
392 virtual LayoutUnit collapsedMarginBefore() const { return maxPositiveMarginBefore() - maxNegativeMarginBefore(); }
393 virtual LayoutUnit collapsedMarginAfter() const { return maxPositiveMarginAfter() - maxNegativeMarginAfter(); }
395 virtual void repaintOverhangingFloats(bool paintAllDescendants);
397 void layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalBottom);
398 void layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
399 BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*);
401 virtual void borderFitAdjust(LayoutRect&) const; // Shrink the box in which the border paints if border-fit is set.
403 virtual void updateBeforeAfterContent(PseudoId);
405 virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG and Ruby.
407 // Called to lay out the legend for a fieldset or the ruby text of a ruby run.
408 virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/) { return 0; }
410 struct FloatWithRect {
411 FloatWithRect(RenderBox* f)
413 , rect(IntRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom()))
414 , everHadLayout(f->m_everHadLayout)
423 struct FloatingObject {
424 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED;
426 // FloatLeftRight is a mask to query for both left and right but not positioned.
427 // FloatAll is a mask to query for all types of floats.
428 enum Type { FloatLeft = 1, FloatRight = 2, FloatLeftRight = 3, FloatPositioned = 4, FloatAll = 7 };
430 FloatingObject(EFloat type)
432 , m_originatingLine(0)
433 , m_paginationStrut(0)
434 , m_shouldPaint(false)
435 , m_isDescendant(false)
438 , m_isInPlacedTree(false)
441 ASSERT(type != NoFloat);
442 if (type == LeftFloat)
444 else if (type == RightFloat)
446 else if (type == PositionedFloat)
447 m_type = FloatPositioned;
450 FloatingObject(Type type, const LayoutRect& frameRect)
452 , m_originatingLine(0)
453 , m_frameRect(frameRect)
454 , m_paginationStrut(0)
456 , m_shouldPaint(type != FloatPositioned)
457 , m_isDescendant(false)
460 , m_isInPlacedTree(false)
465 Type type() const { return static_cast<Type>(m_type); }
466 RenderBox* renderer() const { return m_renderer; }
468 bool isPlaced() const { return m_isPlaced; }
469 void setIsPlaced(bool placed = true) { m_isPlaced = placed; }
471 LayoutUnit x() const { ASSERT(isPlaced()); return m_frameRect.x(); }
472 LayoutUnit maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); }
473 LayoutUnit y() const { ASSERT(isPlaced()); return m_frameRect.y(); }
474 LayoutUnit maxY() const { ASSERT(isPlaced()); return m_frameRect.maxY(); }
475 LayoutUnit width() const { return m_frameRect.width(); }
476 LayoutUnit height() const { return m_frameRect.height(); }
478 void setX(LayoutUnit x) { ASSERT(!isInPlacedTree()); m_frameRect.setX(x); }
479 void setY(LayoutUnit y) { ASSERT(!isInPlacedTree()); m_frameRect.setY(y); }
480 void setWidth(LayoutUnit width) { ASSERT(!isInPlacedTree()); m_frameRect.setWidth(width); }
481 void setHeight(LayoutUnit height) { ASSERT(!isInPlacedTree()); m_frameRect.setHeight(height); }
483 const LayoutRect& frameRect() const { ASSERT(isPlaced()); return m_frameRect; }
484 void setFrameRect(const LayoutRect& frameRect) { ASSERT(!isInPlacedTree()); m_frameRect = frameRect; }
487 bool isInPlacedTree() const { return m_isInPlacedTree; }
488 void setIsInPlacedTree(bool value) { m_isInPlacedTree = value; }
491 RenderBox* m_renderer;
492 RootInlineBox* m_originatingLine;
493 LayoutRect m_frameRect;
494 int m_paginationStrut;
495 unsigned m_type : 3; // Type (left/right aligned or positioned)
496 bool m_shouldPaint : 1;
497 bool m_isDescendant : 1;
500 bool m_isInPlacedTree : 1;
504 LayoutPoint flipFloatForWritingMode(const FloatingObject*, const LayoutPoint&) const;
506 LayoutUnit logicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
507 LayoutUnit logicalBottomForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxY() : child->maxX(); }
508 LayoutUnit logicalLeftForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->x() : child->y(); }
509 LayoutUnit logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); }
510 LayoutUnit logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
511 void setLogicalTopForFloat(FloatingObject* child, LayoutUnit logicalTop)
513 if (isHorizontalWritingMode())
514 child->setY(logicalTop);
516 child->setX(logicalTop);
518 void setLogicalLeftForFloat(FloatingObject* child, LayoutUnit logicalLeft)
520 if (isHorizontalWritingMode())
521 child->setX(logicalLeft);
523 child->setY(logicalLeft);
525 void setLogicalHeightForFloat(FloatingObject* child, LayoutUnit logicalHeight)
527 if (isHorizontalWritingMode())
528 child->setHeight(logicalHeight);
530 child->setWidth(logicalHeight);
532 void setLogicalWidthForFloat(FloatingObject* child, LayoutUnit logicalWidth)
534 if (isHorizontalWritingMode())
535 child->setWidth(logicalWidth);
537 child->setHeight(logicalWidth);
540 LayoutUnit xPositionForFloatIncludingMargin(const FloatingObject* child) const
542 if (isHorizontalWritingMode())
543 return child->x() + child->renderer()->marginLeft();
545 return child->x() + marginBeforeForChild(child->renderer());
548 LayoutUnit yPositionForFloatIncludingMargin(const FloatingObject* child) const
550 if (isHorizontalWritingMode())
551 return child->y() + marginBeforeForChild(child->renderer());
553 return child->y() + child->renderer()->marginTop();
556 // The following functions' implementations are in RenderBlockLineLayout.cpp.
557 typedef std::pair<RenderText*, LazyLineBreakIterator> LineBreakIteratorInfo;
560 LineBreaker(RenderBlock* block)
566 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine, unsigned consecutiveHyphenatedLines);
568 bool lineWasHyphenated() { return m_hyphenated; }
569 const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; }
570 EClear clear() { return m_clear; }
574 void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
575 void skipLeadingWhitespace(InlineBidiResolver&, const LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
577 RenderBlock* m_block;
580 Vector<RenderBox*> m_positionedObjects;
583 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat);
584 RootInlineBox* determineStartPosition(LineLayoutState&, InlineBidiResolver&);
585 void determineEndPosition(LineLayoutState&, RootInlineBox* startBox, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStatus);
586 bool matchedEndLine(LineLayoutState&, const InlineBidiResolver&, const InlineIterator& endLineStart, const BidiStatus& endLineStatus);
588 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
589 InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* childBox);
591 void setMarginsForRubyRun(BidiRun*, RenderRubyRun*, RenderObject*, const LineInfo&);
593 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
594 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
595 void deleteEllipsisLineBoxes();
596 void checkLinesForTextOverflow();
598 // Positions new floats and also adjust all floats encountered on the line if any of them
599 // have to move to the next page/column.
600 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
601 void appendFloatingObjectToLastLine(FloatingObject*);
603 // End of functions defined in RenderBlockLineLayout.cpp.
605 void paintFloats(PaintInfo&, const LayoutPoint&, bool preservePhase = false);
606 void paintContents(PaintInfo&, const LayoutPoint&);
607 void paintColumnContents(PaintInfo&, const LayoutPoint&, bool paintFloats = false);
608 void paintColumnRules(PaintInfo&, const LayoutPoint&);
609 void paintChildren(PaintInfo&, const LayoutPoint&);
610 void paintEllipsisBoxes(PaintInfo&, const LayoutPoint&);
611 void paintSelection(PaintInfo&, const LayoutPoint&);
612 void paintCaret(PaintInfo&, const LayoutPoint&, CaretType);
614 FloatingObject* insertFloatingObject(RenderBox*);
615 void removeFloatingObject(RenderBox*);
616 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset);
618 // Called from lineWidth, to position the floats added in the last line.
619 // Returns true if and only if it has positioned any floats.
620 bool positionNewFloats();
622 bool hasPositionedFloats() const { return m_hasPositionedFloats; }
623 void addPositionedFloats();
624 bool positionedFloatsNeedRelayout();
626 void clearFloats(BlockLayoutPass);
627 LayoutUnit getClearDelta(RenderBox* child, LayoutUnit yPos);
629 virtual bool avoidsFloats() const;
631 bool hasOverhangingFloats() { return parent() && !hasColumns() && containsFloats() && lowestFloatLogicalBottomIncludingPositionedFloats() > logicalHeight(); }
632 bool hasOverhangingFloat(RenderBox*);
633 void addIntrudingFloats(RenderBlock* prev, LayoutUnit xoffset, LayoutUnit yoffset);
634 LayoutUnit addOverhangingFloats(RenderBlock* child, bool makeChildPaintOtherFloats);
636 LayoutUnit lowestFloatLogicalBottom() const { return lowestFloatLogicalBottom(FloatingObject::FloatLeftRight); }
637 LayoutUnit lowestFloatLogicalBottomIncludingPositionedFloats() const { return lowestFloatLogicalBottom(FloatingObject::FloatAll); }
638 LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type) const;
639 LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
641 virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
642 virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
643 bool hitTestFloats(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
645 virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset);
647 void computeInlinePreferredLogicalWidths();
648 void computeBlockPreferredLogicalWidths();
650 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
652 virtual RenderBlock* firstLineBlock() const;
654 virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
655 virtual RenderStyle* outlineStyleForRepaint() const;
657 virtual RenderObject* hoverAncestor() const;
658 virtual void updateDragState(bool dragOn);
659 virtual void childBecameNonInline(RenderObject* child);
661 virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/)
663 return selectionGapRectsForRepaint(repaintContainer);
665 virtual bool shouldPaintSelectionGaps() const;
666 bool isSelectionRoot() const;
667 GapRects selectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
668 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo* = 0);
669 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
670 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo*);
671 GapRects blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
672 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const PaintInfo*);
673 LayoutRect blockSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
674 LayoutUnit lastLogicalTop, LayoutUnit lastLogicalLeft, LayoutUnit lastLogicalRight, LayoutUnit logicalBottom, const PaintInfo*);
675 LayoutUnit logicalLeftSelectionOffset(RenderBlock* rootBlock, LayoutUnit position);
676 LayoutUnit logicalRightSelectionOffset(RenderBlock* rootBlock, LayoutUnit position);
678 virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset);
679 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed);
681 LayoutUnit desiredColumnWidth() const;
682 unsigned desiredColumnCount() const;
683 void setDesiredColumnCountAndWidth(int count, LayoutUnit width);
685 void paintContinuationOutlines(PaintInfo&, const LayoutPoint&);
687 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
689 void adjustPointToColumnContents(LayoutPoint&) const;
690 void adjustForBorderFit(LayoutUnit x, LayoutUnit& left, LayoutUnit& right) const; // Helper function for borderFitAdjust
692 void markLinesDirtyInBlockRange(LayoutUnit logicalTop, LayoutUnit logicalBottom, RootInlineBox* highest = 0);
694 void newLine(EClear);
696 Position positionForBox(InlineBox*, bool start = true) const;
697 VisiblePosition positionForPointWithInlineChildren(const LayoutPoint&);
699 // Adjust from painting offsets to the local coords of this renderer
700 void offsetForContents(LayoutPoint&) const;
702 void calcColumnWidth();
703 bool layoutColumns(bool hasSpecifiedPageLogicalHeight, int pageLogicalHeight, LayoutStateMaintainer&);
704 void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild);
706 bool expandsToEncloseOverhangingFloats() const;
708 void updateScrollInfoAfterLayout();
710 RenderObject* splitAnonymousBlocksAroundChild(RenderObject* beforeChild);
711 void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
712 RenderObject* beforeChild, RenderBoxModelObject* oldCont);
713 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
714 RenderObject* newChild, RenderBoxModelObject* oldCont);
715 RenderBlock* clone() const;
716 RenderBlock* continuationBefore(RenderObject* beforeChild);
717 RenderBlock* containingColumnsBlock(bool allowAnonymousColumnBlock = true);
718 RenderBlock* columnsBlockForSpanningElement(RenderObject* newChild);
721 // Collapsing flags for whether we can collapse our margins with our children's margins.
722 bool m_canCollapseWithChildren : 1;
723 bool m_canCollapseMarginBeforeWithChildren : 1;
724 bool m_canCollapseMarginAfterWithChildren : 1;
726 // Whether or not we are a quirky container, i.e., do we collapse away top and bottom
727 // margins in our container. Table cells and the body are the common examples. We
728 // also have a custom style property for Safari RSS to deal with TypePad blog articles.
729 bool m_quirkContainer : 1;
731 // This flag tracks whether we are still looking at child margins that can all collapse together at the beginning of a block.
732 // They may or may not collapse with the top margin of the block (|m_canCollapseTopWithChildren| tells us that), but they will
733 // always be collapsing with one another. This variable can remain set to true through multiple iterations
734 // as long as we keep encountering self-collapsing blocks.
735 bool m_atBeforeSideOfBlock : 1;
737 // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block.
738 bool m_atAfterSideOfBlock : 1;
740 // These variables are used to detect quirky margins that we need to collapse away (in table cells
741 // and in the body element).
742 bool m_marginBeforeQuirk : 1;
743 bool m_marginAfterQuirk : 1;
744 bool m_determinedMarginBeforeQuirk : 1;
746 // These flags track the previous maximal positive and negative margins.
747 LayoutUnit m_positiveMargin;
748 LayoutUnit m_negativeMargin;
751 MarginInfo(RenderBlock*, LayoutUnit beforeBorderPadding, LayoutUnit afterBorderPadding);
753 void setAtBeforeSideOfBlock(bool b) { m_atBeforeSideOfBlock = b; }
754 void setAtAfterSideOfBlock(bool b) { m_atAfterSideOfBlock = b; }
755 void clearMargin() { m_positiveMargin = m_negativeMargin = 0; }
756 void setMarginBeforeQuirk(bool b) { m_marginBeforeQuirk = b; }
757 void setMarginAfterQuirk(bool b) { m_marginAfterQuirk = b; }
758 void setDeterminedMarginBeforeQuirk(bool b) { m_determinedMarginBeforeQuirk = b; }
759 void setPositiveMargin(int p) { m_positiveMargin = p; }
760 void setNegativeMargin(int n) { m_negativeMargin = n; }
761 void setPositiveMarginIfLarger(int p) { if (p > m_positiveMargin) m_positiveMargin = p; }
762 void setNegativeMarginIfLarger(int n) { if (n > m_negativeMargin) m_negativeMargin = n; }
764 void setMargin(int p, int n) { m_positiveMargin = p; m_negativeMargin = n; }
766 bool atBeforeSideOfBlock() const { return m_atBeforeSideOfBlock; }
767 bool canCollapseWithMarginBefore() const { return m_atBeforeSideOfBlock && m_canCollapseMarginBeforeWithChildren; }
768 bool canCollapseWithMarginAfter() const { return m_atAfterSideOfBlock && m_canCollapseMarginAfterWithChildren; }
769 bool canCollapseMarginBeforeWithChildren() const { return m_canCollapseMarginBeforeWithChildren; }
770 bool canCollapseMarginAfterWithChildren() const { return m_canCollapseMarginAfterWithChildren; }
771 bool quirkContainer() const { return m_quirkContainer; }
772 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQuirk; }
773 bool marginBeforeQuirk() const { return m_marginBeforeQuirk; }
774 bool marginAfterQuirk() const { return m_marginAfterQuirk; }
775 LayoutUnit positiveMargin() const { return m_positiveMargin; }
776 LayoutUnit negativeMargin() const { return m_negativeMargin; }
777 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; }
780 void layoutBlockChild(RenderBox* child, MarginInfo&, LayoutUnit& previousFloatLogicalBottom, LayoutUnit& maxFloatLogicalBottom);
781 void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
782 void adjustFloatingBlock(const MarginInfo&);
783 bool handleSpecialChild(RenderBox* child, const MarginInfo&);
784 bool handleFloatingChild(RenderBox* child, const MarginInfo&);
785 bool handlePositionedChild(RenderBox* child, const MarginInfo&);
786 bool handleRunInChild(RenderBox* child);
787 LayoutUnit collapseMargins(RenderBox* child, MarginInfo&);
788 LayoutUnit clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);
789 LayoutUnit estimateLogicalTopPosition(RenderBox* child, const MarginInfo&);
790 void determineLogicalLeftPositionForChild(RenderBox* child);
791 void handleAfterSideOfBlock(LayoutUnit top, LayoutUnit bottom, MarginInfo&);
792 void setCollapsedBottomMargin(const MarginInfo&);
793 // End helper functions and structs used by layoutBlockChildren.
795 // Helper function for layoutInlineChildren()
796 RootInlineBox* createLineBoxesFromBidiRuns(BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun);
797 void layoutRunsAndFloats(LineLayoutState&, bool hasInlineChild);
798 void layoutRunsAndFloatsInRange(LineLayoutState&, InlineBidiResolver&, const InlineIterator& cleanLineStart, const BidiStatus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines);
799 void linkToEndLineIfNeeded(LineLayoutState&);
800 static void repaintDirtyFloats(Vector<FloatWithRect>& floats);
802 // Pagination routines.
804 // Returns the logicalOffset at the top of the next page. If the offset passed in is already at the top of the current page,
805 // then nextPageLogicalTopExcludingBoundaryPoint will still move to the top of the next page. nextPageLogicalTopIncludingBoundaryPoint
808 // For a page height of 800px, the first function will return 800 if the value passed in is 0. The second function will simply return 0.
809 LayoutUnit nextPageLogicalTopExcludingBoundaryPoint(LayoutUnit logicalOffset) const;
810 LayoutUnit nextPageLogicalTopIncludingBoundaryPoint(LayoutUnit logicalOffset) const;
812 int applyBeforeBreak(RenderBox* child, int logicalOffset); // If the child has a before break, then return a new yPos that shifts to the top of the next page/column.
813 int applyAfterBreak(RenderBox* child, int logicalOffset, MarginInfo& marginInfo); // If the child has an after break, then return a new offset that shifts to the top of the next page/column.
814 LayoutUnit adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins = false); // If the child is unsplittable and can't fit on the current page, return the top of the next page/column.
815 void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
817 struct FloatingObjectHashFunctions {
818 static unsigned hash(FloatingObject* key) { return DefaultHash<RenderBox*>::Hash::hash(key->m_renderer); }
819 static bool equal(FloatingObject* a, FloatingObject* b) { return a->m_renderer == b->m_renderer; }
820 static const bool safeToCompareToEmptyOrDeleted = true;
822 struct FloatingObjectHashTranslator {
823 static unsigned hash(RenderBox* key) { return DefaultHash<RenderBox*>::Hash::hash(key); }
824 static bool equal(FloatingObject* a, RenderBox* b) { return a->m_renderer == b; }
826 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> FloatingObjectSet;
827 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator;
828 typedef PODInterval<LayoutUnit, FloatingObject*> FloatingObjectInterval;
829 typedef PODIntervalTree<LayoutUnit, FloatingObject*> FloatingObjectTree;
831 template <FloatingObject::Type FloatTypeValue>
832 class FloatIntervalSearchAdapter {
834 typedef FloatingObjectInterval IntervalType;
836 FloatIntervalSearchAdapter(const RenderBlock* renderer, LayoutUnit value, LayoutUnit& offset, LayoutUnit* heightRemaining)
837 : m_renderer(renderer)
840 , m_heightRemaining(heightRemaining)
844 inline LayoutUnit lowValue() const { return m_value; }
845 inline LayoutUnit highValue() const { return m_value; }
846 void collectIfNeeded(const IntervalType&) const;
849 const RenderBlock* m_renderer;
851 LayoutUnit& m_offset;
852 LayoutUnit* m_heightRemaining;
855 class FloatingObjects {
857 FloatingObjects(bool horizontalWritingMode)
858 : m_placedFloatsTree(UninitializedTree)
859 , m_leftObjectsCount(0)
860 , m_rightObjectsCount(0)
861 , m_positionedObjectsCount(0)
862 , m_horizontalWritingMode(horizontalWritingMode)
867 void add(FloatingObject*);
868 void remove(FloatingObject*);
869 void addPlacedObject(FloatingObject*);
870 void removePlacedObject(FloatingObject*);
871 void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b; }
873 bool hasLeftObjects() const { return m_leftObjectsCount > 0; }
874 bool hasRightObjects() const { return m_rightObjectsCount > 0; }
875 bool hasPositionedObjects() const { return m_positionedObjectsCount > 0; }
876 const FloatingObjectSet& set() const { return m_set; }
877 const FloatingObjectTree& placedFloatsTree()
879 computePlacedFloatsTreeIfNeeded();
880 return m_placedFloatsTree;
883 void computePlacedFloatsTree();
884 inline void computePlacedFloatsTreeIfNeeded()
886 if (!m_placedFloatsTree.isInitialized())
887 computePlacedFloatsTree();
889 void increaseObjectsCount(FloatingObject::Type);
890 void decreaseObjectsCount(FloatingObject::Type);
891 FloatingObjectInterval intervalForFloatingObject(FloatingObject*);
893 FloatingObjectSet m_set;
894 FloatingObjectTree m_placedFloatsTree;
895 unsigned m_leftObjectsCount;
896 unsigned m_rightObjectsCount;
897 unsigned m_positionedObjectsCount;
898 bool m_horizontalWritingMode;
900 OwnPtr<FloatingObjects> m_floatingObjects;
902 typedef PositionedObjectsListHashSet::const_iterator Iterator;
903 OwnPtr<PositionedObjectsListHashSet> m_positionedObjects;
905 // Allocated only when some of these fields have non-default values
906 struct RenderBlockRareData {
907 WTF_MAKE_NONCOPYABLE(RenderBlockRareData); WTF_MAKE_FAST_ALLOCATED;
909 RenderBlockRareData(const RenderBlock* block)
910 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block))
911 , m_paginationStrut(0)
912 , m_pageLogicalOffset(0)
916 static int positiveMarginBeforeDefault(const RenderBlock* block)
918 return std::max<LayoutUnit>(block->marginBefore(), 0);
921 static int negativeMarginBeforeDefault(const RenderBlock* block)
923 return std::max<LayoutUnit>(-block->marginBefore(), 0);
925 static int positiveMarginAfterDefault(const RenderBlock* block)
927 return std::max<LayoutUnit>(block->marginAfter(), 0);
929 static int negativeMarginAfterDefault(const RenderBlock* block)
931 return std::max<LayoutUnit>(-block->marginAfter(), 0);
934 MarginValues m_margins;
935 int m_paginationStrut;
936 int m_pageLogicalOffset;
939 OwnPtr<RenderBlockRareData> m_rareData;
941 RenderObjectChildList m_children;
942 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>.
944 mutable signed m_lineHeight : 30;
945 bool m_beingDestroyed : 1;
946 bool m_hasPositionedFloats : 1;
948 // RenderRubyBase objects need to be able to split and merge, moving their children around
949 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
950 friend class RenderRubyBase;
951 friend class LineWidth; // Needs to know FloatingObject
954 // Used to store state between styleWillChange and styleDidChange
955 static bool s_canPropagateFloatIntoSibling;
958 inline RenderBlock* toRenderBlock(RenderObject* object)
960 ASSERT(!object || object->isRenderBlock());
961 return static_cast<RenderBlock*>(object);
964 inline const RenderBlock* toRenderBlock(const RenderObject* object)
966 ASSERT(!object || object->isRenderBlock());
967 return static_cast<const RenderBlock*>(object);
970 // This will catch anyone doing an unnecessary cast.
971 void toRenderBlock(const RenderBlock*);
974 // These structures are used by PODIntervalTree for debugging purposes.
975 template <> struct ValueToString<int> {
976 static String string(const int value);
978 template<> struct ValueToString<RenderBlock::FloatingObject*> {
979 static String string(const RenderBlock::FloatingObject*);
983 } // namespace WebCore
985 #endif // RenderBlock_h