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

Re: UA's implementation of ::selection

From: David Hyatt <hyatt@apple.com>
Date: Sat, 15 May 2010 12:19:02 -0500
Cc: François REMY <fremycompany_pub@yahoo.fr>, Boris Zbarsky <bzbarsky@MIT.EDU>, www-style@w3.org
Message-id: <0359AB5B-C2AA-45FB-8E32-95310AD19961@apple.com>
To: "L. David Baron" <dbaron@dbaron.org>
On May 15, 2010, at 12:07 PM, L. David Baron wrote:

> On Saturday 2010-05-15 11:48 -0500, David Hyatt wrote:
>> Selection would work much better if it was a property that was
>> just part of the cascade and inherited by default, e.g.,
>> 
>> #mydiv {
>>  selection: green;
>> }
>> 
>> Or if we want to have more flexibility for extensibility, you
>> could use some kind of identifier reference to point to an
>> external rule:
>> 
>> @selection myselection {
>>  background-color: green;
>> }
>> 
>> #mydiv {
>>  selection: myselection;
>> }
>> 
>> Alternatively we could say ::selection is only queried against the
>> root element, and then have the pseudo element itself take an
>> argument identifier:
>> 
>> html::selection(myselection) {
>>  background-color: green
>> }|
>> 
>> #mydiv {
>>  selection: myselection;
>> }
> 
> One piece of flexibility this wouldn't give us, which I'd like to
> have, is the ability to style multiple types of selections.

I think you could account for that pretty easily, although it would obviously mean introducing multiple values to the selection property,. e.g., you would probably have a list of selection name and selection style identifier pairs:

html::selection(myselectedtextstyle)
{
  background-color:  green
}

html::selection(myfindstyle) {
  background-color: yellow
}

#mydiv {
  selection: find-in-page(myfindstyle) selection(myselectedtextstyle);
}

I kind of like the idea of having only one pseudo element for each unique appearance you'd like to apply to any selection in the whole document.  Having the pseudo elements be singletons off the document root is very efficient, and then inheritance of all the selection types is handled using the same model as everything else in CSS.

dave
(hyatt@apple.com)
Received on Saturday, 15 May 2010 17:20:12 GMT

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