[webkit-dev] :any pseudoclass
ojan at chromium.org
Wed Mar 23 00:25:51 PDT 2011
As of r81742, WebKit supports the :-webkit-any pseudoclass. Our current
implementation matches Mozilla's AFAIK. There's a couple changes I'd like to
1. Allow a group of selectors as the argument to :-webkit-any instead of a
sequence of simple selectors. See
http://lists.w3.org/Archives/Public/www-style/2011Mar/0486.html. I don't see
any objections to this, so I plan to just move forward with this unless
someone here objects.
2. Resolve the specificity question below. The ideal behavior would be
transparent to authors, so the specificity would depend on which argument of
the any pseudoclass matched. In order to make this work, I think we'd need
to add an out-param to checkSelector and then store a wrapper around
RuleData in CSSStyleSelector::m_matchedRules. Then we could get the right
data to sort the rules appropriately when needed.
That seems like a lot of complexity and it likely has memory implications.
Is there a better way? Should we just punt and keep the current specificity
(option 1 below)? Or should we pick the highest (option 5 below)?
My intuition is to keep it as is.
---------- Forwarded message ----------
From: Tab Atkins Jr. <jackalmage at gmail.com>
Date: Fri, Feb 26, 2010 at 10:25 AM
Subject: Re: Specificity of :any (was Re: [css3-selectors] Grouping)
To: "L. David Baron" <dbaron at dbaron.org>
Cc: www-style at w3.org
On Thu, Feb 25, 2010 at 5:16 PM, L. David Baron <dbaron at dbaron.org> wrote:
> On Thursday 2010-02-25 17:58 -0500, Boris Zbarsky wrote:
>> At least in Gecko's case, what you wrote above would indeed be more
>> or less just syntax sugar. But this:
>> :any(#authors, #publications) div
>> would probably be faster to match than:
>> #authors div, #publications div
>> In fact, we're looking into implementing this right now (as
>> :-moz-any()) to more efficiently deal with the numerous rules of
>> this form that appear in our UA stylesheet.
> So the one thing that I just realized I'm not sure how to implement
> is specificity. (What I actually have implemented is treating :any
> as a pseudo-class and ignoring its arguments, which probably isn't
> what we want.)
> So given a selector like:
> Should this selector have:
> specificity 11 (p + :any)
> specificity 111 (p + :hover + #mypara)
> specificity 121 (p + :any + :hover + #mypara)
> specificity 11 (p + :hover) or 101 (p + #mypara) depending on how it
> matches (with 101 if it matches both ways)?
> one of 11 or 101, not depending on how it matches (just always the
> lowest or highest)
> I'd note that the next-to-last seems like it might be best, but I
> can't think of an obvious way to implement it in our code.
Yes, ideally the :any() is transparent wrt specificity, which is your
second-to-last option. I'm not opposed to the first or last(with
highest) options, though, if either of them end up being sufficiently
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev