Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Web Inspector: Implement inline breakpoints.
https://bugs.webkit.org/show_bug.cgi?id=197977 <rdar://problem/50903783> Reviewed by Patrick Angle. This will allow developers more flexibility with JS breakpoints since JS can frequently pack lots of logic onto a single line. For example, ``` |setTimeout(() => { |a(); |b(); |}) ``` has pause locations at each `|`, so developers should be able to set a breakpoint there. Previously, only the first `|` was a valid pause location (unless the file is pretty printed such that the nested inline function is reformatted onto multiple lines) because adding a breakpoint via the text editor gutter will only attempt to add a breakpoint on the first column of that line. * Source/JavaScriptCore/inspector/protocol/Debugger.json: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h: * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::InspectorDebuggerAgent::getBreakpointLocations): Added. * Source/JavaScriptCore/debugger/Debugger.h: * Source/JavaScriptCore/debugger/Debugger.cpp: (JSC::Debugger::forEachBreakpointLocation): Added. * Source/JavaScriptCore/debugger/DebuggerParseData.h: * Source/JavaScriptCore/debugger/DebuggerParseData.cpp: (JSC::DebuggerPausePositions::forEachBreakpointLocation): Added. (JSC::DebuggerPausePositions::firstPositionAfter): Added. (JSC::DebuggerPausePositions::breakpointLocationForLineColumn): * Source/WebInspectorUI/UserInterface/Models/Script.js: (WI.Script.prototype.async breakpointLocations): Added. Add a way for the frontend to get all breakpoint locations between two positions. * Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js: (WI.SourceCodeTextEditor): (WI.SourceCodeTextEditor.prototype._editorPositionForSourceCodeLocation): Added. (WI.SourceCodeTextEditor.prototype._editorLineInfoForSourceCodeLocation): (WI.SourceCodeTextEditor.prototype._editorLineInfoForEditorPosition): Added. (WI.SourceCodeTextEditor.prototype._addBreakpointWithEditorLineInfo): (WI.SourceCodeTextEditor.prototype._removeBreakpointWithEditorLineInfo): (WI.SourceCodeTextEditor.prototype._prepareEditorForInitialContent): (WI.SourceCodeTextEditor.prototype.async _addBreakpointWidgetsForLine): Added. (WI.SourceCodeTextEditor.prototype._removeBreakpointWidgetsForLine): Added. (WI.SourceCodeTextEditor.prototype._removeBreakpointWidgets): Added. (WI.SourceCodeTextEditor.prototype.textEditorBreakpointRemoved): (WI.SourceCodeTextEditor.prototype.textEditorBreakpointClicked): (WI.SourceCodeTextEditor.prototype._handleFormatterDidChange): * Source/WebInspectorUI/UserInterface/Views/BreakpointInlineWidget.js: Added. (WI.BreakpointInlineWidget): (WI.BreakpointInlineWidget.prototype.get element): (WI.BreakpointInlineWidget.prototype.get sourceCodeLocation): (WI.BreakpointInlineWidget.prototype.get breakpoint): (WI.BreakpointInlineWidget.prototype._update): (WI.BreakpointInlineWidget.prototype._handleClick): * Source/WebInspectorUI/UserInterface/Views/BreakpointInlineWidget.css: Added. (.inline-widget.breakpoint): (.inline-widget.breakpoint:not(.disabled)): (.inline-widget.breakpoint.disabled): Add inline widgets for each breakpoint location on a given line after the first breakpoint is added for that line. Clicking these widgets will add/remove a breakpoint at that location, until there are no breakpoints left at which point all of the widgets are removed from the line. Reformatting will recalculate the definition of "line". * Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js: (WI.DebuggerManager.prototype.breakpointsForSourceCodeLocation): Added. (WI.DebuggerManager.prototype.breakpointResolved): (WI.DebuggerManager.prototype.globalObjectCleared): (WI.DebuggerManager.prototype._setBreakpoint): * Source/WebInspectorUI/UserInterface/Models/JavaScriptBreakpoint.js: (WI.JavaScriptBreakpoint.prototype.get resolvedLocations): Added. (WI.JavaScriptBreakpoint.prototype.addResolvedLocation): Added. (WI.JavaScriptBreakpoint.prototype.hasResolvedLocation): Added. (WI.JavaScriptBreakpoint.prototype.clearResolvedLocations): Added. Keep track of all resolved locations each time a JS breakpoint is set. This allows for inline widgets to see if there are any existing breakponts that match the related location, using that instead of creating a new breakpoint. * Source/WebInspectorUI/UserInterface/Models/SourceCodeLocation.js: (WI.SourceCodeLocation.prototype.isEqual): (WI.SourceCodeLocation.prototype.isEqual.resolveSourceCode): Added. * Source/WebInspectorUI/UserInterface/Models/LazySourceCodeLocation.js: (WI.LazySourceCodeLocation.prototype.isEqual): Deleted. If a `WI.Script` is mapped to a `WI.Resource` it should be considered as equal. This allows for the initial breakpoint set on a line to map to the inline widget that is added for the resolved location, since the initial breakpoint can be set with a `WI.Resource` while all breakpoint locations will use the first related `WI.Script`. * Source/WebInspectorUI/UserInterface/Views/TextEditor.js: (WI.TextEditor.prototype._gutterMouseDown): (WI.TextEditor.prototype._documentMouseMoved): (WI.TextEditor.prototype._documentMouseUp): Allow for clicking/dragging the gutter icon when there are multiple breakpoints on the same line. Unlike when there's only a single breakpoint, however, dragging to another line will instead remove all breakpoints for that line. * Source/WebInspectorUI/UserInterface/Base/Utilities.js: (nullish): Added. (Array.prototype.firstValue): Added. (Set.prototype.filter): Added. * Source/WebInspectorUI/.eslintrc: * LayoutTests/inspector/unit-tests/array-utilities.html: * LayoutTests/inspector/unit-tests/array-utilities-expected.txt: * LayoutTests/inspector/unit-tests/set-utilities.html: * LayoutTests/inspector/unit-tests/set-utilities-expected.txt: Add utility functions for `Array.prototype.firstValue` and `Set.prototype.filter` to make it easier to use `Array` and `Set` interchangeably. * Source/WebInspectorUI/UserInterface/Models/SourceCodePosition.js: (WI.SourceCodePosition): Drive-by: Fix typo. * Source/WebInspectorUI/UserInterface/Main.html: * LayoutTests/inspector/debugger/breakpoints/resources/dump.js: (TestPage.registerInitializer.window.addDumpEachLinePauseLocationTestCase): Added. * LayoutTests/inspector/debugger/resources/log-pause-location.js: (TestPage.registerInitializer.window.logResolvedBreakpointLocationsInRange): Added. * LayoutTests/inspector/debugger/breakpoints/resolved-dump-each-line-expected.txt: Canonical link: https://commits.webkit.org/254015@main
- Loading branch information
Showing
27 changed files
with
1,346 additions
and
428 deletions.
There are no files selected for viewing
1,116 changes: 750 additions & 366 deletions
1,116
LayoutTests/inspector/debugger/breakpoints/resolved-dump-each-line-expected.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.