Commit 91f7b27
committed
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@main1 parent 1978c27 commit 91f7b27
File tree
27 files changed
+1346
-428
lines changed- LayoutTests/inspector
- debugger
- breakpoints
- resources
- resources
- unit-tests
- Source
- JavaScriptCore
- debugger
- inspector
- agents
- protocol
- WebInspectorUI
- UserInterface
- Base
- Controllers
- Models
- Views
27 files changed
+1346
-428
lines changedLines changed: 750 additions & 366 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
109 | 144 | | |
110 | 145 | | |
111 | 146 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
229 | 241 | | |
230 | 242 | | |
231 | 243 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
20 | 38 | | |
21 | 39 | | |
22 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
468 | 508 | | |
469 | 509 | | |
470 | 510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
34 | 62 | | |
35 | 63 | | |
36 | | - | |
| 64 | + | |
37 | 65 | | |
38 | 66 | | |
39 | 67 | | |
40 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
41 | 81 | | |
42 | 82 | | |
43 | 83 | | |
| |||
0 commit comments