Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: Source/core/rendering/RenderBox.h

Issue 926193003: Move rendering/RenderBox to layout/LayoutBox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlockLineLayout.cpp ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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.
5 *
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.
10 *
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.
15 *
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.
20 *
21 */
22
23 #ifndef RenderBox_h
24 #define RenderBox_h
25
26 #include "core/layout/LayoutBoxModelObject.h"
27 #include "core/layout/shapes/ShapeOutsideInfo.h"
28 #include "core/rendering/RenderOverflow.h"
29 #include "platform/scroll/ScrollTypes.h"
30 #include "platform/scroll/ScrollableArea.h"
31
32 namespace blink {
33
34 class LayoutMultiColumnSpannerPlaceholder;
35
36 struct PaintInfo;
37
38 enum SizeType { MainOrPreferredSize, MinSize, MaxSize };
39 enum AvailableLogicalHeightType { ExcludeMarginBorderPadding, IncludeMarginBorde rPadding };
40 enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayS crollbarSize };
41 enum MarginDirection { BlockDirection, InlineDirection };
42
43 enum ShouldComputePreferred { ComputeActual, ComputePreferred };
44
45 enum ScrollOffsetClamping {
46 ScrollOffsetUnclamped,
47 ScrollOffsetClamped
48 };
49
50 struct RenderBoxRareData {
51 WTF_MAKE_NONCOPYABLE(RenderBoxRareData); WTF_MAKE_FAST_ALLOCATED;
52 public:
53 RenderBoxRareData()
54 : m_inlineBoxWrapper(0)
55 , m_spannerPlaceholder(0)
56 , m_overrideLogicalContentHeight(-1)
57 , m_overrideLogicalContentWidth(-1)
58 , m_previousBorderBoxSize(-1, -1)
59 {
60 }
61
62 // For inline replaced elements, the inline box that owns us.
63 InlineBox* m_inlineBoxWrapper;
64
65 // For spanners, the spanner placeholder that lays us out within the multico l container.
66 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder;
67
68 LayoutUnit m_overrideLogicalContentHeight;
69 LayoutUnit m_overrideLogicalContentWidth;
70
71 // Set by RenderBox::updatePreviousBorderBoxSizeIfNeeded().
72 LayoutSize m_previousBorderBoxSize;
73 };
74
75 class RenderBox : public LayoutBoxModelObject {
76 public:
77 explicit RenderBox(ContainerNode*);
78
79 virtual LayerType layerTypeRequired() const override;
80
81 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const override;
82
83 virtual bool backgroundShouldAlwaysBeClipped() const { return false; }
84
85 // Use this with caution! No type checking is done!
86 RenderBox* firstChildBox() const;
87 RenderBox* lastChildBox() const;
88
89 int pixelSnappedWidth() const { return m_frameRect.pixelSnappedWidth(); }
90 int pixelSnappedHeight() const { return m_frameRect.pixelSnappedHeight(); }
91
92 void setX(LayoutUnit x) { m_frameRect.setX(x); }
93 void setY(LayoutUnit y) { m_frameRect.setY(y); }
94 void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); }
95 void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); }
96
97 LayoutUnit logicalLeft() const { return style()->isHorizontalWritingMode() ? m_frameRect.x() : m_frameRect.y(); }
98 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); }
99 LayoutUnit logicalTop() const { return style()->isHorizontalWritingMode() ? m_frameRect.y() : m_frameRect.x(); }
100 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); }
101 LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? m_frameRect.width() : m_frameRect.height(); }
102 LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? m_frameRect.height() : m_frameRect.width(); }
103
104 LayoutUnit constrainLogicalWidthByMinMax(LayoutUnit, LayoutUnit, RenderBlock *) const;
105 LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, LayoutUn it intrinsicContentHeight) const;
106 LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight , LayoutUnit intrinsicContentHeight) const;
107
108 int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingM ode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
109 int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMo de() ? pixelSnappedWidth() : pixelSnappedHeight(); }
110
111 void setLogicalLeft(LayoutUnit left)
112 {
113 if (style()->isHorizontalWritingMode())
114 setX(left);
115 else
116 setY(left);
117 }
118 void setLogicalTop(LayoutUnit top)
119 {
120 if (style()->isHorizontalWritingMode())
121 setY(top);
122 else
123 setX(top);
124 }
125 void setLogicalLocation(const LayoutPoint& location)
126 {
127 if (style()->isHorizontalWritingMode())
128 setLocation(location);
129 else
130 setLocation(location.transposedPoint());
131 }
132 void setLogicalWidth(LayoutUnit size)
133 {
134 if (style()->isHorizontalWritingMode())
135 setWidth(size);
136 else
137 setHeight(size);
138 }
139 void setLogicalHeight(LayoutUnit size)
140 {
141 if (style()->isHorizontalWritingMode())
142 setHeight(size);
143 else
144 setWidth(size);
145 }
146
147 LayoutPoint location() const { return m_frameRect.location(); }
148 LayoutSize locationOffset() const { return LayoutSize(m_frameRect.x(), m_fra meRect.y()); }
149 LayoutSize size() const { return m_frameRect.size(); }
150 IntSize pixelSnappedSize() const { return m_frameRect.pixelSnappedSize(); }
151
152 void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(loca tion); }
153
154 void setSize(const LayoutSize& size) { m_frameRect.setSize(size); }
155 void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); }
156
157 LayoutRect frameRect() const { return m_frameRect; }
158 void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
159
160 LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); }
161 LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTo p(), clientWidth(), clientHeight()); }
162 IntRect pixelSnappedBorderBoxRect() const { return IntRect(IntPoint(), m_fra meRect.pixelSnappedSize()); }
163 virtual IntRect borderBoundingBox() const override final { return pixelSnapp edBorderBoxRect(); }
164
165 // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border).
166 LayoutRect contentBoxRect() const { return LayoutRect(borderLeft() + padding Left(), borderTop() + paddingTop(), contentWidth(), contentHeight()); }
167 LayoutSize contentBoxOffset() const { return LayoutSize(borderLeft() + paddi ngLeft(), borderTop() + paddingTop()); }
168 // The content box in absolute coords. Ignores transforms.
169 IntRect absoluteContentBox() const;
170 // The offset of the content box in absolute coords, ignoring transforms.
171 IntSize absoluteContentBoxOffset() const;
172 // The content box converted to absolute coords (taking transforms into acco unt).
173 FloatQuad absoluteContentQuad() const;
174
175 // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect
176 // does include the intrinsic padding in the content box as this is what som e callers expect (like getComputedStyle).
177 LayoutRect computedCSSContentBoxRect() const { return LayoutRect(borderLeft( ) + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), clientWidth () - computedCSSPaddingLeft() - computedCSSPaddingRight(), clientHeight() - comp utedCSSPaddingTop() - computedCSSPaddingBottom()); }
178
179 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const override;
180
181 // Use this with caution! No type checking is done!
182 RenderBox* previousSiblingBox() const;
183 RenderBox* previousInFlowSiblingBox() const;
184 RenderBox* nextSiblingBox() const;
185 RenderBox* nextInFlowSiblingBox() const;
186 RenderBox* parentBox() const;
187
188 // Return the previous sibling column set or spanner placeholder. Only to be used on multicol container children.
189 RenderBox* previousSiblingMultiColumnBox() const;
190 // Return the next sibling column set or spanner placeholder. Only to be use d on multicol container children.
191 RenderBox* nextSiblingMultiColumnBox() const;
192
193 bool canResize() const;
194
195 // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
196 // For horizontal-tb and vertical-lr they will match physical directions, bu t for horizontal-bt and vertical-rl, the top/bottom and left/right
197 // respectively are flipped when compared to their physical counterparts. F or example minX is on the left in vertical-lr,
198 // but it is on the right in vertical-rl.
199 LayoutRect noOverflowRect() const;
200 LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layo utOverflowRect() : noOverflowRect(); }
201 IntRect pixelSnappedLayoutOverflowRect() const { return pixelSnappedIntRect( layoutOverflowRect()); }
202 LayoutSize maxLayoutOverflow() const { return LayoutSize(layoutOverflowRect( ).maxX(), layoutOverflowRect().maxY()); }
203 LayoutUnit logicalLeftLayoutOverflow() const { return style()->isHorizontalW ritingMode() ? layoutOverflowRect().x() : layoutOverflowRect().y(); }
204 LayoutUnit logicalRightLayoutOverflow() const { return style()->isHorizontal WritingMode() ? layoutOverflowRect().maxX() : layoutOverflowRect().maxY(); }
205
206 virtual LayoutRect visualOverflowRect() const { return m_overflow ? m_overfl ow->visualOverflowRect() : borderBoxRect(); }
207 LayoutUnit logicalLeftVisualOverflow() const { return style()->isHorizontalW ritingMode() ? visualOverflowRect().x() : visualOverflowRect().y(); }
208 LayoutUnit logicalRightVisualOverflow() const { return style()->isHorizontal WritingMode() ? visualOverflowRect().maxX() : visualOverflowRect().maxY(); }
209
210 LayoutRect contentsVisualOverflowRect() const { return m_overflow ? m_overfl ow->contentsVisualOverflowRect() : LayoutRect(); }
211
212 void addLayoutOverflow(const LayoutRect&);
213 void addVisualOverflow(const LayoutRect&);
214
215 // Clipped by the contents clip, if one exists.
216 void addContentsVisualOverflow(const LayoutRect&);
217
218 void addVisualEffectOverflow();
219 LayoutRectOutsets computeVisualEffectOverflowOutsets() const;
220 void addOverflowFromChild(RenderBox* child) { addOverflowFromChild(child, ch ild->locationOffset()); }
221 void addOverflowFromChild(RenderBox* child, const LayoutSize& delta);
222 void clearLayoutOverflow();
223 void clearAllOverflows() { m_overflow.clear(); }
224
225 void updateLayerTransformAfterLayout();
226
227 LayoutUnit contentWidth() const { return clientWidth() - paddingLeft() - pad dingRight(); }
228 LayoutUnit contentHeight() const { return clientHeight() - paddingTop() - pa ddingBottom(); }
229 LayoutSize contentSize() const { return LayoutSize(contentWidth(), contentHe ight()); }
230 LayoutUnit contentLogicalWidth() const { return style()->isHorizontalWriting Mode() ? contentWidth() : contentHeight(); }
231 LayoutUnit contentLogicalHeight() const { return style()->isHorizontalWritin gMode() ? contentHeight() : contentWidth(); }
232
233 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin es (RenderFlow)
234 // to return the remaining width on a given line (and the height of a single line).
235 virtual LayoutUnit offsetWidth() const override { return m_frameRect.width() ; }
236 virtual LayoutUnit offsetHeight() const override { return m_frameRect.height (); }
237
238 virtual int pixelSnappedOffsetWidth() const override final;
239 virtual int pixelSnappedOffsetHeight() const override final;
240
241 // More IE extensions. clientWidth and clientHeight represent the interior of an object
242 // excluding border and scrollbar. clientLeft/Top are just the borderLeftWi dth and borderTopWidth.
243 LayoutUnit clientLeft() const { return borderLeft() + (style()->shouldPlaceB lockDirectionScrollbarOnLogicalLeft() ? verticalScrollbarWidth() : 0); }
244 LayoutUnit clientTop() const { return borderTop(); }
245 LayoutUnit clientWidth() const;
246 LayoutUnit clientHeight() const;
247 LayoutUnit clientLogicalWidth() const { return style()->isHorizontalWritingM ode() ? clientWidth() : clientHeight(); }
248 LayoutUnit clientLogicalHeight() const { return style()->isHorizontalWriting Mode() ? clientHeight() : clientWidth(); }
249 LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogic alHeight(); }
250 LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop (), clientWidth(), clientHeight()); }
251
252 int pixelSnappedClientWidth() const;
253 int pixelSnappedClientHeight() const;
254
255 // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unl ess the
256 // object has overflow:hidden/scroll/auto specified and also has overflow.
257 // scrollLeft/Top return the current scroll position. These methods are vir tual so that objects like
258 // textareas can scroll shadow content (but pretend that they are the object s that are
259 // scrolling).
260 virtual LayoutUnit scrollLeft() const;
261 virtual LayoutUnit scrollTop() const;
262 virtual LayoutUnit scrollWidth() const;
263 virtual LayoutUnit scrollHeight() const;
264 int pixelSnappedScrollWidth() const;
265 int pixelSnappedScrollHeight() const;
266 virtual void setScrollLeft(LayoutUnit);
267 virtual void setScrollTop(LayoutUnit);
268
269 void scrollToOffset(const DoubleSize&, ScrollBehavior = ScrollBehaviorInstan t);
270 void scrollByRecursively(const DoubleSize& delta, ScrollOffsetClamping = Scr ollOffsetUnclamped);
271 void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX, c onst ScrollAlignment& alignY);
272
273 virtual LayoutRectOutsets marginBoxOutsets() const override { return m_margi nBoxOutsets; }
274 virtual LayoutUnit marginTop() const override { return m_marginBoxOutsets.to p(); }
275 virtual LayoutUnit marginBottom() const override { return m_marginBoxOutsets .bottom(); }
276 virtual LayoutUnit marginLeft() const override { return m_marginBoxOutsets.l eft(); }
277 virtual LayoutUnit marginRight() const override { return m_marginBoxOutsets. right(); }
278 void setMarginTop(LayoutUnit margin) { m_marginBoxOutsets.setTop(margin); }
279 void setMarginBottom(LayoutUnit margin) { m_marginBoxOutsets.setBottom(margi n); }
280 void setMarginLeft(LayoutUnit margin) { m_marginBoxOutsets.setLeft(margin); }
281 void setMarginRight(LayoutUnit margin) { m_marginBoxOutsets.setRight(margin) ; }
282
283 LayoutUnit marginLogicalLeft() const { return m_marginBoxOutsets.logicalLeft (style()->writingMode()); }
284 LayoutUnit marginLogicalRight() const { return m_marginBoxOutsets.logicalRig ht(style()->writingMode()); }
285
286 virtual LayoutUnit marginBefore(const LayoutStyle* overrideStyle = 0) const override final { return m_marginBoxOutsets.before((overrideStyle ? overrideStyle : style())->writingMode()); }
287 virtual LayoutUnit marginAfter(const LayoutStyle* overrideStyle = 0) const o verride final { return m_marginBoxOutsets.after((overrideStyle ? overrideStyle : style())->writingMode()); }
288 virtual LayoutUnit marginStart(const LayoutStyle* overrideStyle = 0) const o verride final
289 {
290 const LayoutStyle* styleToUse = overrideStyle ? overrideStyle : style();
291 return m_marginBoxOutsets.start(styleToUse->writingMode(), styleToUse->d irection());
292 }
293 virtual LayoutUnit marginEnd(const LayoutStyle* overrideStyle = 0) const ove rride final
294 {
295 const LayoutStyle* styleToUse = overrideStyle ? overrideStyle : style();
296 return m_marginBoxOutsets.end(styleToUse->writingMode(), styleToUse->dir ection());
297 }
298 void setMarginBefore(LayoutUnit value, const LayoutStyle* overrideStyle = 0) { m_marginBoxOutsets.setBefore((overrideStyle ? overrideStyle : style())->writi ngMode(), value); }
299 void setMarginAfter(LayoutUnit value, const LayoutStyle* overrideStyle = 0) { m_marginBoxOutsets.setAfter((overrideStyle ? overrideStyle : style())->writing Mode(), value); }
300 void setMarginStart(LayoutUnit value, const LayoutStyle* overrideStyle = 0)
301 {
302 const LayoutStyle* styleToUse = overrideStyle ? overrideStyle : style();
303 m_marginBoxOutsets.setStart(styleToUse->writingMode(), styleToUse->direc tion(), value);
304 }
305 void setMarginEnd(LayoutUnit value, const LayoutStyle* overrideStyle = 0)
306 {
307 const LayoutStyle* styleToUse = overrideStyle ? overrideStyle : style();
308 m_marginBoxOutsets.setEnd(styleToUse->writingMode(), styleToUse->directi on(), value);
309 }
310
311 // The following functions are used to implement collapsing margins.
312 // All objects know their maximal positive and negative margins. The
313 // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargi n|.
314 // For a non-collapsing box, such as a leaf element, this formula will simpl y return
315 // the margin of the element. Blocks override the maxMarginBefore and maxMa rginAfter
316 // methods.
317 virtual bool isSelfCollapsingBlock() const { return false; }
318 virtual LayoutUnit collapsedMarginBefore() const { return marginBefore(); }
319 virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); }
320 LayoutRectOutsets collapsedMarginBoxLogicalOutsets() const { return LayoutRe ctOutsets(collapsedMarginBefore(), 0, collapsedMarginAfter(), 0); }
321
322 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedO ffset) const override;
323 virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const overrid e;
324
325 int reflectionOffset() const;
326 // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection.
327 LayoutRect reflectedRect(const LayoutRect&) const;
328
329 virtual void layout() override;
330 virtual void paint(const PaintInfo&, const LayoutPoint&) override;
331 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct ion) override;
332
333 virtual LayoutUnit minPreferredLogicalWidth() const override;
334 virtual LayoutUnit maxPreferredLogicalWidth() const override;
335
336 // FIXME: We should rename these back to overrideLogicalHeight/Width and hav e them store
337 // the border-box height/width like the regular height/width accessors on Re nderBox.
338 // Right now, these are different than contentHeight/contentWidth because th ey still
339 // include the scrollbar height/width.
340 LayoutUnit overrideLogicalContentWidth() const;
341 LayoutUnit overrideLogicalContentHeight() const;
342 bool hasOverrideHeight() const;
343 bool hasOverrideWidth() const;
344 void setOverrideLogicalContentHeight(LayoutUnit);
345 void setOverrideLogicalContentWidth(LayoutUnit);
346 void clearOverrideSize();
347 void clearOverrideLogicalContentHeight();
348 void clearOverrideLogicalContentWidth();
349
350 LayoutUnit overrideContainingBlockContentLogicalWidth() const;
351 LayoutUnit overrideContainingBlockContentLogicalHeight() const;
352 bool hasOverrideContainingBlockLogicalWidth() const;
353 bool hasOverrideContainingBlockLogicalHeight() const;
354 void setOverrideContainingBlockContentLogicalWidth(LayoutUnit);
355 void setOverrideContainingBlockContentLogicalHeight(LayoutUnit);
356 void clearContainingBlockOverrideSize();
357 void clearOverrideContainingBlockContentLogicalHeight();
358
359 LayoutUnit extraInlineOffset() const;
360 LayoutUnit extraBlockOffset() const;
361 void setExtraInlineOffset(LayoutUnit inlineOffest);
362 void setExtraBlockOffset(LayoutUnit blockOffest);
363 void clearExtraInlineAndBlockOffests();
364
365 virtual LayoutSize offsetFromContainer(const LayoutObject*, const LayoutPoin t&, bool* offsetDependsOnPoint = 0) const override;
366
367 LayoutUnit adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const;
368 LayoutUnit adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const ;
369 LayoutUnit adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width) const;
370 LayoutUnit adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit height) cons t;
371
372 struct ComputedMarginValues {
373 ComputedMarginValues() { }
374
375 LayoutUnit m_before;
376 LayoutUnit m_after;
377 LayoutUnit m_start;
378 LayoutUnit m_end;
379 };
380 struct LogicalExtentComputedValues {
381 LogicalExtentComputedValues() { }
382
383 LayoutUnit m_extent;
384 LayoutUnit m_position;
385 ComputedMarginValues m_margins;
386 };
387 // Resolve auto margins in the chosen direction of the containing block so t hat objects can be pushed to the start, middle or end
388 // of the containing block.
389 void computeMarginsForDirection(MarginDirection forDirection, const RenderBl ock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUn it& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length marginS tartEnd) const;
390
391 // Used to resolve margins in the containing block's block-flow direction.
392 void computeAndSetBlockDirectionMargins(const RenderBlock* containingBlock);
393
394 virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const;
395
396 void positionLineBox(InlineBox*);
397 void moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal);
398 void markStaticPositionedBoxForLayout(bool isHorizontal, bool isInline);
399
400 virtual InlineBox* createInlineBox();
401 void dirtyLineBoxes(bool fullLayout);
402
403 // For inline replaced elements, this function returns the inline box that o wns us. Enables
404 // the replaced LayoutObject to quickly determine what line it is contained on and to easily
405 // iterate over structures on the line.
406 InlineBox* inlineBoxWrapper() const { return m_rareData ? m_rareData->m_inli neBoxWrapper : 0; }
407 void setInlineBoxWrapper(InlineBox*);
408 void deleteLineBoxWrapper();
409
410 void setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder&);
411 void clearSpannerPlaceholder();
412 virtual LayoutMultiColumnSpannerPlaceholder* spannerPlaceholder() const fina l { return m_rareData ? m_rareData->m_spannerPlaceholder : 0; }
413
414 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo delObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const override;
415 virtual void mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* p aintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const ove rride;
416 virtual void invalidatePaintForOverhangingFloats(bool paintAllDescendants);
417
418 virtual LayoutUnit containingBlockLogicalWidthForContent() const override;
419 LayoutUnit containingBlockLogicalHeightForContent(AvailableLogicalHeightType ) const;
420
421 LayoutUnit containingBlockAvailableLineWidth() const;
422 LayoutUnit perpendicularContainingBlockLogicalHeight() const;
423
424 virtual void updateLogicalWidth();
425 void updateLogicalHeight();
426 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic alTop, LogicalExtentComputedValues&) const;
427
428 void computeLogicalWidth(LogicalExtentComputedValues&) const;
429
430 bool stretchesToViewport() const
431 {
432 return document().inQuirksMode() && style()->logicalHeight().isAuto() && !isFloatingOrOutOfFlowPositioned() && (isDocumentElement() || isBody()) && !isI nline();
433 }
434
435 virtual LayoutSize intrinsicSize() const { return LayoutSize(); }
436 LayoutUnit intrinsicLogicalWidth() const { return style()->isHorizontalWriti ngMode() ? intrinsicSize().width() : intrinsicSize().height(); }
437 LayoutUnit intrinsicLogicalHeight() const { return style()->isHorizontalWrit ingMode() ? intrinsicSize().height() : intrinsicSize().width(); }
438 virtual LayoutUnit intrinsicContentLogicalHeight() const { return m_intrinsi cContentLogicalHeight; }
439
440 // Whether or not the element shrinks to its intrinsic width (rather than fi lling the width
441 // of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this.
442 bool sizesLogicalWidthToFitContent(const Length& logicalWidth) const;
443
444 LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, Layo utUnit childMarginEnd, const RenderBlockFlow* cb) const;
445
446 LayoutUnit computeLogicalWidthUsing(SizeType, const Length& logicalWidth, La youtUnit availableLogicalWidth, const RenderBlock* containingBlock) const;
447 LayoutUnit computeLogicalHeightUsing(const Length& height, LayoutUnit intrin sicContentHeight) const;
448 LayoutUnit computeContentLogicalHeight(const Length& height, LayoutUnit intr insicContentHeight) const;
449 LayoutUnit computeContentAndScrollbarLogicalHeightUsing(const Length& height , LayoutUnit intrinsicContentHeight) const;
450 LayoutUnit computeReplacedLogicalWidthUsing(const Length& width) const;
451 LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logic alWidth, ShouldComputePreferred = ComputeActual) const;
452 LayoutUnit computeReplacedLogicalHeightUsing(const Length& height) const;
453 LayoutUnit computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit log icalHeight) const;
454
455 virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = Com puteActual) const;
456 virtual LayoutUnit computeReplacedLogicalHeight() const;
457
458 static bool logicalWidthIsResolvableFromBlock(const RenderBlock* containingB lock);
459 bool hasDefiniteLogicalWidth() const;
460 static bool percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool outOfFlowPositioned);
461 bool hasDefiniteLogicalHeight() const;
462 LayoutUnit computePercentageLogicalHeight(const Length& height) const;
463
464 // Block flows subclass availableWidth/Height to handle multi column layout (shrinking the width/height available to children when laying out.)
465 virtual LayoutUnit availableLogicalWidth() const { return contentLogicalWidt h(); }
466 virtual LayoutUnit availableLogicalHeight(AvailableLogicalHeightType) const;
467 LayoutUnit availableLogicalHeightUsing(const Length&, AvailableLogicalHeight Type) const;
468
469 // There are a few cases where we need to refer specifically to the availabl e physical width and available physical height.
470 // Relative positioning is one of those cases, since left/top offsets are ph ysical.
471 LayoutUnit availableWidth() const { return style()->isHorizontalWritingMode( ) ? availableLogicalWidth() : availableLogicalHeight(IncludeMarginBorderPadding) ; }
472 LayoutUnit availableHeight() const { return style()->isHorizontalWritingMode () ? availableLogicalHeight(IncludeMarginBorderPadding) : availableLogicalWidth( ); }
473
474 virtual int verticalScrollbarWidth() const;
475 int horizontalScrollbarHeight() const;
476 int intrinsicScrollbarLogicalWidth() const;
477 int scrollbarLogicalWidth() const { return style()->isHorizontalWritingMode( ) ? verticalScrollbarWidth() : horizontalScrollbarHeight(); }
478 int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode () ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
479 virtual bool scroll(ScrollDirection, ScrollGranularity, float delta = 1);
480 bool canBeScrolledAndHasScrollableArea() const;
481 virtual bool canBeProgramaticallyScrolled() const;
482 virtual void autoscroll(const IntPoint&);
483 bool canAutoscroll() const;
484 IntSize calculateAutoscrollDirection(const IntPoint& windowPoint) const;
485 static RenderBox* findAutoscrollable(LayoutObject*);
486 virtual void stopAutoscroll() { }
487 virtual void panScroll(const IntPoint&);
488
489 bool hasAutoVerticalScrollbar() const { return hasOverflowClip() && (style() ->overflowY() == OAUTO || style()->overflowY() == OPAGEDY || style()->overflowY( ) == OOVERLAY); }
490 bool hasAutoHorizontalScrollbar() const { return hasOverflowClip() && (style ()->overflowX() == OAUTO || style()->overflowX() == OOVERLAY); }
491 bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY (); }
492
493 bool hasScrollableOverflowX() const { return scrollsOverflowX() && pixelSnap pedScrollWidth() != pixelSnappedClientWidth(); }
494 bool hasScrollableOverflowY() const { return scrollsOverflowY() && pixelSnap pedScrollHeight() != pixelSnappedClientHeight(); }
495 virtual bool scrollsOverflowX() const { return hasOverflowClip() && (style() ->overflowX() == OSCROLL || hasAutoHorizontalScrollbar()); }
496 virtual bool scrollsOverflowY() const { return hasOverflowClip() && (style() ->overflowY() == OSCROLL || hasAutoVerticalScrollbar()); }
497 bool usesCompositedScrolling() const;
498
499 // Elements such as the <input> field override this to specify that they are scrollable
500 // outside the context of the CSS overflow style
501 virtual bool isIntristicallyScrollable(ScrollbarOrientation orientation) con st { return false; }
502
503 bool hasUnsplittableScrollingOverflow() const;
504 bool isUnsplittableForPagination() const;
505
506 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* e xtraWidthToEndOfLine = 0) override;
507
508 virtual LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScro llbarSizeRelevancy = IgnoreOverlayScrollbarSize);
509 LayoutRect clipRect(const LayoutPoint& location);
510 virtual bool hasControlClip() const { return false; }
511 virtual LayoutRect controlClipRect(const LayoutPoint&) const { return Layout Rect(); }
512
513 virtual void paintObject(const PaintInfo&, const LayoutPoint&) { ASSERT_NOT_ REACHED(); }
514 virtual void paintBoxDecorationBackground(const PaintInfo&, const LayoutPoin t&);
515 virtual void paintMask(const PaintInfo&, const LayoutPoint&);
516 virtual void paintClippingMask(const PaintInfo&, const LayoutPoint&);
517 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) override;
518
519 void logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit& logicalTop, Lo gicalExtentComputedValues&);
520
521 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) override;
522
523 void removeFloatingOrPositionedChildFromBlockLists();
524
525 Layer* enclosingFloatPaintingLayer() const;
526
527 virtual int firstLineBoxBaseline() const { return -1; }
528 virtual int inlineBlockBaseline(LineDirectionMode) const { return -1; } // R eturns -1 if we should skip this box when computing the baseline of an inline-bl ock.
529
530 bool shrinkToAvoidFloats() const;
531 virtual bool avoidsFloats() const;
532
533 virtual void markForPaginationRelayoutIfNeeded(SubtreeLayoutScope&);
534
535 bool isWritingModeRoot() const { return !parent() || parent()->style()->writ ingMode() != style()->writingMode(); }
536
537 bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrOutOf FlowPositioned() && parent() && parent()->isDeprecatedFlexibleBox(); }
538 bool isFlexItemIncludingDeprecated() const { return !isInline() && !isFloati ngOrOutOfFlowPositioned() && parent() && parent()->isFlexibleBoxIncludingDepreca ted(); }
539
540 bool isGridItem() const { return parent() && parent()->isRenderGrid(); }
541
542 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositio nMode = PositionOnContainingLine) const override;
543 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode , LinePositionMode = PositionOnContainingLine) const override;
544
545 virtual LayoutUnit offsetLeft() const override;
546 virtual LayoutUnit offsetTop() const override;
547
548 LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutP oint&) const;
549 LayoutUnit flipForWritingMode(LayoutUnit position) const WARN_UNUSED_RETURN
550 {
551 // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes).
552 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
553 return position;
554 return logicalHeight() - position;
555 }
556 LayoutPoint flipForWritingMode(const LayoutPoint& position) const WARN_UNUSE D_RETURN
557 {
558 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
559 return position;
560 return isHorizontalWritingMode() ? LayoutPoint(position.x(), m_frameRect .height() - position.y()) : LayoutPoint(m_frameRect.width() - position.x(), posi tion.y());
561 }
562 LayoutPoint flipForWritingModeIncludingColumns(const LayoutPoint&) const;
563 LayoutSize flipForWritingMode(const LayoutSize& offset) const WARN_UNUSED_RE TURN
564 {
565 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
566 return offset;
567 return isHorizontalWritingMode() ? LayoutSize(offset.width(), m_frameRec t.height() - offset.height()) : LayoutSize(m_frameRect.width() - offset.width(), offset.height());
568 }
569 void flipForWritingMode(LayoutRect& rect) const
570 {
571 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
572 return;
573 if (isHorizontalWritingMode())
574 rect.setY(m_frameRect.height() - rect.maxY());
575 else
576 rect.setX(m_frameRect.width() - rect.maxX());
577 }
578 FloatPoint flipForWritingMode(const FloatPoint& position) const WARN_UNUSED_ RETURN
579 {
580 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
581 return position;
582 return isHorizontalWritingMode() ? FloatPoint(position.x(), m_frameRect. height() - position.y()) : FloatPoint(m_frameRect.width() - position.x(), positi on.y());
583 }
584 void flipForWritingMode(FloatRect& rect) const
585 {
586 if (!UNLIKELY(hasFlippedBlocksWritingMode()))
587 return;
588 if (isHorizontalWritingMode())
589 rect.setY(m_frameRect.height() - rect.maxY());
590 else
591 rect.setX(m_frameRect.width() - rect.maxX());
592 }
593 // These represent your location relative to your container as a physical of fset.
594 // In layout related methods you almost always want the logical location (e. g. x() and y()).
595 LayoutPoint topLeftLocation() const;
596 LayoutSize topLeftLocationOffset() const { return toLayoutSize(topLeftLocati on()); }
597
598 LayoutRect logicalVisualOverflowRectForPropagation(const LayoutStyle&) const ;
599 LayoutRect visualOverflowRectForPropagation(const LayoutStyle&) const;
600 LayoutRect logicalLayoutOverflowRectForPropagation(const LayoutStyle&) const ;
601 LayoutRect layoutOverflowRectForPropagation(const LayoutStyle&) const;
602
603 bool hasRenderOverflow() const { return m_overflow; }
604 bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().conta ins(m_overflow->visualOverflowRect()); }
605
606 virtual bool needsPreferredWidthsRecalculation() const;
607 virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */ , double& /* intrinsicRatio */) const { }
608
609 IntSize scrolledContentOffset() const;
610 void applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& paintRec t) const;
611
612 virtual bool hasRelativeLogicalHeight() const;
613
614 bool hasHorizontalLayoutOverflow() const
615 {
616 if (!m_overflow)
617 return false;
618
619 LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect();
620 LayoutRect noOverflowRect = this->noOverflowRect();
621 return layoutOverflowRect.x() < noOverflowRect.x() || layoutOverflowRect .maxX() > noOverflowRect.maxX();
622 }
623
624 bool hasVerticalLayoutOverflow() const
625 {
626 if (!m_overflow)
627 return false;
628
629 LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect();
630 LayoutRect noOverflowRect = this->noOverflowRect();
631 return layoutOverflowRect.y() < noOverflowRect.y() || layoutOverflowRect .maxY() > noOverflowRect.maxY();
632 }
633
634 virtual RenderBox* createAnonymousBoxWithSameTypeAs(const LayoutObject*) con st
635 {
636 ASSERT_NOT_REACHED();
637 return 0;
638 }
639
640 bool hasSameDirectionAs(const RenderBox* object) const { return style()->dir ection() == object->style()->direction(); }
641
642 ShapeOutsideInfo* shapeOutsideInfo() const
643 {
644 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*t his) : 0;
645 }
646
647 void markShapeOutsideDependentsForLayout()
648 {
649 if (isFloating())
650 removeFloatingOrPositionedChildFromBlockLists();
651 }
652
653 bool backgroundHasOpaqueTopLayer() const;
654
655 void setIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeig ht) const { m_intrinsicContentLogicalHeight = intrinsicContentLogicalHeight; }
656 protected:
657 virtual void willBeDestroyed() override;
658
659 virtual void styleWillChange(StyleDifference, const LayoutStyle& newStyle) o verride;
660 virtual void styleDidChange(StyleDifference, const LayoutStyle* oldStyle) ov erride;
661 virtual void updateFromStyle() override;
662
663 // Returns false if it could not cheaply compute the extent (e.g. fixed back ground), in which case the returned rect may be incorrect.
664 // FIXME: make this a const method once the RenderBox reference in BoxPainte r is const.
665 bool getBackgroundPaintedExtent(LayoutRect&);
666 virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const;
667 virtual bool computeBackgroundIsKnownToBeObscured() override;
668
669 void computePositionedLogicalWidth(LogicalExtentComputedValues&) const;
670
671 LayoutUnit computeIntrinsicLogicalWidthUsing(const Length& logicalWidthLengt h, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const;
672 LayoutUnit computeIntrinsicLogicalContentHeightUsing(const Length& logicalHe ightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPadding) cons t;
673
674 virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !i sInlineBlockOrInlineTable(); }
675
676 virtual void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidati onContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wa sFixed = 0, const PaintInvalidationState* = 0) const override;
677 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c onst override;
678
679 LayoutObject* splitAnonymousBoxesAroundChild(LayoutObject* beforeChild);
680
681 virtual void addLayerHitTestRects(LayerHitTestRects&, const Layer* currentCo mpositedLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const override;
682 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const override;
683
684 virtual PaintInvalidationReason paintInvalidationReason(const LayoutBoxModel Object& paintInvalidationContainer,
685 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInva lidationContainer,
686 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInva lidationContainer) const override;
687 virtual void incrementallyInvalidatePaint(const LayoutBoxModelObject& paintI nvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationContainer) override;
688
689 virtual void clearPaintInvalidationState(const PaintInvalidationState&) over ride;
690 #if ENABLE(ASSERT)
691 virtual bool paintInvalidationStateIsDirty() const override;
692 #endif
693
694 virtual PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidat ionState&, const LayoutBoxModelObject& newPaintInvalidationContainer) override;
695 virtual void invalidateDisplayItemClients(DisplayItemList*) const override;
696
697 virtual bool hasNonCompositedScrollbars() const override final;
698
699 private:
700 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds);
701
702 void updateShapeOutsideInfoAfterStyleChange(const LayoutStyle&, const Layout Style* oldStyle);
703 void updateGridPositionAfterStyleChange(const LayoutStyle*);
704
705 bool autoWidthShouldFitContent() const;
706 LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutU nit bordersPlusPadding) const;
707
708 // Returns true if we queued up a paint invalidation.
709 bool paintInvalidationLayerRectsForImage(WrappedImagePtr, const FillLayer&, bool drawingBackground);
710
711 bool skipContainingBlockForPercentHeightCalculation(const RenderBox* contain ingBlock) const;
712
713 LayoutUnit containingBlockLogicalWidthForPositioned(const LayoutBoxModelObje ct* containingBlock, bool checkForPerpendicularWritingMode = true) const;
714 LayoutUnit containingBlockLogicalHeightForPositioned(const LayoutBoxModelObj ect* containingBlock, bool checkForPerpendicularWritingMode = true) const;
715
716 void computePositionedLogicalHeight(LogicalExtentComputedValues&) const;
717 void computePositionedLogicalWidthUsing(Length logicalWidth, const LayoutBox ModelObject* containerBlock, TextDirection containerDirection,
718 LayoutUnit containerLogicalWidth, La youtUnit bordersPlusPadding,
719 const Length& logicalLeft, const Len gth& logicalRight, const Length& marginLogicalLeft,
720 const Length& marginLogicalRight, Lo gicalExtentComputedValues&) const;
721 void computePositionedLogicalHeightUsing(Length logicalHeightLength, const L ayoutBoxModelObject* containerBlock,
722 LayoutUnit containerLogicalHeight, LayoutUnit bordersPlusPadding, LayoutUnit logicalHeight,
723 const Length& logicalTop, const Len gth& logicalBottom, const Length& marginLogicalTop,
724 const Length& marginLogicalBottom, LogicalExtentComputedValues&) const;
725
726 void computePositionedLogicalHeightReplaced(LogicalExtentComputedValues&) co nst;
727 void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) con st;
728
729 LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth) const;
730 LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit & marginStart, LayoutUnit& marginEnd) const;
731
732 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layo utUnit& maxLogicalWidth) const;
733
734 // This function calculates the minimum and maximum preferred widths for an object.
735 // These values are used in shrink-to-fit layout systems.
736 // These include tables, positioned objects, floats and flexible boxes.
737 virtual void computePreferredLogicalWidths() { clearPreferredLogicalWidthsDi rty(); }
738
739 RenderBoxRareData& ensureRareData()
740 {
741 if (!m_rareData)
742 m_rareData = adoptPtr(new RenderBoxRareData());
743 return *m_rareData.get();
744 }
745
746 void savePreviousBorderBoxSizeIfNeeded();
747 LayoutSize computePreviousBorderBoxSize(const LayoutSize& previousBoundsSize ) const;
748
749 bool logicalHeightComputesAsNone(SizeType) const;
750
751 bool isBox() const = delete; // This will catch anyone doing an unnecessary check.
752
753 // The width/height of the contents + borders + padding. The x/y location i s relative to our container (which is not always our parent).
754 LayoutRect m_frameRect;
755
756 // Our intrinsic height, used for min-height: min-content etc. Maintained by
757 // updateLogicalHeight. This is logicalHeight() before it is clamped to
758 // min/max.
759 mutable LayoutUnit m_intrinsicContentLogicalHeight;
760
761 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect&) const;
762
763 LayoutRectOutsets m_marginBoxOutsets;
764
765 protected:
766 // The preferred logical width of the element if it were to break its lines at every possible opportunity.
767 LayoutUnit m_minPreferredLogicalWidth;
768
769 // The preferred logical width of the element if it never breaks any lines a t all.
770 LayoutUnit m_maxPreferredLogicalWidth;
771
772 // Our overflow information.
773 OwnPtr<RenderOverflow> m_overflow;
774
775 private:
776 OwnPtr<RenderBoxRareData> m_rareData;
777 };
778
779 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderBox, isBox());
780
781 inline RenderBox* RenderBox::previousSiblingBox() const
782 {
783 return toRenderBox(previousSibling());
784 }
785
786 inline RenderBox* RenderBox::previousInFlowSiblingBox() const
787 {
788 RenderBox* previous = previousSiblingBox();
789 while (previous && previous->isOutOfFlowPositioned())
790 previous = previous->previousSiblingBox();
791 return previous;
792 }
793
794 inline RenderBox* RenderBox::nextSiblingBox() const
795 {
796 return toRenderBox(nextSibling());
797 }
798
799 inline RenderBox* RenderBox::nextInFlowSiblingBox() const
800 {
801 RenderBox* next = nextSiblingBox();
802 while (next && next->isOutOfFlowPositioned())
803 next = next->nextSiblingBox();
804 return next;
805 }
806
807 inline RenderBox* RenderBox::parentBox() const
808 {
809 return toRenderBox(parent());
810 }
811
812 inline RenderBox* RenderBox::firstChildBox() const
813 {
814 return toRenderBox(slowFirstChild());
815 }
816
817 inline RenderBox* RenderBox::lastChildBox() const
818 {
819 return toRenderBox(slowLastChild());
820 }
821
822 inline RenderBox* RenderBox::previousSiblingMultiColumnBox() const
823 {
824 ASSERT(isLayoutMultiColumnSpannerPlaceholder() || isLayoutMultiColumnSet());
825 RenderBox* previousBox = previousSiblingBox();
826 if (previousBox->isLayoutFlowThread())
827 return 0;
828 return previousBox;
829 }
830
831 inline RenderBox* RenderBox::nextSiblingMultiColumnBox() const
832 {
833 ASSERT(isLayoutMultiColumnSpannerPlaceholder() || isLayoutMultiColumnSet());
834 return nextSiblingBox();
835 }
836
837 inline void RenderBox::setInlineBoxWrapper(InlineBox* boxWrapper)
838 {
839 if (boxWrapper) {
840 ASSERT(!inlineBoxWrapper());
841 // m_inlineBoxWrapper should already be 0. Deleting it is a safeguard ag ainst security issues.
842 // Otherwise, there will two line box wrappers keeping the reference to this renderer, and
843 // only one will be notified when the renderer is getting destroyed. The second line box wrapper
844 // will keep a stale reference.
845 if (UNLIKELY(inlineBoxWrapper() != 0))
846 deleteLineBoxWrapper();
847 }
848
849 ensureRareData().m_inlineBoxWrapper = boxWrapper;
850 }
851
852 } // namespace blink
853
854 #endif // RenderBox_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockLineLayout.cpp ('k') | Source/core/rendering/RenderBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698