[CSS21] WD 4.1.6, 4.2: parsing of blocks

The first paragraph of §4.1.6 claims that between the delimiting braces
of a block "there may be any tokens, except that [brackets must be
in nested matched pairs]".

This conflicts with the grammar, which says that a block can't
contain BAD_STRING, BAD_URI or BAD_COMMENT tokens (i.e. not just "any
tokens"), and that in some contexts there are restrictions on what
tokens can occur beyond just that bracketing characters be matched:
e.g. CDO and CDC tokens can only occur within certain bracketing
constructs.

The error-handling rules are unclear about how a user agent should
behave when encountering such an illegal token while parsing what
up to that point appears to be a block.  For example, it isn't clear
whether in this case "while parsing a statement" applies
(on one hand, the tokens preceding this one are consistent with
it being a statement that we're parsing, while on the other
hand this illegal-in-this-context token means that in some sense
we evidently aren't parsing a statement); and nor is it clear
where "the end of the statement" is.

Relatedly, the direction to "[observe] the rules for matching pairs of
[bracketing and quotation characters]" is unclear on what should
occur when encountering the wrong closing bracketing character:
it isn't clear whether it should parse as if that closing bracketing
character were removed, or as if extra closing bracketing characters
were inserted.  For example, if the following illegal sequence counts
as "while parsing a statement", it isn't clear whether the "end of the
statement" occurs at the first or second ‘}’:

  { ... ( ... } ... ) ... }

The following lines each contain a malformed statement, but it isn't
clear where the malformed statement ends, and hence whether the
p{color:blue} is to apply or not:

  } p{color:blue}
  }} p{color:blue}
  }{} p{color:blue}

Similar comments apply to the corresponding phrases "while parsing a
declaration" and "end of the declaration", i.e. it isn't clear what
those phrases mean.

As another example, consider:

  p { margin:0; color: red --> ; }

When we encounter the --> token, it isn't clear whether we are in fact
"parsing a statement" or "parsing a declaration", and thus it isn't
clear whether the whole line should be ignored, or whether it should
behave as ‘p { margin:0; }’, or whether it should behave as
‘p { margin:0; color:red; }’.

The behaviour I see in gecko, konqueror and webkit is that it's
like ‘p { margin:0; }’, even though one could reasonably argue that
‘color: red’ is not a malformed declaration and should not be
discarded.

The text for "malformed statements" says that one should "read until
the end of the statement", but doesn't say what to do with declarations
encountered either prior to or after the illegal token.

One would have thought that encountering a malformed declaration would
also mean that one has a malformed statement: certainly the token
sequence wouldn't be a well-formed statement according to the grammar.
Yet some of the examples in the "malformed declarations" rule
retain declarations encountered after the first token that shows
the statement to be malformed.

pjrm.

Received on Friday, 7 January 2011 19:41:14 UTC