Bug 196230

Summary: Web Inspector: Debugger: modernize serialization of breakpoints and the maps that hold them
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ews-watchlist, hi, inspector-bugzilla-changes, joepeck, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews104 for mac-highsierra-wk2
none
Archive of layout-test-results from ews101 for mac-highsierra
none
Archive of layout-test-results from ews117 for mac-highsierra
none
Patch
none
Archive of layout-test-results from ews204 for win-future
none
Patch none

Description Devin Rousso 2019-03-25 16:52:18 PDT
Leverage static `deserialize` functions, as well as `Multimap`s to hold the breakpoints.
Comment 1 Radar WebKit Bug Importer 2019-03-25 16:55:02 PDT
<rdar://problem/49236485>
Comment 2 Devin Rousso 2019-03-25 16:56:36 PDT
Created attachment 365921 [details]
Patch
Comment 3 EWS Watchlist 2019-03-25 17:53:33 PDT Comment hidden (obsolete)
Comment 4 EWS Watchlist 2019-03-25 17:53:34 PDT Comment hidden (obsolete)
Comment 5 EWS Watchlist 2019-03-25 18:00:45 PDT Comment hidden (obsolete)
Comment 6 EWS Watchlist 2019-03-25 18:00:47 PDT Comment hidden (obsolete)
Comment 7 EWS Watchlist 2019-03-25 19:14:28 PDT Comment hidden (obsolete)
Comment 8 EWS Watchlist 2019-03-25 19:14:30 PDT Comment hidden (obsolete)
Comment 9 Devin Rousso 2019-03-26 10:53:35 PDT
Created attachment 365975 [details]
Patch
Comment 10 EWS Watchlist 2019-03-26 13:59:56 PDT Comment hidden (obsolete)
Comment 11 EWS Watchlist 2019-03-26 14:00:07 PDT Comment hidden (obsolete)
Comment 12 Joseph Pecoraro 2019-04-01 14:47:40 PDT
Comment on attachment 365975 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=365975&action=review

r=me

> Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js:223
> +            return Array.from(this.breakpointsForSourceCode(sourceCode.sourceMap.originalSourceCode))
> +            .filter((breakpoint) => breakpoint.sourceCodeLocation.displaySourceCode === sourceCode);

I don't think this is our usual style.

    $ ack '^\s+\.[^.]' **/*.js -B 1 --ignore External

It is vastly more common to keep this on one line or to at least put the function name on the same line:

    return Array.from(this.breakpointsForSourceCode(sourceCode.sourceMap.originalSourceCode)).filter((breakpoint) => {
        return breakpoint.sourceCodeLocation.displaySourceCode === sourceCode;
    });

> Source/WebInspectorUI/UserInterface/Models/Breakpoint.js:-33
> -        if (sourceCodeLocationOrInfo instanceof WI.SourceCodeLocation) {
> -            var sourceCode = sourceCodeLocationOrInfo.sourceCode;

Some of the oldest ugliest code. Glad to see this cleaned up!

> Source/WebInspectorUI/UserInterface/Models/Breakpoint.js:41
> +        this._sourceCodeLocation = sourceCodeLocation;

After this I'd put:

    this._contentIdentifier = null;

It used to be `null` and would otherwise be `undefined` with this patch for special breakpoints.

> Source/WebInspectorUI/UserInterface/Models/Breakpoint.js:64
> +    // Static

We can make this an "Import / Export" section and put `deserialize` (or `fromJSON`) and `toJSON` next to each other to it is easy to compare them.

> Source/WebInspectorUI/UserInterface/Models/Breakpoint.js:70
> +            // The 'url' fallback is for transitioning from older frontends and should be removed.

Now might be a good time to remove it!

> Source/WebInspectorUI/UserInterface/Models/Breakpoint.js:244
> -        return newAction;
> +        return this._actions[index];

Would be easier to avoid the lookup again by storing the new action in a local. Especially given someone could modify this_actions in the event handler.

> Source/WebInspectorUI/UserInterface/Models/BreakpointAction.js:39
> +    // Static

Same here re: "Import / Export" or at least putting it by the toJSON.

Also, we don't use the "id" in deserialization, but we presumably do for the protocol? There should probably be a toProtocol() [protocol] instead of toJSON() [serialization].
Comment 13 Devin Rousso 2019-04-01 16:06:31 PDT
Created attachment 366435 [details]
Patch
Comment 14 WebKit Commit Bot 2019-04-01 17:20:17 PDT
Comment on attachment 366435 [details]
Patch

Clearing flags on attachment: 366435

Committed r243727: <https://trac.webkit.org/changeset/243727>
Comment 15 WebKit Commit Bot 2019-04-01 17:20:18 PDT
All reviewed patches have been landed.  Closing bug.