Skip to content
Permalink
Browse files
Web Inspector: Inline breakpoint indicators appear for every line aft…
…er refresh+hitting a breakpoint

https://bugs.webkit.org/show_bug.cgi?id=246117

Reviewed by Patrick Angle.

When dealing with minified code, although Web Inspector will attempt to automatically pretty-print,
this happens after the initial content is shown. As a result, any attempt to use the formatter
source map created for pretty-printing will fail, meaning that attempting to map locations will
always result in the original location. This means that the range given to `Debugger.getBreakpointLocations`
will (likely) be the entire file since (most of) the content will be on the first line.

Instead, have the frontend only fetch the entire line if the code is not minified or if it's been
pretty-printed.

* Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype._prepareEditorForInitialContent):
(WI.SourceCodeTextEditor.prototype.async _addBreakpointWidgetsForLine):
Ensure that `_isProbablyMinified` is set before attempting to (re)show breakpoints after recieving
the initial content.

Canonical link: https://commits.webkit.org/255200@main
  • Loading branch information
dcrousso committed Oct 6, 2022
1 parent b770db0 commit aef0fd4fa3ee6ff6676045658292b246cd93887f
Showing 1 changed file with 16 additions and 14 deletions.
@@ -555,19 +555,6 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
if (this._contentPopulated)
return;

if (this._supportsDebugging) {
this._removeBreakpointWidgets();

this._breakpointMap = {};

for (let breakpoint of WI.debuggerManager.breakpointsForSourceCode(this._sourceCode)) {
console.assert(this._matchesBreakpoint(breakpoint));
var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
this._addBreakpointWithEditorLineInfo(breakpoint, lineInfo);
this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
}
}

if (this._sourceCode instanceof WI.Resource)
this.mimeType = this._sourceCode.syntheticMIMEType;
else if (this._sourceCode instanceof WI.Script)
@@ -581,6 +568,19 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
this._autoFormat = true;
this._isProbablyMinified = true;
}

if (this._supportsDebugging) {
this._removeBreakpointWidgets();

this._breakpointMap = {};

for (let breakpoint of WI.debuggerManager.breakpointsForSourceCode(this._sourceCode)) {
console.assert(this._matchesBreakpoint(breakpoint));
var lineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
this._addBreakpointWithEditorLineInfo(breakpoint, lineInfo);
this.setBreakpointInfoForLineAndColumn(lineInfo.lineNumber, lineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
}
}
}

_contentAvailable(parameters)
@@ -743,7 +743,9 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
if (!script)
return;

let endPosition = this.currentPositionToOriginalPosition(new WI.SourceCodePosition(lineNumber + 1, 0));
// If the current content is minified code, only show pause locations within 100 characters.
let limitLocations = this._isProbablyMinified && !this.formatterSourceMap;
let endPosition = this.currentPositionToOriginalPosition(new WI.SourceCodePosition(limitLocations ? lineNumber : (lineNumber + 1), limitLocations ? 100 : 0));
console.assert(script === this._getAssociatedScript(endPosition), script);

let locations = await script.breakpointLocations(startPosition, endPosition);

0 comments on commit aef0fd4

Please sign in to comment.