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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 this._networkProject = networkProject; | 42 this._networkProject = networkProject; |
43 this._workspace = workspace; | 43 this._workspace = workspace; |
44 this._eventListeners = [ | 44 this._eventListeners = [ |
45 this._sourceMapManager.addEventListener( | 45 this._sourceMapManager.addEventListener( |
46 SDK.SourceMapManager.Events.SourceMapAttached, this._sourceMapAttached , this), | 46 SDK.SourceMapManager.Events.SourceMapAttached, this._sourceMapAttached , this), |
47 this._sourceMapManager.addEventListener( | 47 this._sourceMapManager.addEventListener( |
48 SDK.SourceMapManager.Events.SourceMapDetached, this._sourceMapDetached , this), | 48 SDK.SourceMapManager.Events.SourceMapDetached, this._sourceMapDetached , this), |
49 this._sourceMapManager.addEventListener( | 49 this._sourceMapManager.addEventListener( |
50 SDK.SourceMapManager.Events.SourceMapChanged, this._sourceMapChanged, this) | 50 SDK.SourceMapManager.Events.SourceMapChanged, this._sourceMapChanged, this) |
51 ]; | 51 ]; |
52 | |
53 /** @type {!Multimap<string, !SDK.CSSStyleSheetHeader>} */ | |
54 this._frameIdToHeaders = new Multimap(); | |
52 } | 55 } |
53 | 56 |
54 /** | 57 /** |
55 * @param {?SDK.SourceMap} sourceMap | 58 * @param {?SDK.SourceMap} sourceMap |
56 */ | 59 */ |
57 _sourceMapAttachedForTest(sourceMap) { | 60 _sourceMapAttachedForTest(sourceMap) { |
58 } | 61 } |
59 | 62 |
60 /** | 63 /** |
61 * @param {!Common.Event} event | 64 * @param {!Common.Event} event |
62 */ | 65 */ |
63 _sourceMapAttached(event) { | 66 _sourceMapAttached(event) { |
64 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); | 67 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); |
65 var sourceMap = this._sourceMapManager.sourceMapForClient(header); | 68 var sourceMap = this._sourceMapManager.sourceMapForClient(header); |
69 if (this._frameIdToHeaders.has(header.frameId)) { | |
70 this._frameIdToHeaders.set(header.frameId, header); | |
71 this._sourceMapAttachedForTest(sourceMap); | |
72 return; | |
dgozman
2017/03/28 23:37:37
I haven't seen any difference in tests related to
lushnikov
2017/03/29 01:27:24
This stops over-writing sourcemap uiSourceCodes fo
| |
73 } | |
74 this._frameIdToHeaders.set(header.frameId, header); | |
75 | |
66 for (var sassURL of sourceMap.sourceURLs()) { | 76 for (var sassURL of sourceMap.sourceURLs()) { |
67 var contentProvider = sourceMap.sourceContentProvider(sassURL, Common.reso urceTypes.SourceMapStyleSheet); | 77 var contentProvider = sourceMap.sourceContentProvider(sassURL, Common.reso urceTypes.SourceMapStyleSheet); |
68 var embeddedContent = sourceMap.embeddedContentByURL(sassURL); | 78 var embeddedContent = sourceMap.embeddedContentByURL(sassURL); |
69 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null; | 79 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null; |
70 this._networkProject.addSourceMapFile(contentProvider, header.frameId, fal se, embeddedContentLength); | 80 this._networkProject.addSourceMapFile(contentProvider, header.frameId, fal se, embeddedContentLength); |
71 } | 81 } |
72 Bindings.cssWorkspaceBinding.updateLocations(header); | 82 Bindings.cssWorkspaceBinding.updateLocations(header); |
73 this._sourceMapAttachedForTest(sourceMap); | 83 this._sourceMapAttachedForTest(sourceMap); |
74 } | 84 } |
75 | 85 |
76 /** | 86 /** |
77 * @param {!Common.Event} event | 87 * @param {!Common.Event} event |
78 */ | 88 */ |
79 _sourceMapDetached(event) { | 89 _sourceMapDetached(event) { |
80 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); | 90 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data.client); |
91 this._frameIdToHeaders.remove(header.frameId, header); | |
92 if (this._frameIdToHeaders.has(header.frameId)) | |
93 return; | |
94 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap); | |
95 for (var sassURL of sourceMap.sourceURLs()) | |
96 this._networkProject.removeSourceMapFile(sassURL, header.frameId, false); | |
81 Bindings.cssWorkspaceBinding.updateLocations(header); | 97 Bindings.cssWorkspaceBinding.updateLocations(header); |
82 } | 98 } |
83 | 99 |
84 /** | 100 /** |
85 * @param {!Common.Event} event | 101 * @param {!Common.Event} event |
86 */ | 102 */ |
87 _sourceMapChanged(event) { | 103 _sourceMapChanged(event) { |
88 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap); | 104 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap); |
89 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ; | 105 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ; |
90 var headers = this._sourceMapManager.clientsForSourceMap(sourceMap); | 106 var headers = this._sourceMapManager.clientsForSourceMap(sourceMap); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this._wor kspace, entry.sourceURL, header); | 139 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this._wor kspace, entry.sourceURL, header); |
124 if (!uiSourceCode) | 140 if (!uiSourceCode) |
125 return null; | 141 return null; |
126 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber); | 142 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber); |
127 } | 143 } |
128 | 144 |
129 dispose() { | 145 dispose() { |
130 Common.EventTarget.removeEventListeners(this._eventListeners); | 146 Common.EventTarget.removeEventListeners(this._eventListeners); |
131 } | 147 } |
132 }; | 148 }; |
OLD | NEW |