Re: 'legal' / 'important' and cascading order
From: email@example.com (Wolfgang Rieger)
| 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).
Perhaps I'm missing something - why can't you do the same thing in
either case? That is, if you have weights on individual properties
within a rule, you can split the rule into multiple rules, one containing the
unweighted properties and one containing the rules with a given weight.
The separated rules could then be treated as you suggest.
Frankly, it seems to me we should allow the weight to be put in both
places, which gives the author maximum flexibility at the cost of a
small additional amount of work in parsing. That's why we build tools -
to make life easier for tool users.
| 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).
That's about what I would have expected to turn the process into, as a
simple approach, though it's probably overkill (I suspect 99% of style
sheet use will have simple selectors (all heads) and only one rule per
element). If it turns out that people *do* specify complicated
stylesheets, you would probably want to do more complicated
pre-arrangement of the properties into atomic sets and either develop
searchable signatures for the context or track the context as you
traverse the tree, so that only one set of property values is visible at
any time and no searching is required.
motorola/mcg urbana design center 1101 e. university, urbana, il 61801
phone: 217-384-8589 fax: 217-384-8550
internet mail: firstname.lastname@example.org