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

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

Issue 2484283004: [DevTools] added BreakpointManager.possibleBreakpoints method (Closed)
Patch Set: rebased tests 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 */ 263 */
264 findBreakpoint(uiSourceCode, lineNumber, columnNumber) { 264 findBreakpoint(uiSourceCode, lineNumber, columnNumber) {
265 var breakpoints = this._breakpointsForUISourceCode.get(uiSourceCode); 265 var breakpoints = this._breakpointsForUISourceCode.get(uiSourceCode);
266 var lineBreakpoints = breakpoints ? breakpoints.get(lineNumber) : null; 266 var lineBreakpoints = breakpoints ? breakpoints.get(lineNumber) : null;
267 var columnBreakpoints = lineBreakpoints ? lineBreakpoints.get(columnNumber) : null; 267 var columnBreakpoints = lineBreakpoints ? lineBreakpoints.get(columnNumber) : null;
268 return columnBreakpoints ? columnBreakpoints[0] : null; 268 return columnBreakpoints ? columnBreakpoints[0] : null;
269 } 269 }
270 270
271 /** 271 /**
272 * @param {!WebInspector.UISourceCode} uiSourceCode 272 * @param {!WebInspector.UISourceCode} uiSourceCode
273 * @param {!WebInspector.TextRange} textRange
274 * @return {!Promise<!Array<!WebInspector.UILocation>>}
275 */
276 possibleBreakpoints(uiSourceCode, textRange) {
277 var targets = this._targetManager.targets(WebInspector.Target.Capability.JS) ;
278 if (!targets.length)
279 return Promise.resolve([]);
280 for (var target of targets) {
281 var startLocation = this._debuggerWorkspaceBinding.uiLocationToRawLocation (target, uiSourceCode, textRange.startLine, textRange.startColumn);
282 if (!startLocation)
283 continue;
284 var endLocation = this._debuggerWorkspaceBinding.uiLocationToRawLocation(t arget, uiSourceCode, textRange.endLine, textRange.endColumn);
285 if (!endLocation)
286 continue;
287 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target);
288 return debuggerModel.getPossibleBreakpoints(startLocation, endLocation).th en(toUILocations.bind(this));
289 }
290 return Promise.resolve([]);
291
292 /**
293 * @this {!WebInspector.BreakpointManager}
294 * @param {!Array<!WebInspector.DebuggerModel.Location>} locations
295 * @return {!Array<!WebInspector.UILocation>}
296 */
297 function toUILocations(locations)
298 {
dgozman 2016/11/09 20:44:03 { on the previous line
kozy 2016/11/10 03:17:36 Done.
299 var sortedLocations = locations.map(location => this._debuggerWorkspaceBin ding.rawLocationToUILocation(location));
dgozman 2016/11/09 20:44:03 Could rawLocationToUILocation return null?
kozy 2016/11/10 03:17:36 No, there are asserts in our code base that it sho
300 sortedLocations = sortedLocations.filter(location => location.uiSourceCode === uiSourceCode);
301 sortedLocations.sort(compareLocations);
302 if (!sortedLocations.length)
303 return [];
304 var result = [ sortedLocations[0] ];
305 var lastLocation = sortedLocations[0];
306 for (var i = 1; i < sortedLocations.length; ++i) {
307 if (sortedLocations[i].id() === lastLocation.id())
dgozman 2016/11/09 20:44:03 How could this happen?
kozy 2016/11/10 03:17:36 SourceMap maps two different raw location to one U
308 continue;
309 result.push(sortedLocations[i]);
310 lastLocation = sortedLocations[i];
311 }
312 return result;
313 }
314
315 /**
316 * @param {!WebInspector.UILocation} first
317 * @param {!WebInspector.UILocation} second
318 * @return {number}
319 */
320 function compareLocations(first, second)
dgozman 2016/11/09 20:44:03 Don't we have a comparator on UILocation? If not,
kozy 2016/11/10 03:17:36 Done.
321 {
322 if (first.lineNumber !== second.lineNumber)
323 return first.lineNumber - second.lineNumber;
324 return first.columnNumber - second.columnNumber;
325 }
326 }
327
328 /**
329 * @param {!WebInspector.UISourceCode} uiSourceCode
273 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>} 330 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>}
274 */ 331 */
275 breakpointsForUISourceCode(uiSourceCode) { 332 breakpointsForUISourceCode(uiSourceCode) {
276 var result = []; 333 var result = [];
277 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceC ode); 334 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceC ode);
278 var breakpoints = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.valuesAr ray() : []; 335 var breakpoints = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.valuesAr ray() : [];
279 for (var i = 0; i < breakpoints.length; ++i) { 336 for (var i = 0; i < breakpoints.length; ++i) {
280 var lineBreakpoints = breakpoints[i]; 337 var lineBreakpoints = breakpoints[i];
281 var columnBreakpointArrays = lineBreakpoints ? lineBreakpoints.valuesArray () : []; 338 var columnBreakpointArrays = lineBreakpoints ? lineBreakpoints.valuesArray () : [];
282 result = result.concat.apply(result, columnBreakpointArrays); 339 result = result.concat.apply(result, columnBreakpointArrays);
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 this.sourceFileId = breakpoint._sourceFileId; 1104 this.sourceFileId = breakpoint._sourceFileId;
1048 this.lineNumber = breakpoint.lineNumber(); 1105 this.lineNumber = breakpoint.lineNumber();
1049 this.columnNumber = breakpoint.columnNumber(); 1106 this.columnNumber = breakpoint.columnNumber();
1050 this.condition = breakpoint.condition(); 1107 this.condition = breakpoint.condition();
1051 this.enabled = breakpoint.enabled(); 1108 this.enabled = breakpoint.enabled();
1052 } 1109 }
1053 }; 1110 };
1054 1111
1055 /** @type {!WebInspector.BreakpointManager} */ 1112 /** @type {!WebInspector.BreakpointManager} */
1056 WebInspector.breakpointManager; 1113 WebInspector.breakpointManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698