Skip to content

Commit ebf4705

Browse files
committed
[cleanup] Rename RenderBox::frameRect()/setFrameRect() to borderBoxRectInContainer()/setBorderBoxRectInContainer()
https://bugs.webkit.org/show_bug.cgi?id=318048 <rdar://problem/181125416> Reviewed by Antti Koivisto. m_frameRect and its frameRect()/setFrameRect() accessors hold the border box positioned in the container's coordinate space, but "frame" was vague and collided with Frame/LocalFrame. Rename them to m_borderBoxRectInContainer / borderBoxRectInContainer() / setBorderBoxRectInContainer(), naming the thing for what it is and pairing directly with the existing borderBoxRect() (the same rect in the renderer's own coordinates, { 0, 0, size }) -- the only difference is the coordinate space. "container" matches RenderBox.h's own description of the location ("relative to your container") and the mapLocalToContainer/offsetFromContainer vocabulary. Also fixes the stale "frame rect" comments left behind and renames the flex repaint-snapshot helpers (ChildFrameRects/FlexItemFrameRects and their append* functions) to ...BorderBoxRects to match. No behavior change. * Source/WebCore/accessibility/AccessibilityRenderObject.cpp: (AccessibilityRenderObject::localRect): * Source/WebCore/inspector/InspectorOverlay.cpp: (InspectorOverlay::buildFlexOverlay): * Source/WebCore/layout/Verification.cpp: (outputMismatchingBlockBoxInformationIfNeeded): * Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp: (LineLayout::updateRenderTreePositions): * Source/WebCore/page/LocalFrameView.cpp: (LocalFrameView::visibleRectOfChild): * Source/WebCore/rendering/RenderBlockFlow.cpp: (RenderBlockFlow::layoutBlockChild): (RenderBlockFlow::positionNewFloats): * Source/WebCore/rendering/RenderBox.cpp: (RenderBox::repaintDuringLayoutIfMoved): * Source/WebCore/rendering/RenderBox.h: * Source/WebCore/rendering/RenderBoxInlines.h: (RenderBox::logicalSize): * Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp: (appendChildBorderBoxRects): (repaintChildrenDuringLayoutIfMoved): (RenderDeprecatedFlexibleBox::layoutBlock): * Source/WebCore/rendering/RenderElement.cpp: (RenderElement::getTrailingCorner): * Source/WebCore/rendering/RenderFlexibleBox.cpp: (RenderFlexibleBox::appendFlexItemBorderBoxRects): (RenderFlexibleBox::repaintFlexItemsDuringLayoutIfMoved): (RenderFlexibleBox::layoutBlock): * Source/WebCore/rendering/RenderFlexibleBox.h: * Source/WebCore/rendering/RenderGrid.cpp: (RenderGrid::layoutGridItems): * Source/WebCore/rendering/RenderLayer.cpp: (computeLayerPositionAndIntegralSize): * Source/WebCore/rendering/RenderLayerBacking.cpp: (RenderLayerBacking::RenderLayerBacking): * Source/WebCore/rendering/RenderLayerScrollableArea.cpp: (RenderLayerScrollableArea::positionOverflowControls): * Source/WebCore/rendering/RenderLayoutState.h: * Source/WebCore/rendering/RenderMeter.cpp: (RenderMeter::updateLogicalWidth): (RenderMeter::computeLogicalHeight): * Source/WebCore/rendering/RenderMultiColumnSet.cpp: (RenderMultiColumnSet::collectLayerFragments): * Source/WebCore/rendering/RenderObject.cpp: (RenderObject::outputRenderObject): * Source/WebCore/rendering/RenderProgress.cpp: (RenderProgress::updateFromElement): * Source/WebCore/rendering/RenderReplica.cpp: (RenderReplica::layout): * Source/WebCore/rendering/RenderScrollbar.cpp: (RenderScrollbar::buttonRect): * Source/WebCore/rendering/RenderTable.cpp: (RenderTable::layoutCaption): * Source/WebCore/rendering/RenderTableCell.cpp: (backgroundRectForRow): * Source/WebCore/rendering/RenderTableSection.cpp: (RenderTableSection::layoutRows): (RenderTableSection::paintObject): * Source/WebCore/rendering/RenderTextControlSingleLine.cpp: (RenderTextControlSingleLine::controlClipRect): * Source/WebCore/rendering/RenderTreeAsText.cpp: (RenderTreeAsText::writeRenderObject): * Source/WebCore/rendering/mathml/RenderMathMLMath.cpp: (RenderMathMLMath::centerChildren): * Source/WebCore/rendering/mathml/RenderMathMLRow.cpp: (RenderMathMLRow::layoutRowItems): * Source/WebCore/rendering/svg/RenderSVGText.cpp: (RenderSVGText::updatePositionAndOverflow): * Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp: (writePositionAndStyle): Canonical link: https://commits.webkit.org/316286@main
1 parent f9722ad commit ebf4705

33 files changed

Lines changed: 88 additions & 85 deletions

Source/WebCore/accessibility/AccessibilityRenderObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3220,7 +3220,7 @@ FloatRect AccessibilityRenderObject::localRect() const
32203220
{
32213221
CheckedPtr renderer = this->renderer();
32223222
if (CheckedPtr box = dynamicDowncast<RenderBox>(renderer.get()))
3223-
return box ? convertFrameToSpace(box->frameRect(), AccessibilityConversionSpace::Page) : FloatRect();
3223+
return box ? convertFrameToSpace(box->borderBoxRectInContainer(), AccessibilityConversionSpace::Page) : FloatRect();
32243224

32253225
CheckedPtr renderText = dynamicDowncast<RenderText>(renderer.get());
32263226
return renderText ? renderText->linesBoundingBox() : FloatRect();

Source/WebCore/inspector/InspectorOverlay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ std::optional<InspectorOverlay::Highlight::FlexHighlightOverlay> InspectorOverla
22712271
for (CheckedPtr renderChild : renderChildrenInFlexOrder) {
22722272
// Build bounds for each child and collect children on the same logical line.
22732273
{
2274-
auto childRect = renderChild->frameRect();
2274+
auto childRect = renderChild->borderBoxRectInContainer();
22752275
renderFlex->flipForWritingMode(childRect);
22762276
childRect.expand(renderChild->marginBox());
22772277

Source/WebCore/layout/Verification.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con
219219
};
220220

221221
// rendering does not offset for relative positioned boxes.
222-
auto frameRect = renderer.frameRect();
222+
auto frameRect = renderer.borderBoxRectInContainer();
223223
if (renderer.isInFlowPositioned())
224224
frameRect.move(renderer.offsetForInFlowPosition());
225225

@@ -245,7 +245,7 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con
245245
return false;
246246
}
247247
if (!areEssentiallyEqual(frameRect, BoxGeometry::borderBoxRect(boxGeometry))) {
248-
outputRect("frameBox"_s, renderer.frameRect(), BoxGeometry::borderBoxRect(boxGeometry));
248+
outputRect("frameBox"_s, renderer.borderBoxRectInContainer(), BoxGeometry::borderBoxRect(boxGeometry));
249249
return true;
250250
}
251251

Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ void LineLayout::updateRenderTreePositions(const Vector<LineAdjustment>& lineAdj
634634
floatingObject.setMarginOffset({ borderBoxVisualRect.x() - marginBoxVisualRect.x(), borderBoxVisualRect.y() - marginBoxVisualRect.y() });
635635
floatingObject.setIsPlaced(true);
636636

637-
auto oldRect = renderer->frameRect();
637+
auto oldRect = renderer->borderBoxRectInContainer();
638638
renderer->setLocation(borderBoxVisualRect.location());
639639

640640
if (renderer->checkForRepaintDuringLayout()) {

Source/WebCore/page/LocalFrameView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2130,7 +2130,7 @@ std::optional<LayoutRect> LocalFrameView::visibleRectOfChild(const Frame& child)
21302130
ASSERT(childOwnerRenderer->frame().frameID() == m_frame->frameID());
21312131

21322132
auto rects = childOwnerRenderer->computeVisibleRectsInContainer(
2133-
{ childOwnerRenderer->frameRect() },
2133+
{ childOwnerRenderer->borderBoxRectInContainer() },
21342134
&childOwnerRenderer->view(),
21352135
{
21362136
.hasPositionFixedDescendant = false,

Source/WebCore/rendering/RenderBlockFlow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ void RenderBlockFlow::layoutBlockChild(RenderBox& child, MarginInfo& marginInfo,
11821182
LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo, estimateWithoutPagination);
11831183

11841184
// Cache our old rect so that we can dirty the proper repaint rects if the child moves.
1185-
LayoutRect oldRect = child.frameRect();
1185+
LayoutRect oldRect = child.borderBoxRectInContainer();
11861186
LayoutUnit oldLogicalTop = logicalTopForChild(child);
11871187

11881188
#if ASSERT_ENABLED
@@ -2972,7 +2972,7 @@ bool RenderBlockFlow::positionNewFloats()
29722972
if (childBox.containingBlock() != this)
29732973
continue;
29742974

2975-
LayoutRect oldRect = childBox.frameRect();
2975+
LayoutRect oldRect = childBox.borderBoxRectInContainer();
29762976
auto childBoxUsedClear = Style::ComputedStyle::usedClear(childBox);
29772977
if (childBoxUsedClear == UsedClear::Left || childBoxUsedClear == UsedClear::Both)
29782978
logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::FloatLeft), logicalTop);

Source/WebCore/rendering/RenderBox.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ WTF_MAKE_TZONE_ALLOCATED_IMPL(RenderBox);
119119

120120
struct SameSizeAsRenderBox : public RenderBoxModelObject {
121121
virtual ~SameSizeAsRenderBox() = default;
122-
LayoutRect frameRect;
122+
LayoutRect borderBoxRectInContainer;
123123
LayoutBoxExtent marginBox;
124124
LayoutUnit preferredLogicalWidths[2];
125125
void* pointers[1];
@@ -2754,14 +2754,14 @@ auto RenderBox::computeVisibleRectsInContainer(const RepaintRects& rects, const
27542754

27552755
void RenderBox::repaintDuringLayoutIfMoved(const LayoutRect& oldRect)
27562756
{
2757-
if (oldRect.location() != m_frameRect.location()) {
2758-
LayoutRect newRect = m_frameRect;
2757+
if (oldRect.location() != m_borderBoxRectInContainer.location()) {
2758+
LayoutRect newRect = m_borderBoxRectInContainer;
27592759
// The child moved. Invalidate the object's old and new positions. We have to do this
27602760
// since the object may not have gotten a layout.
2761-
m_frameRect = oldRect;
2761+
m_borderBoxRectInContainer = oldRect;
27622762
repaint();
27632763
repaintOverhangingFloats(true);
2764-
m_frameRect = newRect;
2764+
m_borderBoxRectInContainer = newRect;
27652765
repaint();
27662766
repaintOverhangingFloats(true);
27672767
}

Source/WebCore/rendering/RenderBox.h

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,18 @@ class RenderBox : public RenderBoxModelObject {
6262
bool NODELETE requiresLayerWithScrollableArea() const;
6363
bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const override;
6464

65-
LayoutUnit x() const { return m_frameRect.x(); }
66-
LayoutUnit y() const { return m_frameRect.y(); }
67-
LayoutUnit borderBoxWidth() const { return m_frameRect.width(); }
68-
LayoutUnit borderBoxHeight() const { return m_frameRect.height(); }
65+
LayoutUnit x() const { return m_borderBoxRectInContainer.x(); }
66+
LayoutUnit y() const { return m_borderBoxRectInContainer.y(); }
6967

7068
// These represent your location relative to your container as a physical offset.
7169
// In layout related methods you almost always want the logical location (e.g. x() and y()).
7270
LayoutUnit top() const { return topLeftLocation().y(); }
7371
LayoutUnit left() const { return topLeftLocation().x(); }
7472

75-
template<typename T> void setX(T x) { m_frameRect.setX(x); }
76-
template<typename T> void setY(T y) { m_frameRect.setY(y); }
77-
template<typename T> void setBorderBoxWidth(T width) { m_frameRect.setWidth(width); }
78-
template<typename T> void setBorderBoxHeight(T height) { m_frameRect.setHeight(height); }
73+
template<typename T> void setX(T x) { m_borderBoxRectInContainer.setX(x); }
74+
template<typename T> void setY(T y) { m_borderBoxRectInContainer.setY(y); }
75+
template<typename T> void setBorderBoxWidth(T width) { m_borderBoxRectInContainer.setWidth(width); }
76+
template<typename T> void setBorderBoxHeight(T height) { m_borderBoxRectInContainer.setHeight(height); }
7977

8078
inline LayoutUnit logicalLeft() const;
8179
inline LayoutUnit logicalRight() const;
@@ -96,28 +94,22 @@ class RenderBox : public RenderBoxModelObject {
9694
inline void setLogicalHeight(LayoutUnit);
9795
inline void setLogicalSize(LayoutSize);
9896

99-
LayoutPoint location() const { return m_frameRect.location(); }
97+
LayoutPoint location() const { return m_borderBoxRectInContainer.location(); }
10098
LayoutSize locationOffset() const { return LayoutSize(x(), y()); }
101-
LayoutSize borderBoxSize() const { return m_frameRect.size(); }
10299
inline LayoutSize logicalSize() const;
103100

104-
void setLocation(const LayoutPoint& location) { m_frameRect.setLocation(location); }
101+
void setLocation(const LayoutPoint& location) { m_borderBoxRectInContainer.setLocation(location); }
105102

106-
void setBorderBoxSize(const LayoutSize& size) { m_frameRect.setSize(size); }
107-
void move(LayoutUnit dx, LayoutUnit dy) { m_frameRect.move(dx, dy); }
103+
void setBorderBoxSize(const LayoutSize& size) { m_borderBoxRectInContainer.setSize(size); }
104+
void move(LayoutUnit dx, LayoutUnit dy) { m_borderBoxRectInContainer.move(dx, dy); }
108105

109-
LayoutRect frameRect() const { return m_frameRect; }
110-
void setFrameRect(const LayoutRect& rect) { m_frameRect = rect; }
111-
112-
inline LayoutRect marginBoxRect() const;
113-
LayoutRect borderBoxRect() const { return LayoutRect(LayoutPoint(), borderBoxSize()); }
114-
LayoutRect borderBoundingBox() const final { return borderBoxRect(); }
106+
LayoutRect borderBoxRectInContainer() const { return m_borderBoxRectInContainer; }
107+
void setBorderBoxInContainer(const LayoutRect& rect) { m_borderBoxRectInContainer = rect; }
115108

116109
// Don't use this; it doesn't make sense in a future world with corner-shape. Use BorderShape instead.
117110
WEBCORE_EXPORT LayoutRoundedRectRadii borderRadii() const;
118111

119112
// The content area of the box (excludes padding - and intrinsic padding for table cells, etc... - and border).
120-
inline LayoutRect contentBoxRect() const;
121113
LayoutPoint contentBoxLocation() const;
122114
inline LayoutRect flippedContentBoxRect() const;
123115

@@ -196,6 +188,12 @@ class RenderBox : public RenderBoxModelObject {
196188

197189
void applyTransform(TransformationMatrix&, const Style::ComputedStyle&, const FloatRect& boundingBox, OptionSet<Style::TransformResolverOption>) const override;
198190

191+
// margin, border, padding and content box rects are relative to border box.
192+
inline LayoutRect marginBoxRect() const;
193+
LayoutRect borderBoxRect() const { return { { }, borderBoxSize() }; }
194+
LayoutRect paddingBoxRect() const;
195+
inline LayoutRect contentBoxRect() const;
196+
199197
inline LayoutSize contentBoxSize() const;
200198
inline LayoutUnit contentBoxWidth() const;
201199
inline LayoutUnit contentBoxHeight() const;
@@ -210,9 +208,14 @@ class RenderBox : public RenderBoxModelObject {
210208
inline LayoutUnit paddingBoxLogicalWidth() const;
211209
inline LayoutUnit paddingBoxLogicalHeight() const;
212210
inline LayoutUnit paddingBoxLogicalBottom() const;
213-
LayoutRect paddingBoxRect() const;
214211
inline LayoutRect paddingBoxRectIncludingScrollbar() const;
215212

213+
LayoutUnit borderBoxWidth() const { return m_borderBoxRectInContainer.width(); }
214+
LayoutUnit borderBoxHeight() const { return m_borderBoxRectInContainer.height(); }
215+
LayoutSize borderBoxSize() const { return m_borderBoxRectInContainer.size(); }
216+
217+
LayoutRect borderBoundingBox() const final { return borderBoxRect(); }
218+
216219
// IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
217220
// to return the remaining width on a given line (and the height of a single line).
218221
LayoutUnit offsetWidth() const override { return borderBoxWidth(); }
@@ -758,7 +761,7 @@ class RenderBox : public RenderBoxModelObject {
758761
// These include tables, positioned objects, floats and flexible boxes.
759762
virtual void computeIntrinsicLogicalWidthContributions();
760763

761-
LayoutRect frameRectForStickyPositioning() const override { return frameRect(); }
764+
LayoutRect frameRectForStickyPositioning() const override { return borderBoxRectInContainer(); }
762765

763766
RepaintRects computeVisibleRectsUsingPaintOffset(const RepaintRects&) const;
764767

@@ -768,8 +771,8 @@ class RenderBox : public RenderBoxModelObject {
768771
void removeShapeOutsideInfo();
769772

770773
private:
771-
// The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
772-
LayoutRect m_frameRect;
774+
// Relative to our container.
775+
LayoutRect m_borderBoxRectInContainer;
773776

774777
protected:
775778
LayoutBoxExtent m_marginBox;

Source/WebCore/rendering/RenderBoxInlines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ inline LayoutUnit RenderBox::logicalLeftVisualOverflow() const { return writingM
6262
inline LayoutUnit RenderBox::logicalRight() const { return logicalLeft() + logicalWidth(); }
6363
inline LayoutUnit RenderBox::logicalRightLayoutOverflow() const { return writingMode().isHorizontal() ? layoutOverflowRect().maxX() : layoutOverflowRect().maxY(); }
6464
inline LayoutUnit RenderBox::logicalRightVisualOverflow() const { return writingMode().isHorizontal() ? visualOverflowRect().maxX() : visualOverflowRect().maxY(); }
65-
inline LayoutSize RenderBox::logicalSize() const { return writingMode().isHorizontal() ? m_frameRect.size() : m_frameRect.size().transposedSize(); }
65+
inline LayoutSize RenderBox::logicalSize() const { return writingMode().isHorizontal() ? m_borderBoxRectInContainer.size() : m_borderBoxRectInContainer.size().transposedSize(); }
6666
inline LayoutUnit RenderBox::logicalTop() const { return writingMode().isHorizontal() ? y() : x(); }
6767
inline LayoutUnit RenderBox::logicalWidth() const { return writingMode().isHorizontal() ? borderBoxWidth() : borderBoxHeight(); }
6868
inline LayoutUnit RenderBox::paddingBoxHeight() const { return std::max(0_lu, borderBoxHeight() - borderTop() - borderBottom() - horizontalScrollbarHeight()); }

Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,15 @@ void RenderDeprecatedFlexibleBox::computeIntrinsicLogicalWidthContributions()
281281
}
282282

283283
// Use an inline capacity of 8, since flexbox containers usually have less than 8 children.
284-
typedef Vector<LayoutRect, 8> ChildFrameRects;
284+
typedef Vector<LayoutRect, 8> ChildBorderBoxRects;
285285
typedef Vector<LayoutSize, 8> ChildLayoutDeltas;
286286

287-
static void appendChildFrameRects(RenderDeprecatedFlexibleBox* box, ChildFrameRects& childFrameRects)
287+
static void appendChildBorderBoxRects(RenderDeprecatedFlexibleBox* box, ChildBorderBoxRects& childBorderBoxRects)
288288
{
289289
FlexBoxIterator iterator(box);
290290
for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
291291
if (!child->isOutOfFlowPositioned())
292-
childFrameRects.append(child->frameRect());
292+
childBorderBoxRects.append(child->borderBoxRectInContainer());
293293
}
294294
}
295295

@@ -302,7 +302,7 @@ static void appendChildLayoutDeltas(RenderDeprecatedFlexibleBox* box, ChildLayou
302302
}
303303
}
304304

305-
static void repaintChildrenDuringLayoutIfMoved(RenderDeprecatedFlexibleBox* box, const ChildFrameRects& oldChildRects)
305+
static void repaintChildrenDuringLayoutIfMoved(RenderDeprecatedFlexibleBox* box, const ChildBorderBoxRects& oldChildRects)
306306
{
307307
size_t childIndex = 0;
308308
FlexBoxIterator iterator(box);
@@ -383,8 +383,8 @@ void RenderDeprecatedFlexibleBox::layoutBlock(RelayoutChildren relayoutChildren,
383383
// It doesn't get included in the normal layout process but is instead skipped.
384384
layoutExcludedChildren(relayoutChildren);
385385

386-
ChildFrameRects oldChildRects;
387-
appendChildFrameRects(this, oldChildRects);
386+
ChildBorderBoxRects oldChildRects;
387+
appendChildBorderBoxRects(this, oldChildRects);
388388

389389
if (isHorizontal())
390390
layoutHorizontalBox(relayoutChildren);

0 commit comments

Comments
 (0)