Re: "display: image;" for CSS styling of images embedded in XML documents?

On Sat, 5 Jul 2003, Mikko Rantalainen wrote:
>>
>> You can't use a pseudo-class, because that makes the cascade dependent on
>> the layout, which is a definite no-no.
>
> I don't really understand the problem with :broken pseudo-class.

Here is a basic overview of how CSS works:

   1. Take all the stylesheets.
   2. Take an element in the document.
   3. Make a list of all the rules that apply to that element.
   4. For each property, find the most specific rule and note it.
   5. For any inherited properties, take the values from the parent
      element.
   6. Do this for all the elements.
   7. Render the document.

Now in practice it can be optimised a bit and the steps are done
simultaneously for different elements, but that's not important.

The important point is that step 4 comes before step 6.

In addition, there is the overarching principle which is that at ANY point
between two events, you should be able to recheck what rules match what
elements and not come to a different conclusion. In other words, rule
matching is stateless. (Events can be something like a mouse movement,
which can change what elements match the element, but cannot be something
like going through the style rules.)

In other words, applying the style rules cannot affect what style rules
should match. If you apply the rules twice in a row, you should get
consistent results.

Now, given that:

> Something along the lines:
> object { content: url(attr(data)); }
> object:broken { content: normal; }

At step 4, you don't know that the image is broken, so you apply the first
rule. But then you find it is broken, and so apply the second. But now,
it's no longer broken, so you apply the first again.

The invariant rule (that applying style twice in a row should get the same
effect) is thus broken.


(Note: The above should really be qualified by "IMHO". Some members of the
WG may well disagree with me that applying style twice in a row should be
invariant. However, the current CSS specs are not written with that
possibility in mind, and would probably need some important changes to
work well in that kind of environment.)

-- 
Ian Hickson                                      )\._.,--....,'``.    fL
"meow"                                          /,   _.. \   _\  ;`._ ,.
http://index.hixie.ch/                         `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 7 July 2003 05:31:37 UTC