W3C home > Mailing lists > Public > www-style@w3.org > January 2010

Re: Proposal: parent selectors

From: Mikko Rantalainen <mikko.rantalainen@peda.net>
Date: Fri, 22 Jan 2010 14:58:02 +0200
Message-ID: <4B59A0DA.3010309@peda.net>
To: "www-style@w3.org" <www-style@w3.org>
Boris Zbarsky wrote:
> On 1/21/10 3:26 PM, François REMY wrote:
>> The "cache" would contains every element matching "ul > li"
>> because every of those element could potentially match the
>> rule "ul:has(img) > li".
> 
> Ah, I see.  OK....
> 
> [...]
> 
> So you're assuming that we allow :has(img) but not, say :has(p img)?  Or
> that the latter is somehow scoped?

I'd hope that complex rules would be allowed.

How about following optimization strategy:

(1) Split any rule containing a :has() part into simpler pieces. E.g.
  div.message p:has(a img.thumbnail) span.nick
would be split into
  #1: div.message p a img.thumbnail
and
  #2: div.message p span.nick
behind the scenes. (If it possible to have multiple :has() parts in a
single selector, then all possible paths through the elements must
generate additional parts similar to #2.)
(2) Link the parts #1 and #2 to each other and to the original rule.
(3) After any DOM mutation, check if #2 matches (this should be fast
because the UA should already have a high performance implementation
today) and if #2 matches, then (4) follow the link to #1 and test all
elements matched by #1. The elements matched during the #2 check could
be cached because only those would need to be accessed while checking
the full :has() selector.

I'm aware that part (4) is not easy either because CSS is usually
targeted to problem "does *this element* match any rules" instead of
"what elements does *this rules* match"? Perhaps #1 needs to link to
list of elements that has been previously matched by #1? Is that enough?

-- 
Mikko


Received on Friday, 22 January 2010 12:58:43 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:23 GMT