Bug 1222047 - Manage StyleSheets fronts via target.getFront. r=yulia

Summary: Depends On D3316

Tags: #secure-revision

Bug #: 1222047

Differential Revision: https://phabricator.services.mozilla.com/D3317

MozReview-Commit-ID: KMVHXrGlncU
This commit is contained in:
Alexandre Poirot 2018-08-13 09:42:19 -07:00
Родитель e4bf7ca110
Коммит 6f0326bd3a
3 изменённых файлов: 20 добавлений и 37 удалений

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

@ -53,30 +53,33 @@ function SourceMapURLService(toolbox, sourceMapService) {
*/
SourceMapURLService.prototype._getLoadingPromise = function() {
if (!this._loadingPromise) {
let styleSheetsLoadingPromise = null;
this._stylesheetsFront = this._toolbox.initStyleSheetsFront();
if (this._stylesheetsFront) {
this._loadingPromise = (async () => {
if (this._target.isWorkerTarget) {
return;
}
this._stylesheetsFront = await this._target.getFront("stylesheets");
this._stylesheetsFront.on("stylesheet-added", this._onNewStyleSheet);
styleSheetsLoadingPromise =
const styleSheetsLoadingPromise =
this._stylesheetsFront.getStyleSheets().then(sheets => {
sheets.forEach(this._onNewStyleSheet);
}, () => {
// Ignore any protocol-based errors.
});
}
// Start fetching the sources now.
const loadingPromise = this._toolbox.threadClient.getSources().then(({sources}) => {
// Ignore errors. Register the sources we got; we can't rely on
// an event to arrive if the source actor already existed.
for (const source of sources) {
this._onSourceUpdated({source});
}
}, e => {
// Also ignore any protocol-based errors.
});
// Start fetching the sources now.
const loadingPromise = this._toolbox.threadClient.getSources().then(({sources}) => {
// Ignore errors. Register the sources we got; we can't rely on
// an event to arrive if the source actor already existed.
for (const source of sources) {
this._onSourceUpdated({source});
}
}, e => {
// Also ignore any protocol-based errors.
});
this._loadingPromise = Promise.all([styleSheetsLoadingPromise, loadingPromise]);
await styleSheetsLoadingPromise;
await loadingPromise;
})();
}
return this._loadingPromise;
};

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

@ -63,8 +63,6 @@ loader.lazyRequireGetter(this, "HUDService",
"devtools/client/webconsole/hudservice", true);
loader.lazyRequireGetter(this, "viewSource",
"devtools/client/shared/view-source");
loader.lazyRequireGetter(this, "StyleSheetsFront",
"devtools/shared/fronts/stylesheets", true);
loader.lazyRequireGetter(this, "buildHarLog",
"devtools/client/netmonitor/src/har/har-builder-utils", true);
loader.lazyRequireGetter(this, "getKnownDeviceFront",
@ -125,7 +123,6 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId,
this._initInspector = null;
this._inspector = null;
this._styleSheets = null;
this._netMonitorAPI = null;
// Map of frames (id => frame-info) and currently selected frame id.
@ -2938,12 +2935,6 @@ Toolbox.prototype = {
// Destroy the preference front
outstanding.push(this.destroyPreference());
// Destroy the style sheet front.
if (this._styleSheets) {
this._styleSheets.destroy();
this._styleSheets = null;
}
// Destroy the device front for the current client if any.
// A given DeviceFront instance can cached and shared between different panels, so
// destroying it is the responsibility of the toolbox.
@ -3134,17 +3125,6 @@ Toolbox.prototype = {
this._performance = null;
},
/**
* Return the style sheets front, creating it if necessary. If the
* style sheets front is not supported by the target, returns null.
*/
initStyleSheetsFront: function() {
if (!this._styleSheets && this.target.hasActor("styleSheets")) {
this._styleSheets = StyleSheetsFront(this.target.client, this.target.form);
}
return this._styleSheets;
},
/**
* Destroy the preferences actor when the toolbox is unloaded.
*/

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

@ -47,7 +47,7 @@ StyleEditorPanel.prototype = {
this.target.on("close", this.destroy);
this._debuggee = this._toolbox.initStyleSheetsFront();
this._debuggee = await this._target.getFront("stylesheets");
// Initialize the CSS properties database.
const {cssProperties} = await initCssProperties(this._toolbox);