Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js b/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js |
| index 7545f9916357d299cae2ec0bd24bd1b6e60136fd..45ba26769b90f353e2073fe891ca5c1d9b0f937a 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/bindings/BreakpointManager.js |
| @@ -270,6 +270,63 @@ WebInspector.BreakpointManager = class extends WebInspector.Object { |
| /** |
| * @param {!WebInspector.UISourceCode} uiSourceCode |
| + * @param {!WebInspector.TextRange} textRange |
| + * @return {!Promise<!Array<!WebInspector.UILocation>>} |
| + */ |
| + possibleBreakpoints(uiSourceCode, textRange) { |
| + var targets = this._targetManager.targets(WebInspector.Target.Capability.JS); |
| + if (!targets.length) |
| + return Promise.resolve([]); |
| + for (var target of targets) { |
| + var startLocation = this._debuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode, textRange.startLine, textRange.startColumn); |
| + if (!startLocation) |
| + continue; |
| + var endLocation = this._debuggerWorkspaceBinding.uiLocationToRawLocation(target, uiSourceCode, textRange.endLine, textRange.endColumn); |
| + if (!endLocation) |
| + continue; |
| + var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
| + return debuggerModel.getPossibleBreakpoints(startLocation, endLocation).then(toUILocations.bind(this)); |
| + } |
| + return Promise.resolve([]); |
| + |
| + /** |
| + * @this {!WebInspector.BreakpointManager} |
| + * @param {!Array<!WebInspector.DebuggerModel.Location>} locations |
| + * @return {!Array<!WebInspector.UILocation>} |
| + */ |
| + function toUILocations(locations) |
| + { |
|
dgozman
2016/11/09 20:44:03
{ on the previous line
kozy
2016/11/10 03:17:36
Done.
|
| + var sortedLocations = locations.map(location => this._debuggerWorkspaceBinding.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
|
| + sortedLocations = sortedLocations.filter(location => location.uiSourceCode === uiSourceCode); |
| + sortedLocations.sort(compareLocations); |
| + if (!sortedLocations.length) |
| + return []; |
| + var result = [ sortedLocations[0] ]; |
| + var lastLocation = sortedLocations[0]; |
| + for (var i = 1; i < sortedLocations.length; ++i) { |
| + 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
|
| + continue; |
| + result.push(sortedLocations[i]); |
| + lastLocation = sortedLocations[i]; |
| + } |
| + return result; |
| + } |
| + |
| + /** |
| + * @param {!WebInspector.UILocation} first |
| + * @param {!WebInspector.UILocation} second |
| + * @return {number} |
| + */ |
| + 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.
|
| + { |
| + if (first.lineNumber !== second.lineNumber) |
| + return first.lineNumber - second.lineNumber; |
| + return first.columnNumber - second.columnNumber; |
| + } |
| + } |
| + |
| + /** |
| + * @param {!WebInspector.UISourceCode} uiSourceCode |
| * @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>} |
| */ |
| breakpointsForUISourceCode(uiSourceCode) { |