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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourceFormatter.js

Issue 2857453002: DevTools: support resolving a UILocation to multiple raw script locations (Closed)
Patch Set: get rid of uniqueScriptId() 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 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Sources.SourceFormatData = class { 5 Sources.SourceFormatData = class {
6 /** 6 /**
7 * @param {!Workspace.UISourceCode} originalSourceCode 7 * @param {!Workspace.UISourceCode} originalSourceCode
8 * @param {!Workspace.UISourceCode} formattedSourceCode 8 * @param {!Workspace.UISourceCode} formattedSourceCode
9 * @param {!Sources.FormatterSourceMapping} mapping 9 * @param {!Sources.FormatterSourceMapping} mapping
10 */ 10 */
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 var columnNumber = rawLocation.columnNumber || 0; 148 var columnNumber = rawLocation.columnNumber || 0;
149 var formattedLocation = formatData.mapping.originalToFormatted(lineNumber, c olumnNumber); 149 var formattedLocation = formatData.mapping.originalToFormatted(lineNumber, c olumnNumber);
150 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma ttedLocation[1]); 150 return formatData.formattedSourceCode.uiLocation(formattedLocation[0], forma ttedLocation[1]);
151 } 151 }
152 152
153 /** 153 /**
154 * @override 154 * @override
155 * @param {!Workspace.UISourceCode} uiSourceCode 155 * @param {!Workspace.UISourceCode} uiSourceCode
156 * @param {number} lineNumber 156 * @param {number} lineNumber
157 * @param {number} columnNumber 157 * @param {number} columnNumber
158 * @return {?SDK.DebuggerModel.Location} 158 * @return {!Array<!SDK.DebuggerModel.Location>}
159 */ 159 */
160 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { 160 uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
161 var formatData = Sources.SourceFormatData._for(uiSourceCode); 161 var formatData = Sources.SourceFormatData._for(uiSourceCode);
162 if (!formatData) 162 if (!formatData)
163 return null; 163 return [];
164 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co lumnNumber); 164 var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, co lumnNumber);
165 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode); 165 var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode);
166 if (!scripts.length) 166 if (!scripts.length)
167 return null; 167 return [];
168 return scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocati on[0], originalLocation[1]); 168 var location = scripts[0].debuggerModel.createRawLocation(scripts[0], origin alLocation[0], originalLocation[1]);
169 return location ? [location] : [];
169 } 170 }
170 171
171 /** 172 /**
172 * @override 173 * @override
173 * @return {boolean} 174 * @return {boolean}
174 */ 175 */
175 isIdentity() { 176 isIdentity() {
176 return false; 177 return false;
177 } 178 }
178 179
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (uiSourceCode.contentType() === Common.resourceTypes.Document) { 219 if (uiSourceCode.contentType() === Common.resourceTypes.Document) {
219 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); 220 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);
220 var debuggerModel = target && target.model(SDK.DebuggerModel); 221 var debuggerModel = target && target.model(SDK.DebuggerModel);
221 if (debuggerModel) { 222 if (debuggerModel) {
222 var scripts = debuggerModel.scriptsForSourceURL(uiSourceCode.url()) 223 var scripts = debuggerModel.scriptsForSourceURL(uiSourceCode.url())
223 .filter(script => script.isInlineScript() && !script.h asSourceURL); 224 .filter(script => script.isInlineScript() && !script.h asSourceURL);
224 return scripts; 225 return scripts;
225 } 226 }
226 } 227 }
227 if (uiSourceCode.contentType().isScript()) { 228 if (uiSourceCode.contentType().isScript()) {
228 var rawLocation = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocatio n(uiSourceCode, 0, 0); 229 return Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSource Code, 0, 0)
229 if (rawLocation) 230 .map(location => location.script());
230 return [rawLocation.script()];
231 } 231 }
232 return []; 232 return [];
233 } 233 }
234 }; 234 };
235 235
236 /** 236 /**
237 * @implements {Bindings.CSSWorkspaceBinding.SourceMapping} 237 * @implements {Bindings.CSSWorkspaceBinding.SourceMapping}
238 */ 238 */
239 Sources.SourceFormatter.StyleMapping = class { 239 Sources.SourceFormatter.StyleMapping = class {
240 constructor() { 240 constructor() {
(...skipping 26 matching lines...) Expand all
267 return; 267 return;
268 if (enable) 268 if (enable)
269 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData; 269 styleHeader[Sources.SourceFormatData._formatDataSymbol] = formatData;
270 else 270 else
271 delete styleHeader[Sources.SourceFormatData._formatDataSymbol]; 271 delete styleHeader[Sources.SourceFormatData._formatDataSymbol];
272 Bindings.cssWorkspaceBinding.updateLocations(styleHeader); 272 Bindings.cssWorkspaceBinding.updateLocations(styleHeader);
273 } 273 }
274 }; 274 };
275 275
276 Sources.sourceFormatter = new Sources.SourceFormatter(); 276 Sources.sourceFormatter = new Sources.SourceFormatter();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698