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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/SASSSourceMapping.js

Issue 2501883002: DevTools: kill Bindings.NetworkMapping (Closed)
Patch Set: rebaseline Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 Bindings.SASSSourceMapping = class { 34 Bindings.SASSSourceMapping = class {
35 /** 35 /**
36 * @param {!SDK.CSSModel} cssModel 36 * @param {!SDK.CSSModel} cssModel
37 * @param {!Bindings.NetworkMapping} networkMapping 37 * @param {!Workspace.Workspace} workspace
38 * @param {!Bindings.NetworkProject} networkProject 38 * @param {!Bindings.NetworkProject} networkProject
39 */ 39 */
40 constructor(cssModel, networkMapping, networkProject) { 40 constructor(cssModel, workspace, networkProject) {
41 this._cssModel = cssModel; 41 this._cssModel = cssModel;
42 this._networkProject = networkProject; 42 this._networkProject = networkProject;
43 this._networkMapping = networkMapping; 43 this._workspace = workspace;
44 this._eventListeners = [ 44 this._eventListeners = [
45 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapAttached, thi s._sourceMapAttached, this), 45 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapAttached, thi s._sourceMapAttached, this),
46 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapDetached, thi s._sourceMapDetached, this), 46 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapDetached, thi s._sourceMapDetached, this),
47 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapChanged, this ._sourceMapChanged, this) 47 this._cssModel.addEventListener(SDK.CSSModel.Events.SourceMapChanged, this ._sourceMapChanged, this)
48 ]; 48 ];
49 } 49 }
50 50
51 /** 51 /**
52 * @param {!Common.Event} event 52 * @param {!Common.Event} event
53 */ 53 */
(...skipping 22 matching lines...) Expand all
76 * @param {!Common.Event} event 76 * @param {!Common.Event} event
77 */ 77 */
78 _sourceMapChanged(event) { 78 _sourceMapChanged(event) {
79 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap); 79 var sourceMap = /** @type {!SDK.SourceMap} */ (event.data.sourceMap);
80 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ; 80 var newSources = /** @type {!Map<string, string>} */ (event.data.newSources) ;
81 var headers = this._cssModel.headersForSourceMap(sourceMap); 81 var headers = this._cssModel.headersForSourceMap(sourceMap);
82 var handledUISourceCodes = new Set(); 82 var handledUISourceCodes = new Set();
83 for (var header of headers) { 83 for (var header of headers) {
84 Bindings.cssWorkspaceBinding.updateLocations(header); 84 Bindings.cssWorkspaceBinding.updateLocations(header);
85 for (var sourceURL of newSources.keys()) { 85 for (var sourceURL of newSources.keys()) {
86 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(sourceUR L, header); 86 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this. _workspace, sourceURL, header);
87 if (!uiSourceCode) { 87 if (!uiSourceCode) {
88 console.error('Failed to update source for ' + sourceURL); 88 console.error('Failed to update source for ' + sourceURL);
89 continue; 89 continue;
90 } 90 }
91 if (handledUISourceCodes.has(uiSourceCode)) 91 if (handledUISourceCodes.has(uiSourceCode))
92 continue; 92 continue;
93 handledUISourceCodes.add(uiSourceCode); 93 handledUISourceCodes.add(uiSourceCode);
94 var sassText = /** @type {string} */ (newSources.get(sourceURL)); 94 var sassText = /** @type {string} */ (newSources.get(sourceURL));
95 uiSourceCode.setWorkingCopy(sassText); 95 uiSourceCode.setWorkingCopy(sassText);
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 /** 100 /**
101 * @param {!SDK.CSSLocation} rawLocation 101 * @param {!SDK.CSSLocation} rawLocation
102 * @return {?Workspace.UILocation} 102 * @return {?Workspace.UILocation}
103 */ 103 */
104 rawLocationToUILocation(rawLocation) { 104 rawLocationToUILocation(rawLocation) {
105 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header()); 105 var sourceMap = this._cssModel.sourceMapForHeader(rawLocation.header());
106 if (!sourceMap) 106 if (!sourceMap)
107 return null; 107 return null;
108 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber); 108 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber);
109 if (!entry || !entry.sourceURL) 109 if (!entry || !entry.sourceURL)
110 return null; 110 return null;
111 var uiSourceCode = this._networkMapping.uiSourceCodeForStyleURL(entry.source URL, rawLocation.header()); 111 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this._wor kspace, entry.sourceURL, rawLocation.header());
112 if (!uiSourceCode) 112 if (!uiSourceCode)
113 return null; 113 return null;
114 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber); 114 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber);
115 } 115 }
116 116
117 dispose() { 117 dispose() {
118 Common.EventTarget.removeEventListeners(this._eventListeners); 118 Common.EventTarget.removeEventListeners(this._eventListeners);
119 } 119 }
120 }; 120 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698