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 * @param {!WebInspector.CSSModel} cssModel | 33 * @param {!WebInspector.CSSModel} cssModel |
34 * @param {!WebInspector.NetworkMapping} networkMapping | 34 * @param {!WebInspector.NetworkMapping} networkMapping |
35 * @param {!WebInspector.NetworkProject} networkProject | 35 * @param {!WebInspector.NetworkProject} networkProject |
36 */ | 36 */ |
37 WebInspector.SASSSourceMapping = function(cssModel, networkMapping, networkProje ct) | 37 WebInspector.SASSSourceMapping = function(cssModel, networkMapping, networkProje ct) |
38 { | 38 { |
39 this._cssModel = cssModel; | 39 this._cssModel = cssModel; |
40 this._networkProject = networkProject; | 40 this._networkProject = networkProject; |
41 this._networkMapping = networkMapping; | 41 this._networkMapping = networkMapping; |
42 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapAttach ed, this._sourceMapAttached, this); | 42 this._eventListeners = [ |
43 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapDetach ed, this._sourceMapDetached, this); | 43 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapAt tached, this._sourceMapAttached, this), |
44 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapChange d, this._sourceMapChanged, this); | 44 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapDe tached, this._sourceMapDetached, this), |
45 this._cssModel.addEventListener(WebInspector.CSSModel.Events.SourceMapCh anged, this._sourceMapChanged, this) | |
46 ]; | |
45 } | 47 } |
46 | 48 |
47 WebInspector.SASSSourceMapping.prototype = { | 49 WebInspector.SASSSourceMapping.prototype = { |
48 /** | 50 /** |
49 * @param {!WebInspector.Event} event | 51 * @param {!WebInspector.Event} event |
50 */ | 52 */ |
51 _sourceMapAttached: function(event) | 53 _sourceMapAttached: function(event) |
52 { | 54 { |
53 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); | 55 var header = /** @type {!WebInspector.CSSStyleSheetHeader} */ (event.dat a); |
54 var sourceMap = this._cssModel.sourceMapForHeader(header); | 56 var sourceMap = this._cssModel.sourceMapForHeader(header); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 if (handledUISourceCodes.has(uiSourceCode)) | 92 if (handledUISourceCodes.has(uiSourceCode)) |
91 continue; | 93 continue; |
92 handledUISourceCodes.add(uiSourceCode); | 94 handledUISourceCodes.add(uiSourceCode); |
93 var sassText = /** @type {string} */(newSources.get(sourceURL)); | 95 var sassText = /** @type {string} */(newSources.get(sourceURL)); |
94 uiSourceCode.setWorkingCopy(sassText); | 96 uiSourceCode.setWorkingCopy(sassText); |
95 } | 97 } |
96 } | 98 } |
97 }, | 99 }, |
98 | 100 |
99 /** | 101 /** |
100 * @param {!WebInspector.CSSStyleSheetHeader} header | |
101 */ | |
102 addHeader: function(header) | |
103 { | |
104 if (!header.sourceMapURL) | |
105 return; | |
106 WebInspector.cssWorkspaceBinding.updateLocations(header); | |
107 }, | |
108 | |
109 /** | |
110 * @param {!WebInspector.CSSStyleSheetHeader} header | |
111 */ | |
112 removeHeader: function(header) | |
113 { | |
114 if (!header.sourceMapURL) | |
115 return; | |
116 WebInspector.cssWorkspaceBinding.updateLocations(header); | |
dgozman
2016/09/01 00:49:25
Who calls this now?
lushnikov
2016/09/01 01:34:34
SourceMapDetached will call this (if there was a s
| |
117 }, | |
118 | |
119 /** | |
120 * @param {!WebInspector.CSSLocation} rawLocation | 102 * @param {!WebInspector.CSSLocation} rawLocation |
121 * @return {?WebInspector.UILocation} | 103 * @return {?WebInspector.UILocation} |
122 */ | 104 */ |
123 rawLocationToUILocation: function(rawLocation) | 105 rawLocationToUILocation: function(rawLocation) |
124 { | 106 { |
125 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header()); | 107 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header()); |
126 if (!sourceMap) | 108 if (!sourceMap) |
127 return null; | 109 return null; |
128 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.colu mnNumber); | 110 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.colu mnNumber); |
129 if (!entry || !entry.sourceURL) | 111 if (!entry || !entry.sourceURL) |
130 return null; | 112 return null; |
131 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(entry.so urceURL, rawLocation.header()); | 113 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(entry.so urceURL, rawLocation.header()); |
132 if (!uiSourceCode) | 114 if (!uiSourceCode) |
133 return null; | 115 return null; |
134 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.source ColumnNumber); | 116 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.source ColumnNumber); |
135 }, | 117 }, |
118 | |
119 dispose: function() | |
120 { | |
121 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | |
122 } | |
136 } | 123 } |
OLD | NEW |