Bug 189308

Summary: Web Inspector: REGRESSION: breakpoint context menu appears twice in DOM tree
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, inspector-bugzilla-changes, joepeck, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[Image] Screenshot of Issue
none
Patch
none
Patch
joepeck: review+
Patch none

Description Devin Rousso 2018-09-05 10:05:10 PDT
Created attachment 348933 [details]
[Image] Screenshot of Issue

.
Comment 1 Devin Rousso 2018-09-05 10:07:35 PDT
Created attachment 348934 [details]
Patch
Comment 2 BJ Burg 2018-09-05 11:45:48 PDT
Comment on attachment 348934 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js:262
> +            excludeBreakpointItems: treeElement.statusImageElement.contains(event.target),

Can you explain this logic a little bit? Or, the regression...
Comment 3 Devin Rousso 2018-09-05 11:55:29 PDT
Comment on attachment 348934 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js:262
>> +            excludeBreakpointItems: treeElement.statusImageElement.contains(event.target),
> 
> Can you explain this logic a little bit? Or, the regression...

If you contextmenu on the breakpoint icon that's shown in the DOM tree, a few different items get added to the contextmenu:

```
Break on... >
----------
Disable Breakpoints
Delete Breakpoints
```

The `WI.DOMTreeOutline`, however, also tries to add some contextmenu items, since it also always wants to provide a way to set breakpoints on a DOM node.  As such, an additional item gets added:

```
Break on... >
----------
Disable Breakpoints
Delete Breakpoints
----------
Break on... >
```

Notice that the second "Break on... >" gets added by the `WI.DOMTreeOutline`.  This patch just detects if the contextmenu came from the breakpoint icon in the DOM tree, and if so, prevents the `WI.DOMTreeOutline` from adding it's own breakpoint items.
Comment 4 Joseph Pecoraro 2018-09-11 17:33:21 PDT
Comment on attachment 348934 [details]
Patch

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

>>> Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js:262
>>> +            excludeBreakpointItems: treeElement.statusImageElement.contains(event.target),
>> 
>> Can you explain this logic a little bit? Or, the regression...
> 
> If you contextmenu on the breakpoint icon that's shown in the DOM tree, a few different items get added to the contextmenu:
> 
> ```
> Break on... >
> ----------
> Disable Breakpoints
> Delete Breakpoints
> ```
> 
> The `WI.DOMTreeOutline`, however, also tries to add some contextmenu items, since it also always wants to provide a way to set breakpoints on a DOM node.  As such, an additional item gets added:
> 
> ```
> Break on... >
> ----------
> Disable Breakpoints
> Delete Breakpoints
> ----------
> Break on... >
> ```
> 
> Notice that the second "Break on... >" gets added by the `WI.DOMTreeOutline`.  This patch just detects if the contextmenu came from the breakpoint icon in the DOM tree, and if so, prevents the `WI.DOMTreeOutline` from adding it's own breakpoint items.

Seems this could be done in another way.

We could put a symbol / flag on the ContextMenu to say whether or not we've added breakpoint items:

    appendBreakpointItems(contextMenu, ...)
    {
        if (contextMenu.__hasBreakpointItems)
            return;
        contextMenu.__hasBreakpointItems = true;
        ...
    }

Then no matter how many times this gets called, we only add breakpoint items once.
Comment 5 Devin Rousso 2018-09-13 23:56:17 PDT
Created attachment 349741 [details]
Patch
Comment 6 Joseph Pecoraro 2018-09-14 14:44:39 PDT
Comment on attachment 349741 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Controllers/DOMBreakpointTreeController.js:52
> +        if (contextMenu[WI.DOMBreakpointTreeController._contextMenuItemsAddedSymbol])
> +            return;
> +
> +        contextMenu[WI.DOMBreakpointTreeController._contextMenuItemsAddedSymbol] = true;

I still prefer the double underscore approach. It's just cheaper (a symbol doesn't need to exist at all times) and simpler in my opinion (no need to jump around code and its easy to read).
Comment 7 Devin Rousso 2018-09-15 11:04:06 PDT
Created attachment 349859 [details]
Patch
Comment 8 WebKit Commit Bot 2018-09-15 11:42:06 PDT
Comment on attachment 349859 [details]
Patch

Clearing flags on attachment: 349859

Committed r236033: <https://trac.webkit.org/changeset/236033>
Comment 9 WebKit Commit Bot 2018-09-15 11:42:07 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-09-15 11:43:26 PDT
<rdar://problem/44490747>