Contact emails
Spec
https://drafts.csswg.org/selectors-4/#the-dir-pseudo
Summary
The :dir() pseudo-class
allows the author to write selectors that represent an element based on its
directionality as determined by the document language.
Motivation
To identify the element's direction, as of now [dir=..] attribute selector is the only available way.
It does not match an element when no attribute is set even if the element inherits the value of its parent.
On the other hand :dir() will match the elements based on resolved directionality value of elements calculated by UA.
Interoperability and Compatibility Risk
This feature is supported in Firefox browser since version 17 under -moz prefix.
IE, Safari - Not supported as of now.
Ongoing technical constraints
None
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
OWP launch tracking bug
Link to entry on the feature dashboard
https://www.chromestatus.com/features/5751531651465216
Requesting approval to ship?
Yes
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
On Thu, Feb 11, 2016 at 8:32 PM, Boris Zbarsky <bzba...@mit.edu> wrote:
>
> On 2/11/16 11:21 PM, Elliott Sprehn wrote:
>>
>> Having studied the patch in webkit, I don't think we should support this
>> unless it can be computed from just looking at the value
>> of ->style()->direction().
>
>
> How would you go about determining whether a selector matches based on style()?
Err yeah, we need to cache this in the DOM.
>
>> Walking the entire subtree in the auto case is a bad footgun.
>
>
> For what it's worth, Gecko computes that state as needed (e.g. it's needed for layout anyway, right?) and caches it on the element, so the walk doesn't have to be done during selector matching.
Indeed.
- E
On Thu, Feb 11, 2016 at 8:32 PM, Boris Zbarsky <bzba...@mit.edu> wrote:
>
> On 2/11/16 11:21 PM, Elliott Sprehn wrote:
>>
>> Having studied the patch in webkit, I don't think we should support this
>> unless it can be computed from just looking at the value
>> of ->style()->direction().
>
>
> How would you go about determining whether a selector matches based on style()?Err yeah, we need to cache this in the DOM.
The :dir() pseudo-class does not select based on stylistic states—for example, the CSS direction property does not affect whether it matches.
>
>> Walking the entire subtree in the auto case is a bad footgun.
>
>
> For what it's worth, Gecko computes that state as needed (e.g. it's needed for layout anyway, right?) and caches it on the element, so the walk doesn't have to be done during selector matching.Indeed.
- E
--
This is similar to :lang(), which does walk the ancestor chain using Element::computeInheritedLanguage with no cachingAFAICT.
One difference is that there is no 'language' property analogous to the 'direction' property to complicate things.
The spec doesn't say precisely what goes into determining the text directionality, will it only be things that are in the DOM and that are already used for the actual layout? It seems like the best one could hope for here is that :dir() uses all the information except the 'direction' property, and that no additional complexity is required merely to support :dir(). Will that be the case?
On Mon, Apr 11, 2016 at 6:56 PM, Koji Ishii <ko...@chromium.org> wrote:
> Right, the implement doesn't need to take care of Shadow DOM at all.
The resolved direction depends on shadow distribution, no?
> Could I ask clarification as I can interpret your suggestion in two ways:
> 1. We can re-use have methods like
> HTMLElement::directionalityIfhasDirAutoAttribute to traverse and it handles
> Shadow DOM.
> 2. Since selector code always run from matchAuthorRules (?), it can just
> re-use the value set in ElementRuleCollector unless we use :dir() in UA
> rules, and we even don't have to traverse DOM.
>
> Which is your suggestion?
Number 2, since that is already an implementation of :dir() for a
specific case, but I didn't think about the case where :dir() is used
in a non-rightmost compound selector where you need the resolved value
of dir=auto for other elements. So yes, we need to cache it somewhere
for such as was previously mentioned.