Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 26f55fd3fc0fad0474356b03b5cdd4fa1246de7e
      
https://github.com/WebKit/WebKit/commit/26f55fd3fc0fad0474356b03b5cdd4fa1246de7e
  Author: Alan Baradlay <[email protected]>
  Date:   2026-10-12 (Mon, 12 Oct 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001-expected.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001-ref.html
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001.html
    M Source/WebCore/rendering/RenderTable.cpp
    M Source/WebCore/rendering/RenderTable.h

  Log Message:
  -----------
  [Flex] A table flex item with borders is wider than its content and borders
https://bugs.webkit.org/show_bug.cgi?id=327176
<rdar://problem/189766215>

Reviewed by Antti Koivisto.

    <div style="display: flex; justify-content: flex-end; width: 300px">
      <table style="border: 10px solid; border-spacing: 0"><tr><td 
style="padding: 0"><div style="width: 50px"></div></td></tr></table>
    </div>

The table should be 70px wide, its 50px content plus 20px of borders. Instead 
it was 90px and stuck out of the
container.

RenderTable cached its inline borders and only recomputed them when it laid out 
or computed its intrinsic widths.
The flex layout read them before either, getting 0 on the first layout or the 
previous widths after a border change.
FlexLayoutItem cached that as the main-axis border and padding, and 
maxContentMainAxisExtentForFlexItem subtracted the
same stale value from a max-content contribution that had the real borders, so 
the content size came out too big by
the border widths and the border box added the real borders on top.

Compute borderStart() and borderEnd() on demand, the way borderBefore() and 
borderAfter() already are, as the FIXMEs
in layout and computeIntrinsicLogicalWidths asked, and remove the cache.

No measurable cost in PerformanceTests/Layout (median ms over 20 iterations; 
with the change, with the old cache,
then with the change again):

    large-table-with-collapsed-borders-and-no-colspans                  179    
180     184
    large-table-with-collapsed-borders-and-colspans                     181    
183     183
    large-table-with-collapsed-borders-and-colspans-wider-than-table    498    
504.5   512

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001-expected.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001-ref.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/table-flex-item-borders-001.html:
 Added.
* Source/WebCore/rendering/RenderTable.cpp:
(WebCore::RenderTable::layout):
(WebCore::RenderTable::computeIntrinsicLogicalWidths const):
(WebCore::RenderTable::borderStart const): Renamed from calcBorderStart.
(WebCore::RenderTable::borderEnd const): Renamed from calcBorderEnd.
(WebCore::RenderTable::recalcBordersInRowDirection): Deleted.
* Source/WebCore/rendering/RenderTable.h:

Canonical link: https://commits.webkit.org/323471@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to