-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relation between HighlightRange#priority and other highlight pseudo elements #71
Comments
Thanks for this feedback @Reinmar. I think there are two pieces to this: (1) defining a default priority for all highlight pseudo elements, and (2) providing authors with a way to change how the (1) Since the author cares about native highlights in such cases, we need to make sure that the rendering of the native selection, spellchecking or grammar checking isn't inadvertently suppressed by author-defined highlights. (In the example above, we wouldn't want the user's find-on-page highlights to be rendered on top of the selection.) Therefore, I propose that we define the default priority of (2) (a) (b) My preference would be option (a) because there is no known scenario that absolutely requires a user highlight to be stacked in between two native highlights. To reason about this better, let's include the native highlight for find-on-page in our stacking order (this exists in the browser today, but isn't exposed via CSS - see w3c/csswg-drafts#3812), and let's assume the order to be: selection > spelling-error > grammar-error > find-on-page. The interesting scenarios would be if the author wanted to replace spelling-error or grammar-error, or both. If the author wanted to replace grammar-error but keep it behind the native spelling-error, they could prioritize their custom grammar check highlight lower than all the native highlights (behind find-on-page). This would work assuming the author doesn't use the same styles as find-on-page for their custom grammar checking, which seems highly likely. Find-on-page would apply background-color, and maybe color, while the grammar checking may apply text-decoration to show green squiggles. Since the properties don't conflict, the author's grammar highlight would still be visible. Similarly, if the author instead wanted to replace spelling-error and keep it in front of native grammar-error, they could prioritize their custom spellcheck highlight above all native highlights. Since selection should apply different properties (background color, color) to the author's custom spelling error (ex. text decoration), the selection will still be visible. If the author wants to replace both spellchecking and grammar checking - this is the case for extensions like Grammarly - then they have the choice to place them above or below the native highlights, either would work. To keep spellchecking above grammar checking, they could assign their custom spellcheck highlights a higher priority than the custom grammar highlights. This model will also hold for any new native highlights that are introduced in the future. Authors can replace any native highlight from the middle of the stack and still achieve "native-esque" ordering, as long as the pieces that changed order do not have conflicting styles. |
Since the spec is now in the css-wg, I suggest moving the discussion there and closing this issue. w3c/csswg-drafts#4594 is largely the same topic. You may want to repeat your comments there. |
Closing this issue. This has now been moved to the CSS WG drafts repo (see link above). |
moving from https://github.com/dlibby-/highlight/issues/13
@Reinmar as FYI
As I understand,
HighlightRange#priority
is needed to control which highlight is rendered above which. Since we have other highlight pseudo-elements like::selection
or:spelling-error
, could we prioritize our highlight range above those?In other words – do the UA's highlight pseud-elements have defined priorities?
Crazy idea – couldn't
z-index
be used for that instead of priorities?The text was updated successfully, but these errors were encountered: