Bug 1696372 - [devtools] Migrate styleditor panel from toolbox.targetList to commands.TargetCommand. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D110211
This commit is contained in:
Alexandre Poirot 2021-03-30 21:29:39 +00:00
Родитель 76159a7d58
Коммит 23ca20118f
2 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -72,14 +72,16 @@ const HTML_NS = "http://www.w3.org/1999/xhtml";
* 'error': An error occured
*
* @param {Toolbox} toolbox
* @param {Object} commands Object defined from devtools/shared/commands to interact with the devtools backend
* @param {Document} panelDoc
* Document of the toolbox panel to populate UI in.
* @param {CssProperties} A css properties database.
*/
function StyleEditorUI(toolbox, panelDoc, cssProperties) {
function StyleEditorUI(toolbox, commands, panelDoc, cssProperties) {
EventEmitter.decorate(this);
this._toolbox = toolbox;
this._commands = commands;
this._panelDoc = panelDoc;
this._cssProperties = cssProperties;
this._window = this._panelDoc.defaultView;
@ -120,7 +122,7 @@ StyleEditorUI.prototype = {
},
get currentTarget() {
return this._toolbox.targetList.targetFront;
return this._commands.targetCommand.targetFront;
},
/*
@ -138,8 +140,8 @@ StyleEditorUI.prototype = {
async initialize() {
this.createUI();
await this._toolbox.targetList.watchTargets(
[this._toolbox.targetList.TYPES.FRAME],
await this._commands.targetCommand.watchTargets(
[this._commands.targetCommand.TYPES.FRAME],
this._onTargetAvailable
);
@ -1272,8 +1274,8 @@ StyleEditorUI.prototype = {
},
destroy: function() {
this._toolbox.targetList.unwatchTargets(
[this._toolbox.targetList.TYPES.FRAME],
this._commands.targetCommand.unwatchTargets(
[this._commands.targetCommand.TYPES.FRAME],
this._onTargetAvailable
);

Просмотреть файл

@ -44,7 +44,12 @@ StyleEditorPanel.prototype = {
);
// Initialize the UI
this.UI = new StyleEditorUI(this._toolbox, this._panelDoc, cssProperties);
this.UI = new StyleEditorUI(
this._toolbox,
this._commands,
this._panelDoc,
cssProperties
);
this.UI.on("error", this._showError);
await this.UI.initialize();