Re: [csswg-drafts] [css-contain-2] do we need size containment in a single dimension to enable container queries? (#1031)

If we can do the "pinky promise" approach, that might be a nice way out: this would be something you could warn about in dev tools ("the size queried against was changed! don't do that!"), and wouldn't need us to introduce 1d containment at all.

I am afraid this is a pretty risky/complicated move though, because, applied naively, I think it would make layout stateful.

> The CQs won't be evaluated again.

Taken at face value, that assumes that layout is only ever done once, for the whole page. But there are a bunch of case where something changes and the layout of the part of the page needs to be recomputed. You can get out of that by saying that even in those cases, you answer the query not from the current state of the page, but based on the size the element would get if the page was being laid out from scratch, as if the queried elements had been sized as if contained and had not had a chance to influence its ancestors.

That could also create different layouts depending on the order in which you evaluate & layout the container queries. You can get out of that by defining it so that all container queries in a single page are answered as if all queried elements had been sized as if contained (and had not had a chance to influence their ancestors).

However, either of these means that to answer container queries in relayouts or in the case of multiple queried elements, you cannot just use the layout of the page as it is, and you need to know, either through caching or through recomputation, what the page's layout would have been if none of them had been inserted yet, in case some of them do change their ancestors.

That looks solvable, but expensive (and bug prone).

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 2 December 2020 07:44:25 UTC