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

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

Issue 2856233002: DevTools: support uiLocationToRawLocations for CSS (Closed)
Patch Set: Created 3 years, 7 months 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 this._sourceMapIdToHeaders.set(sourceMapId, header); 80 this._sourceMapIdToHeaders.set(sourceMapId, header);
81 this._sourceMapAttachedForTest(sourceMap); 81 this._sourceMapAttachedForTest(sourceMap);
82 return; 82 return;
83 } 83 }
84 this._sourceMapIdToHeaders.set(sourceMapId, header); 84 this._sourceMapIdToHeaders.set(sourceMapId, header);
85 85
86 for (var sassURL of sourceMap.sourceURLs()) { 86 for (var sassURL of sourceMap.sourceURLs()) {
87 var contentProvider = sourceMap.sourceContentProvider(sassURL, Common.reso urceTypes.SourceMapStyleSheet); 87 var contentProvider = sourceMap.sourceContentProvider(sassURL, Common.reso urceTypes.SourceMapStyleSheet);
88 var embeddedContent = sourceMap.embeddedContentByURL(sassURL); 88 var embeddedContent = sourceMap.embeddedContentByURL(sassURL);
89 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null; 89 var embeddedContentLength = typeof embeddedContent === 'string' ? embedded Content.length : null;
90 this._networkProject.addSourceMapFile(contentProvider, header.frameId, fal se, embeddedContentLength); 90 var uiSourceCode =
91 this._networkProject.addSourceMapFile(contentProvider, header.frameId, false, embeddedContentLength);
92 uiSourceCode[Bindings.SASSSourceMapping._sourceMapSymbol] = sourceMap;
91 } 93 }
92 Bindings.cssWorkspaceBinding.updateLocations(header); 94 Bindings.cssWorkspaceBinding.updateLocations(header);
93 this._sourceMapAttachedForTest(sourceMap); 95 this._sourceMapAttachedForTest(sourceMap);
94 } 96 }
95 97
96 /** 98 /**
97 * @param {!Common.Event} event 99 * @param {!Common.Event} event
98 */ 100 */
99 _sourceMapDetached(event) { 101 _sourceMapDetached(event) {
100 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data.client); 102 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data.client);
(...skipping 19 matching lines...) Expand all
120 Bindings.cssWorkspaceBinding.updateLocations(header); 122 Bindings.cssWorkspaceBinding.updateLocations(header);
121 for (var sourceURL of newSources.keys()) { 123 for (var sourceURL of newSources.keys()) {
122 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this. _workspace, sourceURL, header); 124 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this. _workspace, sourceURL, header);
123 if (!uiSourceCode) { 125 if (!uiSourceCode) {
124 console.error('Failed to update source for ' + sourceURL); 126 console.error('Failed to update source for ' + sourceURL);
125 continue; 127 continue;
126 } 128 }
127 if (handledUISourceCodes.has(uiSourceCode)) 129 if (handledUISourceCodes.has(uiSourceCode))
128 continue; 130 continue;
129 handledUISourceCodes.add(uiSourceCode); 131 handledUISourceCodes.add(uiSourceCode);
132 uiSourceCode[Bindings.SASSSourceMapping._sourceMapSymbol] = sourceMap;
130 var sassText = /** @type {string} */ (newSources.get(sourceURL)); 133 var sassText = /** @type {string} */ (newSources.get(sourceURL));
131 uiSourceCode.setWorkingCopy(sassText); 134 uiSourceCode.setWorkingCopy(sassText);
132 } 135 }
133 } 136 }
134 } 137 }
135 138
136 /** 139 /**
137 * @override 140 * @override
138 * @param {!SDK.CSSLocation} rawLocation 141 * @param {!SDK.CSSLocation} rawLocation
139 * @return {?Workspace.UILocation} 142 * @return {?Workspace.UILocation}
140 */ 143 */
141 rawLocationToUILocation(rawLocation) { 144 rawLocationToUILocation(rawLocation) {
142 var header = rawLocation.header(); 145 var header = rawLocation.header();
143 if (!header) 146 if (!header)
144 return null; 147 return null;
145 var sourceMap = this._sourceMapManager.sourceMapForClient(header); 148 var sourceMap = this._sourceMapManager.sourceMapForClient(header);
146 if (!sourceMap) 149 if (!sourceMap)
147 return null; 150 return null;
148 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber); 151 var entry = sourceMap.findEntry(rawLocation.lineNumber, rawLocation.columnNu mber);
149 if (!entry || !entry.sourceURL) 152 if (!entry || !entry.sourceURL)
150 return null; 153 return null;
151 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this._wor kspace, entry.sourceURL, header); 154 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForStyleURL(this._wor kspace, entry.sourceURL, header);
152 if (!uiSourceCode) 155 if (!uiSourceCode)
153 return null; 156 return null;
154 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber); 157 return uiSourceCode.uiLocation(entry.sourceLineNumber || 0, entry.sourceColu mnNumber);
155 } 158 }
156 159
160 /**
161 * @override
162 * @param {!Workspace.UILocation} uiLocation
163 * @return {!Array<!SDK.CSSLocation>}
164 */
165 uiLocationToRawLocations(uiLocation) {
166 var sourceMap = uiLocation.uiSourceCode[Bindings.SASSSourceMapping._sourceMa pSymbol];
167 if (!sourceMap)
168 return [];
169 var headers = this._sourceMapManager.clientsForSourceMap(sourceMap);
170 var entry =
171 sourceMap.findReverseEntry(uiLocation.uiSourceCode.url(), uiLocation.lin eNumber, uiLocation.columnNumber);
dgozman 2017/05/04 00:04:56 Could there be multiple?
172 return headers.map(header => new SDK.CSSLocation(header, entry.lineNumber, e ntry.columnNumber));
173 }
174
157 dispose() { 175 dispose() {
158 Common.EventTarget.removeEventListeners(this._eventListeners); 176 Common.EventTarget.removeEventListeners(this._eventListeners);
159 } 177 }
160 }; 178 };
179
180 Bindings.SASSSourceMapping._sourceMapSymbol = Symbol('sourceMap');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698