-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-tables-3] Table height redistribution algorithm #4418
Comments
Test will land as: @FremyCompany I am getting to implementing the height redistribution. Happy to assist with specs. |
Thanks for looking into this! I am uncertain about whether the greedy approach makes a lot of sense. Based on your findings only Chrome behaves that way, and I think it's unfortunate that reordering rows also changes their size. I'd rather we interpolate linearly between all such cells in Group 1 between their current and preferred size. That is likely to produce the more visually pleasing result. Would that be an option for you, do you think? Other than that, the steps outlined look reasonable to me, I'd be happy to write that down in the spec instead of the blank section :) |
I agree that greedy algorithm is not great, and that proportional is nicer for webdevs. If we are going to grow proportionally, there are a few details to be decided on. One is a fundamental problem, and two are clean problems. Fundamental problem:
The clean solution would be to use "intrinsic" row group height, but that is not what happens on majority of the browsers today. Since a lot of table work happened during IE's dominant market share, IE's solution might be web compatible, and is easiest to spec and implement. Clean problems:
(*) initial comment was edited with additional concern. |
Testcase that shows how 50% tall row gets resolved incorrectly by everyone. |
@atotic All good questions. Here is how I thought about things:
How does that sound to you? |
The reason this does not require capping is that if the sum of percentages is higher than 100% there just won't be enough available space to distribute, so alpha will be smaller than 1, and all is well. |
I am confused. What height are you redistributing? In my model there are three separate height redistributions that happen during table layout:
This issue concerns only tall cell redistribution. I have not looked into the other 2 closely yet.
Row percentage heights are not used to compute initial row height. They are only used as a limit for excess height redistribution. |
Oh sorry, I was talking about table height redistribution. What do you mean by table-cell redistribution? Are you talking about row-spanning cells? |
Yes! |
There are 3 height redistributions in table layout algorithm:
I think they'll all use the same basic algorithm. The only difference between the three is "what height to use for percentage resolution". I will have a proposal soon, after some tests. |
I've ~finished my investgation. I think all redistributions can use the same basic algorithm I've initially proposed here (with modifications for empty rows, and what to do if percentage resolution height is undefined). There is very little agreement between browsers about what should be done. Details about my proposal are in the investigation. Briefly, I think these rules are clean, and hopefully web compatible: Use algorithm I initially proposed for height redistribution. PRH means percentage resolution height. Section CSS height should not be ignored. |
I am reimplementing tables in Chrome. Height redistribution algorithm for tall cells
(rowspan > 1) is not fully defined in current spec.
I've investigated what Chrome and other browsers currently do. Every browser does something different. It'd be nice to spec a web compatible algorithm, so that implementations can converge.
I expect row group and table height redistribution algorithms to be similar.
Based upon Chrome's behavior, I came up with a following algorithm.
Algorithm
Compute row groups.
heights, as row layout algorithm (first pass) has already added fixed heights to row height.
If there are any rows in Group1, distribute excess heights until rows
reach their existing height. Distribution of heights is not proportional
to %ge (like columns). It is greedy. Cells are traversed, and each cell
is resized to its desired %ge height. When we run out of excess height,
distribution stops.
Example:
<tr height:100%> // this row gets all the excess height, because it is 100%.
<tr height:100%> // this row gets nothing, because there is nothing left
If there is excess height left over distribute to Group2, or Group3 if
Group2 is empty. Zero-height rows do not grow. Excess height is distributed in
proportion to existing cell size.
Current spec:
https://drafts.csswg.org/css-tables-3/#height-distribution-principles
https://drafts.csswg.org/css-tables-3/#row-layout
I also have a w-p-t tentative testcase
computing-row-measure-2.tentative.html
Chrome passes (I modeled the algorithm on Chrome's behavior)
PASS Unconstrained cells heights are distributed proportionally.
PASS Constrained fixed cells not resized if unconstrained exist.
PASS Constrained %ge cells grow to %ge size, but no more.
PASS %ge grow greedily.
PASS Zero height rows do not grow.
PASS Unconstrained cells are redistributed proportionally
Firefox has trouble with growing %ge cells:
FAIL Constrained %ge cells grow to %ge size, but no more. expected 30 but got 19
FAIL %ge grow greedily. assert_equals: expected 60 but got 19
Safari, like FF, does not like to grow %ge cells. I am unclear how Safari decides on which cell to grow.
FAIL Unconstrained cells heights are distributed proportionally. assert_equals: expected 50 but got 18
FAIL Constrained %ge cells grow to %ge size, but no more. assert_equals: expected 30 but got 18
FAIL %ge grow greedily. assert_equals: expected 60 but got 18
FAIL Unconstrained cells are redistributed proportionally assert_equals: expected 75 but got 30
Edge 17: Edge grows %ge cells beyond its intrinsic height, and does not grow greedily.
FAIL Constrained fixed cells not resized if unconstrained exist. expected 30, got 62
FAIL Constrained %ge cells grow to %ge size, but no more. expected 30, got 50
FAIL %ge grow greedily. expected 60, got 33
The text was updated successfully, but these errors were encountered: