Bug 189308 - Web Inspector: REGRESSION: breakpoint context menu appears twice in DOM tree
Summary: Web Inspector: REGRESSION: breakpoint context menu appears twice in DOM tree
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-05 10:05 PDT by Devin Rousso
Modified: 2018-09-15 11:43 PDT (History)
5 users (show)

See Also:


Attachments
[Image] Screenshot of Issue (47.21 KB, image/png)
2018-09-05 10:05 PDT, Devin Rousso
no flags Details
Patch (2.93 KB, patch)
2018-09-05 10:07 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (2.07 KB, patch)
2018-09-13 23:56 PDT, Devin Rousso
joepeck: review+
Details | Formatted Diff | Diff
Patch (1.61 KB, patch)
2018-09-15 11:04 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>