| 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 21 matching lines...) Expand all Loading... |
| 32 * @constructor | 32 * @constructor |
| 33 * @implements {WebInspector.CSSSourceMapping} | 33 * @implements {WebInspector.CSSSourceMapping} |
| 34 * @param {!WebInspector.CSSModel} cssModel | 34 * @param {!WebInspector.CSSModel} cssModel |
| 35 * @param {!WebInspector.Workspace} workspace | 35 * @param {!WebInspector.Workspace} workspace |
| 36 * @param {!WebInspector.NetworkMapping} networkMapping | 36 * @param {!WebInspector.NetworkMapping} networkMapping |
| 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); | |
| 43 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAddedToWorkspace, this); | |
| 44 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); | |
| 45 this._networkMapping = networkMapping; | 42 this._networkMapping = networkMapping; |
| 46 | 43 |
| 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>>>} */ | 44 /** @type {!Map<string, !Map<string, !Map<string, !WebInspector.CSSStyleShee
tHeader>>>} */ |
| 51 this._urlToHeadersByFrameId = new Map(); | 45 this._urlToHeadersByFrameId = new Map(); |
| 52 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */ | 46 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.StyleFile>} */ |
| 53 this._styleFiles = new Map(); | 47 this._styleFiles = new Map(); |
| 48 |
| 49 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove
d, this._projectRemoved, this); |
| 50 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAddedToWorkspace, this); |
| 51 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); |
| 52 this._cssModel.addEventListener(WebInspector.CSSModel.Events.StyleSheetChang
ed, this._styleSheetChanged, this); |
| 53 WebInspector.ResourceTreeModel.fromTarget(cssModel.target()).addEventListene
r( |
| 54 WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._unbi
ndAllUISourceCodes, this); |
| 54 } | 55 } |
| 55 | 56 |
| 56 WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; | 57 WebInspector.StylesSourceMapping.ChangeUpdateTimeoutMs = 200; |
| 57 | 58 |
| 58 WebInspector.StylesSourceMapping.prototype = { | 59 WebInspector.StylesSourceMapping.prototype = { |
| 59 /** | 60 /** |
| 60 * @override | 61 * @override |
| 61 * @param {!WebInspector.CSSLocation} rawLocation | 62 * @param {!WebInspector.CSSLocation} rawLocation |
| 62 * @return {?WebInspector.UILocation} | 63 * @return {?WebInspector.UILocation} |
| 63 */ | 64 */ |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 */ | 174 */ |
| 174 _unbindUISourceCode: function(uiSourceCode) | 175 _unbindUISourceCode: function(uiSourceCode) |
| 175 { | 176 { |
| 176 var styleFile = this._styleFiles.get(uiSourceCode); | 177 var styleFile = this._styleFiles.get(uiSourceCode); |
| 177 if (!styleFile) | 178 if (!styleFile) |
| 178 return; | 179 return; |
| 179 styleFile.dispose(); | 180 styleFile.dispose(); |
| 180 this._styleFiles.delete(uiSourceCode); | 181 this._styleFiles.delete(uiSourceCode); |
| 181 }, | 182 }, |
| 182 | 183 |
| 183 _unbindAllUISourceCodes: function() | 184 /** |
| 185 * @param {!WebInspector.Event} event |
| 186 */ |
| 187 _unbindAllUISourceCodes: function(event) |
| 184 { | 188 { |
| 189 if (event.data.target() !== this.target()) |
| 190 return; |
| 185 for (var styleFile of this._styleFiles.values()) | 191 for (var styleFile of this._styleFiles.values()) |
| 186 styleFile.dispose(); | 192 styleFile.dispose(); |
| 187 this._styleFiles.clear(); | 193 this._styleFiles.clear(); |
| 188 this._urlToHeadersByFrameId = new Map(); | 194 this._urlToHeadersByFrameId = new Map(); |
| 189 }, | 195 }, |
| 190 | 196 |
| 191 /** | 197 /** |
| 192 * @param {!WebInspector.Event} event | 198 * @param {!WebInspector.Event} event |
| 193 */ | 199 */ |
| 194 _uiSourceCodeAddedToWorkspace: function(event) | 200 _uiSourceCodeAddedToWorkspace: function(event) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 }, | 402 }, |
| 397 | 403 |
| 398 dispose: function() | 404 dispose: function() |
| 399 { | 405 { |
| 400 if (this._terminated) | 406 if (this._terminated) |
| 401 return; | 407 return; |
| 402 this._terminated = true; | 408 this._terminated = true; |
| 403 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 409 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 404 } | 410 } |
| 405 } | 411 } |
| OLD | NEW |