Closed Bug 1771113 Opened 2 years ago Closed 10 months ago

Removing <style>/<link> node doesn't remove stylesheet in StyleEditor

Categories

(DevTools :: Style Editor, defect, P3)

defect

Tracking

(firefox118 fixed)

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 2 open bugs)

Details

Attachments

(4 files)

There are no events sent from the platform when a stylesheet is removed at the moment, so we should start with that.
Then it should be a matter of firing onResourceDestroyed for stylesheet resources and having a dedicated method in the StyleEditorUI.jsm

Emilio, as discussed yesterday, I call PostStyleSheetApplicableStateChangeEvent from DocumentOrShadowRoot::RemoveStyleSheet (see D147271)
It does work in the end, but if feels a bit off.
The stylesheet is still seen as applicable, so that's not something we can discriminate on; I'm just looking if the stylesheet was registered and if it doesn't have an associated document anymore, which is okay-ish I guess (unless I'm missing something)
But really, the applicable state for the stylesheet didn't "changed".

So should we have another event for this? Or should we make StyleSheet.h check if we have an associated document?

Flags: needinfo?(emilio)

Right... So, I'd like for the "applicable" state (at least internally in Gecko) to be just "is complete and not disabled" (which is what it does now). It's perfectly legit for non-document-associated sheets (like user or user-agent sheets) to be applicable.

Another event might be sensible, yeah, I guess "applicable state" is not the only thing that devtools cares about. Then again it seems a bit overkill to have a new event just for this. But it might be the cleaner over-all.

Flags: needinfo?(emilio)

If I understand Emilio correctly, this bug covers any kind of removal from the document, i.e. also disabling a stylesheet or removing it from Document.adoptedStyleSheets, right?

I am asking because I just saw a related question on Stack Overflow and I was searching whether there's already a bug filed for it.

Sebastian

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

Well changing disabled would cause the sheet not to be applicable, so the patch above would work, yeah.

Flags: needinfo?(emilio)
Flags: needinfo?(nchevobbe)
See Also: → 1798114
Blocks: 1798114
See Also: 1798114
Assignee: nobody → nchevobbe
Attachment #9278103 - Attachment description: WIP: Bug 1771113 - [devtools] Remove stylesheets from StyleEditor when associated node is removed. → Bug 1771113 - [devtools] Emit `StyleSheetApplicableStateChanged` event when stylesheet is removed. r=emilio.
Status: NEW → ASSIGNED
Blocks: 1847208
Duplicate of this bug: 1847165
Depends on: 1847546

Make sure that when removed the applicable state of the style sheet is
false rather than true. Fix tests too (there were a couple typos etc).

Attachment #9278103 - Attachment description: Bug 1771113 - [devtools] Emit `StyleSheetApplicableStateChanged` event when stylesheet is removed. r=emilio. → Bug 1771113 - Add chromeOnly `StyleSheetRemoved` event, emitted when a stylesheet is removed. r=emilio.
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/98df24408c27
Add chromeOnly `StyleSheetRemoved` event, emitted when a stylesheet is removed. r=emilio.
https://hg.mozilla.org/integration/autoland/rev/a8a1e12c259c
[devtools] Notify about removed stylesheet resources. r=devtools-reviewers,ochameau.
https://hg.mozilla.org/integration/autoland/rev/94d6dd1430fc
[devtools] Remove stylesheets from StyleEditor on STYLESHEET resource destroyed. r=devtools-reviewers,ochameau.
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: