Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f63c817dae2427eb2ee48ae805c8a478086aaec8
https://github.com/WebKit/WebKit/commit/f63c817dae2427eb2ee48ae805c8a478086aaec8
Author: Karl Dubost <[email protected]>
Date: 2026-02-05 (Thu, 05 Feb 2026)
Changed paths:
M LayoutTests/platform/glib/tables/mozilla/bugs/bug30332-1-expected.txt
M LayoutTests/platform/glib/tables/mozilla/bugs/bug30332-2-expected.txt
M LayoutTests/platform/glib/tables/mozilla/bugs/bug9879-1-expected.txt
M
LayoutTests/platform/glib/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt
M LayoutTests/platform/ios/tables/mozilla/bugs/bug30332-1-expected.txt
M LayoutTests/platform/ios/tables/mozilla/bugs/bug30332-2-expected.txt
M LayoutTests/platform/ios/tables/mozilla/bugs/bug9879-1-expected.txt
M
LayoutTests/platform/ios/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt
M LayoutTests/platform/mac/tables/mozilla/bugs/bug30332-1-expected.txt
M LayoutTests/platform/mac/tables/mozilla/bugs/bug30332-2-expected.txt
M LayoutTests/platform/mac/tables/mozilla/bugs/bug9879-1-expected.txt
M
LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt
M Source/WebCore/html/HTMLTableCellElement.cpp
M Source/WebCore/rendering/RenderTableCell.cpp
M Source/WebCore/rendering/RenderTableCell.h
Log Message:
-----------
perf issues with rowspan="0" on huge complex tables
https://bugs.webkit.org/show_bug.cgi?id=291405
rdar://146056348
Reviewed by Alan Baradlay.
The HTML specification states that rowspan="0" should span all remaining
rows in the current table row group (tbody, thead, or tfoot). In a
previous patch, we made WebKit returns maxRowspan (65,534) instead of
calculating the actual number of remaining rows. This caused severe
performance issues during table grid construction.
When RenderTableSection::addCell() processes a cell with rowspan="0", it
calls ensureRows(insertionRow + rowSpan) to allocate grid space. With
rowSpan returning 65,534, this created massive grid structures even for
simple tables with just 2-3 rows.
Example:
- A table with 3 rows and 1 cell with rowspan="0"
- Expected: ensureRows(0 + 3) = 3 rows
- Actual (before fix): ensureRows(0 + 65534) = 65,534 rows
- Result: 65,534 iterations instead of 3 (~21,845x slower)
In more dramatic scenarios, it would crash Safari with tables
with ~1000+ cells with rowspan="0", it means millions of iterations.
This patch implements a two-layer approach:
1. DOM Layer (HTMLTableCellElement::rowSpan()):
Return 0 for rowspan="0" instead of maxRowspan (65,534)
This kind of go back to what was done before.
2. Rendering Layer (RenderTableCell::rowSpan()):
When rowSpan from DOM is 0, calculate actual remaining rows using
the DOM structure via calculateRowSpanForRowspanZero()
During grid construction (recalcCells()), the DOM structure is complete
but the render tree is being built incrementally. We must count rows
from the DOM, not the render tree.
This fix makes WebKit spec-compliant and matches Chrome/Firefox behavior.
* LayoutTests/platform/glib/tables/mozilla/bugs/bug30332-1-expected.txt:
* LayoutTests/platform/glib/tables/mozilla/bugs/bug30332-2-expected.txt:
* LayoutTests/platform/glib/tables/mozilla/bugs/bug9879-1-expected.txt:
*
LayoutTests/platform/glib/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt:
* LayoutTests/platform/ios/tables/mozilla/bugs/bug30332-1-expected.txt:
* LayoutTests/platform/ios/tables/mozilla/bugs/bug30332-2-expected.txt:
* LayoutTests/platform/ios/tables/mozilla/bugs/bug9879-1-expected.txt:
*
LayoutTests/platform/ios/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt:
* LayoutTests/platform/mac/tables/mozilla/bugs/bug30332-1-expected.txt:
* LayoutTests/platform/mac/tables/mozilla/bugs/bug30332-2-expected.txt:
* LayoutTests/platform/mac/tables/mozilla/bugs/bug9879-1-expected.txt:
*
LayoutTests/platform/mac/tables/mozilla_expected_failures/bugs/bug9879-1-expected.txt:
* Source/WebCore/html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::rowSpan const): Return 0 for rowspan="0"
instead of maxRowspan (65,534).
* Source/WebCore/rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::calculateRowSpanForRowspanZero const):
(WebCore::RenderTableCell::calculateRowSpanForRowspanZero const): Added.
Navigate DOM structure to calculate actual remaining rows in the table
section. Uses sectionElement->numRows() which is stable during grid
construction, unlike render tree traversal.
* Source/WebCore/rendering/RenderTableCell.h:
(WebCore::RenderTableCell::rowSpan const):
Add calculateRowSpanForRowspanZero() helper function declaration.
Modify inline rowSpan() to call helper when DOM returns 0.
Canonical link: https://commits.webkit.org/306891@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications