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

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

Issue 2484283004: [DevTools] added BreakpointManager.possibleBreakpoints method (Closed)
Patch Set: addressed comments 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 var sortedLocations = locations.map(location => this._debuggerWorkspaceBin ding.rawLocationToUILocation(location));
299 sortedLocations = sortedLocations.filter(location => location && location. uiSourceCode === uiSourceCode);
300 sortedLocations.sort(WebInspector.UILocation.comparator);
301 if (!sortedLocations.length)
302 return [];
303 var result = [ sortedLocations[0] ];
304 var lastLocation = sortedLocations[0];
305 for (var i = 1; i < sortedLocations.length; ++i) {
306 if (sortedLocations[i].id() === lastLocation.id())
307 continue;
308 result.push(sortedLocations[i]);
309 lastLocation = sortedLocations[i];
310 }
311 return result;
312 }
313 }
314
315 /**
316 * @param {!WebInspector.UISourceCode} uiSourceCode
273 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>} 317 * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>}
274 */ 318 */
275 breakpointsForUISourceCode(uiSourceCode) { 319 breakpointsForUISourceCode(uiSourceCode) {
276 var result = []; 320 var result = [];
277 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceC ode); 321 var uiSourceCodeBreakpoints = this._breakpointsForUISourceCode.get(uiSourceC ode);
278 var breakpoints = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.valuesAr ray() : []; 322 var breakpoints = uiSourceCodeBreakpoints ? uiSourceCodeBreakpoints.valuesAr ray() : [];
279 for (var i = 0; i < breakpoints.length; ++i) { 323 for (var i = 0; i < breakpoints.length; ++i) {
280 var lineBreakpoints = breakpoints[i]; 324 var lineBreakpoints = breakpoints[i];
281 var columnBreakpointArrays = lineBreakpoints ? lineBreakpoints.valuesArray () : []; 325 var columnBreakpointArrays = lineBreakpoints ? lineBreakpoints.valuesArray () : [];
282 result = result.concat.apply(result, columnBreakpointArrays); 326 result = result.concat.apply(result, columnBreakpointArrays);
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 this.sourceFileId = breakpoint._sourceFileId; 1091 this.sourceFileId = breakpoint._sourceFileId;
1048 this.lineNumber = breakpoint.lineNumber(); 1092 this.lineNumber = breakpoint.lineNumber();
1049 this.columnNumber = breakpoint.columnNumber(); 1093 this.columnNumber = breakpoint.columnNumber();
1050 this.condition = breakpoint.condition(); 1094 this.condition = breakpoint.condition();
1051 this.enabled = breakpoint.enabled(); 1095 this.enabled = breakpoint.enabled();
1052 } 1096 }
1053 }; 1097 };
1054 1098
1055 /** @type {!WebInspector.BreakpointManager} */ 1099 /** @type {!WebInspector.BreakpointManager} */
1056 WebInspector.breakpointManager; 1100 WebInspector.breakpointManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698