Skip to content
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

[css-pseudo-4] Define the behavior when custom properties must be taken from the root #9279

Merged
merged 9 commits into from
Nov 20, 2023
46 changes: 46 additions & 0 deletions css-pseudo-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,49 @@ Cascading and Per-Element Highlight Styles</h3>
css/css-pseudo/cascade-highlight-002.html
</wpt>

<h4 id="highlight-custom-properties">
Custom Properties in Highlight Styles</h3>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would merge this section with 3.5. Cascading and Per-Element Highlight Styles


A [=custom property=] used in highlight styles uses the
first custom property value found in the highlight cascade.
schenney-chromium marked this conversation as resolved.
Show resolved Hide resolved
However, if a custom property value cannot be resolved
through the highlight cascade, the property value is taken from
the root element.
Copy link
Collaborator

@fantasai fantasai Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding this sentence, I would take this existing sentence:

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

Split it out into a list item like this:

Additionally, for [=highlight pseudo-elements=] originating from the [=root element=]:

  • the inherited value of 'color' is ''currentColor'', not the [=initial value=].
  • [=custom properties=] inherit from the [=root element=].


<div class="example">
For example, if an author specified
<pre class="lang-css">
:root {
--background-color: green;
--decoration-thickness: 10px;
--decoration-color: purple;
}
::selection {
--decoration-thickness: 1px;
--decoration-color: green;
}
div::selection {
--decoration-color: blue;
background-color: var(--background-color, red);
text-decoration-line: underline;
text-decoration-style: line;
text-decoration-thickness: var(--decoration-thickness, 5px);
text-decoration-color: var(--decoration-color, red);
}
</pre>
A div's selection highlight would be a green background to the
selected content, with a 1px thick blue underline. The
''--background-color'' custom property is not found on the
''div::selection'' nor ''::selection'' so it is taken from the
''::root'' custom property match. The ''--decoration-thickness''
property is inherited from ''::selection'' via the highlight
cascade and ''--decoration-color'' is found in
''div::selection'' itself.
</div>

This behavior is intended to accomodate the standard practice of
schenney-chromium marked this conversation as resolved.
Show resolved Hide resolved
defining document-wide custom properties on '':root''.

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

Expand Down Expand Up @@ -1468,6 +1511,9 @@ Changes</h2>
and {{CSSPseudoElement/pseudo()}} method
to address [=sub-pseudo-elements=].
(<a href="https://github.com/w3c/csswg-drafts/issues/3836">Issue 3836</a>)
<li>Defined the behavior when custom property values are not found in the
highlight cascade; they are taken from the root.
(<a href="https://github.com/w3c/csswg-drafts/issues/6641">Issue 6641</a>)
</ul>

Significant changes since the <a href="https://www.w3.org/TR/2019/WD-css-pseudo-4-20190225/">25 February 2019 Working Draft</a> include:
Expand Down