W3C home > Mailing lists > Public > www-style@w3.org > March 2008

Re: [CSS 2.1] General at-blocks and error recovery

From: L. David Baron <dbaron@dbaron.org>
Date: Sat, 8 Mar 2008 08:24:52 -0800
To: Anne van Kesteren <annevk@opera.com>
Cc: www-style@w3.org
Message-ID: <20080308162452.GA724@ridley.dbaron.org>

On Saturday 2008-03-08 10:54 +0100, Anne van Kesteren wrote:
> On Sat, 08 Mar 2008 06:56:11 +0100, L. David Baron <dbaron@dbaron.org> 
> wrote:
>> What Firefox is doing is the following:
>>
>> @media all {
>>   /* ok, we're inside an @media rule, so we parse declaration blocks */
>> @
>>   /* well, this is the beginning of an invalid selector, so we have
>>      to parse until we hit the end of the declaration block, that
>>      is, until we hit an { and then the matching } */
>> }
>>   /* not a {, so keep looking for the { to start our declaration block */
>>   /* ... same for all remaining tokens in the style sheet */
>>
>> I can't find anything that says what @media rules are supposed to
>> have in them, but this seems to match the spec, now that I think
>> about it.
>
> I figured this was the reasoning. So is the reason this does not violate
>
>   http://www.w3.org/TR/CSS21/syndata.html#block
>
> that you're trying to form an at-rule token and therefore the matching { } 
> pair is not actually a matching pair but the closing curly brace is part of 
> a token?

No, it's definitely not part of a token.  The tokenizer is quite
clear.

What's happening is that after the "@" we're parsing an invalid
selector.  When we're parsing an invalid selector, we recover after
we find a "{" and then a matching "}" (a declaration block).  When
we hit the "{", we're looking for a "{" so it doesn't actually match
anything.

If you want Firefox to recover after "@media all { @ }" it will if
you write "{ } }".  The "{ }" is the declaration block it's looking
for, and the final "}" closes the @media rule.

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Saturday, 8 March 2008 16:25:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:02 GMT