Skip to content

[css-pseudo] clarify paired cascade (#6386 + #6779 + #6774 + #7837) #6665

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

Merged
merged 32 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2cacf64
[css-pseudo] clarify paired cascade
delan Sep 22, 2021
a5f78a4
rewrite note about stroke-color + fill-color
delan Sep 23, 2021
bdd64b9
explicitly clarify that UA tweaks to highlight colors are allowed
delan Sep 23, 2021
0f9fd75
clean up old text and references to ::selection-only paired cascade
delan Sep 23, 2021
b961126
clarify that unset always means inherit in highlight styles
delan Sep 23, 2021
8a97a38
fix bug where explicit defaults don’t exist in specified-value space
delan Sep 23, 2021
97ca06b
clarify that the inherit keyword also inherits from parent highlight
delan Sep 23, 2021
957b828
“is” → “happens to be” (it’s a non-normative framing, not the intent)
delan Sep 23, 2021
f639d98
indent the new paired cascade section
delan Sep 23, 2021
e6ec959
fix problems with ::{spelling,grammar}-error + ::highlight (#6779)
delan Nov 18, 2021
44aa6ce
adjust normative references to “UA defaults” towards new dfn
delan Nov 18, 2021
06de02d
simplify by merging ‘unset’ text into ‘inherit’ text
delan Dec 3, 2021
65597ae
move highlight colors dfn to the more appropriate #highlight-styling
delan Dec 3, 2021
64cc5cb
refer to the now-future concept of paired cascade in a clearer way
delan Dec 3, 2021
24df479
linkify “highlight colors” in interop note
delan Dec 20, 2021
bfc6498
update origins considered by paired cascade for resolution in #6386
delan Jan 5, 2022
0c46d9d
remove text allowing UA tweaks to author highlight colors
delan Jan 5, 2022
ad10942
merge from origin/main
delan Jan 14, 2022
4e4fb90
merge from main
delan Mar 30, 2022
ce77850
fix implicit defaulting of ‘color’ at :root (#6774)
delan Apr 15, 2022
4eb95b0
explicitly refer to system colors for ::selection + ::target-text
delan Apr 15, 2022
86bb487
rewrite and heavily simplify paired cascade text
delan Apr 15, 2022
4e092c5
address the simple parts of @fantasai’s feedback
delan Sep 21, 2022
b02b1ed
fix other use of “default highlight colors”
delan Sep 21, 2022
f2bc531
add ISSUE for csswg-drafts#6853 (replacing 0c46d9d9a15a6)
delan Sep 21, 2022
e944186
move paired cascade subsection to default UA styles section
delan Sep 21, 2022
26b6c2b
remove note about paired defaults not being representable as UA rules
delan Sep 21, 2022
d2a694a
fix other reference to #paired-cascade
delan Sep 21, 2022
6a14234
move note about color-like properties (and remove “highlight colors”)
delan Sep 21, 2022
e554b21
reword cascaded-or-specified to something that makes more sense
delan Sep 21, 2022
5084397
s/consisting of/--/
delan Oct 6, 2022
a341d83
reintroduce text about color to #highlight-styling as a note
delan Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions css-highlight-api-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,12 @@ Applicable Properties</h4>
<h4 id=default-styles>
Default Styles</h4>

UAs must not define any styles for [=custom highlight pseudo-elements=] in the default UA
stylesheet. A [=custom highlight pseudo-element=] inherits the styles of its
[=originating element=].
UAs must not define any default UA stylesheet rules
or <a spec=css-pseudo>default highlight colors</a>
for any [=custom highlight pseudo-elements=].
In other words,
when some content is highlighted by an unstyled custom highlight,
its presentation must not change.

<h4 id=c-and-h>
Cascading and Inheritance</h4>
Expand Down
80 changes: 65 additions & 15 deletions css-pseudo-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,8 @@ Styling Highlights</h3>

Issue: Are there any other properties that should be included here?

The 'color' property specifies the color of both the text
Note: The 'color' property sets the color of
both the text
and all line decorations (underline, overline, line-through)
and emphasis marks ('text-emphasis')
applied to the text
Expand Down Expand Up @@ -724,16 +725,68 @@ Default UA Styles</h3>
/* Represent default spelling/grammar error styling in an adjustable way */
:root::spelling-error { text-decoration-line: spelling-error; }
:root::grammar-error { text-decoration-line: grammar-error; }
/* Highlight targeted text */
:root::target-text { color: MarkText; background: Mark; }
</pre>

Some [=highlight pseudo-elements=]
should have <dfn>paired default highlight colors</dfn>--
a default 'color' and 'background-color'
provided by the UA
that are either used or overridden together,
see [[#paired-defaults]].
For ''::selection'' they should correspond to
''HighlightText'' and ''Highlight'',
while for ''::target-text'' they should correspond to
''MarkText'' and ''Mark''.

UAs may apply additional effects to enhance the presentation
of highlighted content,
for example dimming content other than the highlighted text
or transitioning out a highlight style based on user interactions or timing.
These are not controlled by CSS.

ISSUE: UA tweaks to the presentation of highlights
in ways that <em>are</em> controlled by CSS
are currently under discussion
in <a href='https://github.com/w3c/csswg-drafts/issues/6853'>Issue 6853</a>.

<h4 id="paired-defaults">
Paired Defaults</h4>

For compatibility reasons,
[=paired default highlight colors=]
must only be [=used value|used=]
when neither 'color' nor 'background-color'
yield a [=cascaded value=]
from the [=author origin=]
(or inherit their value from the author origin).
When a highlight color is ''revert'' or ''revert-layer'',
the origin <em>after</em> rolling back the cascade
determines the [=cascaded value=]’s [=cascade origin|origin=].

Note: Because this rule is for compatibility reasons,
it does not apply to other similar properties
like 'fill-color' or 'stroke-color'.

<div class="example">
For example,
given the following markup:
<pre class="lang-markup">
&lt;p>Highlight this &lt;em>and this&lt;/em>.&lt;/p>
</pre>
Any of the following rules
would suppress the default 'background-color'
for ''::selection''
in the <code>&lt;em></code> element
if given by the author:
<pre class="lang-css">
em::selection { color: initial; }
em::selection { color: inherit; }
em::selection { color: unset; }
em::selection { color: green; }
p::selection { color: green; }
</pre>
</div>

<h3 id=highlight-bounds>
Area of a Highlight</h3>

Expand Down Expand Up @@ -788,12 +841,20 @@ Cascading and Per-Element Highlight Styles</h3>
for which that element is the <a>originating element</a>.
When multiple styles conflict,
the winning style is determined by the cascade.

When any supported property is not given a value by the cascade,
its value is determined by inheritance from
or given a value of ''inherit'' or ''unset'',
its [=specified value=] is determined by inheritance from
the corresponding <a>highlight pseudo-element</a>
of its <a>originating element</a>'s parent element
(regardless of whether that property is an <a>inherited property</a>).

Additionally,
for [=highlight pseudo-elements=] originating from the root element,
the [=inherited value=] of 'color'
is ''currentColor'',
not the [=initial value=].

<wpt>
css/css-pseudo/active-selection-051.html
css/css-pseudo/active-selection-052.html
Expand Down Expand Up @@ -856,17 +917,6 @@ Cascading and Per-Element Highlight Styles</h3>
css/css-pseudo/cascade-highlight-002.html
</wpt>


The UA must use its own highlight colors for ''::selection'' only
when neither 'color' nor 'background-color' has been specified by the author.

Note: This paired-cascading behavior
does not allow using the normal cascade
(e.g. '':root::selection'' rules in the <a>UA style sheet</a>)
to represent the OS default selection colors.
However it has been interoperably implemented in browsers
and is thus probably a Web-compatibility requirement.

<h3 id="highlight-painting">
Painting the Highlight</h3>

Expand Down