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

Re: [css-pseudo] element::selection and descendants

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 12 Jan 2015 11:48:19 -0800
Message-ID: <CAAWBYDCZgRMX26=8hnvXHJ0dnJuYUqZ7zWtA6ghKu0PZc-AN6A@mail.gmail.com>
To: Rune Lillesveen <rune@opera.com>
Cc: fantasai <fantasai.lists@inkedblade.net>, "www-style@w3.org" <www-style@w3.org>
On Wed, Jan 7, 2015 at 4:57 AM, Rune Lillesveen <rune@opera.com> wrote:
> On Wed, Jan 7, 2015 at 1:31 AM, fantasai <fantasai.lists@inkedblade.net> wrote:
>> Testcase:
>>   data:text/html;charset=utf-8,<!DOCTYPE
>> html>%0D%0A<style>%0D%0Ap%3A%3Aselection { background%3A
>> rgba(0%2C255%2C0%2C0.5)%3B }%0D%0A<%2Fstyle>%0D%0A<p>Test me <em>and
>> me<%2Fem>.<%2Fp>
>>
>> Given
>>
>>   p::selection { background: <color> }
>>
>> and
>>
>>   <p>Some <em>text</em>.</p>
>>
>> I would expect (from an authoring perspective) that, in the absence
>> of rules to the contrary, <em> gets the same highlight styles as <p>.
>> However, only Presto does this. Gecko, Trident, and Blink style the
>> <em>'s highlight using the system default colors.
>> (This probably relates to how Presto handles inheritance.)
>
> In Presto, we implemented ::selection color/background-color as
> synthesized properties that cascaded/inherited independently of
> color/background-color. So,
>
> p::selection { background-color: pink }
>
> was represented internally as
>
> p { selection-background-color: pink }
>
> I assume selection-background-color had inherited:yes (as opposed to
> background-color).

Ah, that's a fascinating way to handle it, and seems like it would be
pretty effective.  It cuts out a lot of the confusion about how things
inherit, I think.

It does involve some weirdness, like the fact that in the rule
"p::selection, div { background-color: pink; }", this sets the
'background-color' for div, but the 'selection-background-color' for
p::selection.  But maybe that's not too horrible.

~TJ
Received on Monday, 12 January 2015 19:49:07 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:50 UTC