On Monday 2009-09-28 06:42 -0700, Emanuele D'Arrigo wrote:
> I'm looking at this section of the Style System Documentation:
>
> https://developer.mozilla.org/en/Mozilla_Style_System_Documentation#Style_contexts_and_the_rule_tree
>
> I realise this is a fairly old document (2003) and if you know a newer
> version please let me know.
The basic concepts in that section are still true; the comments at
the top of nsRuleNode.h and nsStyleContext.h might be a little more
up-to-date on the details.
> I wonder if the tree is the "happiest" metaphor for the structure of
> the rule tree or if maybe its type should be further qualified/
> clarified. When I think to a tree I think to a graph in which each
The rule tree is is a tree. Every node in the rule tree has exactly
one parent, except for the root, which has none.
> 1) div {background-color:red}
> 2) div.blue {color:blue}
> 3) div.pink {color:pink}
> 4) div#mark {border:1px solid orange}
>
> To me, the rule tree of these four rules can take all sorts of
> different shapes depending on the specifics of the document. Take the
> following examples as isolated, in separate documents:
>
> This uses rules 4 and then 1, the rule tree is a simple graph with one
> segment:
> <div id="mark" />
No, in this case (assuming there are no other elements and no other
style rules) the rule tree has three nodes:
A. the root
B. a node pointing to rule (1), child of (A)
C. a node pointing to rule (4), child of (B)
and the style context for the div points to rule node (C).
> Uses rules 4, 3 and finally 1, the rule tree is a simple graph with
> two consecutive segments:
> <div id="mark" class="pink" />
This case is similar, with 4 nodes.
> My understanding is that in this case the rule tree is effectively a
> diamond, with rule 1 at the top, rule 4 at the bottom and rule 2 and 3
> being children of 1 and parents of 4:
>
> <div>
> <div id="mark" class="pink" />
> <div id="mark" class="blue" />
> </div>
>
> Am I correct? Does the rule tree change shape depending on the
No. There can be multiple rule nodes in the rule tree pointing to
the same rule, and in this case there are (both (D) and (F) point to
rule (4)). In this case the rule tree has six nodes:
A. the root
B. node pointing to rule (1), child of (A)
C. node pointing to rule (2), child of (B)
D. node pointing to rule (4), child of (C)
E. node pointing to rule (3), child of (B)
F. node pointing to rule (4), child of (E)
The style context for the outer div points to rule node (B). The
style context for the class=pink div points to rule node (D). The
style context for the class=blue div points to rule node (F).
-David
--
L. David Baron http://dbaron.org/
Mozilla Corporation http://www.mozilla.com/
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout