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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 2881893002: [DevTools] Support async step in from arbitrary position (Closed)
Patch Set: addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
index 871728aee8367a93d3d38f24ae44c29966f1355d..ad3581c54551ae349ed98dcf2c456a2d55912f45 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
@@ -516,12 +516,27 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
this._showContinueToLocations();
}
if (this._continueToLocationDecorations) {
- this.textEditor.element.classList.toggle(
- 'source-frame-async-step-in-hovered',
- !!event.target.enclosingNodeOrSelfWithClass('source-frame-async-step-in'));
+ var textPosition = this.textEditor.coordinatesToCursorPosition(event.x, event.y);
+ var hovering = !!event.target.enclosingNodeOrSelfWithClass('source-frame-async-step-in');
+ this._setAsyncStepInHoveredLine(textPosition ? textPosition.startLine : null, hovering);
}
}
+ /**
+ * @param {?number} line
+ * @param {boolean} hovered
+ */
+ _setAsyncStepInHoveredLine(line, hovered) {
+ if (this._asyncStepInHoveredLine === line && this._asyncStepInHovered === hovered)
+ return;
+ if (this._asyncStepInHovered && this._asyncStepInHoveredLine)
+ this.textEditor.toggleLineClass(this._asyncStepInHoveredLine, 'source-frame-async-step-in-hovered', false);
+ this._asyncStepInHoveredLine = line;
+ this._asyncStepInHovered = hovered;
+ if (this._asyncStepInHovered && this._asyncStepInHoveredLine)
+ this.textEditor.toggleLineClass(this._asyncStepInHoveredLine, 'source-frame-async-step-in-hovered', true);
+ }
+
/**
* @param {!MouseEvent} event
*/
@@ -724,7 +739,7 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
tokenContent === 'setTimeout' || tokenContent === 'setInterval';
var isCurrentPosition = this._executionLocation && lineNumber === this._executionLocation.lineNumber &&
location.columnNumber === this._executionLocation.columnNumber;
- if (location.type === Protocol.Debugger.BreakLocationType.Call && isAsyncCall && isCurrentPosition) {
+ if (location.type === Protocol.Debugger.BreakLocationType.Call && isAsyncCall) {
var functionPosition = line.indexOf('(', token.endColumn);
if (functionPosition !== -1) {
functionPosition++;
@@ -739,10 +754,8 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
highlightRange =
new TextUtils.TextRange(lineNumber, nextToken.startColumn, lineNumber, nextToken.endColumn - 1);
decoration = this.textEditor.highlightRange(highlightRange, 'source-frame-async-step-in');
- this._continueToLocationDecorations.set(decoration, () => {
- debuggerModel.scheduleStepIntoAsync();
- debuggerModel.stepInto();
- });
+ this._continueToLocationDecorations.set(
+ decoration, this._asyncStepIn.bind(this, location, isCurrentPosition));
}
}
}
@@ -750,6 +763,22 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
}
}
+ /**
+ * @param {!SDK.DebuggerModel.BreakLocation} location
+ * @param {boolean} isCurrentPosition
+ */
+ _asyncStepIn(location, isCurrentPosition) {
+ if (!isCurrentPosition)
+ location.continueToLocation(asyncStepIn);
+ else
+ asyncStepIn();
+
+ function asyncStepIn() {
+ location.debuggerModel.scheduleStepIntoAsync();
+ location.debuggerModel.stepInto();
+ }
+ }
+
/**
* @param {!SDK.DebuggerModel.CallFrame} callFrame
* @param {?Array.<!SDK.RemoteObjectProperty>} properties
@@ -920,7 +949,7 @@ Sources.JavaScriptSourceFrame = class extends SourceFrame.UISourceCodeFrame {
for (var decoration of this._continueToLocationDecorations.keys())
this.textEditor.removeHighlight(decoration);
this._continueToLocationDecorations = null;
- this.textEditor.element.classList.remove('source-frame-async-step-in-hovered');
+ this._setAsyncStepInHoveredLine(null, false);
});
}

Powered by Google App Engine
This is Rietveld 408576698