Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Unified Diff: third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js

Issue 2122353002: [DevTools] Make resource tree model optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
index d02ce0a5f8de7668078bb081ce7cd6fe1b16fb33..43a05a84b7938c7d4f640d162cd1069a7fc127a4 100644
--- a/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/StylesSourceMapping.js
@@ -39,18 +39,19 @@ WebInspector.StylesSourceMapping = function(cssModel, workspace, networkMapping)
{
this._cssModel = cssModel;
this._workspace = workspace;
- this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, this._projectRemoved, this);
- this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
- this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
this._networkMapping = networkMapping;
- cssModel.target().resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._unbindAllUISourceCodes, this);
-
- this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetChanged, this._styleSheetChanged, this);
/** @type {!Map<string, !Map<string, !Map<string, !WebInspector.CSSStyleSheetHeader>>>} */
this._urlToHeadersByFrameId = new Map();
/** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */
this._styleFiles = new Map();
+
+ this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemoved, this._projectRemoved, this);
+ this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
+ this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
+ this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetChanged, this._styleSheetChanged, this);
+ WebInspector.ResourceTreeModel.fromTarget(cssModel.target()).addEventListener(
+ WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._unbindAllUISourceCodes, this);
}
WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200;
@@ -180,8 +181,13 @@ WebInspector.StylesSourceMapping.prototype = {
this._styleFiles.delete(uiSourceCode);
},
- _unbindAllUISourceCodes: function()
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _unbindAllUISourceCodes: function(event)
{
+ if (event.data.target() !== this.target())
+ return;
for (var styleFile of this._styleFiles.values())
styleFile.dispose();
this._styleFiles.clear();

Powered by Google App Engine
This is Rietveld 408576698