Bug 1813478 - [devtools] Move StyleSheetsManager to WindowGlobalTargetActor. r=devtools-reviewers,nchevobbe

This is specific to WindowGlobal targets and isn't used by worker/process targets.

Differential Revision: https://phabricator.services.mozilla.com/D168663
This commit is contained in:
Alexandre Poirot 2023-02-07 10:37:01 +00:00
parent 6c01f0d697
commit d356265137
2 changed files with 19 additions and 22 deletions

View File

@ -12,12 +12,6 @@ loader.lazyRequireGetter(
"resource://devtools/server/actors/targets/session-data-processors/index.js",
true
);
loader.lazyRequireGetter(
this,
"StyleSheetsManager",
"resource://devtools/server/actors/utils/stylesheets-manager.js",
true
);
class BaseTargetActor extends Actor {
constructor(conn, targetType, spec) {
@ -30,14 +24,6 @@ class BaseTargetActor extends Actor {
this.targetType = targetType;
}
destroy() {
if (this._styleSheetsManager) {
this._styleSheetsManager.destroy();
this._styleSheetsManager = null;
}
super.destroy();
}
/**
* Process a new data entry, which can be watched resources, breakpoints, ...
*
@ -107,12 +93,5 @@ class BaseTargetActor extends Actor {
resource => (resource.browsingContextID = browsingContextID)
);
}
getStyleSheetsManager() {
if (!this._styleSheetsManager) {
this._styleSheetsManager = new StyleSheetsManager(this);
}
return this._styleSheetsManager;
}
}
exports.BaseTargetActor = BaseTargetActor;

View File

@ -65,6 +65,12 @@ loader.lazyRequireGetter(
"resource://devtools/server/actors/worker/worker-descriptor-actor-list.js",
true
);
loader.lazyRequireGetter(
this,
"StyleSheetsManager",
"resource://devtools/server/actors/utils/stylesheets-manager.js",
true
);
const lazy = {};
ChromeUtils.defineModuleGetter(lazy, "ExtensionContent", EXTENSION_CONTENT_JSM);
@ -557,6 +563,13 @@ class WindowGlobalTargetActor extends BaseTargetActor {
return this._sourcesManager;
}
getStyleSheetsManager() {
if (!this._styleSheetsManager) {
this._styleSheetsManager = new StyleSheetsManager(this);
}
return this._styleSheetsManager;
}
_createExtraActors() {
// Always use the same Pool, so existing actor instances
// (created in createExtraActors) are not lost.
@ -709,6 +722,11 @@ class WindowGlobalTargetActor extends BaseTargetActor {
this._destroyThreadActor();
if (this._styleSheetsManager) {
this._styleSheetsManager.destroy();
this._styleSheetsManager = null;
}
// Shut down actors that belong to this target's pool.
if (this._targetScopedActorPool) {
this._targetScopedActorPool.destroy();
@ -735,7 +753,7 @@ class WindowGlobalTargetActor extends BaseTargetActor {
// which will destroy the EventEmitter API
this.emit("destroyed", { isTargetSwitching, isModeSwitching });
// Destroy BaseTargetActor before nullifying docShell as it uses it via the StyleSheetManager.
// Destroy BaseTargetActor before nullifying docShell in case any child actor queries the window/docShell.
super.destroy();
this.docShell = null;