W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2019

[csswg-drafts] [css-highlight-api] Should priority be expressed on ::highlight instead of HighlightRangeGroup? (#4613)

From: Sanket Joshi via GitHub <sysbot+gh@w3.org>
Date: Wed, 18 Dec 2019 07:48:12 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-539513998-1576655290-sysbot+gh@w3.org>
sanketj has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-highlight-api] Should priority be expressed on ::highlight instead of HighlightRangeGroup? ==
It occurred to me while thinking about #4579 that ::selection and ::inactive-selection are an example of two pseudo elements that target the same set of ranges.

To emulate this with custom highlights, we would currently have to do something like:
```
:root::highlight(active-selection-ranges) {
  /* active selection style */
}
:root::highlight(inactive-selection-ranges) {
  /* inactive selection style */
}
```
Here, `active-selection-ranges` and `inactive-selection-ranges` are HighlightRangeGroups. In order for inactive selection highlights to layer on top of active selection highlights, we can assign `inactive-selection-ranges` the higher priority of the two. Then, if our custom selection transitions from active to inactive, we could either add ranges from `active-selection-ranges` to `inactive-selection-ranges` - which is cumbersome - or we could use the inline style attribute to reverse the styles - which is ugly because `active-selection-ranges` will then have inactive styles.

If we could express priority on the ::highlight pseudo instead of the HighlightRangeGroup, then we could do the following:
```
:root:highlight(selection-ranges) {
  /* active selection style */
  /* assign lower priority */
}
:root::highlight(selection-ranges) {
  /* inactive selection style */
  /* assign higher priority */
}
```
Now we can just have one HighlightRangeGroup that doesn't need to be modified as we transition from one selection state to another.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4613 using your GitHub account
Received on Wednesday, 18 December 2019 07:48:14 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:57 UTC