1 | /* |
2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 | * Copyright (C) 2003, 2006, 2007, 2015 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 | #pragma once |
24 | |
25 | #include "FrameView.h" |
26 | #include "RenderBoxModelObject.h" |
27 | #include "RenderOverflow.h" |
28 | #include "ScrollTypes.h" |
29 | #include "ShapeOutsideInfo.h" |
30 | |
31 | namespace WebCore { |
32 | |
33 | class InlineElementBox; |
34 | class RenderBlockFlow; |
35 | class RenderBoxFragmentInfo; |
36 | class RenderFragmentContainer; |
37 | struct PaintInfo; |
38 | |
39 | enum SizeType { MainOrPreferredSize, MinSize, MaxSize }; |
40 | enum AvailableLogicalHeightType { ExcludeMarginBorderPadding, IncludeMarginBorderPadding }; |
41 | enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayScrollbarSize }; |
42 | |
43 | enum ShouldComputePreferred { ComputeActual, ComputePreferred }; |
44 | |
45 | class RenderBox : public RenderBoxModelObject { |
46 | WTF_MAKE_ISO_ALLOCATED(RenderBox); |
47 | public: |
48 | virtual ~RenderBox(); |
49 | |
50 | // hasAutoZIndex only returns true if the element is positioned or a flex-item since |
51 | // position:static elements that are not flex-items get their z-index coerced to auto. |
52 | bool requiresLayer() const override |
53 | { |
54 | return isDocumentElementRenderer() || isPositioned() || createsGroup() || hasClipPath() || hasOverflowClip() |
55 | || hasTransformRelatedProperty() || hasHiddenBackface() || hasReflection() || style().specifiesColumns() |
56 | || !style().hasAutoZIndex() || hasRunningAcceleratedAnimations(); |
57 | } |
58 | |
59 | bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const final; |
60 | |
61 | // Returns false for the body renderer if its background is propagated to the root. |
62 | bool paintsOwnBackground() const; |
63 | |
64 | LayoutUnit x() const { return m_frameRect.x(); } |
65 | LayoutUnit y() const { return m_frameRect.y(); } |
66 | LayoutUnit width() const { return m_frameRect.width(); } |
67 | LayoutUnit height() const { return m_frameRect.height(); } |
68 | |
69 | // These represent your location relative to your container as a physical offset. |
70 | // In layout related methods you almost always want the logical location (e.g. x() and y()). |
71 | LayoutUnit top() const { return topLeftLocation().y(); } |
72 | LayoutUnit left() const { return topLeftLocation().x(); } |
73 | |
74 | void setX(LayoutUnit x) { m_frameRect.setX(x); } |
75 | void setY(LayoutUnit y) { m_frameRect.setY(y); } |
76 | void setWidth(LayoutUnit width) { m_frameRect.setWidth(width); } |
77 | void setHeight(LayoutUnit height) { m_frameRect.setHeight(height); } |
78 | |
79 | LayoutUnit logicalLeft() const { return style().isHorizontalWritingMode() ? x() : y(); } |
80 | LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } |
81 | LayoutUnit logicalTop() const { return style().isHorizontalWritingMode() ? y() : x(); } |
82 | LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } |
83 | LayoutUnit logicalWidth() const { return style().isHorizontalWritingMode() ? width() : height(); } |
84 | LayoutUnit logicalHeight() const { return style().isHorizontalWritingMode() ? height() : width(); } |
85 | |
86 | LayoutUnit constrainLogicalWidthInFragmentByMinMax(LayoutUnit, LayoutUnit, RenderBlock&, RenderFragmentContainer* = nullptr) const; |
87 | LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, Optional<LayoutUnit> intrinsicContentHeight) const; |
88 | LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight, Optional<LayoutUnit> intrinsicContentHeight) const; |
89 | |
90 | void setLogicalLeft(LayoutUnit left) |
91 | { |
92 | if (style().isHorizontalWritingMode()) |
93 | setX(left); |
94 | else |
95 | setY(left); |
96 | } |
97 | void setLogicalTop(LayoutUnit top) |
98 | { |
99 | if (style().isHorizontalWritingMode()) |
100 | setY(top); |
101 | else |
102 | setX(top); |
103 | } |
104 | void setLogicalLocation(const LayoutPoint& location) |
105 | { |
106 | if (style().isHorizontalWritingMode()) |
107 | setLocation(location); |
108 | else |
109 | setLocation(location.transposedPoint()); |
110 | } |
111 | void setLogicalWidth(LayoutUnit size) |
112 | { |
113 | if (style().isHorizontalWritingMode()) |
114 | setWidth(size); |
115 | else |
116 | setHeight(size); |
117 | } |
118 | void setLogicalHeight(LayoutUnit size) |
119 | { |
120 | if (style().isHorizontalWritingMode()) |
121 | setHeight(size); |
122 | else |
123 | setWidth(size); |
124 | } |
125 | void setLogicalSize(const LayoutSize& size) |
126 | { |
127 | if (style().isHorizontalWritingMode()) |
128 | setSize(size); |
129 | else |
130 | setSize(size.transposedSize()); |
131 | } |
132 | |
133 | LayoutPoint location() const { return m_frameRect.location(); } |
134 | LayoutSize locationOffset() const { return LayoutSize(x(), y()); } |
135 | LayoutSize size() const { return m_frameRect.size(); } |
136 | |
137 | void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(location); } |
138 | |
139 | void setSize(const LayoutSize& size) { m_frameRect.setSize(size); } |
140 | void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); } |
141 | |
142 | LayoutRect frameRect() const { return m_frameRect; } |
143 | void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; } |
144 | |
145 | LayoutRect marginBoxRect() const |
146 | { |
147 | auto marginLeft = computedCSSPadding(style().marginLeft()); |
148 | auto marginRight = computedCSSPadding(style().marginRight()); |
149 | auto marginTop = computedCSSPadding(style().marginTop()); |
150 | auto marginBottom = computedCSSPadding(style().marginBottom()); |
151 | return LayoutRect(-marginLeft, -marginTop, size().width() + marginLeft + marginRight, size().height() + marginTop + marginBottom); |
152 | } |
153 | LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), size()); } |
154 | LayoutRect borderBoundingBox() const final { return borderBoxRect(); } |
155 | |
156 | WEBCORE_EXPORT RoundedRect::Radii borderRadii() const; |
157 | |
158 | // The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border). |
159 | LayoutRect contentBoxRect() const; |
160 | LayoutPoint contentBoxLocation() const; |
161 | |
162 | // The content box in absolute coords. Ignores transforms. |
163 | IntRect absoluteContentBox() const; |
164 | // The content box converted to absolute coords (taking transforms into account). |
165 | WEBCORE_EXPORT FloatQuad absoluteContentQuad() const; |
166 | |
167 | // This returns the content area of the box (excluding padding and border). The only difference with contentBoxRect is that computedCSSContentBoxRect |
168 | // does include the intrinsic padding in the content box as this is what some callers expect (like getComputedStyle). |
169 | LayoutRect computedCSSContentBoxRect() const { return LayoutRect(borderLeft() + computedCSSPaddingLeft(), borderTop() + computedCSSPaddingTop(), paddingBoxWidth() - computedCSSPaddingLeft() - computedCSSPaddingRight(), paddingBoxHeight() - computedCSSPaddingTop() - computedCSSPaddingBottom()); } |
170 | |
171 | // Bounds of the outline box in absolute coords. Respects transforms |
172 | LayoutRect outlineBoundsForRepaint(const RenderLayerModelObject* /*repaintContainer*/, const RenderGeometryMap*) const final; |
173 | void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = nullptr) override; |
174 | |
175 | FloatRect repaintRectInLocalCoordinates() const override { return borderBoxRect(); } |
176 | FloatRect objectBoundingBox() const override { return borderBoxRect(); } |
177 | |
178 | // Note these functions are not equivalent of childrenOfType<RenderBox> |
179 | RenderBox* parentBox() const; |
180 | RenderBox* firstChildBox() const; |
181 | RenderBox* lastChildBox() const; |
182 | RenderBox* previousSiblingBox() const; |
183 | RenderBox* nextSiblingBox() const; |
184 | |
185 | // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions. |
186 | // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right |
187 | // respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr, |
188 | // but it is on the right in vertical-rl. |
189 | WEBCORE_EXPORT LayoutRect flippedClientBoxRect() const; |
190 | LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : flippedClientBoxRect(); } |
191 | LayoutUnit logicalLeftLayoutOverflow() const { return style().isHorizontalWritingMode() ? layoutOverflowRect().x() : layoutOverflowRect().y(); } |
192 | LayoutUnit logicalRightLayoutOverflow() const { return style().isHorizontalWritingMode() ? layoutOverflowRect().maxX() : layoutOverflowRect().maxY(); } |
193 | |
194 | virtual LayoutRect visualOverflowRect() const { return m_overflow ? m_overflow->visualOverflowRect() : borderBoxRect(); } |
195 | LayoutUnit logicalLeftVisualOverflow() const { return style().isHorizontalWritingMode() ? visualOverflowRect().x() : visualOverflowRect().y(); } |
196 | LayoutUnit logicalRightVisualOverflow() const { return style().isHorizontalWritingMode() ? visualOverflowRect().maxX() : visualOverflowRect().maxY(); } |
197 | |
198 | LayoutRect overflowRectForPaintRejection() const; |
199 | |
200 | void addLayoutOverflow(const LayoutRect&); |
201 | void addVisualOverflow(const LayoutRect&); |
202 | void clearOverflow(); |
203 | |
204 | virtual bool isTopLayoutOverflowAllowed() const { return !style().isLeftToRightDirection() && !isHorizontalWritingMode(); } |
205 | virtual bool isLeftLayoutOverflowAllowed() const { return !style().isLeftToRightDirection() && isHorizontalWritingMode(); } |
206 | |
207 | void addVisualEffectOverflow(); |
208 | LayoutRect applyVisualEffectOverflow(const LayoutRect&) const; |
209 | void addOverflowFromChild(const RenderBox* child) { addOverflowFromChild(child, child->locationOffset()); } |
210 | void addOverflowFromChild(const RenderBox* child, const LayoutSize& delta); |
211 | |
212 | void updateLayerTransform(); |
213 | |
214 | LayoutSize contentSize() const { return { contentWidth(), contentHeight() }; } |
215 | LayoutUnit contentWidth() const { return paddingBoxWidth() - paddingLeft() - paddingRight(); } |
216 | LayoutUnit contentHeight() const { return paddingBoxHeight() - paddingTop() - paddingBottom(); } |
217 | LayoutUnit contentLogicalWidth() const { return style().isHorizontalWritingMode() ? contentWidth() : contentHeight(); } |
218 | LayoutUnit contentLogicalHeight() const { return style().isHorizontalWritingMode() ? contentHeight() : contentWidth(); } |
219 | |
220 | LayoutUnit paddingBoxWidth() const { return width() - borderLeft() - borderRight() - verticalScrollbarWidth(); } |
221 | LayoutUnit paddingBoxHeight() const { return height() - borderTop() - borderBottom() - horizontalScrollbarHeight(); } |
222 | LayoutRect paddingBoxRect() const { return LayoutRect(borderLeft(), borderTop(), paddingBoxWidth(), paddingBoxHeight()); } |
223 | LayoutRect paddingBoxRectIncludingScrollbar() const { return LayoutRect(borderLeft(), borderTop(), width() - borderLeft() - borderRight(), height() - borderTop() - borderBottom()); } |
224 | |
225 | // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow) |
226 | // to return the remaining width on a given line (and the height of a single line). |
227 | LayoutUnit offsetWidth() const override { return width(); } |
228 | LayoutUnit offsetHeight() const override { return height(); } |
229 | |
230 | // More IE extensions. clientWidth and clientHeight represent the interior of an object |
231 | // excluding border and scrollbar. clientLeft/Top are just the borderLeftWidth and borderTopWidth. |
232 | LayoutUnit clientLeft() const { return borderLeft(); } |
233 | LayoutUnit clientTop() const { return borderTop(); } |
234 | WEBCORE_EXPORT LayoutUnit clientWidth() const; |
235 | WEBCORE_EXPORT LayoutUnit clientHeight() const; |
236 | LayoutUnit clientLogicalWidth() const { return style().isHorizontalWritingMode() ? clientWidth() : clientHeight(); } |
237 | LayoutUnit clientLogicalHeight() const { return style().isHorizontalWritingMode() ? clientHeight() : clientWidth(); } |
238 | LayoutUnit clientLogicalBottom() const { return borderBefore() + clientLogicalHeight(); } |
239 | LayoutRect clientBoxRect() const { return LayoutRect(clientLeft(), clientTop(), clientWidth(), clientHeight()); } |
240 | |
241 | // scrollWidth/scrollHeight will be the same as clientWidth/clientHeight unless the |
242 | // object has overflow:hidden/scroll/auto specified and also has overflow. |
243 | // scrollLeft/Top return the current scroll position. These methods are virtual so that objects like |
244 | // textareas can scroll shadow content (but pretend that they are the objects that are |
245 | // scrolling). |
246 | virtual int scrollLeft() const; |
247 | virtual int scrollTop() const; |
248 | virtual int scrollWidth() const; |
249 | virtual int scrollHeight() const; |
250 | virtual void setScrollLeft(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); |
251 | virtual void setScrollTop(int, ScrollType, ScrollClamping = ScrollClamping::Clamped); |
252 | |
253 | LayoutUnit marginTop() const override { return m_marginBox.top(); } |
254 | LayoutUnit marginBottom() const override { return m_marginBox.bottom(); } |
255 | LayoutUnit marginLeft() const override { return m_marginBox.left(); } |
256 | LayoutUnit marginRight() const override { return m_marginBox.right(); } |
257 | void setMarginTop(LayoutUnit margin) { m_marginBox.setTop(margin); } |
258 | void setMarginBottom(LayoutUnit margin) { m_marginBox.setBottom(margin); } |
259 | void setMarginLeft(LayoutUnit margin) { m_marginBox.setLeft(margin); } |
260 | void setMarginRight(LayoutUnit margin) { m_marginBox.setRight(margin); } |
261 | |
262 | LayoutUnit marginLogicalLeft() const { return m_marginBox.start(style().writingMode()); } |
263 | LayoutUnit marginLogicalRight() const { return m_marginBox.end(style().writingMode()); } |
264 | |
265 | LayoutUnit marginBefore(const RenderStyle* overrideStyle = nullptr) const final { return m_marginBox.before((overrideStyle ? overrideStyle : &style())->writingMode()); } |
266 | LayoutUnit marginAfter(const RenderStyle* overrideStyle = nullptr) const final { return m_marginBox.after((overrideStyle ? overrideStyle : &style())->writingMode()); } |
267 | LayoutUnit marginStart(const RenderStyle* overrideStyle = nullptr) const final |
268 | { |
269 | const RenderStyle* styleToUse = overrideStyle ? overrideStyle : &style(); |
270 | return m_marginBox.start(styleToUse->writingMode(), styleToUse->direction()); |
271 | } |
272 | LayoutUnit marginEnd(const RenderStyle* overrideStyle = nullptr) const final |
273 | { |
274 | const RenderStyle* styleToUse = overrideStyle ? overrideStyle : &style(); |
275 | return m_marginBox.end(styleToUse->writingMode(), styleToUse->direction()); |
276 | } |
277 | void setMarginBefore(LayoutUnit value, const RenderStyle* overrideStyle = nullptr) { m_marginBox.setBefore(value, (overrideStyle ? overrideStyle : &style())->writingMode()); } |
278 | void setMarginAfter(LayoutUnit value, const RenderStyle* overrideStyle = nullptr) { m_marginBox.setAfter(value, (overrideStyle ? overrideStyle : &style())->writingMode()); } |
279 | void setMarginStart(LayoutUnit value, const RenderStyle* overrideStyle = nullptr) |
280 | { |
281 | const RenderStyle* styleToUse = overrideStyle ? overrideStyle : &style(); |
282 | m_marginBox.setStart(value, styleToUse->writingMode(), styleToUse->direction()); |
283 | } |
284 | void setMarginEnd(LayoutUnit value, const RenderStyle* overrideStyle = nullptr) |
285 | { |
286 | const RenderStyle* styleToUse = overrideStyle ? overrideStyle : &style(); |
287 | m_marginBox.setEnd(value, styleToUse->writingMode(), styleToUse->direction()); |
288 | } |
289 | |
290 | virtual bool isSelfCollapsingBlock() const { return false; } |
291 | virtual LayoutUnit collapsedMarginBefore() const { return marginBefore(); } |
292 | virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); } |
293 | |
294 | void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const override; |
295 | void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override; |
296 | |
297 | int reflectionOffset() const; |
298 | // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection. |
299 | LayoutRect reflectedRect(const LayoutRect&) const; |
300 | |
301 | void layout() override; |
302 | bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override; |
303 | |
304 | LayoutUnit minPreferredLogicalWidth() const override; |
305 | LayoutUnit maxPreferredLogicalWidth() const override; |
306 | |
307 | // FIXME: We should rename these back to overrideLogicalHeight/Width and have them store |
308 | // the border-box height/width like the regular height/width accessors on RenderBox. |
309 | // Right now, these are different than contentHeight/contentWidth because they still |
310 | // include the scrollbar height/width. |
311 | LayoutUnit overrideContentLogicalWidth() const; |
312 | LayoutUnit overrideContentLogicalHeight() const; |
313 | bool hasOverrideContentLogicalHeight() const; |
314 | bool hasOverrideContentLogicalWidth() const; |
315 | void setOverrideContentLogicalHeight(LayoutUnit); |
316 | void setOverrideContentLogicalWidth(LayoutUnit); |
317 | void clearOverrideContentSize(); |
318 | void clearOverrideContentLogicalHeight(); |
319 | void clearOverrideContentLogicalWidth(); |
320 | |
321 | Optional<LayoutUnit> overrideContainingBlockContentWidth() const override; |
322 | Optional<LayoutUnit> overrideContainingBlockContentHeight() const override; |
323 | bool hasOverrideContainingBlockContentWidth() const override; |
324 | bool hasOverrideContainingBlockContentHeight() const override; |
325 | Optional<LayoutUnit> overrideContainingBlockContentLogicalWidth() const; |
326 | Optional<LayoutUnit> overrideContainingBlockContentLogicalHeight() const; |
327 | bool hasOverrideContainingBlockContentLogicalWidth() const; |
328 | bool hasOverrideContainingBlockContentLogicalHeight() const; |
329 | void setOverrideContainingBlockContentLogicalWidth(Optional<LayoutUnit>); |
330 | void setOverrideContainingBlockContentLogicalHeight(Optional<LayoutUnit>); |
331 | void clearOverrideContainingBlockContentSize(); |
332 | void clearOverrideContainingBlockContentLogicalHeight(); |
333 | |
334 | LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = nullptr) const override; |
335 | |
336 | LayoutUnit adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const; |
337 | LayoutUnit adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width) const; |
338 | |
339 | // Overridden by fieldsets to subtract out the intrinsic border. |
340 | virtual LayoutUnit adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height) const; |
341 | virtual LayoutUnit adjustContentBoxLogicalHeightForBoxSizing(Optional<LayoutUnit> height) const; |
342 | |
343 | struct ComputedMarginValues { |
344 | LayoutUnit m_before; |
345 | LayoutUnit m_after; |
346 | LayoutUnit m_start; |
347 | LayoutUnit m_end; |
348 | }; |
349 | struct LogicalExtentComputedValues { |
350 | LayoutUnit m_extent; |
351 | LayoutUnit m_position; |
352 | ComputedMarginValues m_margins; |
353 | }; |
354 | // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end |
355 | // of the containing block. |
356 | void computeInlineDirectionMargins(const RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const; |
357 | |
358 | // Used to resolve margins in the containing block's block-flow direction. |
359 | void computeBlockDirectionMargins(const RenderBlock& containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const; |
360 | void computeAndSetBlockDirectionMargins(const RenderBlock& containingBlock); |
361 | |
362 | enum RenderBoxFragmentInfoFlags { CacheRenderBoxFragmentInfo, DoNotCacheRenderBoxFragmentInfo }; |
363 | LayoutRect borderBoxRectInFragment(RenderFragmentContainer*, RenderBoxFragmentInfoFlags = CacheRenderBoxFragmentInfo) const; |
364 | LayoutRect clientBoxRectInFragment(RenderFragmentContainer*) const; |
365 | RenderFragmentContainer* clampToStartAndEndFragments(RenderFragmentContainer*) const; |
366 | bool hasFragmentRangeInFragmentedFlow() const; |
367 | virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const; |
368 | |
369 | void positionLineBox(InlineElementBox&); |
370 | |
371 | virtual std::unique_ptr<InlineElementBox> createInlineBox(); |
372 | void dirtyLineBoxes(bool fullLayout); |
373 | |
374 | // For inline replaced elements, this function returns the inline box that owns us. Enables |
375 | // the replaced RenderObject to quickly determine what line it is contained on and to easily |
376 | // iterate over structures on the line. |
377 | InlineElementBox* inlineBoxWrapper() const { return m_inlineBoxWrapper; } |
378 | void setInlineBoxWrapper(InlineElementBox*); |
379 | void deleteLineBoxWrapper(); |
380 | |
381 | LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; |
382 | Optional<LayoutRect> computeVisibleRectInContainer(const LayoutRect&, const RenderLayerModelObject* container, VisibleRectContext) const |
383 | override; |
384 | void repaintDuringLayoutIfMoved(const LayoutRect&); |
385 | virtual void repaintOverhangingFloats(bool paintAllDescendants); |
386 | |
387 | LayoutUnit containingBlockLogicalWidthForContent() const override; |
388 | LayoutUnit containingBlockLogicalHeightForContent(AvailableLogicalHeightType) const; |
389 | LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject& containingBlock, RenderFragmentContainer* = nullptr, bool checkForPerpendicularWritingMode = true) const; |
390 | LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject& containingBlock, bool checkForPerpendicularWritingMode = true) const; |
391 | LayoutUnit containingBlockLogicalWidthForContentInFragment(RenderFragmentContainer*) const; |
392 | LayoutUnit containingBlockAvailableLineWidthInFragment(RenderFragmentContainer*) const; |
393 | LayoutUnit perpendicularContainingBlockLogicalHeight() const; |
394 | |
395 | virtual void updateLogicalWidth(); |
396 | virtual void updateLogicalHeight(); |
397 | virtual LogicalExtentComputedValues computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const; |
398 | |
399 | void cacheIntrinsicContentLogicalHeightForFlexItem(LayoutUnit) const; |
400 | |
401 | // This function will compute the logical border-box height, without laying |
402 | // out the box. This means that the result is only "correct" when the height |
403 | // is explicitly specified. This function exists so that intrinsic width |
404 | // calculations have a way to deal with children that have orthogonal writing modes. |
405 | // When there is no explicit height, this function assumes a content height of |
406 | // zero (and returns just border + padding). |
407 | LayoutUnit computeLogicalHeightWithoutLayout() const; |
408 | |
409 | RenderBoxFragmentInfo* renderBoxFragmentInfo(RenderFragmentContainer*, RenderBoxFragmentInfoFlags = CacheRenderBoxFragmentInfo) const; |
410 | void computeLogicalWidthInFragment(LogicalExtentComputedValues&, RenderFragmentContainer* = nullptr) const; |
411 | |
412 | bool stretchesToViewport() const |
413 | { |
414 | return document().inQuirksMode() && style().logicalHeight().isAuto() && !isFloatingOrOutOfFlowPositioned() && (isDocumentElementRenderer() || isBody()) && !isInline(); |
415 | } |
416 | |
417 | virtual LayoutSize intrinsicSize() const { return LayoutSize(); } |
418 | LayoutUnit intrinsicLogicalWidth() const { return style().isHorizontalWritingMode() ? intrinsicSize().width() : intrinsicSize().height(); } |
419 | LayoutUnit intrinsicLogicalHeight() const { return style().isHorizontalWritingMode() ? intrinsicSize().height() : intrinsicSize().width(); } |
420 | |
421 | // Whether or not the element shrinks to its intrinsic width (rather than filling the width |
422 | // of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this. |
423 | bool sizesLogicalWidthToFitContent(SizeType) const; |
424 | |
425 | bool hasStretchedLogicalWidth() const; |
426 | bool isStretchingColumnFlexItem() const; |
427 | bool columnFlexItemHasStretchAlignment() const; |
428 | |
429 | LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock& cb, RenderFragmentContainer*) const; |
430 | |
431 | LayoutUnit computeLogicalWidthInFragmentUsing(SizeType, Length logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock& containingBlock, RenderFragmentContainer*) const; |
432 | Optional<LayoutUnit> computeLogicalHeightUsing(SizeType, const Length& height, Optional<LayoutUnit> intrinsicContentHeight) const; |
433 | Optional<LayoutUnit> computeContentLogicalHeight(SizeType, const Length& height, Optional<LayoutUnit> intrinsicContentHeight) const; |
434 | Optional<LayoutUnit> computeContentAndScrollbarLogicalHeightUsing(SizeType, const Length& height, Optional<LayoutUnit> intrinsicContentHeight) const; |
435 | LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const; |
436 | LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred = ComputeActual) const; |
437 | LayoutUnit computeReplacedLogicalHeightUsing(SizeType, Length height) const; |
438 | LayoutUnit computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const; |
439 | |
440 | virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActual) const; |
441 | virtual LayoutUnit computeReplacedLogicalHeight(Optional<LayoutUnit> estimatedUsedWidth = WTF::nullopt) const; |
442 | |
443 | Optional<LayoutUnit> computePercentageLogicalHeight(const Length& height) const; |
444 | |
445 | virtual LayoutUnit availableLogicalWidth() const { return contentLogicalWidth(); } |
446 | virtual LayoutUnit availableLogicalHeight(AvailableLogicalHeightType) const; |
447 | LayoutUnit availableLogicalHeightUsing(const Length&, AvailableLogicalHeightType) const; |
448 | |
449 | // There are a few cases where we need to refer specifically to the available physical width and available physical height. |
450 | // Relative positioning is one of those cases, since left/top offsets are physical. |
451 | LayoutUnit availableWidth() const { return style().isHorizontalWritingMode() ? availableLogicalWidth() : availableLogicalHeight(IncludeMarginBorderPadding); } |
452 | LayoutUnit availableHeight() const { return style().isHorizontalWritingMode() ? availableLogicalHeight(IncludeMarginBorderPadding) : availableLogicalWidth(); } |
453 | |
454 | WEBCORE_EXPORT virtual int verticalScrollbarWidth() const; |
455 | WEBCORE_EXPORT int horizontalScrollbarHeight() const; |
456 | int intrinsicScrollbarLogicalWidth() const; |
457 | int scrollbarLogicalWidth() const { return style().isHorizontalWritingMode() ? verticalScrollbarWidth() : horizontalScrollbarHeight(); } |
458 | int scrollbarLogicalHeight() const { return style().isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); } |
459 | virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr, RenderBox* startBox = nullptr, const IntPoint& wheelEventAbsolutePoint = IntPoint()); |
460 | virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Element** stopElement = nullptr); |
461 | WEBCORE_EXPORT bool canBeScrolledAndHasScrollableArea() const; |
462 | virtual bool canBeProgramaticallyScrolled() const; |
463 | virtual void autoscroll(const IntPoint&); |
464 | bool canAutoscroll() const; |
465 | IntSize calculateAutoscrollDirection(const IntPoint& windowPoint) const; |
466 | static RenderBox* findAutoscrollable(RenderObject*); |
467 | virtual void stopAutoscroll() { } |
468 | virtual void panScroll(const IntPoint&); |
469 | |
470 | bool hasVerticalScrollbarWithAutoBehavior() const; |
471 | bool hasHorizontalScrollbarWithAutoBehavior() const; |
472 | |
473 | bool canUseOverlayScrollbars() const; |
474 | |
475 | bool scrollsOverflow() const { return scrollsOverflowX() || scrollsOverflowY(); } |
476 | bool scrollsOverflowX() const { return hasOverflowClip() && (style().overflowX() == Overflow::Scroll || style().overflowX() == Overflow::Auto); } |
477 | bool scrollsOverflowY() const { return hasOverflowClip() && (style().overflowY() == Overflow::Scroll || style().overflowY() == Overflow::Auto); } |
478 | |
479 | bool hasHorizontalOverflow() const { return scrollWidth() != roundToInt(paddingBoxWidth()); } |
480 | bool hasVerticalOverflow() const { return scrollHeight() != roundToInt(paddingBoxHeight()); } |
481 | |
482 | bool hasScrollableOverflowX() const { return scrollsOverflowX() && hasHorizontalOverflow(); } |
483 | bool hasScrollableOverflowY() const { return scrollsOverflowY() && hasVerticalOverflow(); } |
484 | |
485 | bool usesCompositedScrolling() const; |
486 | |
487 | bool percentageLogicalHeightIsResolvable() const; |
488 | bool hasUnsplittableScrollingOverflow() const; |
489 | bool () const; |
490 | |
491 | bool shouldTreatChildAsReplacedInTableCells() const; |
492 | |
493 | LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* = nullptr) override; |
494 | |
495 | virtual LayoutRect overflowClipRect(const LayoutPoint& location, RenderFragmentContainer* = nullptr, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, PaintPhase = PaintPhase::BlockBackground); |
496 | virtual LayoutRect overflowClipRectForChildLayers(const LayoutPoint& location, RenderFragmentContainer* fragment, OverlayScrollbarSizeRelevancy relevancy) { return overflowClipRect(location, fragment, relevancy); } |
497 | LayoutRect clipRect(const LayoutPoint& location, RenderFragmentContainer*); |
498 | virtual bool hasControlClip() const { return false; } |
499 | virtual LayoutRect controlClipRect(const LayoutPoint&) const { return LayoutRect(); } |
500 | bool pushContentsClip(PaintInfo&, const LayoutPoint& accumulatedOffset); |
501 | void popContentsClip(PaintInfo&, PaintPhase originalPhase, const LayoutPoint& accumulatedOffset); |
502 | |
503 | virtual void paintObject(PaintInfo&, const LayoutPoint&) { ASSERT_NOT_REACHED(); } |
504 | virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&); |
505 | virtual void paintMask(PaintInfo&, const LayoutPoint&); |
506 | virtual void paintClippingMask(PaintInfo&, const LayoutPoint&); |
507 | void imageChanged(WrappedImagePtr, const IntRect* = nullptr) override; |
508 | |
509 | // Called when a positioned object moves but doesn't necessarily change size. A simplified layout is attempted |
510 | // that just updates the object's position. If the size does change, the object remains dirty. |
511 | bool tryLayoutDoingPositionedMovementOnly() |
512 | { |
513 | LayoutUnit oldWidth = width(); |
514 | updateLogicalWidth(); |
515 | // If we shrink to fit our width may have changed, so we still need full layout. |
516 | if (oldWidth != width()) |
517 | return false; |
518 | updateLogicalHeight(); |
519 | return true; |
520 | } |
521 | |
522 | LayoutRect maskClipRect(const LayoutPoint& paintOffset); |
523 | |
524 | VisiblePosition positionForPoint(const LayoutPoint&, const RenderFragmentContainer*) override; |
525 | |
526 | void removeFloatingOrPositionedChildFromBlockLists(); |
527 | |
528 | RenderLayer* enclosingFloatPaintingLayer() const; |
529 | |
530 | const RenderBlock& enclosingScrollportBox() const; |
531 | |
532 | virtual Optional<int> firstLineBaseline() const { return Optional<int>(); } |
533 | virtual Optional<int> inlineBlockBaseline(LineDirectionMode) const { return Optional<int>(); } // Returns empty if we should skip this box when computing the baseline of an inline-block. |
534 | |
535 | bool shrinkToAvoidFloats() const; |
536 | virtual bool avoidsFloats() const; |
537 | |
538 | virtual void () { } |
539 | |
540 | bool isWritingModeRoot() const { return !parent() || parent()->style().writingMode() != style().writingMode(); } |
541 | |
542 | bool isDeprecatedFlexItem() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isDeprecatedFlexibleBox(); } |
543 | bool isFlexItemIncludingDeprecated() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isFlexibleBoxIncludingDeprecated(); } |
544 | |
545 | LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override; |
546 | int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override; |
547 | |
548 | LayoutUnit offsetLeft() const override; |
549 | LayoutUnit offsetTop() const override; |
550 | |
551 | LayoutPoint flipForWritingModeForChild(const RenderBox* child, const LayoutPoint&) const; |
552 | LayoutUnit flipForWritingMode(LayoutUnit position) const; // The offset is in the block direction (y for horizontal writing modes, x for vertical writing modes). |
553 | LayoutPoint flipForWritingMode(const LayoutPoint&) const; |
554 | LayoutSize flipForWritingMode(const LayoutSize&) const; |
555 | void flipForWritingMode(LayoutRect&) const; |
556 | FloatPoint flipForWritingMode(const FloatPoint&) const; |
557 | void flipForWritingMode(FloatRect&) const; |
558 | // These represent your location relative to your container as a physical offset. |
559 | // In layout related methods you almost always want the logical location (e.g. x() and y()). |
560 | LayoutPoint topLeftLocation() const; |
561 | LayoutSize topLeftLocationOffset() const; |
562 | void applyTopLeftLocationOffset(LayoutPoint& point) const |
563 | { |
564 | // This is inlined for speed, since it is used by updateLayerPosition() during scrolling. |
565 | if (!document().view()->hasFlippedBlockRenderers()) |
566 | point.move(m_frameRect.x(), m_frameRect.y()); |
567 | else |
568 | applyTopLeftLocationOffsetWithFlipping(point); |
569 | } |
570 | |
571 | LayoutRect logicalVisualOverflowRectForPropagation(const RenderStyle*) const; |
572 | LayoutRect visualOverflowRectForPropagation(const RenderStyle*) const; |
573 | LayoutRect logicalLayoutOverflowRectForPropagation(const RenderStyle*) const; |
574 | LayoutRect layoutOverflowRectForPropagation(const RenderStyle*) const; |
575 | |
576 | bool hasRenderOverflow() const { return m_overflow; } |
577 | bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); } |
578 | |
579 | virtual bool needsPreferredWidthsRecalculation() const; |
580 | virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */) const { } |
581 | |
582 | ScrollPosition scrollPosition() const; |
583 | LayoutSize cachedSizeForOverflowClip() const; |
584 | |
585 | // Returns false if the rect has no intersection with the applied clip rect. When the context specifies edge-inclusive |
586 | // intersection, this return value allows distinguishing between no intersection and zero-area intersection. |
587 | bool applyCachedClipAndScrollPosition(LayoutRect&, const RenderLayerModelObject* container, VisibleRectContext) const; |
588 | |
589 | virtual bool hasRelativeDimensions() const; |
590 | virtual bool hasRelativeLogicalHeight() const; |
591 | virtual bool hasRelativeLogicalWidth() const; |
592 | |
593 | bool hasHorizontalLayoutOverflow() const |
594 | { |
595 | if (!m_overflow) |
596 | return false; |
597 | |
598 | LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect(); |
599 | flipForWritingMode(layoutOverflowRect); |
600 | return layoutOverflowRect.x() < x() || layoutOverflowRect.maxX() > x() + logicalWidth(); |
601 | } |
602 | |
603 | bool hasVerticalLayoutOverflow() const |
604 | { |
605 | if (!m_overflow) |
606 | return false; |
607 | |
608 | LayoutRect layoutOverflowRect = m_overflow->layoutOverflowRect(); |
609 | flipForWritingMode(layoutOverflowRect); |
610 | return layoutOverflowRect.y() < y() || layoutOverflowRect.maxY() > y() + logicalHeight(); |
611 | } |
612 | |
613 | virtual RenderPtr<RenderBox> createAnonymousBoxWithSameTypeAs(const RenderBox&) const |
614 | { |
615 | ASSERT_NOT_REACHED(); |
616 | return nullptr; |
617 | } |
618 | |
619 | ShapeOutsideInfo* shapeOutsideInfo() const |
620 | { |
621 | return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; |
622 | } |
623 | |
624 | void markShapeOutsideDependentsForLayout() |
625 | { |
626 | if (isFloating()) |
627 | removeFloatingOrPositionedChildFromBlockLists(); |
628 | } |
629 | |
630 | // True if this box can have a range in an outside fragmentation context. |
631 | bool canHaveOutsideFragmentRange() const { return !isInFlowRenderFragmentedFlow(); } |
632 | virtual bool needsLayoutAfterFragmentRangeChange() const { return false; } |
633 | |
634 | const RenderBox* findEnclosingScrollableContainer() const; |
635 | |
636 | bool isGridItem() const { return parent() && parent()->isRenderGrid() && !isExcludedFromNormalLayout(); } |
637 | bool isFlexItem() const { return parent() && parent()->isFlexibleBox() && !isExcludedFromNormalLayout(); } |
638 | |
639 | virtual void adjustBorderBoxRectForPainting(LayoutRect&) { }; |
640 | |
641 | protected: |
642 | RenderBox(Element&, RenderStyle&&, BaseTypeFlags); |
643 | RenderBox(Document&, RenderStyle&&, BaseTypeFlags); |
644 | |
645 | void styleWillChange(StyleDifference, const RenderStyle& newStyle) override; |
646 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
647 | void updateFromStyle() override; |
648 | |
649 | void willBeDestroyed() override; |
650 | |
651 | bool createsNewFormattingContext() const; |
652 | |
653 | virtual ItemPosition selfAlignmentNormalBehavior(const RenderBox* = nullptr) const { return ItemPosition::Stretch; } |
654 | |
655 | // Returns false if it could not cheaply compute the extent (e.g. fixed background), in which case the returned rect may be incorrect. |
656 | bool getBackgroundPaintedExtent(const LayoutPoint& paintOffset, LayoutRect&) const; |
657 | virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const; |
658 | bool computeBackgroundIsKnownToBeObscured(const LayoutPoint& paintOffset) override; |
659 | |
660 | void paintBackground(const PaintInfo&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone); |
661 | |
662 | void paintFillLayer(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, CompositeOperator, RenderElement* backgroundObject, BaseBackgroundColorUsage = BaseBackgroundColorUse); |
663 | void paintFillLayers(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance = BackgroundBleedNone, CompositeOperator = CompositeSourceOver, RenderElement* backgroundObject = nullptr); |
664 | |
665 | void paintMaskImages(const PaintInfo&, const LayoutRect&); |
666 | |
667 | BackgroundBleedAvoidance determineBackgroundBleedAvoidance(GraphicsContext&) const; |
668 | bool backgroundHasOpaqueTopLayer() const; |
669 | |
670 | void computePositionedLogicalWidth(LogicalExtentComputedValues&, RenderFragmentContainer* = nullptr) const; |
671 | |
672 | LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const; |
673 | virtual Optional<LayoutUnit> computeIntrinsicLogicalContentHeightUsing(Length logicalHeightLength, Optional<LayoutUnit> intrinsicContentHeight, LayoutUnit borderAndPadding) const; |
674 | |
675 | virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); } |
676 | |
677 | void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override; |
678 | const RenderObject* pushMappingToContainer(const RenderLayerModelObject*, RenderGeometryMap&) const override; |
679 | void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const override; |
680 | |
681 | void paintRootBoxFillLayers(const PaintInfo&); |
682 | |
683 | bool skipContainingBlockForPercentHeightCalculation(const RenderBox& containingBlock, bool isPerpendicularWritingMode) const; |
684 | |
685 | private: |
686 | bool replacedMinMaxLogicalHeightComputesAsNone(SizeType) const; |
687 | |
688 | void updateShapeOutsideInfoAfterStyleChange(const RenderStyle&, const RenderStyle* oldStyle); |
689 | |
690 | void updateGridPositionAfterStyleChange(const RenderStyle&, const RenderStyle* oldStyle); |
691 | |
692 | bool scrollLayer(ScrollDirection, ScrollGranularity, float multiplier, Element** stopElement); |
693 | |
694 | bool fixedElementLaysOutRelativeToFrame(const FrameView&) const; |
695 | |
696 | bool includeVerticalScrollbarSize() const; |
697 | bool includeHorizontalScrollbarSize() const; |
698 | |
699 | bool isScrollableOrRubberbandableBox() const override; |
700 | |
701 | // Returns true if we did a full repaint. |
702 | bool repaintLayerRectsForImage(WrappedImagePtr, const FillLayer& layers, bool drawingBackground); |
703 | |
704 | void computePositionedLogicalHeight(LogicalExtentComputedValues&) const; |
705 | void computePositionedLogicalWidthUsing(SizeType, Length logicalWidth, const RenderBoxModelObject& containerBlock, TextDirection containerDirection, |
706 | LayoutUnit containerLogicalWidth, LayoutUnit bordersPlusPadding, |
707 | Length logicalLeft, Length logicalRight, Length marginLogicalLeft, Length marginLogicalRight, |
708 | LogicalExtentComputedValues&) const; |
709 | void computePositionedLogicalHeightUsing(SizeType, Length logicalHeightLength, const RenderBoxModelObject& containerBlock, |
710 | LayoutUnit containerLogicalHeight, LayoutUnit bordersPlusPadding, LayoutUnit logicalHeight, |
711 | Length logicalTop, Length logicalBottom, Length marginLogicalTop, Length marginLogicalBottom, |
712 | LogicalExtentComputedValues&) const; |
713 | |
714 | void computePositionedLogicalHeightReplaced(LogicalExtentComputedValues&) const; |
715 | void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) const; |
716 | |
717 | LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth) const; |
718 | LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const; |
719 | |
720 | virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const; |
721 | |
722 | // This function calculates the minimum and maximum preferred widths for an object. |
723 | // These values are used in shrink-to-fit layout systems. |
724 | // These include tables, positioned objects, floats and flexible boxes. |
725 | virtual void computePreferredLogicalWidths() { setPreferredLogicalWidthsDirty(false); } |
726 | |
727 | LayoutRect frameRectForStickyPositioning() const final { return frameRect(); } |
728 | |
729 | LayoutRect computeVisibleRectUsingPaintOffset(const LayoutRect&) const; |
730 | |
731 | void applyTopLeftLocationOffsetWithFlipping(LayoutPoint&) const; |
732 | |
733 | private: |
734 | // The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent). |
735 | LayoutRect m_frameRect; |
736 | |
737 | protected: |
738 | LayoutBoxExtent m_marginBox; |
739 | |
740 | // The preferred logical width of the element if it were to break its lines at every possible opportunity. |
741 | LayoutUnit m_minPreferredLogicalWidth; |
742 | |
743 | // The preferred logical width of the element if it never breaks any lines at all. |
744 | LayoutUnit m_maxPreferredLogicalWidth; |
745 | |
746 | // For inline replaced elements, the inline box that owns us. |
747 | InlineElementBox* m_inlineBoxWrapper { nullptr }; |
748 | |
749 | // Our overflow information. |
750 | RefPtr<RenderOverflow> m_overflow; |
751 | |
752 | private: |
753 | // Used to store state between styleWillChange and styleDidChange |
754 | static bool s_hadOverflowClip; |
755 | }; |
756 | |
757 | inline RenderBox* RenderBox::parentBox() const |
758 | { |
759 | if (is<RenderBox>(parent())) |
760 | return downcast<RenderBox>(parent()); |
761 | |
762 | ASSERT(!parent()); |
763 | return nullptr; |
764 | } |
765 | |
766 | inline RenderBox* RenderBox::firstChildBox() const |
767 | { |
768 | if (is<RenderBox>(firstChild())) |
769 | return downcast<RenderBox>(firstChild()); |
770 | |
771 | ASSERT(!firstChild()); |
772 | return nullptr; |
773 | } |
774 | |
775 | inline RenderBox* RenderBox::lastChildBox() const |
776 | { |
777 | if (is<RenderBox>(lastChild())) |
778 | return downcast<RenderBox>(lastChild()); |
779 | |
780 | ASSERT(!lastChild()); |
781 | return nullptr; |
782 | } |
783 | |
784 | inline RenderBox* RenderBox::previousSiblingBox() const |
785 | { |
786 | if (is<RenderBox>(previousSibling())) |
787 | return downcast<RenderBox>(previousSibling()); |
788 | |
789 | ASSERT(!previousSibling()); |
790 | return nullptr; |
791 | } |
792 | |
793 | inline RenderBox* RenderBox::nextSiblingBox() const |
794 | { |
795 | if (is<RenderBox>(nextSibling())) |
796 | return downcast<RenderBox>(nextSibling()); |
797 | |
798 | ASSERT(!nextSibling()); |
799 | return nullptr; |
800 | } |
801 | |
802 | inline void RenderBox::setInlineBoxWrapper(InlineElementBox* boxWrapper) |
803 | { |
804 | if (boxWrapper) { |
805 | ASSERT(!m_inlineBoxWrapper); |
806 | // m_inlineBoxWrapper should already be 0. Deleting it is a safeguard against security issues. |
807 | // Otherwise, there will two line box wrappers keeping the reference to this renderer, and |
808 | // only one will be notified when the renderer is getting destroyed. The second line box wrapper |
809 | // will keep a stale reference. |
810 | if (UNLIKELY(m_inlineBoxWrapper != nullptr)) |
811 | deleteLineBoxWrapper(); |
812 | } |
813 | |
814 | m_inlineBoxWrapper = boxWrapper; |
815 | } |
816 | |
817 | } // namespace WebCore |
818 | |
819 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderBox, isBox()) |
820 | |