Re: Suggestion for CSS3 selectors (fwd)

q.v. below.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

---------- Forwarded message ----------
Subject: Re: Suggestion for CSS3 selectors
From: Brian J. Fink <desertowl23@gmail.com>
To: Ian Hickson <ian@hixie.ch>
Date: Mon, 28 Apr 2008 17:42:15 -0400

On the outside chance that you might be able to pass my suggestion
along to the W3C team, could you add one more suggestion? It seems to
me that:

a. for Direct Ancestor, the browser would only have to check the
immediate children of the element, and only until it found a match,
and
b. for Indirect Ancestor, the browser could scan one level at a time
in the document tree, until a match was found.

True, all cases would have to be exhausted before it could be proven
that a match did not exist. Hmm....

Hey wait! I have an idea! Why not use the existing descendant
algorithm and apply the styles to the ancestors at the same time? This
is how it would work:

1. Scan through the document, checking for selector1.
2. At each occurence of selector1, check if its direct parent is selector2.
3. Apply the style to that parent.

A similar adaptation of the contextual algorithm could be used for
Indirect Ancestor:

1. Scan through the document, checking for selector1.
2. At each occurence, scan up the tree checking for context element selector2.
3. Apply the style to selector2.

That way you could locate the ancestor by finding its descendant
first! (a lesson taken from genealogy!)

Received on Monday, 28 April 2008 22:47:22 UTC