Bug 311064

Summary: Table with fixed-height cells and border-spacing doesn't respect specified height
Product: WebKit Reporter: Karl Dubost <karlcow>
Component: TablesAssignee: Karl Dubost <karlcow>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
testcase none

Karl Dubost
Reported 2026-03-29 22:51:08 PDT
A table with height: 500px, border-spacing: 0 50px, and two rows with fixed-height cells (td { height: 20px }) renders at 418px in Safari instead of the specified 500px. Chrome and Firefox both correctly render the table at 500px. The root cause is in RenderTableSection::distributeRemainingExtraLogicalHeight (RenderTableSection.cpp). The function distributes extra height proportionally using m_rowPos[totalRows] as the denominator, but this value includes the initial m_rowPos[0] offset which is set to vBorderSpacing() for the top section. The code has a FIXME acknowledging this: // FIXME: m_rowPos[totalRows] - m_rowPos[0] is the total rows' size. LayoutUnit totalRowSize = m_rowPos[totalRows]; The sum of all row-slice numerators in the loop equals m_rowPos[totalRows] - m_rowPos[0], which is less than the denominator m_rowPos[totalRows]. This means a fraction of the extra height proportional to m_rowPos[0] / m_rowPos[totalRows] is never distributed, leaving the table shorter than specified. For the test case: m_rowPos is [50, 120, 190]. The extra height to distribute is 500 - 190 = 310px. The sum of numerators is (120-50) + (190-120) = 140, but the denominator is 190. Only 310 * 140/190 ≈ 228px gets distributed, yielding a final height of 190 + 228 = 418px instead of 500px. The fix is to change the denominator to m_rowPos[totalRows] - m_rowPos[0], matching what the FIXME describes. Steps to Reproduce: 1. Create a table with height: 500px; border-spacing: 0 50px; border: none 2. Add two rows with td { height: 20px } 3. Compare table height across browsers Expected: Table renders at 500px (Chrome, Firefox behavior) Actual: Table renders at 418px in Safari
Attachments
testcase (1.58 KB, text/html)
2026-03-29 22:52 PDT, Karl Dubost
no flags
Radar WebKit Bug Importer
Comment 1 2026-03-29 22:51:14 PDT
Karl Dubost
Comment 2 2026-03-29 22:52:41 PDT
Created attachment 478838 [details] testcase
Karl Dubost
Comment 3 2026-03-29 23:12:58 PDT
Karl Dubost
Comment 4 2026-04-27 22:50:30 PDT
*** This bug has been marked as a duplicate of bug 226002 ***
Note You need to log in before you can comment on or make changes to this bug.