Re: WebKit now supports CSS Variables

On Jun 24, 2008, at 1:29 PM, Håkon Wium Lie wrote:

> Also sprach David Hyatt:
>>> Still, it may be simpler and better not to allow any such crossing.
>>> Take for instance this example:
>>> style sheet 1: @variable { X: 10px }
>>> style sheet 2: @variable { X: none }
>>> style sheet 3: div { width: var(X) }
>>> Style sheet numbering is in document order. If the
>>> fininshed-loading-order is: 3, 1, 2, the width declaration would  
>>> first
>>> be invalid ("The declaration becomes invalid if the variable does  
>>> not
>>> exist") then valid with 10px, and then invalid again when X is none.
>> In WebKit at least, the parsing of the declaration with the variable
>> call is delayed until all stylesheets have been loaded (we don't show
>> any content in WebKit while stylesheets are still loading).
> Ok, so you don't see the problem outlined above. Opera supports
> progressive rendering of content as style sheets are loaded so for us
> the problem is real.
> Progessive rendering of content is a long-established concept in CSS
> and I don't think the benefit of variables outweight the cost of
> breaking progressive rendering.

I didn't say CSS variables broke progressive rendering.  They don't.   
All I said was that WebKit on the desktop and phone doesn't do it,  
since flashes of unstyled or wrongly styled content are ugly.  I know  
some mobile devices FOUC anyway. :)

This isn't really covered in the spec, but WebKit preserves variable- 
dependent values as unresolved in the CSS OM.  So progressive  
rendering (were we to do it) would even still work.  I don't see the  
problem.  If the variable is initially undefined, you preserve the  
property/value in the CSS OM with an unresolved value, and if at any  
time you can later resolve it (when new stylesheets load) you do.  The  
variable could end up using the wrong value before using the right one  
as well with progressive rendering, but that's no worse than getting  
the wrong style before getting the right one (which is what happens  
today with FOUC).


Received on Tuesday, 24 June 2008 18:37:34 UTC