Closed Bug 1995943 Opened 2 months ago Closed 2 months ago

InspectorUtils.selectorMatchesElement returns invalid result for nested shadow host with shared stylesheet

Categories

(DevTools :: Inspector, defect)

defect

Tracking

(firefox146 fixed)

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 1 obsolete file)

Steps to reproduce

  1. Open the attached page
  2. Inspect the "nested shadow dom section" element
  3. Hover the --a variable in the section { color: var(--a); } rule

Expected results

The popup indicates that --a is red

Actual results

The popup says that --a is not defined


This is caused by CSSStyleRule::selectorMatchesElement not property working for the :host rule on the nested shadow host for the shared stylesheet.

D269727 highlights the issue.
CSSStyleRule::selectorMatchesElement was fixed to handle :host in Bug 1836755 , but I guess we missed this specific case

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

Emilio, since you took care of Bug 1836755, do you know what's happening here?

Flags: needinfo?(emilio)
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED

Added rules view test checking the variable in D269733

When you call .selectorMatchesElement on a rule from an adopted stylesheet, both answers are technically correct depending on which scope you're matching from. In the regressing bug I added this comment which is still true.

I guess we could try to match all the potentially-relevant hosts? So basically changing that GetHost(..) call by a ForEachHost? I guess that wouldn't be too bad, you're likely to want that answer...

Do you want to give that a try? might not be hard to fix :)

Flags: needinfo?(emilio) → needinfo?(nchevobbe)

(In reply to Emilio Cobos Álvarez [:emilio] from comment #7)

When you call .selectorMatchesElement on a rule from an adopted stylesheet, both answers are technically correct depending on which scope you're matching from. In the regressing bug I added this comment which is still true.

I guess we could try to match all the potentially-relevant hosts? So basically changing that GetHost(..) call by a ForEachHost? I guess that wouldn't be too bad, you're likely to want that answer...

Do you want to give that a try? might not be hard to fix :)

Not sure I understand everything, but I gave it a try: D269931 , we can discuss the details on phab :)

Flags: needinfo?(nchevobbe)
Pushed by nchevobbe@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/5d0f81407228 https://hg.mozilla.org/integration/autoland/rev/683392c38072 Check all potentially related hosts in CSSStyleRule::SelectorMatchesElement. r=emilio,firefox-style-system-reviewers. https://github.com/mozilla-firefox/firefox/commit/e999124172a9 https://hg.mozilla.org/integration/autoland/rev/f78c58f49a96 Add test for CSSStyleRule::selectorMatchesElement on :host rules. r=layout-reviewers,dshin.
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
Blocks: 1996508

Comment on attachment 9521916 [details]
Bug 1995943 - [devtools] Add rules view test for CSS variables from shared stylesheet used in nested shadow dom element. r=#devtools.

Revision D269733 was moved to bug 1996508. Setting attachment 9521916 [details] to obsolete.

Attachment #9521916 - Attachment is obsolete: true
QA Whiteboard: [qa-triage-done-c147/b146]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: