Re: [csswg-drafts] [css-tables] How does table-layout:fixed even work?

In Gecko, we used fixed layout when all of the following conditions 
(see nsTableFrame::IsAutoLayout) hold:
* computed value of table-layout is fixed
* computed value of 'inline-size' is not 'auto' or 'max-content'

Fixed-layout tables report an intrinsic max-content inline size as 
infinite.  The intrinsic min-content inline size is computed by 
adding, for each column:
 * the inline component of the cell-spacing, plus:
 * if the column has a specified inline-size, the value if it is a 
length or length-only calc(), and 0 otherwise
 * otherwise, if there is a cell in the first row of the column with a
 width that is a length or a calc() that is length-only, or 
min-content or max-content, the intrinsic inline size of that cell 
(which includes adjustment of the value for box-sizing), adjusted for 
the cell's colspan and the cell-spacing, i.e., ((inline-size + 
inline-cell-spacing) / colspan) - inline-cell-spacing
 * otherwise, if there is a cell in the first row of the column with a
 percent width and that cell has a colspan, attempt to cancel out the 
above addition of cell-spacing but do it wrong and subtract too much 
(so it subtracts colspan-1 spacings for each column this happens in, 
instead of 1)
 * otherwise, 0

The actual column size calculations in final layout are similar, 
except that there's a percent distribution and balancing pass.  
Columns either have a length width, a percent width, or no width, 
based on the same rules used above for min-content width computation, 
except without the bogus attempts to subtract off cell-spacing for 
percentage widths.  Note that, again, we use the colspan-adjusted 
share of cells in the first row for each column, which doesn't really 
make sense if some of those columns have other specified widths.  If 
you want me to try to write out this algorithm in more detail, let me 
know.

Then, if that assignment takes up too much space, reduce the width of 
any percentage-width columns proportionally to their percentage, but 
not below zero.

Then, if there is extra space:
 * if there are any columns with no width specified, distributed in 
equally to such columns
 * otherwise, if there are columns with non-zero length widths from 
the above width assignment to columns, distribute the excess 
proportionally to width among those columns
 * otherwise, if there are columns with non-zero percentage widths 
from the above assignment, distribute the excess proportionally to 
percentage width among those columns
 * otherwise, distribute the space equally to the zero-sized columns
(This is much like auto layout.)

-- 
GitHub Notification of comment by dbaron
Please view or discuss this issue at 
https://github.com/w3c/csswg-drafts/issues/121#issuecomment-221418421 
using your GitHub account

Received on Tuesday, 24 May 2016 22:16:27 UTC