Re: UA's implementation of ::selection

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 UTC