Re: The :min-width/:max-width pseudo-classes

On Thu, Mar 21, 2013 at 8:35 PM, François REMY <
francois.remy.dev@outlook.com> wrote:

> > Oh! So your idea is that a :max-width() pseudo would, regardless of
> > where in the selector it appears, match based on the nearest viewport
> > element of the selector's subject?
>
> Not exactly. I'm just saying that if the layout of the element hasn't been
> calculated in a previous pass, the pseudo-class doesn't match. And the
> condition to which the layout of the target element has been computed in a
> previous pass is that it should be the nearest parent viewport of the
> element to be matched, or an ancestor.
>
> So :min-width() consider the width of the element it's applied on, but
> only if the width of the element is known. If it's not, the pseudo-class do
> not match.
>
>
I'm not sure I follow what you're talking about. We could break the
craziness by forcing all the subsequent style matches to only be scoped to
the subtree of the current viewport:

!.viewport1 div:min-width(...) > .viewport2 div:min-width(...) {
  display: table;
}

If we follow the steps we would:

A. Match all rules on the document, min-width and max-width never match
B. Layout the entire document but skip all viewports
C. Layout the viewports in document order:
 1. layout viewport1
 2. Rematch all rules for descendants of viewport1
 3. layout viewport2
 4. Rematch all rules for descendants of viewport2
D. Layout the whole document (again) with regions, quotes, first-letter,
first-line etc.
E. finish

After step E you have the knowledge to match the above rule, but since you
only recalc style going down the tree as you go .viewport1 never gets it's
style recalculated.

This would probably be okay. I think there's a high implementation cost for
this kind of thing, at least in WebKit, since it breaks from the two step
model and fancy features like :first-letter/regions/etc. need to be moved
to a separate phase since their state depends on the style of the inside of
the viewports being known. It certainly could be done given enough time and
someone very motivated...

I'd love to hear thoughts from other implementors. :)

- E

Received on Friday, 22 March 2013 01:35:29 UTC