Changeset 247639 in webkit


Ignore:
Timestamp:
Jul 19, 2019 12:39:12 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Issues toggling multiple breakpoints on one line
https://bugs.webkit.org/show_bug.cgi?id=199918

Reviewed by Joseph Pecoraro.

  • UserInterface/Views/SourceCodeTextEditor.js:

(WI.SourceCodeTextEditor):
(WI.SourceCodeTextEditor.prototype.close):
(WI.SourceCodeTextEditor.prototype.textEditorGutterContextMenu):
(WI.SourceCodeTextEditor.prototype.textEditorUpdatedFormatting):
(WI.SourceCodeTextEditor.prototype._handleFormatterDidChange): Added.
Listen for WI.SourceCode.Event.FormatterDidChange events as there may be multiple content
views for the same WI.SourceCode. Previously, if there were, only the active one would
properly update it's "line -> column -> breakpoint" mapping, causing an error to be thrown
when the non-active content views tried to retrieve the breakpoint for the new line/column.

Location:
trunk/Source/WebInspectorUI
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r247533 r247639  
     12019-07-19  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Issues toggling multiple breakpoints on one line
     4        https://bugs.webkit.org/show_bug.cgi?id=199918
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Views/SourceCodeTextEditor.js:
     9        (WI.SourceCodeTextEditor):
     10        (WI.SourceCodeTextEditor.prototype.close):
     11        (WI.SourceCodeTextEditor.prototype.textEditorGutterContextMenu):
     12        (WI.SourceCodeTextEditor.prototype.textEditorUpdatedFormatting):
     13        (WI.SourceCodeTextEditor.prototype._handleFormatterDidChange): Added.
     14        Listen for `WI.SourceCode.Event.FormatterDidChange` events as there may be multiple content
     15        views for the same `WI.SourceCode`. Previously, if there were, only the active one would
     16        properly update it's "line -> column -> breakpoint" mapping, causing an error to be thrown
     17        when the non-active content views tried to retrieve the breakpoint for the new line/column.
     18
    1192019-07-17  Olivier Blin  <olivier.blin@softathome.com>
    220
  • trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

    r246667 r247639  
    9191        WI.consoleManager.addEventListener(WI.ConsoleManager.Event.IssueAdded, this._issueWasAdded, this);
    9292
     93        this._sourceCode.addEventListener(WI.SourceCode.Event.FormatterDidChange, this._handleFormatterDidChange, this);
    9394        if (this._sourceCode instanceof WI.SourceMapResource || this._sourceCode.sourceMaps.length > 0)
    9495            WI.notifications.addEventListener(WI.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
     
    177178        }
    178179
    179         WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.IssueAdded, this._issueWasAdded, this);
    180 
    181         if (this._sourceCode instanceof WI.SourceMapResource || this._sourceCode.sourceMaps.length > 0)
    182             WI.notifications.removeEventListener(WI.Notification.GlobalModifierKeysDidChange, this._updateTokenTrackingControllerState, this);
    183         else
    184             this._sourceCode.removeEventListener(WI.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
     180        WI.consoleManager.removeEventListener(null, null, this);
     181        WI.notifications.removeEventListener(null, null, this);
     182        this._sourceCode.removeEventListener(null, null, this);
    185183    }
    186184
     
    12631261        }
    12641262
    1265         // Multiple breakpoints.
    1266         let removeBreakpoints = () => {
    1267             for (let breakpoint of breakpoints) {
    1268                 if (WI.debuggerManager.isBreakpointRemovable(breakpoint))
    1269                     WI.debuggerManager.removeBreakpoint(breakpoint);
    1270             }
    1271         };
    1272 
    12731263        let shouldDisable = breakpoints.some((breakpoint) => !breakpoint.disabled);
    1274         let toggleBreakpoints = (shouldDisable) => {
     1264        contextMenu.appendItem(shouldDisable ? WI.UIString("Disable Breakpoints") : WI.UIString("Enable Breakpoints"), () => {
    12751265            for (let breakpoint of breakpoints)
    12761266                breakpoint.disabled = shouldDisable;
    1277         };
    1278 
    1279         if (shouldDisable)
    1280             contextMenu.appendItem(WI.UIString("Disable Breakpoints"), toggleBreakpoints);
    1281         else
    1282             contextMenu.appendItem(WI.UIString("Enable Breakpoints"), toggleBreakpoints);
    1283         contextMenu.appendItem(WI.UIString("Delete Breakpoints"), removeBreakpoints);
     1267        });
     1268
     1269        contextMenu.appendItem(WI.UIString("Delete Breakpoints"), () => {
     1270            for (let breakpoint of breakpoints)
     1271                WI.debuggerManager.removeBreakpoint(breakpoint);
     1272        });
    12841273    }
    12851274
     
    13881377        }
    13891378
    1390         // Some breakpoints / issues may have moved, some might not have. Just go through
    1391         // and remove and reinsert all the breakpoints / issues.
    1392 
    1393         var oldBreakpointMap = this._breakpointMap;
    1394         this._breakpointMap = {};
    1395 
    1396         for (var lineNumber in oldBreakpointMap) {
    1397             for (var columnNumber in oldBreakpointMap[lineNumber]) {
    1398                 var breakpoint = oldBreakpointMap[lineNumber][columnNumber];
    1399                 var newLineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
    1400                 this._addBreakpointWithEditorLineInfo(breakpoint, newLineInfo);
    1401                 this.setBreakpointInfoForLineAndColumn(lineNumber, columnNumber, null);
    1402                 this.setBreakpointInfoForLineAndColumn(newLineInfo.lineNumber, newLineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
    1403             }
    1404         }
    1405 
    1406         this._reinsertAllIssues();
    1407         this._reinsertAllThreadIndicators();
     1379        this._handleFormatterDidChange();
    14081380    }
    14091381
     
    16081580    }
    16091581
     1582    _handleFormatterDidChange(event)
     1583    {
     1584        if (this._ignoreAllBreakpointLocationUpdates)
     1585            return;
     1586
     1587        // Some breakpoints / issues may have moved, some might not have. Just go through
     1588        // and remove and reinsert all the breakpoints / issues.
     1589
     1590        var oldBreakpointMap = this._breakpointMap;
     1591        this._breakpointMap = {};
     1592
     1593        for (var lineNumber in oldBreakpointMap) {
     1594            for (var columnNumber in oldBreakpointMap[lineNumber]) {
     1595                var breakpoint = oldBreakpointMap[lineNumber][columnNumber];
     1596                var newLineInfo = this._editorLineInfoForSourceCodeLocation(breakpoint.sourceCodeLocation);
     1597                this._addBreakpointWithEditorLineInfo(breakpoint, newLineInfo);
     1598                this.setBreakpointInfoForLineAndColumn(lineNumber, columnNumber, null);
     1599                this.setBreakpointInfoForLineAndColumn(newLineInfo.lineNumber, newLineInfo.columnNumber, this._breakpointInfoForBreakpoint(breakpoint));
     1600            }
     1601        }
     1602
     1603        this._reinsertAllIssues();
     1604        this._reinsertAllThreadIndicators();
     1605    }
     1606
    16101607    _sourceCodeSourceMapAdded(event)
    16111608    {
Note: See TracChangeset for help on using the changeset viewer.