Title: [192789] trunk/Source/WebInspectorUI
Revision
192789
Author
[email protected]
Date
2015-11-29 16:39:08 -0800 (Sun, 29 Nov 2015)

Log Message

Web Inspector: allow multiple UI components to add menu items upon getting a "contextmenu" event
https://bugs.webkit.org/show_bug.cgi?id=151629

Reviewed by Timothy Hatcher.

The existing Context Menu system assumes that only one UI component
will need to provide context menu items. But in some scenarios, there
are multiple UI components that could provide relevant menu items. For
example, right-clicking on an DOM element in the console should show
menu items relevant to 1) the DOM element, 2) the console in general,
and 3) global menu items. Existing code shows menu items provided by
the first object that handles the event and calls ContextMenu.show().

This patch changes behavior so that a context menu can be built up
by multiple 'contextmenu' event handlers. A ContextMenu instance is
hidden on the 'contextmenu' event object; client code calls a
factory method that digs out this existing context menu or creates a
new one as needed. To actually show the context menu through the
InspectorFrontendHost methods, the top-level app controller adds a
bubbling listener for 'contextmenu' and shows the event's context
menu if one has been created.

Along the way, do some cleanup. Do s/var/let/, arrowize some functions,
use Array.{map,some}, and simplify some other code as a result.

No new tests yet, since we can't trigger context menu easily from
an inspector test. All affected context menus were manually verified.

* UserInterface/Base/Main.js:
(WebInspector.contentLoaded):
* UserInterface/Controllers/BreakpointPopoverController.js:
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems):
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.editBreakpoint): Deleted.
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.removeBreakpoint): Deleted.
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.toggleBreakpoint): Deleted.
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.toggleAutoContinue): Deleted.
(WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.revealOriginalSourceCodeLocation): Deleted.
* UserInterface/Views/BreakpointTreeElement.js:
(WebInspector.BreakpointTreeElement.prototype.oncontextmenu):
* UserInterface/Views/CSSStyleDeclarationSection.js:
* UserInterface/Views/ContextMenu.js:
(WebInspector.ContextMenuItem.prototype._buildDescriptor):
(WebInspector.ContextMenuItem):
(WebInspector.ContextSubMenuItem.prototype.appendItem):
(WebInspector.ContextSubMenuItem.prototype.appendSubMenuItem):
(WebInspector.ContextSubMenuItem.prototype.appendCheckboxItem):
(WebInspector.ContextSubMenuItem.prototype._pushItem):
(WebInspector.ContextSubMenuItem.prototype._buildDescriptor):
(WebInspector.ContextSubMenuItem):
(WebInspector.ContextMenu.createFromEvent):
(WebInspector.ContextMenu.prototype.show):
(WebInspector.ContextMenu.prototype.handleEvent):
(WebInspector.ContextMenu.prototype._buildDescriptor):
* UserInterface/Views/DOMTreeOutline.js:
(WebInspector.DOMTreeOutline.prototype._contextMenuEventFired):
(WebInspector.DOMTreeOutline.prototype._populateContextMenu.logElement):
(WebInspector.DOMTreeOutline.prototype._populateContextMenu):
* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype._contextMenuInDataTable):
* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement):
(WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement.removeAllResourceBreakpoints): Deleted.
(WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement.toggleAllResourceBreakpoints): Deleted.
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView.prototype._handleContextMenuEvent):
* UserInterface/Views/ObjectPreviewView.js:
(WebInspector.ObjectPreviewView.prototype._contextMenuHandler):
(WebInspector.ObjectPreviewView):
* UserInterface/Views/ObjectTreeBaseTreeElement.js:
(WebInspector.ObjectTreeBaseTreeElement.prototype._contextMenuHandler):
(WebInspector.ObjectTreeBaseTreeElement.prototype._appendMenusItemsForObject):
(WebInspector.ObjectTreeBaseTreeElement):
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu):
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.continueToLocation): Deleted.
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.addBreakpoint): Deleted.
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.revealInSidebar): Deleted.
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.removeBreakpoints): Deleted.
(WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.toggleBreakpoints): Deleted.
* UserInterface/Views/TabBarItem.js:
(WebInspector.TabBarItem.prototype._handleContextMenuEvent):
(WebInspector.TabBarItem):
(WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeTab): Deleted.
(WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeOtherTabs): Deleted.
* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel.prototype._contextMenuNavigationBarOrStatusBar):
(WebInspector.TimelineSidebarPanel.prototype._contextMenuNavigationBarOrStatusBar.toggleReplayInterface): Deleted.
* UserInterface/Views/Toolbar.js:
(WebInspector.Toolbar.prototype._handleContextMenuEvent):
* UserInterface/Views/VisualStyleSelectorTreeItem.js:
(WebInspector.VisualStyleSelectorTreeItem.prototype._handleContextMenuEvent):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (192788 => 192789)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-11-30 00:39:08 UTC (rev 192789)
@@ -1,3 +1,97 @@
+2015-11-29  Brian Burg  <[email protected]>
+
+        Web Inspector: allow multiple UI components to add menu items upon getting a "contextmenu" event
+        https://bugs.webkit.org/show_bug.cgi?id=151629
+
+        Reviewed by Timothy Hatcher.
+
+        The existing Context Menu system assumes that only one UI component
+        will need to provide context menu items. But in some scenarios, there
+        are multiple UI components that could provide relevant menu items. For
+        example, right-clicking on an DOM element in the console should show
+        menu items relevant to 1) the DOM element, 2) the console in general,
+        and 3) global menu items. Existing code shows menu items provided by
+        the first object that handles the event and calls ContextMenu.show().
+
+        This patch changes behavior so that a context menu can be built up
+        by multiple 'contextmenu' event handlers. A ContextMenu instance is
+        hidden on the 'contextmenu' event object; client code calls a
+        factory method that digs out this existing context menu or creates a
+        new one as needed. To actually show the context menu through the
+        InspectorFrontendHost methods, the top-level app controller adds a
+        bubbling listener for 'contextmenu' and shows the event's context
+        menu if one has been created.
+
+        Along the way, do some cleanup. Do s/var/let/, arrowize some functions,
+        use Array.{map,some}, and simplify some other code as a result.
+
+        No new tests yet, since we can't trigger context menu easily from
+        an inspector test. All affected context menus were manually verified.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.contentLoaded):
+        * UserInterface/Controllers/BreakpointPopoverController.js:
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems):
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.editBreakpoint): Deleted.
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.removeBreakpoint): Deleted.
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.toggleBreakpoint): Deleted.
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.toggleAutoContinue): Deleted.
+        (WebInspector.BreakpointPopoverController.prototype.appendContextMenuItems.revealOriginalSourceCodeLocation): Deleted.
+        * UserInterface/Views/BreakpointTreeElement.js:
+        (WebInspector.BreakpointTreeElement.prototype.oncontextmenu):
+        * UserInterface/Views/CSSStyleDeclarationSection.js:
+        * UserInterface/Views/ContextMenu.js:
+        (WebInspector.ContextMenuItem.prototype._buildDescriptor):
+        (WebInspector.ContextMenuItem):
+        (WebInspector.ContextSubMenuItem.prototype.appendItem):
+        (WebInspector.ContextSubMenuItem.prototype.appendSubMenuItem):
+        (WebInspector.ContextSubMenuItem.prototype.appendCheckboxItem):
+        (WebInspector.ContextSubMenuItem.prototype._pushItem):
+        (WebInspector.ContextSubMenuItem.prototype._buildDescriptor):
+        (WebInspector.ContextSubMenuItem):
+        (WebInspector.ContextMenu.createFromEvent):
+        (WebInspector.ContextMenu.prototype.show):
+        (WebInspector.ContextMenu.prototype.handleEvent):
+        (WebInspector.ContextMenu.prototype._buildDescriptor):
+        * UserInterface/Views/DOMTreeOutline.js:
+        (WebInspector.DOMTreeOutline.prototype._contextMenuEventFired):
+        (WebInspector.DOMTreeOutline.prototype._populateContextMenu.logElement):
+        (WebInspector.DOMTreeOutline.prototype._populateContextMenu):
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid.prototype._contextMenuInDataTable):
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement):
+        (WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement.removeAllResourceBreakpoints): Deleted.
+        (WebInspector.DebuggerSidebarPanel.prototype._breakpointTreeOutlineContextMenuTreeElement.toggleAllResourceBreakpoints): Deleted.
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView.prototype._handleContextMenuEvent):
+        * UserInterface/Views/ObjectPreviewView.js:
+        (WebInspector.ObjectPreviewView.prototype._contextMenuHandler):
+        (WebInspector.ObjectPreviewView):
+        * UserInterface/Views/ObjectTreeBaseTreeElement.js:
+        (WebInspector.ObjectTreeBaseTreeElement.prototype._contextMenuHandler):
+        (WebInspector.ObjectTreeBaseTreeElement.prototype._appendMenusItemsForObject):
+        (WebInspector.ObjectTreeBaseTreeElement):
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu):
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.continueToLocation): Deleted.
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.addBreakpoint): Deleted.
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.revealInSidebar): Deleted.
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.removeBreakpoints): Deleted.
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorGutterContextMenu.toggleBreakpoints): Deleted.
+        * UserInterface/Views/TabBarItem.js:
+        (WebInspector.TabBarItem.prototype._handleContextMenuEvent):
+        (WebInspector.TabBarItem):
+        (WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeTab): Deleted.
+        (WebInspector.TabBarItem.prototype._handleContextMenuEvent.closeOtherTabs): Deleted.
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel.prototype._contextMenuNavigationBarOrStatusBar):
+        (WebInspector.TimelineSidebarPanel.prototype._contextMenuNavigationBarOrStatusBar.toggleReplayInterface): Deleted.
+        * UserInterface/Views/Toolbar.js:
+        (WebInspector.Toolbar.prototype._handleContextMenuEvent):
+        * UserInterface/Views/VisualStyleSelectorTreeItem.js:
+        (WebInspector.VisualStyleSelectorTreeItem.prototype._handleContextMenuEvent):
+
 2015-11-28  Devin Rousso  <[email protected]>
 
         Web Inspector: Styles sidebar placeholder is misaligned

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -190,6 +190,7 @@
     window.addEventListener("keyup", this._windowKeyUp.bind(this));
     window.addEventListener("mousemove", this._mouseMoved.bind(this), true);
     window.addEventListener("pagehide", this._pageHidden.bind(this));
+    window.addEventListener("contextmenu", this._contextMenuRequested.bind(this));
 
     // Add platform style classes so the UI can be tweaked per-platform.
     document.body.classList.add(WebInspector.Platform.name + "-platform");
@@ -1325,6 +1326,14 @@
     this._saveCookieForOpenTabs();
 };
 
+WebInspector._contextMenuRequested = function(event)
+{
+    const _onlyExisting_ = true;
+    let proposedContextMenu = WebInspector.ContextMenu.createFromEvent(event, onlyExisting);
+    if (proposedContextMenu)
+        proposedContextMenu.show();
+};
+
 WebInspector._undock = function(event)
 {
     InspectorFrontendHost.requestSetDockSide("undocked");

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointPopoverController.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -40,8 +40,7 @@
     {
         console.assert(document.body.contains(breakpointDisplayElement), "Breakpoint popover display element must be in the DOM.");
 
-        function editBreakpoint()
-        {
+        const editBreakpoint = () => {
             console.assert(!this._popover, "Breakpoint popover already exists.");
             if (this._popover)
                 return;
@@ -53,50 +52,46 @@
             let bounds = WebInspector.Rect.rectFromClientRect(breakpointDisplayElement.getBoundingClientRect());
             bounds.origin.x -= 1; // Move the anchor left one pixel so it looks more centered.
             this._popover.present(bounds.pad(2), [WebInspector.RectEdge.MAX_Y]);
-        }
+        };
 
-        function removeBreakpoint()
-        {
+        const removeBreakpoint = () => {
             WebInspector.debuggerManager.removeBreakpoint(breakpoint);
-        }
+        };
 
-        function toggleBreakpoint()
-        {
+        const toggleBreakpoint = () => {
             breakpoint.disabled = !breakpoint.disabled;
-        }
+        };
 
-        function toggleAutoContinue()
-        {
+        const toggleAutoContinue = () => {
             breakpoint.autoContinue = !breakpoint.autoContinue;
-        }
+        };
 
-        function revealOriginalSourceCodeLocation()
-        {
+        const revealOriginalSourceCodeLocation = () => {
             WebInspector.showOriginalOrFormattedSourceCodeLocation(breakpoint.sourceCodeLocation);
-        }
+        };
 
         if (WebInspector.debuggerManager.isBreakpointEditable(breakpoint))
-            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpoint.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpoint);
 
         if (breakpoint.autoContinue && !breakpoint.disabled) {
-            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), toggleBreakpoint.bind(this));
-            contextMenu.appendItem(WebInspector.UIString("Cancel Automatic Continue"), toggleAutoContinue.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), toggleBreakpoint);
+            contextMenu.appendItem(WebInspector.UIString("Cancel Automatic Continue"), toggleAutoContinue);
         } else if (!breakpoint.disabled)
-            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), toggleBreakpoint.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoint"), toggleBreakpoint);
         else
-            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), toggleBreakpoint.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoint"), toggleBreakpoint);
 
         if (!breakpoint.autoContinue && !breakpoint.disabled && breakpoint.actions.length)
-            contextMenu.appendItem(WebInspector.UIString("Set to Automatically Continue"), toggleAutoContinue.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Set to Automatically Continue"), toggleAutoContinue);
 
         if (WebInspector.debuggerManager.isBreakpointRemovable(breakpoint)) {
             contextMenu.appendSeparator();
-            contextMenu.appendItem(WebInspector.UIString("Delete Breakpoint"), removeBreakpoint.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Delete Breakpoint"), removeBreakpoint);
         }
 
         if (breakpoint._sourceCodeLocation.hasMappedLocation()) {
             contextMenu.appendSeparator();
-            contextMenu.appendItem(WebInspector.UIString("Reveal in Original Resource"), revealOriginalSourceCodeLocation.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Reveal in Original Resource"), revealOriginalSourceCodeLocation);
         }
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -99,9 +99,8 @@
 
     oncontextmenu(event)
     {
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
         WebInspector.breakpointPopoverController.appendContextMenuItems(contextMenu, this._breakpoint, this._statusImageElement);
-        contextMenu.show();
     }
 
     onattach()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -431,22 +431,20 @@
         if (window.getSelection().toString().length)
             return;
 
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
         if (!this._style.inherited) {
-            contextMenu.appendItem(WebInspector.UIString("Duplicate Selector"), function() {
+            contextMenu.appendItem(WebInspector.UIString("Duplicate Selector"), () => {
                 if (this._delegate && typeof this._delegate.cssStyleDeclarationSectionFocusNextNewInspectorRule === "function")
                     this._delegate.cssStyleDeclarationSectionFocusNextNewInspectorRule();
 
                 this._style.nodeStyles.addRule(this._currentSelectorText);
-            }.bind(this));
+            });
         }
 
-        contextMenu.appendItem(WebInspector.UIString("Copy Rule"), function() {
+        contextMenu.appendItem(WebInspector.UIString("Copy Rule"), () => {
             InspectorFrontendHost.copyText(this._style.generateCSSRuleString());
-        }.bind(this));
-
-        contextMenu.show();
+        });
     }
 
     _toggleRuleOnOff()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenu.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -73,11 +73,11 @@
     {
         switch (this._type) {
         case "item":
-            return { type: "item", id: this._id, label: this._label, enabled: !this._disabled };
+            return {type: "item", id: this._id, label: this._label, enabled: !this._disabled};
         case "separator":
-            return { type: "separator" };
+            return {type: "separator"};
         case "checkbox":
-            return { type: "checkbox", id: this._id, label: this._label, checked: !!this._checked, enabled: !this._disabled };
+            return {type: "checkbox", id: this._id, label: this._label, checked: !!this._checked, enabled: !this._disabled};
         }
     }
 };
@@ -95,7 +95,7 @@
 
     appendItem(label, handler, disabled)
     {
-        var item = new WebInspector.ContextMenuItem(this._contextMenu, "item", label, disabled);
+        let item = new WebInspector.ContextMenuItem(this._contextMenu, "item", label, disabled);
         this._pushItem(item);
         this._contextMenu._setHandler(item.id(), handler);
         return item;
@@ -103,14 +103,14 @@
 
     appendSubMenuItem(label, disabled)
     {
-        var item = new WebInspector.ContextSubMenuItem(this._contextMenu, label, disabled);
+        let item = new WebInspector.ContextSubMenuItem(this._contextMenu, label, disabled);
         this._pushItem(item);
         return item;
     }
 
     appendCheckboxItem(label, handler, checked, disabled)
     {
-        var item = new WebInspector.ContextMenuItem(this._contextMenu, "checkbox", label, disabled, checked);
+        let item = new WebInspector.ContextMenuItem(this._contextMenu, "checkbox", label, disabled, checked);
         this._pushItem(item);
         this._contextMenu._setHandler(item.id(), handler);
         return item;
@@ -126,7 +126,7 @@
     {
         if (this._pendingSeparator) {
             this._items.push(new WebInspector.ContextMenuItem(this._contextMenu, "separator"));
-            delete this._pendingSeparator;
+            this._pendingSeparator = null;
         }
         this._items.push(item);
     }
@@ -138,10 +138,8 @@
 
     _buildDescriptor()
     {
-        var result = { type: "subMenu", label: this._label, enabled: !this._disabled, subItems: [] };
-        for (var i = 0; i < this._items.length; ++i)
-            result.subItems.push(this._items[i]._buildDescriptor());
-        return result;
+        let subItems = this._items.map((item) => item._buildDescriptor());
+        return {type: "subMenu", label: this._label, enabled: !this._disabled, subItems};
     }
 };
 
@@ -158,6 +156,14 @@
 
     // Static
 
+    static createFromEvent(event, _onlyExisting_ = false)
+    {
+        if (!event[WebInspector.ContextMenu.ProposedMenuSymbol] && !onlyExisting)
+            event[WebInspector.ContextMenu.ProposedMenuSymbol] = new WebInspector.ContextMenu(event);
+
+        return event[WebInspector.ContextMenu.ProposedMenuSymbol] || null;
+    }
+
     static contextMenuItemSelected(id)
     {
         if (WebInspector.ContextMenu._lastContextMenu)
@@ -181,8 +187,7 @@
     {
         console.assert(this._event instanceof MouseEvent);
 
-        var menuObject = this._buildDescriptor();
-
+        let menuObject = this._buildDescriptor();
         if (menuObject.length) {
             WebInspector.ContextMenu._lastContextMenu = this;
 
@@ -204,7 +209,7 @@
     {
         this._event.target.removeEventListener("contextmenu", this, true);
         InspectorFrontendHost.showContextMenu(event, this._menuObject);
-        delete this._menuObject;
+        this._menuObject = null;
 
         event.stopImmediatePropagation();
     }
@@ -219,10 +224,7 @@
 
     _buildDescriptor()
     {
-        var result = [];
-        for (var i = 0; i < this._items.length; ++i)
-            result.push(this._items[i]._buildDescriptor());
-        return result;
+        return this._items.map((item) => item._buildDescriptor());
     }
 
     _itemSelected(id)
@@ -231,3 +233,5 @@
             this._handlers[id].call(this);
     }
 };
+
+WebInspector.ContextMenu.ProposedMenuSymbol = Symbol("context-menu-proposed-menu");
\ No newline at end of file

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -485,13 +485,12 @@
 
     _contextMenuEventFired(event)
     {
-        var treeElement = this._treeElementFromEvent(event);
+        let treeElement = this._treeElementFromEvent(event);
         if (!treeElement)
             return;
 
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
         this.populateContextMenu(contextMenu, event, treeElement);
-        contextMenu.show();
     }
 
     _updateModifiedNodes()
@@ -512,7 +511,7 @@
             WebInspector.RemoteObject.resolveNode(domNode, WebInspector.RuntimeManager.ConsoleObjectGroup, function(remoteObject) {
                 if (!remoteObject)
                     return;
-                var text = WebInspector.UIString("Selected Element");
+                let text = WebInspector.UIString("Selected Element");
                 WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, true);
             });
         }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -1101,9 +1101,9 @@
 
     _contextMenuInDataTable(event)
     {
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
-        var gridNode = this.dataGridNodeFromNode(event.target);
+        let gridNode = this.dataGridNodeFromNode(event.target);
         if (this.dataGrid._refreshCallback && (!gridNode || gridNode !== this.placeholderNode))
             contextMenu.appendItem(WebInspector.UIString("Refresh"), this._refreshCallback.bind(this));
 
@@ -1114,17 +1114,15 @@
                 if (gridNode === this.placeholderNode)
                     contextMenu.appendItem(WebInspector.UIString("Add New"), this._startEditing.bind(this, event.target));
                 else {
-                    var element = event.target.enclosingNodeOrSelfWithNodeName("td");
-                    var columnIdentifier = element.__columnIdentifier;
-                    var columnTitle = this.dataGrid.columns.get(columnIdentifier)["title"];
+                    let element = event.target.enclosingNodeOrSelfWithNodeName("td");
+                    let columnIdentifier = element.__columnIdentifier;
+                    let columnTitle = this.dataGrid.columns.get(columnIdentifier)["title"];
                     contextMenu.appendItem(WebInspector.UIString("Edit “%s”").format(columnTitle), this._startEditing.bind(this, event.target));
                 }
             }
             if (this.dataGrid._deleteCallback && gridNode !== this.placeholderNode)
                 contextMenu.appendItem(WebInspector.UIString("Delete"), this._deleteCallback.bind(this, gridNode));
         }
-
-        contextMenu.show();
     }
 
     _clickInDataTable(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -579,32 +579,23 @@
         if (!(treeElement instanceof WebInspector.ResourceTreeElement) && !(treeElement instanceof WebInspector.ScriptTreeElement))
             return;
 
-        var breakpoints = this._breakpointsBeneathTreeElement(treeElement);
-        var shouldDisable = false;
-        for (var i = 0; i < breakpoints.length; ++i) {
-            if (!breakpoints[i].disabled) {
-                shouldDisable = true;
-                break;
-            }
-        }
+        let breakpoints = this._breakpointsBeneathTreeElement(treeElement);
+        let shouldDisable = breakpoints.some((breakpoint) => !breakpoint.disabled);
 
-        function removeAllResourceBreakpoints()
-        {
+        let removeAllResourceBreakpoints = () => {
             this._removeAllBreakpoints(breakpoints);
-        }
+        };
 
-        function toggleAllResourceBreakpoints()
-        {
+        let toggleAllResourceBreakpoints = () => {
             this._toggleAllBreakpoints(breakpoints, shouldDisable);
-        }
+        };
 
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
         if (shouldDisable)
-            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoints"), toggleAllResourceBreakpoints.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoints"), toggleAllResourceBreakpoints);
         else
-            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoints"), toggleAllResourceBreakpoints.bind(this));
-        contextMenu.appendItem(WebInspector.UIString("Delete Breakpoints"), removeAllResourceBreakpoints.bind(this));
-        contextMenu.show();
+            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoints"), toggleAllResourceBreakpoints);
+        contextMenu.appendItem(WebInspector.UIString("Delete Breakpoints"), removeAllResourceBreakpoints);
     }
 
     _treeElementSelected(treeElement, selectedByUser)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -352,15 +352,12 @@
         if (event.target.enclosingNodeOrSelfWithNodeName("a"))
             return;
 
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
         contextMenu.appendItem(WebInspector.UIString("Clear Log"), this._clearLog.bind(this));
         contextMenu.appendSeparator();
 
-        var clearLogOnReloadUIString = WebInspector.logManager.clearLogOnNavigateSetting.value ? WebInspector.UIString("Keep Log on Navigation") : WebInspector.UIString("Clear Log on Navigation");
-
+        let clearLogOnReloadUIString = WebInspector.logManager.clearLogOnNavigateSetting.value ? WebInspector.UIString("Keep Log on Navigation") : WebInspector.UIString("Clear Log on Navigation");
         contextMenu.appendItem(clearLogOnReloadUIString, this._toggleClearLogOnNavigateSetting.bind(this));
-
-        contextMenu.show();
     }
 
     _mousedown(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectPreviewView.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -261,20 +261,18 @@
 
     _contextMenuHandler(event)
     {
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
-        contextMenu.appendItem(WebInspector.UIString("Log Value"), function() {
-            var remoteObject = this._remoteObject;
-            var isImpossible = !this._propertyPath || this._propertyPath.isFullPathImpossible();
-            var text = isImpossible ? WebInspector.UIString("Selected Value") : this._propertyPath.displayPath(WebInspector.PropertyPath.Type.Value);
+        contextMenu.appendItem(WebInspector.UIString("Log Value"), () => {
+            let remoteObject = this._remoteObject;
+            let isImpossible = !this._propertyPath || this._propertyPath.isFullPathImpossible();
+            let text = isImpossible ? WebInspector.UIString("Selected Value") : this._propertyPath.displayPath(WebInspector.PropertyPath.Type.Value);
 
             if (!isImpossible)
                 WebInspector.quickConsole.prompt.pushHistoryItem(text);
 
             WebInspector.consoleLogViewController.appendImmediateExecutionWithResult(text, this._remoteObject, isImpossible);
-        }.bind(this));
-
-        contextMenu.show();        
+        });
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeBaseTreeElement.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -182,7 +182,7 @@
 
     _contextMenuHandler(event)
     {
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
         if (typeof this.treeOutline.objectTreeElementAddContextMenuItems === "function") {
             this.treeOutline.objectTreeElementAddContextMenuItems(this, contextMenu);
@@ -190,30 +190,24 @@
                 contextMenu.appendSeparator();
         }             
 
-        var resolvedValue = this.resolvedValue();
-        if (!resolvedValue) {
-            if (!contextMenu.isEmpty())
-                contextMenu.show();
+        if (!this.resolvedValue())
             return;
-        }
 
         if (this._property && this._property.symbol)
             contextMenu.appendItem(WebInspector.UIString("Log Symbol"), this._logSymbolProperty.bind(this));
 
         contextMenu.appendItem(WebInspector.UIString("Log Value"), this._logValue.bind(this));
 
-        var propertyPath = this.resolvedValuePropertyPath();
+        let propertyPath = this.resolvedValuePropertyPath();
         if (propertyPath && !propertyPath.isFullPathImpossible()) {
-            contextMenu.appendItem(WebInspector.UIString("Copy Path to Property"), function() {
+            contextMenu.appendItem(WebInspector.UIString("Copy Path to Property"), () => {
                 InspectorFrontendHost.copyText(propertyPath.displayPath(WebInspector.PropertyPath.Type.Value));
-            }.bind(this));
+            });
         }
 
         contextMenu.appendSeparator();
 
         this._appendMenusItemsForObject(contextMenu, resolvedValue);
-
-        contextMenu.show();
     }
 
     _appendMenusItemsForObject(contextMenu, resolvedValue)
@@ -226,12 +220,12 @@
                         if (error)
                             return;
 
-                        var location = response.location;
-                        var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
+                        let location = response.location;
+                        let sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
                         if (!sourceCode)
                             return;
 
-                        var sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
+                        let sourceCodeLocation = sourceCode.createSourceCodeLocation(location.lineNumber, location.columnNumber || 0);
                         WebInspector.showSourceCodeLocation(sourceCodeLocation);
                     });
                 });

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -971,46 +971,36 @@
 
         event.preventDefault();
 
-        function continueToLocation()
-        {
-            WebInspector.debuggerManager.continueToLocation(script.id, sourceCodeLocation.lineNumber, sourceCodeLocation.columnNumber);
-        }
-
-        function addBreakpoint()
-        {
-            var data = "" lineNumber, columnNumber);
+        let addBreakpoint = () => {
+            let data = "" lineNumber, columnNumber);
             this.setBreakpointInfoForLineAndColumn(data.lineNumber, data.columnNumber, data.breakpointInfo);
-        }
+        };
 
-        function revealInSidebar()
-        {
-            WebInspector.showDebuggerTab(breakpoint);
-        }
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
-        var contextMenu = new WebInspector.ContextMenu(event);
-
         // Paused. Add Continue to Here option only if we have a script identifier for the location.
         if (WebInspector.debuggerManager.paused) {
-            var editorLineInfo = {lineNumber, columnNumber};
-            var unformattedLineInfo = this._unformattedLineInfoForEditorLineInfo(editorLineInfo);
-            var sourceCodeLocation = this._sourceCode.createSourceCodeLocation(unformattedLineInfo.lineNumber, unformattedLineInfo.columnNumber);
+            let editorLineInfo = {lineNumber, columnNumber};
+            let unformattedLineInfo = this._unformattedLineInfoForEditorLineInfo(editorLineInfo);
+            let sourceCodeLocation = this._sourceCode.createSourceCodeLocation(unformattedLineInfo.lineNumber, unformattedLineInfo.columnNumber);
 
+            let script;
             if (sourceCodeLocation.sourceCode instanceof WebInspector.Script)
-                var script = sourceCodeLocation.sourceCode;
+                script = sourceCodeLocation.sourceCode;
             else if (sourceCodeLocation.sourceCode instanceof WebInspector.Resource)
-                var script = sourceCodeLocation.sourceCode.scriptForLocation(sourceCodeLocation);
+                script = sourceCodeLocation.sourceCode.scriptForLocation(sourceCodeLocation);
 
             if (script) {
-
-                contextMenu.appendItem(WebInspector.UIString("Continue to Here"), continueToLocation);
+                contextMenu.appendItem(WebInspector.UIString("Continue to Here"), () => {
+                    WebInspector.debuggerManager.continueToLocation(script.id, sourceCodeLocation.lineNumber, sourceCodeLocation.columnNumber);
+                });
                 contextMenu.appendSeparator();
             }
         }
 
-        var breakpoints = [];
-        for (var i = 0; i < editorBreakpoints.length; ++i) {
-            var lineInfo = editorBreakpoints[i];
-            var breakpoint = this._breakpointForEditorLineInfo(lineInfo);
+        let breakpoints = [];
+        for (let lineInfo of editorBreakpoints) {
+            let breakpoint = this._breakpointForEditorLineInfo(lineInfo);
             console.assert(breakpoint);
             if (breakpoint)
                 breakpoints.push(breakpoint);
@@ -1018,9 +1008,7 @@
 
         // No breakpoints.
         if (!breakpoints.length) {
-
             contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), addBreakpoint.bind(this));
-            contextMenu.show();
             return;
         }
 
@@ -1030,43 +1018,33 @@
 
             if (!WebInspector.isShowingDebuggerTab()) {
                 contextMenu.appendSeparator();
-                contextMenu.appendItem(WebInspector.UIString("Reveal in Debugger Tab"), revealInSidebar);
+                contextMenu.appendItem(WebInspector.UIString("Reveal in Debugger Tab"), () => {
+                    WebInspector.showDebuggerTab(breakpoint);
+                });
             }
 
-            contextMenu.show();
             return;
         }
 
         // Multiple breakpoints.
-        var shouldDisable = false;
-        for (var i = 0; i < breakpoints.length; ++i) {
-            if (!breakpoints[i].disabled) {
-                shouldDisable = true;
-                break;
-            }
-        }
-
-        function removeBreakpoints()
-        {
-            for (var i = 0; i < breakpoints.length; ++i) {
-                var breakpoint = breakpoints[i];
+        let removeBreakpoints = () => {
+            for (let breakpoint of breakpoints) {
                 if (WebInspector.debuggerManager.isBreakpointRemovable(breakpoint))
                     WebInspector.debuggerManager.removeBreakpoint(breakpoint);
             }
-        }
+        };
 
-        function toggleBreakpoints()
-        {
-            for (var i = 0; i < breakpoints.length; ++i)
-                breakpoints[i].disabled = shouldDisable;
-        }
+        let shouldDisable = breakpoints.some((breakpoint) => !breakpoint.disabled);
+        let toggleBreakpoints = (shouldDisable) => {
+            for (let breakpoint of breakpoints)
+                breakpoint.disabled = shouldDisable;
+        };
 
         if (shouldDisable)
-            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoints"), toggleBreakpoints.bind(this));
+            contextMenu.appendItem(WebInspector.UIString("Disable Breakpoints"), toggleBreakpoints);
         else
-            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoints"), toggleBreakpoints.bind(this));
-        contextMenu.appendItem(WebInspector.UIString("Delete Breakpoints"), removeBreakpoints.bind(this));
-        contextMenu.show();
+            contextMenu.appendItem(WebInspector.UIString("Enable Breakpoints"), toggleBreakpoints);
+        contextMenu.appendItem(WebInspector.UIString("Delete Breakpoints"), removeBreakpoints);
     }
 
     textEditorBreakpointAdded(textEditor, lineNumber, columnNumber)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBarItem.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -180,34 +180,24 @@
         if (!this._parentTabBar)
             return;
 
-        var hasOtherNonPinnedTabs = false;
-        for (var item of this._parentTabBar.tabBarItems) {
-            if (item === this || item.pinned)
-                continue;
-            hasOtherNonPinnedTabs = true;
-            break; 
-        }
-
-        function closeTab()
-        {
+        let closeTab = () => {
             this._parentTabBar.removeTabBarItem(this);
-        }
+        };
 
-        function closeOtherTabs()
-        {
-            var tabBarItems = this._parentTabBar.tabBarItems;
-            for (var i = tabBarItems.length - 1; i >= 0; --i) {
-                var item = tabBarItems[i];
+        let closeOtherTabs = () => {
+            let tabBarItems = this._parentTabBar.tabBarItems;
+            for (let i = tabBarItems.length - 1; i >= 0; --i) {
+                let item = tabBarItems[i];
                 if (item === this || item.pinned)
                     continue;
                 this._parentTabBar.removeTabBarItem(item);
             }
-        }
+        };
 
-        var contextMenu = new WebInspector.ContextMenu(event);
-        contextMenu.appendItem(WebInspector.UIString("Close Tab"), closeTab.bind(this), !hasOtherNonPinnedTabs);
-        contextMenu.appendItem(WebInspector.UIString("Close Other Tabs"), closeOtherTabs.bind(this), !hasOtherNonPinnedTabs);
-        contextMenu.show();
+        let hasOtherNonPinnedTabs = this._parentTabBar.tabBarItems.some((item) => item !== this && !item.pinned);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
+        contextMenu.appendItem(WebInspector.UIString("Close Tab"), closeTab, !hasOtherNonPinnedTabs);
+        contextMenu.appendItem(WebInspector.UIString("Close Other Tabs"), closeOtherTabs, !hasOtherNonPinnedTabs);
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -944,16 +944,15 @@
         if (!window.ReplayAgent)
             return;
 
-        function toggleReplayInterface() {
+        let toggleReplayInterface = () => {
             WebInspector.showReplayInterfaceSetting.value = !WebInspector.showReplayInterfaceSetting.value;
-        }
+        };
 
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
         if (WebInspector.showReplayInterfaceSetting.value)
             contextMenu.appendItem(WebInspector.UIString("Hide Replay Controls"), toggleReplayInterface);
         else
             contextMenu.appendItem(WebInspector.UIString("Show Replay Controls"), toggleReplayInterface);
-        contextMenu.show();
     }
 
     _replayCaptureButtonClicked()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -199,7 +199,7 @@
 
     _handleContextMenuEvent(event)
     {
-        var contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
         contextMenu.appendCheckboxItem(WebInspector.UIString("Icon and Text (Vertical)"), this._changeDisplayMode.bind(this, WebInspector.Toolbar.DisplayMode.IconAndLabelVertical), this._displayMode === WebInspector.Toolbar.DisplayMode.IconAndLabelVertical);
         contextMenu.appendCheckboxItem(WebInspector.UIString("Icon and Text (Horizontal)"), this._changeDisplayMode.bind(this, WebInspector.Toolbar.DisplayMode.IconAndLabelHorizontal), this._displayMode === WebInspector.Toolbar.DisplayMode.IconAndLabelHorizontal);
@@ -210,8 +210,6 @@
             contextMenu.appendSeparator();
             contextMenu.appendCheckboxItem(WebInspector.UIString("Small Icons"), this._toggleSmallIcons.bind(this), this._sizeMode === WebInspector.Toolbar.SizeMode.Small);
         }
-
-        contextMenu.show();
     }
 
     _changeDisplayMode(displayMode)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js (192788 => 192789)


--- trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js	2015-11-29 22:03:18 UTC (rev 192788)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/VisualStyleSelectorTreeItem.js	2015-11-30 00:39:08 UTC (rev 192789)
@@ -132,27 +132,25 @@
 
     _handleContextMenuEvent(event)
     {
-        let contextMenu = new WebInspector.ContextMenu(event);
+        let contextMenu = WebInspector.ContextMenu.createFromEvent(event);
 
         if (this.representedObject.ownerRule) {
-            contextMenu.appendItem(WebInspector.UIString("Show Source"), function() {
+            contextMenu.appendItem(WebInspector.UIString("Show Source"), () => {
                 if (event.metaKey)
                     WebInspector.showOriginalUnformattedSourceCodeLocation(this.representedObject.ownerRule.sourceCodeLocation);
                 else
                     WebInspector.showSourceCodeLocation(this.representedObject.ownerRule.sourceCodeLocation);
-            }.bind(this));
+            });
         }
 
-        contextMenu.appendItem(WebInspector.UIString("Copy Rule"), function() {
+        contextMenu.appendItem(WebInspector.UIString("Copy Rule"), () => {
             InspectorFrontendHost.copyText(this.representedObject.generateCSSRuleString());
-        }.bind(this));
+        });
 
-        contextMenu.appendItem(WebInspector.UIString("Reset"), function() {
+        contextMenu.appendItem(WebInspector.UIString("Reset"), () => {
             this.representedObject.resetText();
             this.dispatchEventToListeners(WebInspector.VisualStyleSelectorTreeItem.Event.StyleTextReset);
-        }.bind(this));
-
-        contextMenu.show();
+        });
     }
 
     _handleCheckboxChanged(event)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to