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

Unified 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 side-by-side diff with in-line comments
Download patch
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..4c45f448e6eb5c71578c5cf671c4b9aa0b7a9b4a 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,50 @@ 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) {
+ var sortedLocations = locations.map(location => this._debuggerWorkspaceBinding.rawLocationToUILocation(location));
+ sortedLocations = sortedLocations.filter(location => location && location.uiSourceCode === uiSourceCode);
+ sortedLocations.sort(WebInspector.UILocation.comparator);
+ 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())
+ continue;
+ result.push(sortedLocations[i]);
+ lastLocation = sortedLocations[i];
+ }
+ return result;
+ }
+ }
+
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
* @return {!Array.<!WebInspector.BreakpointManager.Breakpoint>}
*/
breakpointsForUISourceCode(uiSourceCode) {

Powered by Google App Engine
This is Rietveld 408576698