2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include "core/CoreExport.h"
27 #include "core/layout/LayoutBoxModelObject.h"
28 #include "core/layout/OverflowModel.h"
29 #include "platform/scroll/ScrollTypes.h"
30 #include "platform/scroll/ScrollableArea.h"
34 class LayoutBlockFlow
;
35 class LayoutMultiColumnSpannerPlaceholder
;
36 class ShapeOutsideInfo
;
40 enum SizeType
{ MainOrPreferredSize
, MinSize
, MaxSize
};
41 enum AvailableLogicalHeightType
{ ExcludeMarginBorderPadding
, IncludeMarginBorderPadding
};
42 enum OverlayScrollbarSizeRelevancy
{ IgnoreOverlayScrollbarSize
, IncludeOverlayScrollbarSize
};
43 enum MarginDirection
{ BlockDirection
, InlineDirection
};
45 enum ShouldComputePreferred
{ ComputeActual
, ComputePreferred
};
47 enum ScrollOffsetClamping
{
48 ScrollOffsetUnclamped
,
52 struct LayoutBoxRareData
{
53 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData
); WTF_MAKE_FAST_ALLOCATED(LayoutBoxRareData
);
56 : m_inlineBoxWrapper(nullptr)
57 , m_spannerPlaceholder(nullptr)
58 , m_overrideLogicalContentHeight(-1)
59 , m_overrideLogicalContentWidth(-1)
60 , m_previousBorderBoxSize(-1, -1)
64 // For inline replaced elements, the inline box that owns us.
65 InlineBox
* m_inlineBoxWrapper
;
67 // For spanners, the spanner placeholder that lays us out within the multicol container.
68 LayoutMultiColumnSpannerPlaceholder
* m_spannerPlaceholder
;
70 LayoutUnit m_overrideLogicalContentHeight
;
71 LayoutUnit m_overrideLogicalContentWidth
;
73 // Set by LayoutBox::savePreviousBoxSizesIfNeeded().
74 LayoutSize m_previousBorderBoxSize
;
75 LayoutRect m_previousContentBoxRect
;
76 LayoutRect m_previousLayoutOverflowRect
;
78 LayoutUnit m_pageLogicalOffset
;
81 class CORE_EXPORT LayoutBox
: public LayoutBoxModelObject
{
83 explicit LayoutBox(ContainerNode
*);
85 DeprecatedPaintLayerType
layerTypeRequired() const override
;
87 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect
& localRect
) const override
;
89 virtual bool backgroundShouldAlwaysBeClipped() const { return false; }
91 // Use this with caution! No type checking is done!
92 LayoutBox
* firstChildBox() const;
93 LayoutBox
* lastChildBox() const;
95 int pixelSnappedWidth() const { return m_frameRect
.pixelSnappedWidth(); }
96 int pixelSnappedHeight() const { return m_frameRect
.pixelSnappedHeight(); }
98 void setX(LayoutUnit x
)
100 if (x
== m_frameRect
.x())
105 void setY(LayoutUnit y
)
107 if (y
== m_frameRect
.y())
112 void setWidth(LayoutUnit width
)
114 if (width
== m_frameRect
.width())
116 m_frameRect
.setWidth(width
);
119 void setHeight(LayoutUnit height
)
121 if (height
== m_frameRect
.height())
123 m_frameRect
.setHeight(height
);
127 LayoutUnit
logicalLeft() const { return style()->isHorizontalWritingMode() ? m_frameRect
.x() : m_frameRect
.y(); }
128 LayoutUnit
logicalRight() const { return logicalLeft() + logicalWidth(); }
129 LayoutUnit
logicalTop() const { return style()->isHorizontalWritingMode() ? m_frameRect
.y() : m_frameRect
.x(); }
130 LayoutUnit
logicalBottom() const { return logicalTop() + logicalHeight(); }
131 LayoutUnit
logicalWidth() const { return style()->isHorizontalWritingMode() ? m_frameRect
.width() : m_frameRect
.height(); }
132 LayoutUnit
logicalHeight() const { return style()->isHorizontalWritingMode() ? m_frameRect
.height() : m_frameRect
.width(); }
134 LayoutUnit
constrainLogicalWidthByMinMax(LayoutUnit
, LayoutUnit
, LayoutBlock
*) const;
135 LayoutUnit
constrainLogicalHeightByMinMax(LayoutUnit logicalHeight
, LayoutUnit intrinsicContentHeight
) const;
136 LayoutUnit
constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight
, LayoutUnit intrinsicContentHeight
) const;
138 int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
139 int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMode() ? pixelSnappedWidth() : pixelSnappedHeight(); }
141 LayoutUnit
minimumLogicalHeightForEmptyLine() const
143 return borderAndPaddingLogicalHeight() + scrollbarLogicalHeight()
144 + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine
: VerticalLine
, PositionOfInteriorLineBoxes
);
147 void setLogicalLeft(LayoutUnit left
)
149 if (style()->isHorizontalWritingMode())
154 void setLogicalTop(LayoutUnit top
)
156 if (style()->isHorizontalWritingMode())
161 void setLogicalLocation(const LayoutPoint
& location
)
163 if (style()->isHorizontalWritingMode())
164 setLocation(location
);
166 setLocation(location
.transposedPoint());
168 void setLogicalWidth(LayoutUnit size
)
170 if (style()->isHorizontalWritingMode())
175 void setLogicalHeight(LayoutUnit size
)
177 if (style()->isHorizontalWritingMode())
183 LayoutPoint
location() const { return m_frameRect
.location(); }
184 LayoutSize
locationOffset() const { return LayoutSize(m_frameRect
.x(), m_frameRect
.y()); }
185 LayoutSize
size() const { return m_frameRect
.size(); }
186 IntSize
pixelSnappedSize() const { return m_frameRect
.pixelSnappedSize(); }
188 void setLocation(const LayoutPoint
& location
)
190 if (location
== m_frameRect
.location())
192 m_frameRect
.setLocation(location
);
196 // FIXME: Currently scrollbars are using int geometry and positioned based on
197 // pixelSnappedBorderBoxRect whose size may change when location changes because of
198 // pixel snapping. This function is used to change location of the LayoutBox outside
199 // of LayoutBox::layout(). Will remove when we use LayoutUnits for scrollbars.
200 void setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint
&);
202 void setSize(const LayoutSize
& size
)
204 if (size
== m_frameRect
.size())
206 m_frameRect
.setSize(size
);
209 void move(LayoutUnit dx
, LayoutUnit dy
)
213 m_frameRect
.move(dx
, dy
);
217 LayoutRect
frameRect() const { return m_frameRect
; }
218 void setFrameRect(const LayoutRect
& rect
)
220 if (rect
== m_frameRect
)
226 LayoutRect
borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
227 LayoutRect
paddingBoxRect() const { return LayoutRect(borderLeft(), borderTop(), clientWidth(), clientHeight()); }
228 IntRect
pixelSnappedBorderBoxRect() const { return IntRect(IntPoint(), m_frameRect
.pixelSnappedSize()); }
229 IntRect
borderBoundingBox() const final
{ return pixelSnappedBorderBoxRect(); }
231 // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border).
232 LayoutRect
contentBoxRect() const { return LayoutRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
233 LayoutSize
contentBoxOffset() const { return LayoutSize(borderLeft() + paddingLeft(), borderTop() + paddingTop()); }
234 // The content box in absolute coords. Ignores transforms.
235 IntRect
absoluteContentBox() const;
236 // The offset of the content box in absolute coords, ignoring transforms.
237 IntSize
absoluteContentBoxOffset() const;
238 // The content box converted to absolute coords (taking transforms into account).
239 FloatQuad
absoluteContentQuad() const;
241 // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect
242 // does include the intrinsic padding in the content box as this is what some callers expect (like getComputedStyle).
243 LayoutRect
computedCSSContentBoxRect() const { return LayoutRect(borderLeft() + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), clientWidth() - computedCSSPaddingLeft() - computedCSSPaddingRight(), clientHeight() - computedCSSPaddingTop() - computedCSSPaddingBottom()); }
245 void addOutlineRects(Vector
<LayoutRect
>&, const LayoutPoint
& additionalOffset
, IncludeBlockVisualOverflowOrNot
) const override
;
247 // Use this with caution! No type checking is done!
248 LayoutBox
* previousSiblingBox() const;
249 LayoutBox
* previousInFlowSiblingBox() const;
250 LayoutBox
* nextSiblingBox() const;
251 LayoutBox
* nextInFlowSiblingBox() const;
252 LayoutBox
* parentBox() const;
254 // Return the previous sibling column set or spanner placeholder. Only to be used on multicol container children.
255 LayoutBox
* previousSiblingMultiColumnBox() const;
256 // Return the next sibling column set or spanner placeholder. Only to be used on multicol container children.
257 LayoutBox
* nextSiblingMultiColumnBox() const;
259 bool canResize() const;
261 // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
262 // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
263 // respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr,
264 // but it is on the right in vertical-rl.
265 LayoutRect
noOverflowRect() const;
266 LayoutRect
layoutOverflowRect() const { return m_overflow
? m_overflow
->layoutOverflowRect() : noOverflowRect(); }
267 IntRect
pixelSnappedLayoutOverflowRect() const { return pixelSnappedIntRect(layoutOverflowRect()); }
268 LayoutSize
maxLayoutOverflow() const { return LayoutSize(layoutOverflowRect().maxX(), layoutOverflowRect().maxY()); }
269 LayoutUnit
logicalLeftLayoutOverflow() const { return style()->isHorizontalWritingMode() ? layoutOverflowRect().x() : layoutOverflowRect().y(); }
270 LayoutUnit
logicalRightLayoutOverflow() const { return style()->isHorizontalWritingMode() ? layoutOverflowRect().maxX() : layoutOverflowRect().maxY(); }
272 LayoutRect
visualOverflowRect() const override
{ return m_overflow
? m_overflow
->visualOverflowRect() : borderBoxRect(); }
273 LayoutUnit
logicalLeftVisualOverflow() const { return style()->isHorizontalWritingMode() ? visualOverflowRect().x() : visualOverflowRect().y(); }
274 LayoutUnit
logicalRightVisualOverflow() const { return style()->isHorizontalWritingMode() ? visualOverflowRect().maxX() : visualOverflowRect().maxY(); }
276 LayoutRect
contentsVisualOverflowRect() const { return m_overflow
? m_overflow
->contentsVisualOverflowRect() : LayoutRect(); }
278 void addLayoutOverflow(const LayoutRect
&);
279 void addVisualOverflow(const LayoutRect
&);
281 // Clipped by the contents clip, if one exists.
282 void addContentsVisualOverflow(const LayoutRect
&);
284 void addVisualEffectOverflow();
285 LayoutRectOutsets
computeVisualEffectOverflowOutsets() const;
286 void addOverflowFromChild(LayoutBox
* child
) { addOverflowFromChild(child
, child
->locationOffset()); }
287 void addOverflowFromChild(LayoutBox
* child
, const LayoutSize
& delta
);
288 void clearLayoutOverflow();
289 void clearAllOverflows() { m_overflow
.clear(); }
291 void updateLayerTransformAfterLayout();
293 LayoutUnit
contentWidth() const { return clientWidth() - paddingLeft() - paddingRight(); }
294 LayoutUnit
contentHeight() const { return clientHeight() - paddingTop() - paddingBottom(); }
295 LayoutSize
contentSize() const { return LayoutSize(contentWidth(), contentHeight()); }
296 LayoutUnit
contentLogicalWidth() const { return style()->isHorizontalWritingMode() ? contentWidth() : contentHeight(); }
297 LayoutUnit
contentLogicalHeight() const { return style()->isHorizontalWritingMode() ? contentHeight() : contentWidth(); }
299 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (LayoutFlow)
300 // to return the remaining width on a given line (and the height of a single line).
301 LayoutUnit
offsetWidth() const override
{ return m_frameRect
.width(); }
302 LayoutUnit
offsetHeight() const override
{ return m_frameRect
.height(); }
304 int pixelSnappedOffsetWidth() const final
;
305 int pixelSnappedOffsetHeight() const final
;
307 // More IE extensions. clientWidth and clientHeight represent the interior of an object
308 // excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth.
309 LayoutUnit
clientLeft() const { return borderLeft() + (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft() ? verticalScrollbarWidth() : 0); }
310 LayoutUnit
clientTop() const { return borderTop(); }
311 LayoutUnit
clientWidth() const;
312 LayoutUnit
clientHeight() const;
313 LayoutUnit
clientLogicalWidth() const { return style()->isHorizontalWritingMode() ? clientWidth() : clientHeight(); }
314 LayoutUnit
clientLogicalHeight() const { return style()->isHorizontalWritingMode() ? clientHeight() : clientWidth(); }
315 LayoutUnit
clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); }
316 LayoutRect
clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); }
318 int pixelSnappedClientWidth() const;
319 int pixelSnappedClientHeight() const;
321 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the
322 // object has overflow:hidden/scroll/auto specified and also has overflow.
323 // scrollLeft/Top return the current scroll position. These methods are virtual so that objects like
324 // textareas can scroll shadow content (but pretend that they are the objects that are
326 virtual LayoutUnit
scrollLeft() const;
327 virtual LayoutUnit
scrollTop() const;
328 virtual LayoutUnit
scrollWidth() const;
329 virtual LayoutUnit
scrollHeight() const;
330 int pixelSnappedScrollWidth() const;
331 int pixelSnappedScrollHeight() const;
332 virtual void setScrollLeft(LayoutUnit
);
333 virtual void setScrollTop(LayoutUnit
);
335 void scrollToOffset(const DoubleSize
&, ScrollBehavior
= ScrollBehaviorInstant
);
336 void scrollByRecursively(const DoubleSize
& delta
, ScrollOffsetClamping
= ScrollOffsetUnclamped
);
337 void scrollRectToVisible(const LayoutRect
&, const ScrollAlignment
& alignX
, const ScrollAlignment
& alignY
);
339 LayoutRectOutsets
marginBoxOutsets() const override
{ return m_marginBoxOutsets
; }
340 LayoutUnit
marginTop() const override
{ return m_marginBoxOutsets
.top(); }
341 LayoutUnit
marginBottom() const override
{ return m_marginBoxOutsets
.bottom(); }
342 LayoutUnit
marginLeft() const override
{ return m_marginBoxOutsets
.left(); }
343 LayoutUnit
marginRight() const override
{ return m_marginBoxOutsets
.right(); }
344 void setMarginTop(LayoutUnit margin
) { m_marginBoxOutsets
.setTop(margin
); }
345 void setMarginBottom(LayoutUnit margin
) { m_marginBoxOutsets
.setBottom(margin
); }
346 void setMarginLeft(LayoutUnit margin
) { m_marginBoxOutsets
.setLeft(margin
); }
347 void setMarginRight(LayoutUnit margin
) { m_marginBoxOutsets
.setRight(margin
); }
349 LayoutUnit
marginLogicalLeft() const { return m_marginBoxOutsets
.logicalLeft(style()->writingMode()); }
350 LayoutUnit
marginLogicalRight() const { return m_marginBoxOutsets
.logicalRight(style()->writingMode()); }
352 LayoutUnit
marginBefore(const ComputedStyle
* overrideStyle
= nullptr) const final
{ return m_marginBoxOutsets
.before((overrideStyle
? overrideStyle
: style())->writingMode()); }
353 LayoutUnit
marginAfter(const ComputedStyle
* overrideStyle
= nullptr) const final
{ return m_marginBoxOutsets
.after((overrideStyle
? overrideStyle
: style())->writingMode()); }
354 LayoutUnit
marginStart(const ComputedStyle
* overrideStyle
= nullptr) const final
356 const ComputedStyle
* styleToUse
= overrideStyle
? overrideStyle
: style();
357 return m_marginBoxOutsets
.start(styleToUse
->writingMode(), styleToUse
->direction());
359 LayoutUnit
marginEnd(const ComputedStyle
* overrideStyle
= nullptr) const final
361 const ComputedStyle
* styleToUse
= overrideStyle
? overrideStyle
: style();
362 return m_marginBoxOutsets
.end(styleToUse
->writingMode(), styleToUse
->direction());
364 void setMarginBefore(LayoutUnit value
, const ComputedStyle
* overrideStyle
= nullptr) { m_marginBoxOutsets
.setBefore((overrideStyle
? overrideStyle
: style())->writingMode(), value
); }
365 void setMarginAfter(LayoutUnit value
, const ComputedStyle
* overrideStyle
= nullptr) { m_marginBoxOutsets
.setAfter((overrideStyle
? overrideStyle
: style())->writingMode(), value
); }
366 void setMarginStart(LayoutUnit value
, const ComputedStyle
* overrideStyle
= nullptr)
368 const ComputedStyle
* styleToUse
= overrideStyle
? overrideStyle
: style();
369 m_marginBoxOutsets
.setStart(styleToUse
->writingMode(), styleToUse
->direction(), value
);
371 void setMarginEnd(LayoutUnit value
, const ComputedStyle
* overrideStyle
= nullptr)
373 const ComputedStyle
* styleToUse
= overrideStyle
? overrideStyle
: style();
374 m_marginBoxOutsets
.setEnd(styleToUse
->writingMode(), styleToUse
->direction(), value
);
377 // The following functions are used to implement collapsing margins.
378 // All objects know their maximal positive and negative margins. The
379 // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
380 // For a non-collapsing box, such as a leaf element, this formula will simply return
381 // the margin of the element. Blocks override the maxMarginBefore and maxMarginAfter
383 virtual bool isSelfCollapsingBlock() const { return false; }
384 virtual LayoutUnit
collapsedMarginBefore() const { return marginBefore(); }
385 virtual LayoutUnit
collapsedMarginAfter() const { return marginAfter(); }
386 LayoutRectOutsets
collapsedMarginBoxLogicalOutsets() const { return LayoutRectOutsets(collapsedMarginBefore(), 0, collapsedMarginAfter(), 0); }
388 void absoluteRects(Vector
<IntRect
>&, const LayoutPoint
& accumulatedOffset
) const override
;
389 void absoluteQuads(Vector
<FloatQuad
>&, bool* wasFixed
) const override
;
391 int reflectionOffset() const;
392 // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection.
393 LayoutRect
reflectedRect(const LayoutRect
&) const;
395 void layout() override
;
396 void paint(const PaintInfo
&, const LayoutPoint
&) override
;
397 bool nodeAtPoint(HitTestResult
&, const HitTestLocation
& locationInContainer
, const LayoutPoint
& accumulatedOffset
, HitTestAction
) override
;
399 LayoutUnit
minPreferredLogicalWidth() const override
;
400 LayoutUnit
maxPreferredLogicalWidth() const override
;
402 // FIXME: We should rename these back to overrideLogicalHeight/Width and have them store
403 // the border-box height/width like the regular height/width accessors on LayoutBox.
404 // Right now, these are different than contentHeight/contentWidth because they still
405 // include the scrollbar height/width.
406 LayoutUnit
overrideLogicalContentWidth() const;
407 LayoutUnit
overrideLogicalContentHeight() const;
408 bool hasOverrideLogicalContentHeight() const;
409 bool hasOverrideLogicalContentWidth() const;
410 void setOverrideLogicalContentHeight(LayoutUnit
);
411 void setOverrideLogicalContentWidth(LayoutUnit
);
412 void clearOverrideSize();
413 void clearOverrideLogicalContentHeight();
414 void clearOverrideLogicalContentWidth();
416 LayoutUnit
overrideContainingBlockContentLogicalWidth() const;
417 LayoutUnit
overrideContainingBlockContentLogicalHeight() const;
418 bool hasOverrideContainingBlockLogicalWidth() const;
419 bool hasOverrideContainingBlockLogicalHeight() const;
420 void setOverrideContainingBlockContentLogicalWidth(LayoutUnit
);
421 void setOverrideContainingBlockContentLogicalHeight(LayoutUnit
);
422 void clearContainingBlockOverrideSize();
423 void clearOverrideContainingBlockContentLogicalHeight();
425 LayoutUnit
extraInlineOffset() const;
426 LayoutUnit
extraBlockOffset() const;
427 void setExtraInlineOffset(LayoutUnit inlineOffest
);
428 void setExtraBlockOffset(LayoutUnit blockOffest
);
429 void clearExtraInlineAndBlockOffests();
431 LayoutSize
offsetFromContainer(const LayoutObject
*, const LayoutPoint
&, bool* offsetDependsOnPoint
= nullptr) const override
;
433 LayoutUnit
adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width
) const;
434 LayoutUnit
adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height
) const;
435 LayoutUnit
adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width
) const;
436 LayoutUnit
adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit height
) const;
438 struct ComputedMarginValues
{
439 DISALLOW_ALLOCATION();
440 ComputedMarginValues() { }
447 struct LogicalExtentComputedValues
{
449 LogicalExtentComputedValues() { }
452 LayoutUnit m_position
;
453 ComputedMarginValues m_margins
;
455 // Resolve auto margins in the chosen direction of the containing block so that objects can be pushed to the start, middle or end
456 // of the containing block.
457 void computeMarginsForDirection(MarginDirection forDirection
, const LayoutBlock
* containingBlock
, LayoutUnit containerWidth
, LayoutUnit childWidth
, LayoutUnit
& marginStart
, LayoutUnit
& marginEnd
, Length marginStartLength
, Length marginStartEnd
) const;
459 // Used to resolve margins in the containing block's block-flow direction.
460 void computeAndSetBlockDirectionMargins(const LayoutBlock
* containingBlock
);
462 LayoutUnit
offsetFromLogicalTopOfFirstPage() const;
464 // The page logical offset is the object's offset from the top of the page in the page progression
465 // direction (so an x-offset in vertical text and a y-offset for horizontal text).
466 LayoutUnit
pageLogicalOffset() const { return m_rareData
? m_rareData
->m_pageLogicalOffset
: LayoutUnit(); }
467 void setPageLogicalOffset(LayoutUnit
);
469 void positionLineBox(InlineBox
*);
470 void moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal
);
472 virtual InlineBox
* createInlineBox();
473 void dirtyLineBoxes(bool fullLayout
);
475 // For inline replaced elements, this function returns the inline box that owns us. Enables
476 // the replaced LayoutObject to quickly determine what line it is contained on and to easily
477 // iterate over structures on the line.
478 InlineBox
* inlineBoxWrapper() const { return m_rareData
? m_rareData
->m_inlineBoxWrapper
: 0; }
479 void setInlineBoxWrapper(InlineBox
*);
480 void deleteLineBoxWrapper();
482 void setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder
&);
483 void clearSpannerPlaceholder();
484 LayoutMultiColumnSpannerPlaceholder
* spannerPlaceholder() const final
{ return m_rareData
? m_rareData
->m_spannerPlaceholder
: 0; }
486 LayoutRect
clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObject
* paintInvalidationContainer
, const PaintInvalidationState
* = nullptr) const override
;
487 void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject
* paintInvalidationContainer
, LayoutRect
&, const PaintInvalidationState
*) const override
;
488 virtual void invalidatePaintForOverhangingFloats(bool paintAllDescendants
);
490 LayoutUnit
containingBlockLogicalHeightForGetComputedStyle() const;
492 LayoutUnit
containingBlockLogicalWidthForContent() const override
;
493 LayoutUnit
containingBlockLogicalHeightForContent(AvailableLogicalHeightType
) const;
495 LayoutUnit
containingBlockAvailableLineWidth() const;
496 LayoutUnit
perpendicularContainingBlockLogicalHeight() const;
498 virtual void updateLogicalWidth();
499 void updateLogicalHeight();
500 virtual void computeLogicalHeight(LayoutUnit logicalHeight
, LayoutUnit logicalTop
, LogicalExtentComputedValues
&) const;
501 // This function will compute the logical border-box height, without laying out the box. This means that the result
502 // is only "correct" when the height is explicitly specified. This function exists so that intrinsic width calculations
503 // have a way to deal with children that have orthogonal flows.
504 // When there is no explicit height, this function assumes a content height of zero (and returns just border+padding)
505 LayoutUnit
computeLogicalHeightWithoutLayout() const;
507 void computeLogicalWidth(LogicalExtentComputedValues
&) const;
509 bool stretchesToViewport() const
511 return document().inQuirksMode() && style()->logicalHeight().isAuto() && !isFloatingOrOutOfFlowPositioned() && (isDocumentElement() || isBody()) && !isInline();
514 virtual LayoutSize
intrinsicSize() const { return LayoutSize(); }
515 LayoutUnit
intrinsicLogicalWidth() const { return style()->isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); }
516 LayoutUnit
intrinsicLogicalHeight() const { return style()->isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
517 virtual LayoutUnit
intrinsicContentLogicalHeight() const { return m_intrinsicContentLogicalHeight
; }
519 // Whether or not the element shrinks to its intrinsic width (rather than filling the width
520 // of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this.
521 bool sizesLogicalWidthToFitContent(const Length
& logicalWidth
) const;
523 LayoutUnit
shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart
, LayoutUnit childMarginEnd
, const LayoutBlockFlow
* cb
) const;
525 LayoutUnit
computeLogicalWidthUsing(SizeType
, const Length
& logicalWidth
, LayoutUnit availableLogicalWidth
, const LayoutBlock
* containingBlock
) const;
526 LayoutUnit
computeLogicalHeightUsing(SizeType
, const Length
& height
, LayoutUnit intrinsicContentHeight
) const;
527 LayoutUnit
computeContentLogicalHeight(SizeType
, const Length
& height
, LayoutUnit intrinsicContentHeight
) const;
528 LayoutUnit
computeContentAndScrollbarLogicalHeightUsing(SizeType
, const Length
& height
, LayoutUnit intrinsicContentHeight
) const;
529 LayoutUnit
computeReplacedLogicalWidthUsing(SizeType
, const Length
& width
) const;
530 LayoutUnit
computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth
, ShouldComputePreferred
= ComputeActual
) const;
531 LayoutUnit
computeReplacedLogicalHeightUsing(SizeType
, const Length
& height
) const;
532 LayoutUnit
computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight
) const;
534 virtual LayoutUnit
computeReplacedLogicalWidth(ShouldComputePreferred
= ComputeActual
) const;
535 virtual LayoutUnit
computeReplacedLogicalHeight() const;
537 bool hasDefiniteLogicalWidth() const;
538 bool percentageLogicalHeightIsResolvable() const;
539 bool hasDefiniteLogicalHeight() const;
540 LayoutUnit
computePercentageLogicalHeight(const Length
& height
) const;
542 // Block flows subclass availableWidth/Height to handle multi column layout (shrinking the width/height available to children when laying out.)
543 LayoutUnit
availableLogicalWidth() const { return contentLogicalWidth(); }
544 LayoutUnit
availableLogicalHeight(AvailableLogicalHeightType
) const;
545 LayoutUnit
availableLogicalHeightUsing(const Length
&, AvailableLogicalHeightType
) const;
547 // There are a few cases where we need to refer specifically to the available physical width and available physical height.
548 // Relative positioning is one of those cases, since left/top offsets are physical.
549 LayoutUnit
availableWidth() const { return style()->isHorizontalWritingMode() ? availableLogicalWidth() : availableLogicalHeight(IncludeMarginBorderPadding
); }
550 LayoutUnit
availableHeight() const { return style()->isHorizontalWritingMode() ? availableLogicalHeight(IncludeMarginBorderPadding
) : availableLogicalWidth(); }
552 int verticalScrollbarWidth() const;
553 int horizontalScrollbarHeight() const;
554 int intrinsicScrollbarLogicalWidth() const;
555 int scrollbarLogicalWidth() const { return style()->isHorizontalWritingMode() ? verticalScrollbarWidth() : horizontalScrollbarHeight(); }
556 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
557 virtual ScrollResultOneDimensional
scroll(ScrollDirectionPhysical
, ScrollGranularity
, float delta
= 1);
558 bool canBeScrolledAndHasScrollableArea() const;
559 virtual bool canBeProgramaticallyScrolled() const;
560 virtual void autoscroll(const IntPoint
&);
561 bool canAutoscroll() const;
562 IntSize
calculateAutoscrollDirection(const IntPoint
& pointInRootFrame
) const;
563 static LayoutBox
* findAutoscrollable(LayoutObject
*);
564 virtual void stopAutoscroll() { }
565 virtual void panScroll(const IntPoint
&);
567 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style()->overflowY() == OAUTO
|| style()->overflowY() == OPAGEDY
|| style()->overflowY() == OOVERLAY
); }
568 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style()->overflowX() == OAUTO
|| style()->overflowX() == OOVERLAY
); }
569 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); }
571 bool hasScrollableOverflowX() const { return scrollsOverflowX() && pixelSnappedScrollWidth() != pixelSnappedClientWidth(); }
572 bool hasScrollableOverflowY() const { return scrollsOverflowY() && pixelSnappedScrollHeight() != pixelSnappedClientHeight(); }
573 virtual bool scrollsOverflowX() const { return hasOverflowClip() && (style()->overflowX() == OSCROLL
|| hasAutoHorizontalScrollbar()); }
574 virtual bool scrollsOverflowY() const { return hasOverflowClip() && (style()->overflowY() == OSCROLL
|| hasAutoVerticalScrollbar()); }
576 // Elements such as the <input> field override this to specify that they are scrollable
577 // outside the context of the CSS overflow style
578 virtual bool isIntrinsicallyScrollable(ScrollbarOrientation orientation
) const { return false; }
580 bool hasUnsplittableScrollingOverflow() const;
581 bool isUnsplittableForPagination() const;
583 LayoutRect
localCaretRect(InlineBox
*, int caretOffset
, LayoutUnit
* extraWidthToEndOfLine
= nullptr) override
;
585 virtual LayoutRect
overflowClipRect(const LayoutPoint
& location
, OverlayScrollbarSizeRelevancy
= IgnoreOverlayScrollbarSize
) const;
586 LayoutRect
clipRect(const LayoutPoint
& location
);
587 virtual bool hasControlClip() const { return false; }
588 virtual LayoutRect
controlClipRect(const LayoutPoint
&) const { return LayoutRect(); }
590 virtual void paintBoxDecorationBackground(const PaintInfo
&, const LayoutPoint
&);
591 virtual void paintMask(const PaintInfo
&, const LayoutPoint
&);
592 void imageChanged(WrappedImagePtr
, const IntRect
* = nullptr) override
;
594 void logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit
& logicalTop
, LogicalExtentComputedValues
&);
596 PositionWithAffinity
positionForPoint(const LayoutPoint
&) override
;
598 void removeFloatingOrPositionedChildFromBlockLists();
600 DeprecatedPaintLayer
* enclosingFloatPaintingLayer() const;
602 virtual int firstLineBoxBaseline() const { return -1; }
603 virtual int inlineBlockBaseline(LineDirectionMode
) const { return -1; } // Returns -1 if we should skip this box when computing the baseline of an inline-block.
605 bool shrinkToAvoidFloats() const;
606 virtual bool avoidsFloats() const;
608 virtual void markForPaginationRelayoutIfNeeded(SubtreeLayoutScope
&);
610 bool isWritingModeRoot() const { return !parent() || parent()->style()->writingMode() != style()->writingMode(); }
612 bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isDeprecatedFlexibleBox(); }
613 bool isFlexItemIncludingDeprecated() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isFlexibleBoxIncludingDeprecated(); }
615 bool isGridItem() const { return parent() && parent()->isLayoutGrid(); }
617 LayoutUnit
lineHeight(bool firstLine
, LineDirectionMode
, LinePositionMode
= PositionOnContainingLine
) const override
;
618 int baselinePosition(FontBaseline
, bool firstLine
, LineDirectionMode
, LinePositionMode
= PositionOnContainingLine
) const override
;
620 LayoutUnit
offsetLeft() const override
;
621 LayoutUnit
offsetTop() const override
;
623 LayoutPoint
flipForWritingModeForChild(const LayoutBox
* child
, const LayoutPoint
&) const;
624 LayoutUnit
flipForWritingMode(LayoutUnit position
) const WARN_UNUSED_RETURN
{
625 // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
626 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
628 return logicalHeight() - position
;
630 LayoutPoint
flipForWritingMode(const LayoutPoint
& position
) const WARN_UNUSED_RETURN
{
631 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
633 return isHorizontalWritingMode() ? LayoutPoint(position
.x(), m_frameRect
.height() - position
.y()) : LayoutPoint(m_frameRect
.width() - position
.x(), position
.y());
635 LayoutSize
flipForWritingMode(const LayoutSize
& offset
) const WARN_UNUSED_RETURN
{
636 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
638 return isHorizontalWritingMode() ? LayoutSize(offset
.width(), m_frameRect
.height() - offset
.height()) : LayoutSize(m_frameRect
.width() - offset
.width(), offset
.height());
640 void flipForWritingMode(LayoutRect
& rect
) const
642 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
644 if (isHorizontalWritingMode())
645 rect
.setY(m_frameRect
.height() - rect
.maxY());
647 rect
.setX(m_frameRect
.width() - rect
.maxX());
649 FloatPoint
flipForWritingMode(const FloatPoint
& position
) const WARN_UNUSED_RETURN
{
650 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
652 return isHorizontalWritingMode() ? FloatPoint(position
.x(), m_frameRect
.height() - position
.y()) : FloatPoint(m_frameRect
.width() - position
.x(), position
.y());
654 void flipForWritingMode(FloatRect
& rect
) const
656 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
658 if (isHorizontalWritingMode())
659 rect
.setY(m_frameRect
.height() - rect
.maxY());
661 rect
.setX(m_frameRect
.width() - rect
.maxX());
663 // These represent your location relative to your container as a physical offset.
664 // In layout related methods you almost always want the logical location (e.g. x() and y()).
665 LayoutPoint
topLeftLocation() const;
666 LayoutSize
topLeftLocationOffset() const { return toLayoutSize(topLeftLocation()); }
668 LayoutRect
logicalVisualOverflowRectForPropagation(const ComputedStyle
&) const;
669 LayoutRect
visualOverflowRectForPropagation(const ComputedStyle
&) const;
670 LayoutRect
logicalLayoutOverflowRectForPropagation(const ComputedStyle
&) const;
671 LayoutRect
layoutOverflowRectForPropagation(const ComputedStyle
&) const;
673 bool hasOverflowModel() const { return m_overflow
; }
674 bool hasVisualOverflow() const { return m_overflow
&& !borderBoxRect().contains(m_overflow
->visualOverflowRect()); }
676 virtual bool needsPreferredWidthsRecalculation() const;
677 virtual void computeIntrinsicRatioInformation(FloatSize
& /* intrinsicSize */, double& /* intrinsicRatio */) const { }
679 IntSize
scrolledContentOffset() const;
680 void applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect
& paintRect
) const;
682 virtual bool hasRelativeLogicalWidth() const;
683 virtual bool hasRelativeLogicalHeight() const;
685 bool hasHorizontalLayoutOverflow() const
690 LayoutRect layoutOverflowRect
= m_overflow
->layoutOverflowRect();
691 LayoutRect noOverflowRect
= this->noOverflowRect();
692 return layoutOverflowRect
.x() < noOverflowRect
.x() || layoutOverflowRect
.maxX() > noOverflowRect
.maxX();
695 bool hasVerticalLayoutOverflow() const
700 LayoutRect layoutOverflowRect
= m_overflow
->layoutOverflowRect();
701 LayoutRect noOverflowRect
= this->noOverflowRect();
702 return layoutOverflowRect
.y() < noOverflowRect
.y() || layoutOverflowRect
.maxY() > noOverflowRect
.maxY();
705 virtual LayoutBox
* createAnonymousBoxWithSameTypeAs(const LayoutObject
*) const
707 ASSERT_NOT_REACHED();
711 bool hasSameDirectionAs(const LayoutBox
* object
) const { return style()->direction() == object
->style()->direction(); }
713 ShapeOutsideInfo
* shapeOutsideInfo() const;
715 void markShapeOutsideDependentsForLayout()
718 removeFloatingOrPositionedChildFromBlockLists();
721 void setIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeight
) const { m_intrinsicContentLogicalHeight
= intrinsicContentLogicalHeight
; }
723 bool canRenderBorderImage() const;
726 void willBeDestroyed() override
;
728 void styleWillChange(StyleDifference
, const ComputedStyle
& newStyle
) override
;
729 void styleDidChange(StyleDifference
, const ComputedStyle
* oldStyle
) override
;
730 void updateFromStyle() override
;
732 // Returns false if it could not cheaply compute the extent (e.g. fixed background), in which case the returned rect may be incorrect.
733 // FIXME: make this a const method once the LayoutBox reference in BoxPainter is const.
734 bool getBackgroundPaintedExtent(LayoutRect
&);
735 virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect
& localRect
, unsigned maxDepthToTest
) const;
736 bool computeBackgroundIsKnownToBeObscured() override
;
738 void computePositionedLogicalWidth(LogicalExtentComputedValues
&) const;
740 LayoutUnit
computeIntrinsicLogicalWidthUsing(const Length
& logicalWidthLength
, LayoutUnit availableLogicalWidth
, LayoutUnit borderAndPadding
) const;
741 LayoutUnit
computeIntrinsicLogicalContentHeightUsing(const Length
& logicalHeightLength
, LayoutUnit intrinsicContentHeight
, LayoutUnit borderAndPadding
) const;
743 virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
745 void mapLocalToContainer(const LayoutBoxModelObject
* paintInvalidationContainer
, TransformState
&, MapCoordinatesFlags
= ApplyContainerFlip
, bool* wasFixed
= nullptr, const PaintInvalidationState
* = nullptr) const override
;
746 void mapAbsoluteToLocalPoint(MapCoordinatesFlags
, TransformState
&) const override
;
748 LayoutObject
* splitAnonymousBoxesAroundChild(LayoutObject
* beforeChild
);
750 void addLayerHitTestRects(LayerHitTestRects
&, const DeprecatedPaintLayer
* currentCompositedLayer
, const LayoutPoint
& layerOffset
, const LayoutRect
& containerRect
) const override
;
751 void computeSelfHitTestRects(Vector
<LayoutRect
>&, const LayoutPoint
& layerOffset
) const override
;
753 PaintInvalidationReason
paintInvalidationReason(const LayoutBoxModelObject
& paintInvalidationContainer
,
754 const LayoutRect
& oldBounds
, const LayoutPoint
& oldPositionFromPaintInvalidationContainer
,
755 const LayoutRect
& newBounds
, const LayoutPoint
& newPositionFromPaintInvalidationContainer
) const override
;
756 void incrementallyInvalidatePaint(const LayoutBoxModelObject
& paintInvalidationContainer
, const LayoutRect
& oldBounds
, const LayoutRect
& newBounds
, const LayoutPoint
& positionFromPaintInvalidationContainer
) override
;
758 void clearPaintInvalidationState(const PaintInvalidationState
&) override
;
760 bool paintInvalidationStateIsDirty() const override
;
763 PaintInvalidationReason
invalidatePaintIfNeeded(PaintInvalidationState
&, const LayoutBoxModelObject
& newPaintInvalidationContainer
) override
;
765 bool hasNonCompositedScrollbars() const final
;
766 void excludeScrollbars(LayoutRect
&, OverlayScrollbarSizeRelevancy
= IgnoreOverlayScrollbarSize
) const;
769 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
770 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
771 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer
&) const;
773 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject
& paintInvalidationContainer
, const LayoutRect
&, const LayoutRect
& oldBounds
, const LayoutRect
& newBounds
);
775 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle
&, const ComputedStyle
* oldStyle
);
776 void updateGridPositionAfterStyleChange(const ComputedStyle
*);
778 bool autoWidthShouldFitContent() const;
779 LayoutUnit
shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth
, LayoutUnit bordersPlusPadding
) const;
781 // Returns true if we queued up a paint invalidation.
782 bool invalidatePaintOfLayerRectsForImage(WrappedImagePtr
, const FillLayer
&, bool drawingBackground
);
784 bool skipContainingBlockForPercentHeightCalculation(const LayoutBox
* containingBlock
) const;
786 LayoutUnit
containingBlockLogicalWidthForPositioned(const LayoutBoxModelObject
* containingBlock
, bool checkForPerpendicularWritingMode
= true) const;
787 LayoutUnit
containingBlockLogicalHeightForPositioned(const LayoutBoxModelObject
* containingBlock
, bool checkForPerpendicularWritingMode
= true) const;
789 void computePositionedLogicalHeight(LogicalExtentComputedValues
&) const;
790 void computePositionedLogicalWidthUsing(SizeType
, Length logicalWidth
, const LayoutBoxModelObject
* containerBlock
, TextDirection containerDirection
,
791 LayoutUnit containerLogicalWidth
, LayoutUnit bordersPlusPadding
,
792 const Length
& logicalLeft
, const Length
& logicalRight
, const Length
& marginLogicalLeft
,
793 const Length
& marginLogicalRight
, LogicalExtentComputedValues
&) const;
794 void computePositionedLogicalHeightUsing(SizeType
, Length logicalHeightLength
, const LayoutBoxModelObject
* containerBlock
,
795 LayoutUnit containerLogicalHeight
, LayoutUnit bordersPlusPadding
, LayoutUnit logicalHeight
,
796 const Length
& logicalTop
, const Length
& logicalBottom
, const Length
& marginLogicalTop
,
797 const Length
& marginLogicalBottom
, LogicalExtentComputedValues
&) const;
799 void computePositionedLogicalHeightReplaced(LogicalExtentComputedValues
&) const;
800 void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues
&) const;
802 LayoutUnit
fillAvailableMeasure(LayoutUnit availableLogicalWidth
) const;
803 LayoutUnit
fillAvailableMeasure(LayoutUnit availableLogicalWidth
, LayoutUnit
& marginStart
, LayoutUnit
& marginEnd
) const;
805 virtual void computeIntrinsicLogicalWidths(LayoutUnit
& minLogicalWidth
, LayoutUnit
& maxLogicalWidth
) const;
807 // This function calculates the minimum and maximum preferred widths for an object.
808 // These values are used in shrink-to-fit layout systems.
809 // These include tables, positioned objects, floats and flexible boxes.
810 virtual void computePreferredLogicalWidths() { clearPreferredLogicalWidthsDirty(); }
812 LayoutBoxRareData
& ensureRareData()
815 m_rareData
= adoptPtr(new LayoutBoxRareData());
816 return *m_rareData
.get();
819 bool needToSavePreviousBoxSizes();
820 void savePreviousBoxSizesIfNeeded();
821 LayoutSize
computePreviousBorderBoxSize(const LayoutSize
& previousBoundsSize
) const;
823 bool logicalHeightComputesAsNone(SizeType
) const;
825 bool isBox() const = delete; // This will catch anyone doing an unnecessary check.
827 void frameRectChanged()
829 // The frame rect may change because of layout of other objects.
830 // Should check this object for paint invalidation.
832 setMayNeedPaintInvalidation();
835 // Returns true if the box intersects the viewport visible to the user.
836 bool intersectsVisibleViewport();
838 void updateSlowRepaintStatusAfterStyleChange();
840 // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
841 LayoutRect m_frameRect
;
843 // Our intrinsic height, used for min-height: min-content etc. Maintained by
844 // updateLogicalHeight. This is logicalHeight() before it is clamped to
846 mutable LayoutUnit m_intrinsicContentLogicalHeight
;
848 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect
&) const;
850 LayoutRectOutsets m_marginBoxOutsets
;
853 // The preferred logical width of the element if it were to break its lines at every
854 // possible opportunity. CSS 2.1 calls this width the "preferred minimum width" and
855 // "minimum content width".
856 // See https://drafts.csswg.org/css-sizing-3/#intrinsic for more information.
857 LayoutUnit m_minPreferredLogicalWidth
;
859 // The preferred logical width of the element if it never breaks any lines at all.
860 // CSS 2.1 calls this width the "preferred width" and "maximum cell width".
861 // See https://drafts.csswg.org/css-sizing-3/#intrinsic for more information.
862 LayoutUnit m_maxPreferredLogicalWidth
;
864 // Our overflow information.
865 OwnPtr
<OverflowModel
> m_overflow
;
868 OwnPtr
<LayoutBoxRareData
> m_rareData
;
871 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBox
, isBox());
873 inline LayoutBox
* LayoutBox::previousSiblingBox() const
875 return toLayoutBox(previousSibling());
878 inline LayoutBox
* LayoutBox::previousInFlowSiblingBox() const
880 LayoutBox
* previous
= previousSiblingBox();
881 while (previous
&& previous
->isOutOfFlowPositioned())
882 previous
= previous
->previousSiblingBox();
886 inline LayoutBox
* LayoutBox::nextSiblingBox() const
888 return toLayoutBox(nextSibling());
891 inline LayoutBox
* LayoutBox::nextInFlowSiblingBox() const
893 LayoutBox
* next
= nextSiblingBox();
894 while (next
&& next
->isOutOfFlowPositioned())
895 next
= next
->nextSiblingBox();
899 inline LayoutBox
* LayoutBox::parentBox() const
901 return toLayoutBox(parent());
904 inline LayoutBox
* LayoutBox::firstChildBox() const
906 return toLayoutBox(slowFirstChild());
909 inline LayoutBox
* LayoutBox::lastChildBox() const
911 return toLayoutBox(slowLastChild());
914 inline LayoutBox
* LayoutBox::previousSiblingMultiColumnBox() const
916 ASSERT(isLayoutMultiColumnSpannerPlaceholder() || isLayoutMultiColumnSet());
917 LayoutBox
* previousBox
= previousSiblingBox();
918 if (previousBox
->isLayoutFlowThread())
923 inline LayoutBox
* LayoutBox::nextSiblingMultiColumnBox() const
925 ASSERT(isLayoutMultiColumnSpannerPlaceholder() || isLayoutMultiColumnSet());
926 return nextSiblingBox();
929 inline void LayoutBox::setInlineBoxWrapper(InlineBox
* boxWrapper
)
932 ASSERT(!inlineBoxWrapper());
933 // m_inlineBoxWrapper should already be 0. Deleting it is a safeguard against security issues.
934 // Otherwise, there will two line box wrappers keeping the reference to this layoutObject, and
935 // only one will be notified when the layoutObject is getting destroyed. The second line box wrapper
936 // will keep a stale reference.
937 if (UNLIKELY(inlineBoxWrapper() != nullptr))
938 deleteLineBoxWrapper();
941 ensureRareData().m_inlineBoxWrapper
= boxWrapper
;
946 #endif // LayoutBox_h