Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 */ | 37 */ |
| 38 WebInspector.StylesSourceMapping = function(cssModel, workspace, networkMapping) | 38 WebInspector.StylesSourceMapping = function(cssModel, workspace, networkMapping) |
| 39 { | 39 { |
| 40 this._cssModel = cssModel; | 40 this._cssModel = cssModel; |
| 41 this._workspace = workspace; | 41 this._workspace = workspace; |
| 42 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove d, this._projectRemoved, this); | 42 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove d, this._projectRemoved, this); |
| 43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAddedToWorkspace, this); | 43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAddedToWorkspace, this); |
| 44 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR emoved, this._uiSourceCodeRemoved, this); | 44 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR emoved, this._uiSourceCodeRemoved, this); |
| 45 this._networkMapping = networkMapping; | 45 this._networkMapping = networkMapping; |
| 46 | 46 |
| 47 cssModel.target().resourceTreeModel.addEventListener(WebInspector.ResourceTr eeModel.EventTypes.MainFrameNavigated, this._unbindAllUISourceCodes, this); | |
| 48 | |
| 49 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetChang ed, this._styleSheetChanged, this); | |
| 50 /** @type {!Map<string, !Map<string, !Map<string, !WebInspector.CSSStyleShee tHeader>>>} */ | 47 /** @type {!Map<string, !Map<string, !Map<string, !WebInspector.CSSStyleShee tHeader>>>} */ |
| 51 this._urlToHeadersByFrameId = new Map(); | 48 this._urlToHeadersByFrameId = new Map(); |
| 52 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */ | 49 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */ |
| 53 this._styleFiles = new Map(); | 50 this._styleFiles = new Map(); |
| 51 | |
| 52 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetChang ed, this._styleSheetChanged, this); | |
| 53 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.MainFrameNavigated, this._unbindAllUISourceCodes, this); | |
|
dgozman
2016/08/19 20:23:37
This class wants to listen to specific resourceTre
eostroukhov
2016/08/20 01:22:30
Done.
| |
| 54 } | 54 } |
| 55 | 55 |
| 56 WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; | 56 WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; |
| 57 | 57 |
| 58 WebInspector.StylesSourceMapping.prototype = { | 58 WebInspector.StylesSourceMapping.prototype = { |
| 59 /** | 59 /** |
| 60 * @override | 60 * @override |
| 61 * @param {!WebInspector.CSSLocation} rawLocation | 61 * @param {!WebInspector.CSSLocation} rawLocation |
| 62 * @return {?WebInspector.UILocation} | 62 * @return {?WebInspector.UILocation} |
| 63 */ | 63 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 */ | 173 */ |
| 174 _unbindUISourceCode: function(uiSourceCode) | 174 _unbindUISourceCode: function(uiSourceCode) |
| 175 { | 175 { |
| 176 var styleFile = this._styleFiles.get(uiSourceCode); | 176 var styleFile = this._styleFiles.get(uiSourceCode); |
| 177 if (!styleFile) | 177 if (!styleFile) |
| 178 return; | 178 return; |
| 179 styleFile.dispose(); | 179 styleFile.dispose(); |
| 180 this._styleFiles.delete(uiSourceCode); | 180 this._styleFiles.delete(uiSourceCode); |
| 181 }, | 181 }, |
| 182 | 182 |
| 183 _unbindAllUISourceCodes: function() | 183 /** |
| 184 * @param {!WebInspector.Event} event | |
| 185 */ | |
| 186 _unbindAllUISourceCodes: function(event) | |
| 184 { | 187 { |
| 188 if (event.data.target() !== this.target()) | |
| 189 return; | |
| 185 for (var styleFile of this._styleFiles.values()) | 190 for (var styleFile of this._styleFiles.values()) |
| 186 styleFile.dispose(); | 191 styleFile.dispose(); |
| 187 this._styleFiles.clear(); | 192 this._styleFiles.clear(); |
| 188 this._urlToHeadersByFrameId = new Map(); | 193 this._urlToHeadersByFrameId = new Map(); |
| 189 }, | 194 }, |
| 190 | 195 |
| 191 /** | 196 /** |
| 192 * @param {!WebInspector.Event} event | 197 * @param {!WebInspector.Event} event |
| 193 */ | 198 */ |
| 194 _uiSourceCodeAddedToWorkspace: function(event) | 199 _uiSourceCodeAddedToWorkspace: function(event) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 }, | 401 }, |
| 397 | 402 |
| 398 dispose: function() | 403 dispose: function() |
| 399 { | 404 { |
| 400 if (this._terminated) | 405 if (this._terminated) |
| 401 return; | 406 return; |
| 402 this._terminated = true; | 407 this._terminated = true; |
| 403 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 408 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 404 } | 409 } |
| 405 } | 410 } |
| OLD | NEW |