W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2020

[csswg-drafts] Algorithm for computing GRID_MIN from column %ge size is not well defined (#5816)

From: Aleksandar Totic via GitHub <sysbot+gh@w3.org>
Date: Tue, 22 Dec 2020 07:55:59 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-772729307-1608623758-sysbot+gh@w3.org>
atotic has just created a new issue for https://github.com/w3c/csswg-drafts:

== Algorithm for computing GRID_MIN from column %ge size is not well defined ==
https://www.w3.org/TR/css-tables-3/#computing-the-table-width
Compute standard GRID_MIN/GRID_MAX. 

Standard does not specify in detail how to handle column percentages.
"a percentage represents a constraint on the column's inline size, which a
UA should try to satisfy"

While reimplementing tables in Chrome, I've discovered that following 
algorithm works:

Percentages cannot be resolved into pixels because size of containing
block is unknown. Instead, percentages are used to enforce following
constraints:
1) Column min inline size and percentage imply that total inline sum must
be large enough to fit the column. Mathematically, column with
min_inline_size of X, and percentage Y% implies that the
total inline sum MINSUM must satisfy: MINSUM * Y% >= X.
2) Let T% be sum of all percentages. Let M be sum of min_inline_sizes of
all non-percentage columns. Total min size sum MINSUM must satisfy:
T% * MINSUM + M = MINSUM.

All  major browsers (more or less) implement this the same way. I think standard should specify relationship between GRIDMIN/MAX and column percentages in detail.

#### There is a further issue with flex/grid/table cell ancestors:

The formula above can result in very large table minimum widths. For example:

    <table>
        <td style="width:1%"><div style="width:50px"></div></td>
    </table>

would result in 5000px GRIDMIN.

This works in block layout, because block layout forces table to never be wider than container width.

If table is a flex/grid child, this would result in a 5000px wide table, which is not what developers expect.
Major browsers have recognized this as a problem, and implemented non-standardized workarounds.
Most of the workarounds are a variation of 
"if table ancestor is flex/grid/table cell, ignore column percentages when computing GRIDMIN"

This exception should also be part of the standard.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5816 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 22 December 2020 07:56:01 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:24 UTC