Bug 1644193: Make walker.getStyleSheetOwnerNode() to reflect resource watcher. r=ochameau

Depends on D89282

Differential Revision: https://phabricator.services.mozilla.com/D89283
This commit is contained in:
Daisuke Akatsuka 2020-09-14 23:37:39 +00:00
parent 581ea9af20
commit aa9f77e93e
3 changed files with 25 additions and 5 deletions

View File

@ -658,9 +658,7 @@ StyleSheetEditor.prototype = {
return;
}
const node = await this.walker.getStyleSheetOwnerNode(
this.styleSheet.actorID
);
const node = await this.walker.getStyleSheetOwnerNode(this.resourceId);
await this.highlighter.show(node, {
selector: info.selector,
hideInfoBar: true,

View File

@ -14,6 +14,10 @@ const InspectorUtils = require("InspectorUtils");
const {
EXCLUDED_LISTENER,
} = require("devtools/server/actors/inspector/constants");
const {
TYPES,
getResourceWatcher,
} = require("devtools/server/actors/resources/index");
loader.lazyRequireGetter(
this,
@ -2708,8 +2712,18 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
* NodeActor.
* Note that getNodeFromActor was added later and can now be used instead.
*/
getStyleSheetOwnerNode: function(styleSheetActorID) {
return this.getNodeFromActor(styleSheetActorID, ["ownerNode"]);
getStyleSheetOwnerNode: function(resourceId) {
const watcher = getResourceWatcher(this.targetActor, TYPES.STYLESHEET);
if (watcher) {
const ownerNode = watcher.getOwnerNode(resourceId);
return this.attachElement(ownerNode);
}
// Following code can be removed once we enable STYLESHEET resource on the watcher/server
// side by default. For now it is being preffed off and we have to support the two
// codepaths. Once enabled we will only support the stylesheet watcher codepath.
const actorBasedNode = this.getNodeFromActor(resourceId, ["ownerNode"]);
return actorBasedNode;
},
/**

View File

@ -136,6 +136,14 @@ class StyleSheetWatcher {
this._stylesheetCreationData.set(style.sheet, { fileName });
}
/**
* Return owner node of the style sheet of the given resource id.
*/
getOwnerNode(resourceId) {
const { styleSheet } = this._styleSheetMap.get(resourceId);
return styleSheet.ownerNode;
}
/**
* Protocol method to get the text of stylesheet of resourceId.
*/