Closed Bug 1953807 Opened 7 months ago Closed 6 months ago

Inherited properties from ::details-content pseudo element are not displayed in the Rules view

Categories

(DevTools :: Inspector: Rules, defect, P3)

defect

Tracking

(firefox139 fixed)

RESOLVED FIXED
139 Branch
Tracking Status
firefox139 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

  1. Set layout.css.details-content.enabled to true
  2. Navigate to data:text/html,<meta charset=utf8><style>details::details-content {color: tomato;}</style><details open><summary>Example summary</summary><p>First paragraph.</p><p>Second paragraph</p></details>
  3. Open the inspector
  4. Select one of the p element inside the <details> node

-> make sure that we can see that the paragraph inherits its tomato color from the ::details-content pseudo

This does make the inherited rule appear:

diff --git a/devtools/server/actors/page-style.js b/devtools/server/actors/page-style.js
--- a/devtools/server/actors/page-style.js
+++ b/devtools/server/actors/page-style.js
@@ -704,7 +704,7 @@ class PageStyleActor extends Actor {
     );
 
     // Now any pseudos.
-    if (showElementStyles && !options.skipPseudo) {
+    if (!options.skipPseudo) {
       const relevantPseudoElements = [];
       for (const readPseudo of PSEUDO_ELEMENTS) {
         if (!this._pseudoIsRelevant(bindingElement, readPseudo)) {
@@ -806,7 +806,7 @@ class PageStyleActor extends Actor {
       case "::file-selector-button":
         return node.nodeName == "INPUT" && node.type == "file";
       case "::details-content":
-        return node.nodeName == "DETAILS";
+        return !!node.closest("details");
       case "::placeholder":
       case "::-moz-placeholder":
         return this._nodeIsTextfieldLike(node);

But it appears at the very top of the rules view, as if the pseudo element was on the p element.
It also doesn't seem to be taken into account for the "overridden" properties (e.g. if there's a color declaration on details, it won't be stroke through, even if it's not applied), and it also doesn't appear in the computed panel.
So I guess we need to have something specific for pseudo elements that can have whose declarations inherits.


Note that these kind of pseudo element rules should also be taken into account for CSS variable.
E.g. on data:text/html,<meta charset=utf8><!DOCTYPE html><style>details{ color: gold;}details[open]::details-content {--x: tomato; color: dodgerblue;padding: 0.5em;border: thin solid grey;} p { outline: 1px solid var(--x);} </style><details open><summary>Example summary</summary><p>First</p><p>Second</p></details> , var(--x) is properly computed to tomato (we have a redish outline on the paragraph), and so hovering --x should show in the tooltip tomato.

Type: task → defect
Summary: Make sure inherited properties from ::details-content pseudo element are displayed in the Rules view → Inherited properties from ::details-content pseudo element are not displayed in the Rules view
Severity: -- → S3
Priority: -- → P3

Luke suggested that we could use the same setup as what we have for ::part(), as we do actually handle this properly for them.
InspectorUtils.getMatchingCSSRules(node) will return (inherited or not) ::part() rules, even though the pseudo parameter isn't passed.

We should probably align what we do so ::part and ::details-content (and any other pseudo element from which "child" elements might inherit) would work the same.

Emilio, there doesn't seem to be any test for DevTools + ::part(), so I wonder if this is intentional or if it just happens to work by mistake ?

Flags: needinfo?(emilio)

But I'm confused, getMatchingCSSRules doesn't return inherited declarations, does it? If you pass node = the-slot, and pseudo = null, it should also return the ::details-content rules.

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #3)

But I'm confused, getMatchingCSSRules doesn't return inherited declarations, does it? If you pass node = the-slot, and pseudo = null, it should also return the ::details-content rules.

When you say the-slot, I guess this doesn't refer to the <details> element (because getMatchingCSSRules(detailEl) won't return the ::details-content rules (you actively need to pass the pseudo param to get them).

The differentce with ::part() may also comes from the fact that Inspector.getCSSPseudoElementNames() doesn't return ::part (again, not sure if it's wanted or not)

Right, when I say the-slot, I mean the slot element which is I'm detail's shadow tree (and matches this pseudo)

Blocks: 1955190
Blocks: 1959940

This required a few changes both on the server and the client.
For such element-backed pseudo element rules, they need to be considered "closer"
to the selected element than the rules on the <details> element.
This means we also need to display those rules in their own dedicated "Inherited from"
section to make sure overridden declarations are properly marked as such.

A test is added to cover the different cases we have to handle.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2e20be07e39b [devtools] Display inherited rules from ::details-content rules. r=ochameau
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
QA Whiteboard: [qa-triage-done-c140/b139]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: