Re: [whatwg] Proposal for change in recommendation for loading behavior of non-applicable stylesheets

On 6/10/12 4:33 PM, Scott Jehl wrote:
>> One issue with this is that in many cases the UA may not yet know what
>> media queries apply to the document when starting the sheet loads.  In
>> some cases it does, of course, but those may be rarer than you think…
>
> That makes sense. For my own understanding, do you have any examples of media queries that can't be determined until a later time?

Well, for example inside an iframe determining whether a width query 
matches requires flushing out DOM construction, style computation, and 
layout on the parent document.  Right now none of that is done, at least 
in Gecko, when kicking off a stylesheet load.

And note that this would be racy: the iframe width might depend on other 
things in the parent document that haven't loaded yet (e.g., think a 
grid layout where the sizes of the grid cells depend on images whose 
intrinsic size is not known yet).

Even for a non-iframe document in Gecko right now the style loads can 
start before any sort of presentation has been set up and before the 
document knows what screen it's on, which viewport it's being rendered 
into, etc.  Communicating this information to the style loader is 
obviously possible, but would involve flushing out various work that's 
done lazily and reduces parallelism opportunities....

> I'd presume a UA would be able to run these before a page has begun loading, or at least after a meta[name=viewport] element has loaded (so that would need to come before stylesheets in the head to take advantage of this feature).
>
>   Is that not the case?

I don't think we can rely on it being the case, necessarily.... 
especially long-term (e.g. the addition of <meta viewport> changed how 
all this stuff works, and I bet there will be future spec changes that 
change it too).

> I'm not entirely sure I understand your iframe example and how it would relate to the media query differently than any viewport width.

See above about having to do extra work, not normally needed, to lay out 
the parent document and the inherent races that entails.

> Okay. But even if a user's preferences have previously changed the default font-size of the browser (say, by increasing their font size), wouldn't the UA would be privy to that size at load time, and be able to use that in determining whether, say, an EM-based media query was applicable to the viewport width or not?

The point is that if the sheet is not loaded at all and then the user 
zooms the page so that the viewport size changes while the page is 
loaded... what happens? Recall that this part of the proposal was to not 
load the sheet at all, as opposed to lazy-loading it.  Lazy-loading is 
definitely desirable, though I'd be wary of the specs requiring it, 
especially because such requirements are not easily testable.  E.g. 
nothing in the spec actually has any requirements at all on starting 
rendering.

I'm not sure what the sanest thing is to do here in spec terms.  :(

-Boris

Received on Monday, 11 June 2012 02:55:46 UTC