Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5cdc6587c3c0c45deb6e819f21570c58b94e7d9f
https://github.com/WebKit/WebKit/commit/5cdc6587c3c0c45deb6e819f21570c58b94e7d9f
Author: Alan Baradlay <[email protected]>
Date: 2026-03-16 (Mon, 16 Mar 2026)
Changed paths:
A LayoutTests/fast/table/table-sizing-with-adjacent-floats-expected.html
A LayoutTests/fast/table/table-sizing-with-adjacent-floats.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-justify-self-002-expected.txt
M Source/WebCore/rendering/RenderTable.cpp
Log Message:
-----------
Float right table overlaps other table on Wikipedia
https://bugs.webkit.org/show_bug.cgi?id=309737
Reviewed by Antti Koivisto.
1. Tables avoid floats. They do not overlap with float boxes,
unlike regular block-level boxes (the default behavior of display: block).
2. In order to avoid float boxes (in the inline direction),
we must have the final block-direction size (height) computed.
The top position alone is not sufficient, as intrusive floats may appear
below our top position.
___________
_________ | |
| | | float box |
| table | _______|___________|
| || |
|_________|| float box |
|___________________|
(The second float is below our top position. If we only checked the top
position line, the table would stretch and overlap the second float box.)
Such cases are handled as a post-layout task in computedClearDeltaForChild().
At this point in the layout flow, the final geometry has already been computed
(e.g., for the table),
meaning we can check against floats using top + height.
By calling updateLogicalWidth() in computedClearDeltaForChild() on the child
container (the table),
we probe this vertical extent to see whether a float caused us to shrink. If
so, we mark the child (table) for re-layout.
However, when we restart the table layout, the height is first reset to zero,
followed by a call to updateLogicalWidth().
A height of 0 prevents us from computing the available size in the inline
direction, which results in overlapping the second float.
This issue is already fixed in RenderBlockFlow (and RenderFlexBox) by flipping
the order of updateLogicalWidth() and resetLogicalHeightBeforeLayoutIfNeeded().
(It is still broken in grid; see webkit.org/b/309912.)
Let's fix it by following the RenderBlockFlow pattern and resetting the height
only after computing the width.
(Alternatively, we could set a flag on RenderTable in
computedClearDeltaForChild() to mark this re-layout as special and skip (or
flip) the height reset in such cases.)
Test: fast/table/table-sizing-with-adjacent-floats.html
* LayoutTests/fast/table/table-sizing-with-adjacent-floats-expected.html: Added.
* LayoutTests/fast/table/table-sizing-with-adjacent-floats.html: Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-justify-self-002-expected.txt:
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):
Canonical link: https://commits.webkit.org/309316@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications