Re: 'legal' / 'important' and cascading order

Thanks for the very thorough discussion of the implications of my
previous post. But I think you show by your implementation scetches
just what I wanted to point out, namely that as long priority is
specified for each declaration, finding a property-value is rather
costly.

On Mon, 22 Apr 1996 23:57:44 +0200, you wrote:

[long snip, sorry, but since you are right I have nothing to comment]

> > However, IMHO there is no big use in being able to specify weight on
> > the declaration level. As far as I can see, it would be sufficient to
> > specify weight on the rule level. In this case, one would have instead
> > of the example given above the following rules:
> > 
> > spec1 { prop1 : value1; !important }
> > spec1 { prop2 : value2; }
> > spec2 { prop1 : value1; }
> > spec2 { prop2 : value2; !important }
>
>This is a different matter and independent of any processing
>algorithm. If you use !important a lot, it makes sense to devise a
>short-hand to apply it to a whole collection of rules at a time. If
>!important is uncommon, it either doesn't matter, or it is easier to
>specify it for each property individually.
>
>We think !important will not be used a lot. It was introduced as the
>answer for some specific situations: a legal requirement that text be
>in a certain size, a color-blind reader putting !important colors in
>his local default style.
>
>Usually, most people will happily accept what the author has put in
>the style sheet (or they will turn off the style sheet altogether...)
>The user's local style sheet is unlikely to contain !important, so
>there is little reason for the author to put it in.
>
I think that !important will be used quite seldom, too. And because of
this, I do not like to hamper performance by a seldom used feature. 

If priority is specified on a per-rule basis, one could compute a
compound weight from specificity, weight, source and declaration
order. You could then have a sorted (lowest weight first) list of
selectors and pointers to structures with all properties from the
corresponding rule (i.e. you do not have to look for a property, the
property is a member of the structure which has been set or not).

You the proceed as follows: For each element

1. Hash the name and find the first selector with that head (selectors
with the same head are connected in a sorted linked list).
2. Match the rest of the selector. If it matches, put the
selector/properties-pair on a stack.
3. Continue until all matching selectors are found. After this the
matching selectors are on the stack (highest weight first).
4. To find the current value of a certain property, search the stack
until you find the property specified. If you find it, use the value.
Otherwise, use the default.
5. When the element is processed, pop the stack.

I think, this would be considerably faster (and simpler to implement).

(Note: I assume, that properties declared !important in an ancestor do
not override specified properties in a child.)

Regards

Wolfgang Rieger
Buero fuer Software-Entwicklung           Email: rieger@bse.de
                                          WWW  : http://www.bse.de/
Rosenheimer Str. 214                      Phone: +49 89 497738	
81669 Munich, Germany                     Fax  : +49 89 497738

Received on Wednesday, 24 April 1996 19:50:24 UTC