Re: [csswg-drafts] [css-grid] Percentages and intrinsic size

Again more comments about the [new text on the spec](https://github.com/w3c/csswg-drafts/commit/15cf0c6d56efdbb44383134ebe19dff672b01546):
> then the must be treated as auto, for the purpose of calculating the intrinsic sizes of the grid container and then resolve against that resulting grid container size for the purpose of laying out the grid and its items.

As I said for columns that's what all browser do, but for rows that's not the case (and I'm not 100% sure if it'd be possible to do that or not).

Let me explain my thoughts. For a grid container with indefinite width and height, on Blink/WebKit we do the following things:
1. First we **calculate the intrinsic width** (for that we run the algorithm for the columns).
   If we find a percentage column we treat it as `auto`.
   As a result we set the intrinsic width of the grid container.
2. Then we **layout the grid container**, first the columns and then the rows:
  * **For columns**, if we find a percentage column at this stage, we simply resolve the percentage against the intrinsic width. Like it happens on regular blocks for percentage widths.
  * **For rows**, if we find a percentage row we treat it as `auto` (we cannot resolve it yet, as we don't have an *intrinsic height*). This is the same that happens on regular blocks for percentage heights.
    With these result we set the grid container height.

So we're not resolving the percentages for rows. If we want to resolve the percentage at this point, we'd need to re-run the algorithm (an extra pass) setting the previously computed height as a grid container fixed height. In that way when we're in **2. For rows**, we'll resolve the percentage rows against that height calculated in the previous iteration.
If we do that, percentage rows will behave like percentage colums, but different to percentage heights in regular blocks.

Before trying to implement something like this we'd like to know if the rest of the browsers will be happy to do so (cc @MatsPalmgren @atanassov).


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

Received on Thursday, 5 October 2017 11:29:34 UTC