Changeset 171784 in webkit


Ignore:
Timestamp:
Jul 29, 2014 8:48:54 PM (10 years ago)
Author:
Brian Burg
Message:

Web Inspector: breakpoints are always speculatively resolved when restored from local storage
https://bugs.webkit.org/show_bug.cgi?id=135396

Reviewed by Timothy Hatcher.

A longstanding quirk/optimization in the frontend is that we immediately set a breakpoint
as resolved if the breakpoint was successfully set in the backend. This ensures that clicking in
the gutter immediately produces a resolved breakpoint with only one round-trip.

However, not all breakpoints should be speculatively resolved, because the corresponding resource
may not be loaded yet. This situation causes problems for code that assumes a resolved breakpoint
also has a valid sourceCodeLocation.sourceCode.

  • UserInterface/Controllers/DebuggerManager.js:

(WebInspector.DebuggerManager.restoreBreakpointsSoon): Don't leak the variable to global scope.
(WebInspector.DebuggerManager):
(WebInspector.DebuggerManager.prototype.speculativelyResolveBreakpoint):
(WebInspector.DebuggerManager.prototype.addBreakpoint): Speculatively resolve here if requested
using the success callback passed to _setBreakpoint.

(WebInspector.DebuggerManager.prototype.didSetBreakpoint): Emit simulated
Debugger.breakpointResolved events since they are only sent by the backend when a script is parsed.

(WebInspector.DebuggerManager.prototype._setBreakpoint):

  • UserInterface/Views/SourceCodeTextEditor.js:

(WebInspector.SourceCodeTextEditor.prototype.textEditorBreakpointAdded): Request speculative resolve.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r171783 r171784  
     12014-07-29  Brian J. Burg  <burg@cs.washington.edu>
     2
     3        Web Inspector: breakpoints are always speculatively resolved when restored from local storage
     4        https://bugs.webkit.org/show_bug.cgi?id=135396
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        A longstanding quirk/optimization in the frontend is that we immediately set a breakpoint
     9        as resolved if the breakpoint was successfully set in the backend. This ensures that clicking in
     10        the gutter immediately produces a resolved breakpoint with only one round-trip.
     11
     12        However, not all breakpoints should be speculatively resolved, because the corresponding resource
     13        may not be loaded yet. This situation causes problems for code that assumes a resolved breakpoint
     14        also has a valid sourceCodeLocation.sourceCode.
     15
     16        * UserInterface/Controllers/DebuggerManager.js:
     17        (WebInspector.DebuggerManager.restoreBreakpointsSoon): Don't leak the variable to global scope.
     18        (WebInspector.DebuggerManager):
     19        (WebInspector.DebuggerManager.prototype.speculativelyResolveBreakpoint):
     20        (WebInspector.DebuggerManager.prototype.addBreakpoint): Speculatively resolve here if requested
     21        using the success callback passed to _setBreakpoint.
     22
     23        (WebInspector.DebuggerManager.prototype.didSetBreakpoint): Emit simulated
     24        Debugger.breakpointResolved events since they are only sent by the backend when a script is parsed.
     25
     26        (WebInspector.DebuggerManager.prototype._setBreakpoint):
     27        * UserInterface/Views/SourceCodeTextEditor.js:
     28        (WebInspector.SourceCodeTextEditor.prototype.textEditorBreakpointAdded): Request speculative resolve.
     29
    1302014-07-29  Joseph Pecoraro  <pecoraro@apple.com>
    231
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js

    r171013 r171784  
    6868
    6969    function restoreBreakpointsSoon() {
    70         for (cookie of this._breakpointsSetting.value)
     70        for (var cookie of this._breakpointsSetting.value)
    7171            this.addBreakpoint(new WebInspector.Breakpoint(cookie));
    7272    }
     
    228228    },
    229229
    230     addBreakpoint: function(breakpoint, skipEventDispatch)
     230    addBreakpoint: function(breakpoint, skipEventDispatch, shouldSpeculativelyResolve)
    231231    {
    232232        console.assert(breakpoint instanceof WebInspector.Breakpoint, "Bad argument to DebuggerManger.addBreakpoint: ", breakpoint);
     
    250250        this._breakpoints.push(breakpoint);
    251251
     252        function speculativelyResolveBreakpoint(breakpoint) {
     253            breakpoint.resolved = true;
     254        }
     255
    252256        if (!breakpoint.disabled)
    253             this._setBreakpoint(breakpoint);
     257            this._setBreakpoint(breakpoint, shouldSpeculativelyResolve ? speculativelyResolveBreakpoint.bind(null, breakpoint) : null);
    254258
    255259        if (!skipEventDispatch)
     
    525529        this.breakpointsEnabled = true;
    526530
    527         function didSetBreakpoint(error, breakpointIdentifier)
     531        function didSetBreakpoint(error, breakpointIdentifier, locations)
    528532        {
    529533            if (error)
     
    533537
    534538            breakpoint.identifier = breakpointIdentifier;
    535             breakpoint.resolved = true;
     539
     540            // Debugger.setBreakpoint returns a single location.
     541            if (!(locations instanceof Array))
     542                locations = [locations];
     543
     544            for (var location of locations)
     545                this.breakpointResolved(breakpointIdentifier, location);
    536546
    537547            if (typeof callback === "function")
  • trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

    r170899 r171784  
    840840
    841841        this._ignoreBreakpointAddedBreakpoint = breakpoint;
    842         WebInspector.debuggerManager.addBreakpoint(breakpoint);
     842
     843        var shouldSkipEventDispatch = false;
     844        var shouldSpeculativelyResolveBreakpoint = true;
     845        WebInspector.debuggerManager.addBreakpoint(breakpoint, shouldSkipEventDispatch, shouldSpeculativelyResolveBreakpoint);
    843846        delete this._ignoreBreakpointAddedBreakpoint;
    844847
Note: See TracChangeset for help on using the changeset viewer.