Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions Source/WebCore/rendering/RenderBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,27 +558,12 @@ void RenderBlock::layoutBlock(RelayoutChildren, LayoutUnit)
ASSERT_NOT_REACHED();
}

void RenderBlock::addOverflowFromChildren()
{
if (childrenInline()) {
addOverflowFromInlineChildren();

// If this block is flowed inside a flow thread, make sure its overflow is propagated to the containing fragments.
if (m_overflow) {
if (CheckedPtr flow = enclosingFragmentedFlow())
flow->addFragmentsVisualOverflow(*this, m_overflow->visualOverflowRect());
}
} else
addOverflowFromBlockChildren();
}

// Overflow is always relative to the border-box of the element in question.
// Therefore, if the element has a vertical scrollbar placed on the left, an overflow rect at x=2px would conceptually intersect the scrollbar.
void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool)
void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> options)
{
clearOverflow();
addOverflowFromChildren();

addOverflowFromInFlowChildren(options);
addOverflowFromOutOfFlowBoxes();

if (hasNonVisibleOverflow()) {
Expand Down Expand Up @@ -622,14 +607,6 @@ void RenderBlock::clearLayoutOverflow()
m_overflow->setLayoutOverflow(borderBoxRect());
}

void RenderBlock::addOverflowFromBlockChildren()
{
for (auto& child : childrenOfType<RenderBox>(*this)) {
if (!child.isFloatingOrOutOfFlowPositioned())
addOverflowFromInFlowChildOrAbsolutePositionedDescendant(child);
}
}

void RenderBlock::addOverflowFromOutOfFlowBoxes()
{
TrackedRendererListHashSet* outOfFlowDescendants = outOfFlowBoxes();
Expand All @@ -639,7 +616,7 @@ void RenderBlock::addOverflowFromOutOfFlowBoxes()
for (auto& outOfFlowBox : *outOfFlowDescendants) {
// Fixed positioned elements don't contribute to layout overflow, since they don't scroll with the content.
if (outOfFlowBox.isAbsolutelyPositioned())
addOverflowFromInFlowChildOrAbsolutePositionedDescendant(outOfFlowBox);
addOverflowFromContainedBox(outOfFlowBox);
}
}

Expand Down Expand Up @@ -757,7 +734,7 @@ bool RenderBlock::simplifiedLayout()
// computeOverflow expects the bottom edge before we clamp our height. Since this information isn't available during
// simplifiedLayout, we cache the value in m_overflow.
LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layoutClientAfterEdge() : clientLogicalBottom();
computeOverflow(oldClientAfterEdge, true);
computeOverflow(oldClientAfterEdge, ComputeOverflowOptions::RecomputeFloats);

updateLayerTransform();

Expand Down
6 changes: 1 addition & 5 deletions Source/WebCore/rendering/RenderBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class RenderBlock : public RenderBox {
LayoutUnit offsetFromLogicalTopOfFirstPage() const override;
RenderFragmentContainer* fragmentAtBlockOffset(LayoutUnit) const;

virtual void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false);
void clearLayoutOverflow();

// Adjust from painting offsets to the local coords of this renderer
Expand Down Expand Up @@ -309,10 +308,7 @@ class RenderBlock : public RenderBox {

virtual bool isPointInOverflowControl(HitTestResult&, const LayoutPoint& locationInContainer, const LayoutPoint& accumulatedOffset);

virtual void addOverflowFromChildren();
// FIXME-BLOCKFLOW: Remove virtualization when all callers have moved to RenderBlockFlow
virtual void addOverflowFromInlineChildren() { }
void addOverflowFromBlockChildren();
virtual void computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> = { });
void addOverflowFromOutOfFlowBoxes();
void addVisualOverflowFromTheme();

Expand Down
20 changes: 17 additions & 3 deletions Source/WebCore/rendering/RenderBlockFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2469,15 +2469,15 @@ void RenderBlockFlow::addFloatsToNewParent(RenderBlockFlow& toBlockFlow) const
}
}

void RenderBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats)
void RenderBlockFlow::computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> options)
{
RenderBlock::computeOverflow(oldClientAfterEdge, recomputeFloats);
RenderBlock::computeOverflow(oldClientAfterEdge, options);

auto addOverflowFromFloatsIfApplicable = [&] {

if (!m_floatingObjects)
return;
auto shouldIncludeFloats = !multiColumnFlow() && (recomputeFloats || createsNewFormattingContext() || hasSelfPaintingLayer());
auto shouldIncludeFloats = !multiColumnFlow() && (options.contains(ComputeOverflowOptions::RecomputeFloats) || createsNewFormattingContext() || hasSelfPaintingLayer());
if (!shouldIncludeFloats)
return;

Expand Down Expand Up @@ -3227,6 +3227,20 @@ void RenderBlockFlow::addOverflowFromInlineChildren()
svgTextLayout()->addOverflowFromInlineChildren();
}

void RenderBlockFlow::addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> options)
{
if (childrenInline()) {
addOverflowFromInlineChildren();

// If this block is flowed inside a flow thread, make sure its overflow is propagated to the containing fragments.
if (m_overflow) {
if (CheckedPtr flow = enclosingFragmentedFlow())
flow->addFragmentsVisualOverflow(*this, m_overflow->visualOverflowRect());
}
} else
RenderBlock::addOverflowFromInFlowChildren(options);
}

std::optional<LayoutUnit> RenderBlockFlow::firstLineBaseline() const
{
if (isWritingModeRoot() && !isGridItem() && !isFlexItem())
Expand Down
7 changes: 4 additions & 3 deletions Source/WebCore/rendering/RenderBlockFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ class RenderBlockFlow : public RenderBlock {
void simplifiedNormalFlowLayout() override;
LayoutUnit shiftForAlignContent(LayoutUnit intrinsicLogicalHeight, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);

void computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> = { }) override;
void addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> = { }) override;

// RenderBlockFlows override these methods, since they are the only class that supports margin collapsing.
LayoutUnit collapsedMarginBefore() const final { return maxPositiveMarginBefore() - maxNegativeMarginBefore(); }
LayoutUnit collapsedMarginAfter() const final { return maxPositiveMarginAfter() - maxNegativeMarginAfter(); }
Expand Down Expand Up @@ -282,7 +285,6 @@ class RenderBlockFlow : public RenderBlock {
bool subtreeContainsFloats() const;
bool subtreeContainsFloat(const RenderBox&) const;

void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false) override;
Position positionForPoint(const LayoutPoint&, HitTestSource) override;
PositionWithAffinity positionForPoint(const LayoutPoint&, HitTestSource, const RenderFragmentContainer*) override;

Expand Down Expand Up @@ -458,7 +460,6 @@ class RenderBlockFlow : public RenderBlock {

virtual void computeColumnCountAndWidth();

protected:
// Called to lay out the legend for a fieldset or the ruby text of a ruby run. Also used by multi-column layout to handle
// the flow thread child.
void layoutExcludedChildren(RelayoutChildren) override;
Expand Down Expand Up @@ -506,7 +507,7 @@ class RenderBlockFlow : public RenderBlock {
bool hitTestFloats(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) override;
bool hitTestInlineChildren(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) override;

void addOverflowFromInlineChildren() override;
void addOverflowFromInlineChildren();

GapRects inlineSelectionGaps(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const LogicalSelectionOffsetCaches&, const PaintInfo*) override;
Expand Down
52 changes: 30 additions & 22 deletions Source/WebCore/rendering/RenderBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4548,27 +4548,37 @@ LayoutRect RenderBox::applyVisualEffectOverflow(const LayoutRect& borderBox) con
return LayoutRect(overflowMinX, overflowMinY, overflowMaxX - overflowMinX, overflowMaxY - overflowMinY);
}

void RenderBox::addOverflowFromInFlowChildOrAbsolutePositionedDescendant(const RenderBox& inFlowChildOrAbsolutePositionedDescendant)
void RenderBox::addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> options)
{
ASSERT(!inFlowChildOrAbsolutePositionedDescendant.isFloating());
addOverflowWithRendererOffset(inFlowChildOrAbsolutePositionedDescendant, inFlowChildOrAbsolutePositionedDescendant.locationOffset());
for (auto& child : childrenOfType<RenderBox>(*this)) {
if (!child.isFloatingOrOutOfFlowPositioned())
addOverflowFromContainedBox(child, options);
}
}

void RenderBox::addOverflowFromContainedBox(const RenderBox& child, OptionSet<ComputeOverflowOptions> options)
{
ASSERT(!child.isFloating());
addOverflowWithRendererOffset(child, child.locationOffset(), options);
}

void RenderBox::addOverflowFromFloatBox(const FloatingObject& floatBox)
{
addOverflowWithRendererOffset(floatBox.renderer(), floatBox.locationOffsetOfBorderBox());
}

void RenderBox::addOverflowWithRendererOffset(const RenderBox& renderer, LayoutSize offsetFromThis)
// 'offsetFromThis' is normally the renderer's position (RenderBox::location()).
// However in case of a float box, it may belong to a different container
// (but is intrusive to this container hence calling this function),
// meaning that the renderer's position may not be the same as its actual offset from this container.
void RenderBox::addOverflowWithRendererOffset(const RenderBox& renderer, LayoutSize offsetFromThis, OptionSet<ComputeOverflowOptions> options)
{
UNUSED_PARAM(options);

// Never allow flow threads to propagate overflow up to a parent.
if (renderer.isRenderFragmentedFlow())
return;

// 'offsetFromThis' is normally the renderer's position (RenderBox::location()).
// However in case of a float box, it may belong to a different container (but is intrusive to this container hence calling this function),
// meaning that the renderer's position may not be the same as its actual offset from this container.
auto flippedClientRect = flippedClientBoxRect();
CheckedPtr fragmentedFlow = enclosingFragmentedFlow();
if (fragmentedFlow)
fragmentedFlow->addFragmentsOverflowFromChild(*this, renderer, offsetFromThis);
Expand All @@ -4578,7 +4588,7 @@ void RenderBox::addOverflowWithRendererOffset(const RenderBox& renderer, LayoutS
// and just propagates the border box rect instead.
auto childLayoutOverflowRect = renderer.layoutOverflowRectForPropagation(writingMode());
childLayoutOverflowRect.move(offsetFromThis);
addLayoutOverflow(childLayoutOverflowRect, flippedClientRect);
addLayoutOverflow(childLayoutOverflowRect);

auto ensurePaddingEndIsIncluded = [&] {
if (!hasNonVisibleOverflow())
Expand Down Expand Up @@ -4678,11 +4688,7 @@ LayoutOptionalOutsets RenderBox::allowedLayoutOverflow() const

void RenderBox::addLayoutOverflow(const LayoutRect& rect)
{
addLayoutOverflow(rect, flippedClientBoxRect());
}

void RenderBox::addLayoutOverflow(const LayoutRect& rect, const LayoutRect& clientBox)
{
auto clientBox = flippedClientBoxRect();
if (clientBox.contains(rect) || rect.isEmpty())
return;

Expand All @@ -4706,10 +4712,7 @@ void RenderBox::addLayoutOverflow(const LayoutRect& rect, const LayoutRect& clie
return;
}

if (!m_overflow)
m_overflow = makeUnique<RenderOverflow>(clientBox, borderBoxRect());

m_overflow->addLayoutOverflow(overflowRect);
ensureOverflow().addLayoutOverflow(overflowRect);
}

void RenderBox::addVisualOverflow(const LayoutRect& rect)
Expand All @@ -4718,10 +4721,7 @@ void RenderBox::addVisualOverflow(const LayoutRect& rect)
if (borderBox.contains(rect) || rect.isEmpty())
return;

if (!m_overflow)
m_overflow = makeUnique<RenderOverflow>(flippedClientBoxRect(), borderBox);

m_overflow->addVisualOverflow(rect);
ensureOverflow().addVisualOverflow(rect);
}

void RenderBox::clearOverflow()
Expand All @@ -4731,6 +4731,14 @@ void RenderBox::clearOverflow()
fragmentedFlow->clearFragmentsOverflow(*this);
}

RenderOverflow& RenderBox::ensureOverflow()
{
if (!m_overflow)
m_overflow = makeUnique<RenderOverflow>(flippedClientBoxRect(), borderBoxRect());

return *m_overflow;
}

bool RenderBox::percentageLogicalHeightIsResolvable() const
{
// Do this to avoid duplicating all the logic that already exists when computing an actual percentage height.
Expand Down
13 changes: 9 additions & 4 deletions Source/WebCore/rendering/RenderBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,18 @@ class RenderBox : public RenderBoxModelObject {
void addLayoutOverflow(const LayoutRect&);
void addVisualOverflow(const LayoutRect&);
void clearOverflow();
RenderOverflow& ensureOverflow();

void addVisualEffectOverflow();
LayoutRect applyVisualEffectOverflow(const LayoutRect&) const;

void addOverflowFromInFlowChildOrAbsolutePositionedDescendant(const RenderBox&);

enum class ComputeOverflowOptions {
None,
RecomputeFloats = 1 << 0,
};
virtual void addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> = { });
void addOverflowFromContainedBox(const RenderBox& child, OptionSet<ComputeOverflowOptions> = { });
void addOverflowFromFloatBox(const FloatingObject&);

void applyTransform(TransformationMatrix&, const RenderStyle&, const FloatRect& boundingBox, OptionSet<RenderStyle::TransformOperationOption>) const override;
Expand Down Expand Up @@ -693,7 +700,7 @@ class RenderBox : public RenderBoxModelObject {
bool overflowChangesMayAffectLayout() const final;

private:
void addOverflowWithRendererOffset(const RenderBox&, LayoutSize);
void addOverflowWithRendererOffset(const RenderBox&, LayoutSize, OptionSet<ComputeOverflowOptions> = { });

void updateShapeOutsideInfoAfterStyleChange(const RenderStyle&, const RenderStyle* oldStyle);

Expand Down Expand Up @@ -748,8 +755,6 @@ class RenderBox : public RenderBoxModelObject {

LayoutPoint topLeftLocationWithFlipping() const;

void addLayoutOverflow(const LayoutRect&, const LayoutRect& flippedClientRect);

ShapeOutsideInfo& ensureShapeOutsideInfo();
void removeShapeOutsideInfo();

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/RenderGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2575,9 +2575,9 @@ void RenderGrid::GridWrapper::resetCurrentGrid() const
m_currentGrid = std::ref(const_cast<Grid&>(m_layoutGrid));
}

void RenderGrid::computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats)
void RenderGrid::computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> options)
{
RenderBlock::computeOverflow(oldClientAfterEdge, recomputeFloats);
RenderBlock::computeOverflow(oldClientAfterEdge, options);

if (!hasPotentiallyScrollableOverflow() || isMasonry() || isSubgridRows() || isSubgridColumns())
return;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class RenderGrid final : public RenderBlock {
void paintChildren(PaintInfo& forSelf, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect) override;
bool hitTestChildren(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& adjustedLocation, HitTestAction) override;
LayoutOptionalOutsets allowedLayoutOverflow() const override;
void computeOverflow(LayoutUnit oldClientAfterEdge, bool recomputeFloats = false) final;
void computeOverflow(LayoutUnit oldClientAfterEdge, OptionSet<ComputeOverflowOptions> = { }) override;

StyleSelfAlignmentData justifySelfForGridItem(const RenderBox&, StretchingMode = StretchingMode::Any, const RenderStyle* = nullptr) const;
StyleSelfAlignmentData alignSelfForGridItem(const RenderBox&, StretchingMode = StretchingMode::Any, const RenderStyle* = nullptr) const;
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/rendering/RenderMultiColumnSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,10 @@ LayoutPoint RenderMultiColumnSet::columnTranslationForOffset(const LayoutUnit& o
return translationOffset;
}

void RenderMultiColumnSet::addOverflowFromChildren()
void RenderMultiColumnSet::addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> options)
{
UNUSED_PARAM(options);

// FIXME: Need to do much better here.
unsigned colCount = columnCount();
if (!colCount)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderMultiColumnSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class RenderMultiColumnSet final : public RenderFragmentContainerSet {
LayoutUnit columnGap() const;

private:
void addOverflowFromChildren() override;
void addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> = { }) override;

void layout() override;

Expand Down
8 changes: 5 additions & 3 deletions Source/WebCore/rendering/RenderTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,10 @@ void RenderTable::recalcCollapsedBorders()
m_collapsedBordersValid = true;
}

void RenderTable::addOverflowFromChildren()
void RenderTable::addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> options)
{
UNUSED_PARAM(options);

// Add overflow from borders.
// Technically it's odd that we are incorporating the borders into layout overflow, which is only supposed to be about overflow from our
// descendant objects, but since tables don't support overflow:auto, this works out fine.
Expand All @@ -761,12 +763,12 @@ void RenderTable::addOverflowFromChildren()
// Add overflow from our caption.
for (unsigned i = 0; i < m_captions.size(); ++i) {
if (auto* caption = m_captions[i].get())
addOverflowFromInFlowChildOrAbsolutePositionedDescendant(*caption);
addOverflowFromContainedBox(*caption);
}

// Add overflow from our sections.
for (auto* section = topSection(); section; section = sectionBelow(section))
addOverflowFromInFlowChildOrAbsolutePositionedDescendant(*section);
addOverflowFromContainedBox(*section);
}

void RenderTable::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class RenderTable : public RenderBlock {
LayoutRect overflowClipRect(const LayoutPoint& location, OverlayScrollbarSizeRelevancy = OverlayScrollbarSizeRelevancy::IgnoreOverlayScrollbarSize, PaintPhase = PaintPhase::BlockBackground) const final;
LayoutRect overflowClipRectForChildLayers(const LayoutPoint& location, OverlayScrollbarSizeRelevancy relevancy) const override { return RenderBox::overflowClipRect(location, relevancy); }

void addOverflowFromChildren() final;
void addOverflowFromInFlowChildren(OptionSet<ComputeOverflowOptions> = { }) final;

void adjustBorderBoxRectForPainting(LayoutRect&) override;

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTableSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void RenderTableSection::computeOverflowFromCells(unsigned totalRows, unsigned n
continue;
if (r < totalRows - 1 && cell == primaryCellAt(r + 1, c))
continue;
addOverflowFromInFlowChildOrAbsolutePositionedDescendant(*cell);
addOverflowFromContainedBox(*cell);
#if ASSERT_ENABLED
hasOverflowingCell |= cell->hasVisualOverflow();
#endif
Expand Down
Loading