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, 2010 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 "GapRects.h"
27 #include "RenderBox.h"
28 #include "RenderLineBoxList.h"
29 #include "RootInlineBox.h"
30 #include <wtf/OwnPtr.h>
31 #include <wtf/ListHashSet.h>
32
33 namespace WebCore {
34
35 class BidiContext;
36 class ColumnInfo;
37 class InlineIterator;
38 class LayoutStateMaintainer;
39 class LazyLineBreakIterator;
40 class LineWidth;
41 class RenderInline;
42 class RenderText;
43
44 struct BidiRun;
45 struct PaintInfo;
46 class LineInfo;
47 class RenderRubyRun;
48
49 template <class Iterator, class Run> class BidiResolver;
50 template <class Run> class BidiRunList;
51 template <class Iterator> struct MidpointState;
52 typedef BidiResolver<InlineIterator, BidiRun> InlineBidiResolver;
53 typedef MidpointState<InlineIterator> LineMidpointState;
54
55 enum CaretType { CursorCaret, DragCaret };
56
57 class RenderBlock : public RenderBox {
58 public:
59 RenderBlock(Node*);
60 virtual ~RenderBlock();
61
children()62 const RenderObjectChildList* children() const { return &m_children; }
children()63 RenderObjectChildList* children() { return &m_children; }
64
65 virtual void destroy();
beingDestroyed()66 bool beingDestroyed() const { return m_beingDestroyed; }
67
68 // These two functions are overridden for inline-block.
69 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
70 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
71
lineBoxes()72 RenderLineBoxList* lineBoxes() { return &m_lineBoxes; }
lineBoxes()73 const RenderLineBoxList* lineBoxes() const { return &m_lineBoxes; }
74
firstLineBox()75 InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
lastLineBox()76 InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
77
78 void deleteLineBoxTree();
79
80 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
81 virtual void removeChild(RenderObject*);
82
83 virtual void layoutBlock(bool relayoutChildren, int pageLogicalHeight = 0);
84
85 void insertPositionedObject(RenderBox*);
86 void removePositionedObject(RenderBox*);
87 void removePositionedObjects(RenderBlock*);
88
89 typedef ListHashSet<RenderBox*, 4> PositionedObjectsListHashSet;
positionedObjects()90 PositionedObjectsListHashSet* positionedObjects() const { return m_positionedObjects.get(); }
91
92 void addPercentHeightDescendant(RenderBox*);
93 static void removePercentHeightDescendant(RenderBox*);
94 HashSet<RenderBox*>* percentHeightDescendants() const;
95
96 RootInlineBox* createAndAppendRootInlineBox();
97
98 bool generatesLineBoxesForInlineChild(RenderObject*);
99
100 void markAllDescendantsWithFloatsForLayout(RenderBox* floatToRemove = 0, bool inLayout = true);
101 void markSiblingsWithFloatsForLayout();
102 void markPositionedObjectsForLayout();
103 virtual void markForPaginationRelayoutIfNeeded();
104
containsFloats()105 bool containsFloats() { return m_floatingObjects && !m_floatingObjects->set().isEmpty(); }
106 bool containsFloat(RenderBox*);
107
108 int availableLogicalWidthForLine(int position, bool firstLine) const;
logicalRightOffsetForLine(int position,bool firstLine)109 int logicalRightOffsetForLine(int position, bool firstLine) const { return logicalRightOffsetForLine(position, logicalRightOffsetForContent(), firstLine); }
logicalLeftOffsetForLine(int position,bool firstLine)110 int logicalLeftOffsetForLine(int position, bool firstLine) const { return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(), firstLine); }
startOffsetForLine(int position,bool firstLine)111 int startOffsetForLine(int position, bool firstLine) const { return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, firstLine) : logicalRightOffsetForLine(position, firstLine); }
112
113 virtual VisiblePosition positionForPoint(const IntPoint&);
114
115 // Block flows subclass availableWidth to handle multi column layout (shrinking the width available to children when laying out.)
116 virtual int availableLogicalWidth() const;
117
118 IntPoint flipForWritingModeIncludingColumns(const IntPoint&) const;
119 void flipForWritingModeIncludingColumns(IntRect&) const;
120
firstRootBox()121 RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
lastRootBox()122 RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
123
124 bool containsNonZeroBidiLevel() const;
125
126 GapRects selectionGapRectsForRepaint(RenderBoxModelObject* repaintContainer);
127 IntRect logicalLeftSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
128 RenderObject* selObj, int logicalLeft, int logicalTop, int logicalHeight, const PaintInfo*);
129 IntRect logicalRightSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
130 RenderObject* selObj, int logicalRight, int logicalTop, int logicalHeight, const PaintInfo*);
131 void getSelectionGapInfo(SelectionState, bool& leftGap, bool& rightGap);
132 IntRect logicalRectToPhysicalRect(const IntPoint& physicalPosition, const IntRect& logicalRect);
133
134 // Helper methods for computing line counts and heights for line counts.
135 RootInlineBox* lineAtIndex(int);
136 int lineCount();
137 int heightForLineCount(int);
138 void clearTruncation();
139
140 void adjustRectForColumns(IntRect&) const;
141 virtual void adjustForColumns(IntSize&, const IntPoint&) const;
142
143 void addContinuationWithOutline(RenderInline*);
144 bool paintsContinuationOutline(RenderInline*);
145
virtualContinuation()146 virtual RenderBoxModelObject* virtualContinuation() const { return continuation(); }
isAnonymousBlockContinuation()147 bool isAnonymousBlockContinuation() const { return continuation() && isAnonymousBlock(); }
148 RenderInline* inlineElementContinuation() const;
149 RenderBlock* blockElementContinuation() const;
150
151 using RenderBoxModelObject::continuation;
152 using RenderBoxModelObject::setContinuation;
153
154 // This function is a convenience helper for creating an anonymous block that inherits its
155 // style from this RenderBlock.
156 RenderBlock* createAnonymousBlock(bool isFlexibleBox = false) const;
157 RenderBlock* createAnonymousColumnsBlock() const;
158 RenderBlock* createAnonymousColumnSpanBlock() const;
159 RenderBlock* createAnonymousBlockWithSameTypeAs(RenderBlock* otherAnonymousBlock) const;
160
161 static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&);
162
163 ColumnInfo* columnInfo() const;
164 int columnGap() const;
165
166 // These two functions take the ColumnInfo* to avoid repeated lookups of the info in the global HashMap.
167 unsigned columnCount(ColumnInfo*) const;
168 IntRect columnRectAt(ColumnInfo*, unsigned) const;
169
paginationStrut()170 int paginationStrut() const { return m_rareData ? m_rareData->m_paginationStrut : 0; }
171 void setPaginationStrut(int);
172
shouldBreakAtLineToAvoidWidow()173 bool shouldBreakAtLineToAvoidWidow() const { return m_rareData && m_rareData->m_shouldBreakAtLineToAvoidWidow; }
174 void clearShouldBreakAtLineToAvoidWidow() const;
lineBreakToAvoidWidow()175 RootInlineBox* lineBreakToAvoidWidow() const { return m_rareData ? m_rareData->m_lineBreakToAvoidWidow : 0; }
176 void setBreakAtLineToAvoidWidow(RootInlineBox*);
177
178 // The page logical offset is the object's offset from the top of the page in the page progression
179 // direction (so an x-offset in vertical text and a y-offset for horizontal text).
pageLogicalOffset()180 int pageLogicalOffset() const { return m_rareData ? m_rareData->m_pageLogicalOffset : 0; }
181 void setPageLogicalOffset(int);
182
183 // Accessors for logical width/height and margins in the containing block's block-flow direction.
184 enum ApplyLayoutDeltaMode { ApplyLayoutDelta, DoNotApplyLayoutDelta };
logicalWidthForChild(RenderBox * child)185 int logicalWidthForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->width() : child->height(); }
logicalHeightForChild(RenderBox * child)186 int logicalHeightForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->height() : child->width(); }
logicalTopForChild(RenderBox * child)187 int logicalTopForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->y() : child->x(); }
188 void setLogicalLeftForChild(RenderBox* child, int logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
189 void setLogicalTopForChild(RenderBox* child, int logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
190 int marginBeforeForChild(RenderBoxModelObject* child) const;
191 int marginAfterForChild(RenderBoxModelObject* child) const;
192 int marginStartForChild(RenderBoxModelObject* child) const;
193 int marginEndForChild(RenderBoxModelObject* child) const;
194 void setMarginStartForChild(RenderBox* child, int);
195 void setMarginEndForChild(RenderBox* child, int);
196 void setMarginBeforeForChild(RenderBox* child, int);
197 void setMarginAfterForChild(RenderBox* child, int);
198 int collapsedMarginBeforeForChild(RenderBox* child) const;
199 int collapsedMarginAfterForChild(RenderBox* child) const;
200
201 virtual void updateFirstLetter();
202
203 class MarginValues {
204 public:
MarginValues(int beforePos,int beforeNeg,int afterPos,int afterNeg)205 MarginValues(int beforePos, int beforeNeg, int afterPos, int afterNeg)
206 : m_positiveMarginBefore(beforePos)
207 , m_negativeMarginBefore(beforeNeg)
208 , m_positiveMarginAfter(afterPos)
209 , m_negativeMarginAfter(afterNeg)
210 { }
211
positiveMarginBefore()212 int positiveMarginBefore() const { return m_positiveMarginBefore; }
negativeMarginBefore()213 int negativeMarginBefore() const { return m_negativeMarginBefore; }
positiveMarginAfter()214 int positiveMarginAfter() const { return m_positiveMarginAfter; }
negativeMarginAfter()215 int negativeMarginAfter() const { return m_negativeMarginAfter; }
216
setPositiveMarginBefore(int pos)217 void setPositiveMarginBefore(int pos) { m_positiveMarginBefore = pos; }
setNegativeMarginBefore(int neg)218 void setNegativeMarginBefore(int neg) { m_negativeMarginBefore = neg; }
setPositiveMarginAfter(int pos)219 void setPositiveMarginAfter(int pos) { m_positiveMarginAfter = pos; }
setNegativeMarginAfter(int neg)220 void setNegativeMarginAfter(int neg) { m_negativeMarginAfter = neg; }
221
222 private:
223 int m_positiveMarginBefore;
224 int m_negativeMarginBefore;
225 int m_positiveMarginAfter;
226 int m_negativeMarginAfter;
227 };
228 MarginValues marginValuesForChild(RenderBox* child);
229
scrollbarsChanged(bool,bool)230 virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { };
231
logicalRightOffsetForContent()232 int logicalRightOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() + availableLogicalWidth() : borderTop() + paddingTop() + availableLogicalWidth(); }
logicalLeftOffsetForContent()233 int logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
234
235 #ifndef NDEBUG
236 void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
237 #endif
238 protected:
239 // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode.
240 // Since they are typically called only to move objects around within anonymous blocks (which only have layers in
241 // the case of column spans), the default for fullRemoveInsert is false rather than true.
242 void moveChildTo(RenderBlock* to, RenderObject* child, bool fullRemoveInsert = false)
243 {
244 return moveChildTo(to, child, 0, fullRemoveInsert);
245 }
246 void moveChildTo(RenderBlock* to, RenderObject* child, RenderObject* beforeChild, bool fullRemoveInsert = false);
247 void moveAllChildrenTo(RenderBlock* to, bool fullRemoveInsert = false)
248 {
249 return moveAllChildrenTo(to, 0, fullRemoveInsert);
250 }
251 void moveAllChildrenTo(RenderBlock* to, RenderObject* beforeChild, bool fullRemoveInsert = false)
252 {
253 return moveChildrenTo(to, firstChild(), 0, beforeChild, fullRemoveInsert);
254 }
255 // Move all of the kids from |startChild| up to but excluding |endChild|. 0 can be passed as the endChild to denote
256 // that all the kids from |startChild| onwards should be added.
257 void moveChildrenTo(RenderBlock* to, RenderObject* startChild, RenderObject* endChild, bool fullRemoveInsert = false)
258 {
259 return moveChildrenTo(to, startChild, endChild, 0, fullRemoveInsert);
260 }
261 void moveChildrenTo(RenderBlock* to, RenderObject* startChild, RenderObject* endChild, RenderObject* beforeChild, bool fullRemoveInsert = false);
262
maxPositiveMarginBefore()263 int maxPositiveMarginBefore() const { return m_rareData ? m_rareData->m_margins.positiveMarginBefore() : RenderBlockRareData::positiveMarginBeforeDefault(this); }
maxNegativeMarginBefore()264 int maxNegativeMarginBefore() const { return m_rareData ? m_rareData->m_margins.negativeMarginBefore() : RenderBlockRareData::negativeMarginBeforeDefault(this); }
maxPositiveMarginAfter()265 int maxPositiveMarginAfter() const { return m_rareData ? m_rareData->m_margins.positiveMarginAfter() : RenderBlockRareData::positiveMarginAfterDefault(this); }
maxNegativeMarginAfter()266 int maxNegativeMarginAfter() const { return m_rareData ? m_rareData->m_margins.negativeMarginAfter() : RenderBlockRareData::negativeMarginAfterDefault(this); }
267
268 void setMaxMarginBeforeValues(int pos, int neg);
269 void setMaxMarginAfterValues(int pos, int neg);
270
initMaxMarginValues()271 void initMaxMarginValues()
272 {
273 if (m_rareData) {
274 m_rareData->m_margins = MarginValues(RenderBlockRareData::positiveMarginBeforeDefault(this) , RenderBlockRareData::negativeMarginBeforeDefault(this),
275 RenderBlockRareData::positiveMarginAfterDefault(this), RenderBlockRareData::negativeMarginAfterDefault(this));
276 m_rareData->m_paginationStrut = 0;
277 }
278 }
279
280 virtual void layout();
281
282 void layoutPositionedObjects(bool relayoutChildren);
283
284 virtual void paint(PaintInfo&, int tx, int ty);
285 virtual void paintObject(PaintInfo&, int tx, int ty);
286
287 int logicalRightOffsetForLine(int position, int fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
288 int logicalLeftOffsetForLine(int position, int fixedOffset, bool applyTextIndent = true, int* logicalHeightRemaining = 0) const;
289
290 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
adjustInlineDirectionLineBounds(int,float &,float &)291 virtual void adjustInlineDirectionLineBounds(int /* expansionOpportunityCount */, float& /* logicalLeft */, float& /* logicalWidth */) const { }
292
293 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
294
295 virtual void computePreferredLogicalWidths();
296
297 virtual int firstLineBoxBaseline() const;
298 virtual int lastLineBoxBaseline() const;
299
300 virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
301
302 // Delay update scrollbar until finishDelayRepaint() will be
303 // called. This function is used when a flexbox is laying out its
304 // descendant. If multiple calls are made to startDelayRepaint(),
305 // finishDelayRepaint() will do nothing until finishDelayRepaint()
306 // is called the same number of times.
307 static void startDelayUpdateScrollInfo();
308 static void finishDelayUpdateScrollInfo();
309
310 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
311 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
312
313 virtual bool hasLineIfEmpty() const;
314
315 bool simplifiedLayout();
316 void simplifiedNormalFlowLayout();
317
318 void computeOverflow(int oldClientAfterEdge, bool recomputeFloats = false);
319 virtual void addOverflowFromChildren();
320 void addOverflowFromFloats();
321 void addOverflowFromPositionedObjects();
322 void addOverflowFromBlockChildren();
323 void addOverflowFromInlineChildren();
324
325 virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
326
327 #if ENABLE(SVG)
328 // Only used by RenderSVGText, which explicitely overrides RenderBlock::layoutBlock(), do NOT use for anything else.
forceLayoutInlineChildren()329 void forceLayoutInlineChildren()
330 {
331 int repaintLogicalTop = 0;
332 int repaintLogicalBottom = 0;
333 layoutInlineChildren(true, repaintLogicalTop, repaintLogicalBottom);
334 }
335 #endif
336
337 private:
virtualChildren()338 virtual RenderObjectChildList* virtualChildren() { return children(); }
virtualChildren()339 virtual const RenderObjectChildList* virtualChildren() const { return children(); }
340
341 virtual const char* renderName() const;
342
isRenderBlock()343 virtual bool isRenderBlock() const { return true; }
isBlockFlow()344 virtual bool isBlockFlow() const { return (!isInline() || isReplaced()) && !isTable(); }
isInlineBlockOrInlineTable()345 virtual bool isInlineBlockOrInlineTable() const { return isInline() && isReplaced(); }
346
347 void makeChildrenNonInline(RenderObject* insertionPoint = 0);
348 virtual void removeLeftoverAnonymousBlock(RenderBlock* child);
349
dirtyLinesFromChangedChild(RenderObject * child)350 virtual void dirtyLinesFromChangedChild(RenderObject* child) { m_lineBoxes.dirtyLinesFromChangedChild(this, child); }
351
352 void addChildToContinuation(RenderObject* newChild, RenderObject* beforeChild);
353 void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild);
354 void addChildToAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild);
355 virtual void addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild, RenderObject* beforeChild = 0);
356
357 virtual bool isSelfCollapsingBlock() const;
358
collapsedMarginBefore()359 virtual int collapsedMarginBefore() const { return maxPositiveMarginBefore() - maxNegativeMarginBefore(); }
collapsedMarginAfter()360 virtual int collapsedMarginAfter() const { return maxPositiveMarginAfter() - maxNegativeMarginAfter(); }
361
362 virtual void repaintOverhangingFloats(bool paintAllDescendants);
363
364 void layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom);
365 void layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom);
366 BidiRun* handleTrailingSpaces(BidiRunList<BidiRun>&, BidiContext*);
367
368 virtual void borderFitAdjust(int& x, int& w) const; // Shrink the box in which the border paints if border-fit is set.
369
370 virtual void updateBeforeAfterContent(PseudoId);
371
372 virtual RootInlineBox* createRootInlineBox(); // Subclassed by SVG and Ruby.
373
374 // Called to lay out the legend for a fieldset or the ruby text of a ruby run.
layoutSpecialExcludedChild(bool)375 virtual RenderObject* layoutSpecialExcludedChild(bool /*relayoutChildren*/) { return 0; }
376
377 struct FloatWithRect {
FloatWithRectFloatWithRect378 FloatWithRect(RenderBox* f)
379 : object(f)
380 , rect(IntRect(f->x() - f->marginLeft(), f->y() - f->marginTop(), f->width() + f->marginLeft() + f->marginRight(), f->height() + f->marginTop() + f->marginBottom()))
381 , everHadLayout(f->m_everHadLayout)
382 {
383 }
384
385 RenderBox* object;
386 IntRect rect;
387 bool everHadLayout;
388 };
389
390 struct FloatingObject {
391 WTF_MAKE_NONCOPYABLE(FloatingObject); WTF_MAKE_FAST_ALLOCATED;
392 public:
393 // Note that Type uses bits so you can use FloatBoth as a mask to query for both left and right.
394 enum Type { FloatLeft = 1, FloatRight = 2, FloatBoth = 3 };
395
FloatingObjectFloatingObject396 FloatingObject(Type type)
397 : m_renderer(0)
398 , m_originatingLine(0)
399 , m_paginationStrut(0)
400 , m_type(type)
401 , m_shouldPaint(true)
402 , m_isDescendant(false)
403 , m_isPlaced(false)
404 {
405 }
406
FloatingObjectFloatingObject407 FloatingObject(Type type, const IntRect& frameRect)
408 : m_renderer(0)
409 , m_originatingLine(0)
410 , m_frameRect(frameRect)
411 , m_paginationStrut(0)
412 , m_type(type)
413 , m_shouldPaint(true)
414 , m_isDescendant(false)
415 , m_isPlaced(true)
416 {
417 }
418
typeFloatingObject419 Type type() const { return static_cast<Type>(m_type); }
rendererFloatingObject420 RenderBox* renderer() const { return m_renderer; }
421
isPlacedFloatingObject422 bool isPlaced() const { return m_isPlaced; }
423 void setIsPlaced(bool placed = true) { m_isPlaced = placed; }
424
xFloatingObject425 int x() const { ASSERT(isPlaced()); return m_frameRect.x(); }
maxXFloatingObject426 int maxX() const { ASSERT(isPlaced()); return m_frameRect.maxX(); }
yFloatingObject427 int y() const { ASSERT(isPlaced()); return m_frameRect.y(); }
maxYFloatingObject428 int maxY() const { ASSERT(isPlaced()); return m_frameRect.maxY(); }
widthFloatingObject429 int width() const { return m_frameRect.width(); }
heightFloatingObject430 int height() const { return m_frameRect.height(); }
431
setXFloatingObject432 void setX(int x) { m_frameRect.setX(x); }
setYFloatingObject433 void setY(int y) { m_frameRect.setY(y); }
setWidthFloatingObject434 void setWidth(int width) { m_frameRect.setWidth(width); }
setHeightFloatingObject435 void setHeight(int height) { m_frameRect.setHeight(height); }
436
frameRectFloatingObject437 const IntRect& frameRect() const { ASSERT(isPlaced()); return m_frameRect; }
setFrameRectFloatingObject438 void setFrameRect(const IntRect& frameRect) { m_frameRect = frameRect; }
439
440 RenderBox* m_renderer;
441 RootInlineBox* m_originatingLine;
442 IntRect m_frameRect;
443 int m_paginationStrut;
444 unsigned m_type : 2; // Type (left or right aligned)
445 bool m_shouldPaint : 1;
446 bool m_isDescendant : 1;
447 bool m_isPlaced : 1;
448 };
449
450 IntPoint flipFloatForWritingMode(const FloatingObject*, const IntPoint&) const;
451
logicalTopForFloat(const FloatingObject * child)452 int logicalTopForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->y() : child->x(); }
logicalBottomForFloat(const FloatingObject * child)453 int logicalBottomForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxY() : child->maxX(); }
logicalLeftForFloat(const FloatingObject * child)454 int logicalLeftForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->x() : child->y(); }
logicalRightForFloat(const FloatingObject * child)455 int logicalRightForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->maxX() : child->maxY(); }
logicalWidthForFloat(const FloatingObject * child)456 int logicalWidthForFloat(const FloatingObject* child) const { return isHorizontalWritingMode() ? child->width() : child->height(); }
setLogicalTopForFloat(FloatingObject * child,int logicalTop)457 void setLogicalTopForFloat(FloatingObject* child, int logicalTop)
458 {
459 if (isHorizontalWritingMode())
460 child->setY(logicalTop);
461 else
462 child->setX(logicalTop);
463 }
setLogicalLeftForFloat(FloatingObject * child,int logicalLeft)464 void setLogicalLeftForFloat(FloatingObject* child, int logicalLeft)
465 {
466 if (isHorizontalWritingMode())
467 child->setX(logicalLeft);
468 else
469 child->setY(logicalLeft);
470 }
setLogicalHeightForFloat(FloatingObject * child,int logicalHeight)471 void setLogicalHeightForFloat(FloatingObject* child, int logicalHeight)
472 {
473 if (isHorizontalWritingMode())
474 child->setHeight(logicalHeight);
475 else
476 child->setWidth(logicalHeight);
477 }
setLogicalWidthForFloat(FloatingObject * child,int logicalWidth)478 void setLogicalWidthForFloat(FloatingObject* child, int logicalWidth)
479 {
480 if (isHorizontalWritingMode())
481 child->setWidth(logicalWidth);
482 else
483 child->setHeight(logicalWidth);
484 }
485
xPositionForFloatIncludingMargin(const FloatingObject * child)486 int xPositionForFloatIncludingMargin(const FloatingObject* child) const
487 {
488 if (isHorizontalWritingMode())
489 return child->x() + child->renderer()->marginLeft();
490 else
491 return child->x() + marginBeforeForChild(child->renderer());
492 }
493
yPositionForFloatIncludingMargin(const FloatingObject * child)494 int yPositionForFloatIncludingMargin(const FloatingObject* child) const
495 {
496 if (isHorizontalWritingMode())
497 return child->y() + marginBeforeForChild(child->renderer());
498 else
499 return child->y() + child->renderer()->marginTop();
500 }
501
502 // The following functions' implementations are in RenderBlockLineLayout.cpp.
503 typedef std::pair<RenderText*, LazyLineBreakIterator> LineBreakIteratorInfo;
504 class LineBreaker {
505 public:
LineBreaker(RenderBlock * block)506 LineBreaker(RenderBlock* block)
507 : m_block(block)
508 {
509 reset();
510 }
511
512 InlineIterator nextLineBreak(InlineBidiResolver&, LineInfo&, LineBreakIteratorInfo&, FloatingObject* lastFloatFromPreviousLine);
513
lineWasHyphenated()514 bool lineWasHyphenated() { return m_hyphenated; }
positionedObjects()515 const Vector<RenderBox*>& positionedObjects() { return m_positionedObjects; }
clear()516 EClear clear() { return m_clear; }
517 private:
518 void reset();
519
520 void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
521 void skipLeadingWhitespace(InlineBidiResolver&, const LineInfo&, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
522
523 RenderBlock* m_block;
524 bool m_hyphenated;
525 EClear m_clear;
526 Vector<RenderBox*> m_positionedObjects;
527 };
528
529 void checkFloatsInCleanLine(RootInlineBox*, Vector<FloatWithRect>&, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByFloat);
530 RootInlineBox* determineStartPosition(LineInfo&, bool& fullLayout, InlineBidiResolver&, Vector<FloatWithRect>& floats, unsigned& numCleanFloats,
531 bool& useRepaintBounds, int& repaintTop, int& repaintBottom);
532 RootInlineBox* determineEndPosition(RootInlineBox* startBox, Vector<FloatWithRect>& floats, size_t floatIndex, InlineIterator& cleanLineStart,
533 BidiStatus& cleanLineBidiStatus, int& yPos);
534 bool matchedEndLine(const InlineBidiResolver&, const InlineIterator& endLineStart, const BidiStatus& endLineStatus,
535 RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop);
536
537 RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
538 InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox* childBox);
539
540 void setMarginsForRubyRun(BidiRun*, RenderRubyRun*, RenderObject*, const LineInfo&);
541
542 void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
543 void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
544 void deleteEllipsisLineBoxes();
545 void checkLinesForTextOverflow();
546
547 // Positions new floats and also adjust all floats encountered on the line if any of them
548 // have to move to the next page/column.
549 bool positionNewFloatOnLine(FloatingObject* newFloat, FloatingObject* lastFloatFromPreviousLine, LineWidth&);
550 void appendFloatingObjectToLastLine(FloatingObject*);
551
552 // End of functions defined in RenderBlockLineLayout.cpp.
553
554 void paintFloats(PaintInfo&, int tx, int ty, bool preservePhase = false);
555 void paintContents(PaintInfo&, int tx, int ty);
556 void paintColumnContents(PaintInfo&, int tx, int ty, bool paintFloats = false);
557 void paintColumnRules(PaintInfo&, int tx, int ty);
558 void paintChildren(PaintInfo&, int tx, int ty);
559 void paintEllipsisBoxes(PaintInfo&, int tx, int ty);
560 void paintSelection(PaintInfo&, int tx, int ty);
561 void paintCaret(PaintInfo&, int tx, int ty, CaretType);
562
563 FloatingObject* insertFloatingObject(RenderBox*);
564 void removeFloatingObject(RenderBox*);
565 void removeFloatingObjectsBelow(FloatingObject*, int logicalOffset);
566
567 // Called from lineWidth, to position the floats added in the last line.
568 // Returns true if and only if it has positioned any floats.
569 bool positionNewFloats();
570
571 void clearFloats();
572 int getClearDelta(RenderBox* child, int yPos);
573
574 virtual bool avoidsFloats() const;
575
hasOverhangingFloats()576 bool hasOverhangingFloats() { return parent() && !hasColumns() && containsFloats() && lowestFloatLogicalBottom() > logicalHeight(); }
577 bool hasOverhangingFloat(RenderBox*);
578 void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset);
579 int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats);
580
581 int lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatBoth) const;
582 int nextFloatLogicalBottomBelow(int) const;
583
584 virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
585 virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
586 bool hitTestFloats(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
587
588 virtual bool isPointInOverflowControl(HitTestResult&, int x, int y, int tx, int ty);
589
590 void computeInlinePreferredLogicalWidths();
591 void computeBlockPreferredLogicalWidths();
592
593 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
594 // children.
595 virtual RenderBlock* firstLineBlock() const;
596
597 virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
598 virtual RenderStyle* outlineStyleForRepaint() const;
599
600 virtual RenderObject* hoverAncestor() const;
601 virtual void updateDragState(bool dragOn);
602 virtual void childBecameNonInline(RenderObject* child);
603
selectionRectForRepaint(RenderBoxModelObject * repaintContainer,bool)604 virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool /*clipToVisibleContent*/)
605 {
606 return selectionGapRectsForRepaint(repaintContainer);
607 }
608 virtual bool shouldPaintSelectionGaps() const;
609 bool isSelectionRoot() const;
610 GapRects selectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
611 int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo* = 0);
612 GapRects inlineSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
613 int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo*);
614 GapRects blockSelectionGaps(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
615 int& lastLogicalTop, int& lastLogicalLeft, int& lastLogicalRight, const PaintInfo*);
616 IntRect blockSelectionGap(RenderBlock* rootBlock, const IntPoint& rootBlockPhysicalPosition, const IntSize& offsetFromRootBlock,
617 int lastLogicalTop, int lastLogicalLeft, int lastLogicalRight, int logicalBottom, const PaintInfo*);
618 int logicalLeftSelectionOffset(RenderBlock* rootBlock, int position);
619 int logicalRightSelectionOffset(RenderBlock* rootBlock, int position);
620
621 virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
622 virtual void absoluteQuads(Vector<FloatQuad>&);
623
624 int desiredColumnWidth() const;
625 unsigned desiredColumnCount() const;
626 void setDesiredColumnCountAndWidth(int count, int width);
627
628 void paintContinuationOutlines(PaintInfo&, int tx, int ty);
629
630 virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
631
632 void adjustPointToColumnContents(IntPoint&) const;
633 void adjustForBorderFit(int x, int& left, int& right) const; // Helper function for borderFitAdjust
634
635 void markLinesDirtyInBlockRange(int logicalTop, int logicalBottom, RootInlineBox* highest = 0);
636
637 void newLine(EClear);
638
639 Position positionForBox(InlineBox*, bool start = true) const;
640 VisiblePosition positionForPointWithInlineChildren(const IntPoint&);
641
642 // Adjust tx and ty from painting offsets to the local coords of this renderer
643 void offsetForContents(int& tx, int& ty) const;
644
645 void calcColumnWidth();
646 bool layoutColumns(bool hasSpecifiedPageLogicalHeight, int pageLogicalHeight, LayoutStateMaintainer&);
647 void makeChildrenAnonymousColumnBlocks(RenderObject* beforeChild, RenderBlock* newBlockBox, RenderObject* newChild);
648
649 bool expandsToEncloseOverhangingFloats() const;
650
651 void updateScrollInfoAfterLayout();
652
653 RenderObject* splitAnonymousBlocksAroundChild(RenderObject* beforeChild);
654 void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
655 RenderObject* beforeChild, RenderBoxModelObject* oldCont);
656 void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
657 RenderObject* newChild, RenderBoxModelObject* oldCont);
658 RenderBlock* clone() const;
659 RenderBlock* continuationBefore(RenderObject* beforeChild);
660 RenderBlock* containingColumnsBlock(bool allowAnonymousColumnBlock = true);
661 RenderBlock* columnsBlockForSpanningElement(RenderObject* newChild);
662
663 class MarginInfo {
664 // Collapsing flags for whether we can collapse our margins with our children's margins.
665 bool m_canCollapseWithChildren : 1;
666 bool m_canCollapseMarginBeforeWithChildren : 1;
667 bool m_canCollapseMarginAfterWithChildren : 1;
668
669 // Whether or not we are a quirky container, i.e., do we collapse away top and bottom
670 // margins in our container. Table cells and the body are the common examples. We
671 // also have a custom style property for Safari RSS to deal with TypePad blog articles.
672 bool m_quirkContainer : 1;
673
674 // This flag tracks whether we are still looking at child margins that can all collapse together at the beginning of a block.
675 // They may or may not collapse with the top margin of the block (|m_canCollapseTopWithChildren| tells us that), but they will
676 // always be collapsing with one another. This variable can remain set to true through multiple iterations
677 // as long as we keep encountering self-collapsing blocks.
678 bool m_atBeforeSideOfBlock : 1;
679
680 // This flag is set when we know we're examining bottom margins and we know we're at the bottom of the block.
681 bool m_atAfterSideOfBlock : 1;
682
683 // These variables are used to detect quirky margins that we need to collapse away (in table cells
684 // and in the body element).
685 bool m_marginBeforeQuirk : 1;
686 bool m_marginAfterQuirk : 1;
687 bool m_determinedMarginBeforeQuirk : 1;
688
689 // These flags track the previous maximal positive and negative margins.
690 int m_positiveMargin;
691 int m_negativeMargin;
692
693 public:
694 MarginInfo(RenderBlock* b, int beforeBorderPadding, int afterBorderPadding);
695
setAtBeforeSideOfBlock(bool b)696 void setAtBeforeSideOfBlock(bool b) { m_atBeforeSideOfBlock = b; }
setAtAfterSideOfBlock(bool b)697 void setAtAfterSideOfBlock(bool b) { m_atAfterSideOfBlock = b; }
clearMargin()698 void clearMargin() { m_positiveMargin = m_negativeMargin = 0; }
setMarginBeforeQuirk(bool b)699 void setMarginBeforeQuirk(bool b) { m_marginBeforeQuirk = b; }
setMarginAfterQuirk(bool b)700 void setMarginAfterQuirk(bool b) { m_marginAfterQuirk = b; }
setDeterminedMarginBeforeQuirk(bool b)701 void setDeterminedMarginBeforeQuirk(bool b) { m_determinedMarginBeforeQuirk = b; }
setPositiveMargin(int p)702 void setPositiveMargin(int p) { m_positiveMargin = p; }
setNegativeMargin(int n)703 void setNegativeMargin(int n) { m_negativeMargin = n; }
setPositiveMarginIfLarger(int p)704 void setPositiveMarginIfLarger(int p) { if (p > m_positiveMargin) m_positiveMargin = p; }
setNegativeMarginIfLarger(int n)705 void setNegativeMarginIfLarger(int n) { if (n > m_negativeMargin) m_negativeMargin = n; }
706
setMargin(int p,int n)707 void setMargin(int p, int n) { m_positiveMargin = p; m_negativeMargin = n; }
708
atBeforeSideOfBlock()709 bool atBeforeSideOfBlock() const { return m_atBeforeSideOfBlock; }
canCollapseWithMarginBefore()710 bool canCollapseWithMarginBefore() const { return m_atBeforeSideOfBlock && m_canCollapseMarginBeforeWithChildren; }
canCollapseWithMarginAfter()711 bool canCollapseWithMarginAfter() const { return m_atAfterSideOfBlock && m_canCollapseMarginAfterWithChildren; }
canCollapseMarginBeforeWithChildren()712 bool canCollapseMarginBeforeWithChildren() const { return m_canCollapseMarginBeforeWithChildren; }
canCollapseMarginAfterWithChildren()713 bool canCollapseMarginAfterWithChildren() const { return m_canCollapseMarginAfterWithChildren; }
quirkContainer()714 bool quirkContainer() const { return m_quirkContainer; }
determinedMarginBeforeQuirk()715 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQuirk; }
marginBeforeQuirk()716 bool marginBeforeQuirk() const { return m_marginBeforeQuirk; }
marginAfterQuirk()717 bool marginAfterQuirk() const { return m_marginAfterQuirk; }
positiveMargin()718 int positiveMargin() const { return m_positiveMargin; }
negativeMargin()719 int negativeMargin() const { return m_negativeMargin; }
margin()720 int margin() const { return m_positiveMargin - m_negativeMargin; }
721 };
722
723 void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom);
724 void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
725 void adjustFloatingBlock(const MarginInfo&);
726 bool handleSpecialChild(RenderBox* child, const MarginInfo&);
727 bool handleFloatingChild(RenderBox* child, const MarginInfo&);
728 bool handlePositionedChild(RenderBox* child, const MarginInfo&);
729 bool handleRunInChild(RenderBox* child);
730 int collapseMargins(RenderBox* child, MarginInfo&);
731 int clearFloatsIfNeeded(RenderBox* child, MarginInfo&, int oldTopPosMargin, int oldTopNegMargin, int yPos);
732 int estimateLogicalTopPosition(RenderBox* child, const MarginInfo&);
733 void determineLogicalLeftPositionForChild(RenderBox* child);
734 void handleAfterSideOfBlock(int top, int bottom, MarginInfo&);
735 void setCollapsedBottomMargin(const MarginInfo&);
736 // End helper functions and structs used by layoutBlockChildren.
737
738 // Helper function for layoutInlineChildren()
739 RootInlineBox* createLineBoxesFromBidiRuns(BidiRunList<BidiRun>&, const InlineIterator& end, LineInfo&, VerticalPositionCache&, BidiRun* trailingSpaceRun);
740 void layoutRunsAndFloats(bool fullLayout, bool hasInlineChild, Vector<FloatWithRect>&, int& repaintLogicalTop, int& repaintLogicalBottom);
741
742 // Pagination routines.
743 int nextPageLogicalTop(int logicalOffset) const; // Returns the top of the next page following logicalOffset.
744 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.
745 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.
746 int adjustForUnsplittableChild(RenderBox* child, int 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.
747 void adjustLinePositionForPagination(RootInlineBox*, int& 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.
748
749 struct FloatingObjectHashFunctions {
hashFloatingObjectHashFunctions750 static unsigned hash(FloatingObject* key) { return DefaultHash<RenderBox*>::Hash::hash(key->m_renderer); }
equalFloatingObjectHashFunctions751 static bool equal(FloatingObject* a, FloatingObject* b) { return a->m_renderer == b->m_renderer; }
752 static const bool safeToCompareToEmptyOrDeleted = true;
753 };
754 struct FloatingObjectHashTranslator {
hashFloatingObjectHashTranslator755 static unsigned hash(RenderBox* key) { return DefaultHash<RenderBox*>::Hash::hash(key); }
equalFloatingObjectHashTranslator756 static bool equal(FloatingObject* a, RenderBox* b) { return a->m_renderer == b; }
757 };
758 typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> FloatingObjectSet;
759 typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator;
760 class FloatingObjects {
761 public:
FloatingObjects()762 FloatingObjects()
763 : m_leftObjectsCount(0)
764 , m_rightObjectsCount(0)
765 {
766 }
767
768 void clear();
769 void increaseObjectsCount(FloatingObject::Type);
770 void decreaseObjectsCount(FloatingObject::Type);
hasLeftObjects()771 bool hasLeftObjects() const { return m_leftObjectsCount > 0; }
hasRightObjects()772 bool hasRightObjects() const { return m_rightObjectsCount > 0; }
set()773 FloatingObjectSet& set() { return m_set; }
774
775 private:
776 FloatingObjectSet m_set;
777 unsigned m_leftObjectsCount;
778 unsigned m_rightObjectsCount;
779 };
780 OwnPtr<FloatingObjects> m_floatingObjects;
781
782 typedef PositionedObjectsListHashSet::const_iterator Iterator;
783 OwnPtr<PositionedObjectsListHashSet> m_positionedObjects;
784
785 // Allocated only when some of these fields have non-default values
786 struct RenderBlockRareData {
787 WTF_MAKE_NONCOPYABLE(RenderBlockRareData); WTF_MAKE_FAST_ALLOCATED;
788 public:
RenderBlockRareDataRenderBlockRareData789 RenderBlockRareData(const RenderBlock* block)
790 : m_margins(positiveMarginBeforeDefault(block), negativeMarginBeforeDefault(block), positiveMarginAfterDefault(block), negativeMarginAfterDefault(block))
791 , m_paginationStrut(0)
792 , m_pageLogicalOffset(0)
793 , m_shouldBreakAtLineToAvoidWidow(false)
794 , m_lineBreakToAvoidWidow(0)
795 {
796 }
797
positiveMarginBeforeDefaultRenderBlockRareData798 static int positiveMarginBeforeDefault(const RenderBlock* block)
799 {
800 return std::max(block->marginBefore(), 0);
801 }
802
negativeMarginBeforeDefaultRenderBlockRareData803 static int negativeMarginBeforeDefault(const RenderBlock* block)
804 {
805 return std::max(-block->marginBefore(), 0);
806 }
positiveMarginAfterDefaultRenderBlockRareData807 static int positiveMarginAfterDefault(const RenderBlock* block)
808 {
809 return std::max(block->marginAfter(), 0);
810 }
negativeMarginAfterDefaultRenderBlockRareData811 static int negativeMarginAfterDefault(const RenderBlock* block)
812 {
813 return std::max(-block->marginAfter(), 0);
814 }
815
816 MarginValues m_margins;
817 int m_paginationStrut;
818 int m_pageLogicalOffset;
819
820 bool m_shouldBreakAtLineToAvoidWidow;
821 RootInlineBox* m_lineBreakToAvoidWidow;
822 };
823
824 OwnPtr<RenderBlockRareData> m_rareData;
825
826 RenderObjectChildList m_children;
827 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>.
828
829 mutable int m_lineHeight : 31;
830 bool m_beingDestroyed : 1;
831
832 // RenderRubyBase objects need to be able to split and merge, moving their children around
833 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
834 friend class RenderRubyBase;
835 friend class LineWidth; // Needs to know FloatingObject
836
837 private:
838 // Used to store state between styleWillChange and styleDidChange
839 static bool s_canPropagateFloatIntoSibling;
840 };
841
toRenderBlock(RenderObject * object)842 inline RenderBlock* toRenderBlock(RenderObject* object)
843 {
844 ASSERT(!object || object->isRenderBlock());
845 return static_cast<RenderBlock*>(object);
846 }
847
toRenderBlock(const RenderObject * object)848 inline const RenderBlock* toRenderBlock(const RenderObject* object)
849 {
850 ASSERT(!object || object->isRenderBlock());
851 return static_cast<const RenderBlock*>(object);
852 }
853
854 // This will catch anyone doing an unnecessary cast.
855 void toRenderBlock(const RenderBlock*);
856
857 } // namespace WebCore
858
859 #endif // RenderBlock_h
860