Title: [247803] trunk/Source/WebInspectorUI
Revision
247803
Author
[email protected]
Date
2019-07-24 17:42:23 -0700 (Wed, 24 Jul 2019)

Log Message

Web Inspector: REGRESSION: no context menu items work when context menu clicking on "Add Breakpoint"
https://bugs.webkit.org/show_bug.cgi?id=199953

Reviewed by Joseph Pecoraro.

* UserInterface/Views/ContextMenuUtilities.js:
(WI.addMouseDownContextMenuHandlers): Added.
Create a helper function for managing elements that show a context menu on "mousedown".

* UserInterface/Base/SearchUtilities.js:
(WI.SearchUtilities.createSettingsButton):
* UserInterface/Views/CanvasContentView.js:
(WI.CanvasContentView.prototype.initialLayout):
(WI.CanvasContentView.prototype._populateCanvasElementButtonContextMenu): Added.
(WI.CanvasContentView.prototype._populateViewShaderButtonContextMenu): Added.
(WI.CanvasContentView.prototype._populateViewRecordingButtonContextMenu): Added.
(WI.CanvasContentView.prototype._handleCanvasElementButtonMouseDown): Deleted.
(WI.CanvasContentView.prototype._handleViewShaderButtonMouseDown): Deleted.
(WI.CanvasContentView.prototype._handleViewRecordingButtonMouseDown): Deleted.
* UserInterface/Views/DebuggerSidebarPanel.js:
(WI.DebuggerSidebarPanel):
(WI.DebuggerSidebarPanel.prototype._populateCreateBreakpointContextMenu): Added.
(WI.DebuggerSidebarPanel.prototype._handleCreateBreakpointMouseDown): Deleted.
* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel):
(WI.SourcesNavigationSidebarPanel.prototype._populateResourceGroupingModeContextMenu): Added.
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu): Added.
(WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeMouseDown): Deleted.
(WI.SourcesNavigationSidebarPanel.prototype._handleCreateBreakpointMouseDown): Deleted.

* UserInterface/Views/TabBar.js:
(WI.TabBar):
(WI.TabBar.prototype._handleTabPickerTabContextMenu): Deleted.
* UserInterface/Views/LegacyTabBar.js:
(WI.LegacyTabBar):
(WI.LegacyTabBar.prototype._handleTabPickerTabContextMenu): Deleted.
Remove the "contextmenu" handler on the tab picker, as that's already used by the entire
tab bar to show/hide tabs.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (247802 => 247803)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-07-25 00:42:23 UTC (rev 247803)
@@ -1,5 +1,46 @@
 2019-07-24  Devin Rousso  <[email protected]>
 
+        Web Inspector: REGRESSION: no context menu items work when context menu clicking on "Add Breakpoint"
+        https://bugs.webkit.org/show_bug.cgi?id=199953
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/ContextMenuUtilities.js:
+        (WI.addMouseDownContextMenuHandlers): Added.
+        Create a helper function for managing elements that show a context menu on "mousedown".
+
+        * UserInterface/Base/SearchUtilities.js:
+        (WI.SearchUtilities.createSettingsButton):
+        * UserInterface/Views/CanvasContentView.js:
+        (WI.CanvasContentView.prototype.initialLayout):
+        (WI.CanvasContentView.prototype._populateCanvasElementButtonContextMenu): Added.
+        (WI.CanvasContentView.prototype._populateViewShaderButtonContextMenu): Added.
+        (WI.CanvasContentView.prototype._populateViewRecordingButtonContextMenu): Added.
+        (WI.CanvasContentView.prototype._handleCanvasElementButtonMouseDown): Deleted.
+        (WI.CanvasContentView.prototype._handleViewShaderButtonMouseDown): Deleted.
+        (WI.CanvasContentView.prototype._handleViewRecordingButtonMouseDown): Deleted.
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WI.DebuggerSidebarPanel):
+        (WI.DebuggerSidebarPanel.prototype._populateCreateBreakpointContextMenu): Added.
+        (WI.DebuggerSidebarPanel.prototype._handleCreateBreakpointMouseDown): Deleted.
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel):
+        (WI.SourcesNavigationSidebarPanel.prototype._populateResourceGroupingModeContextMenu): Added.
+        (WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu): Added.
+        (WI.SourcesNavigationSidebarPanel.prototype._handleResourceGroupingModeMouseDown): Deleted.
+        (WI.SourcesNavigationSidebarPanel.prototype._handleCreateBreakpointMouseDown): Deleted.
+
+        * UserInterface/Views/TabBar.js:
+        (WI.TabBar):
+        (WI.TabBar.prototype._handleTabPickerTabContextMenu): Deleted.
+        * UserInterface/Views/LegacyTabBar.js:
+        (WI.LegacyTabBar):
+        (WI.LegacyTabBar.prototype._handleTabPickerTabContextMenu): Deleted.
+        Remove the "contextmenu" handler on the tab picker, as that's already used by the entire
+        tab bar to show/hide tabs.
+
+2019-07-24  Devin Rousso  <[email protected]>
+
         Web Inspector: print the target of `console.screenshot` last so the target is the closest item to the image
         https://bugs.webkit.org/show_bug.cgi?id=199308
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -72,22 +72,10 @@
     {
         console.assert(!isEmptyObject(settings));
 
-        let ignoreMouseDown = false;
-
         let button = document.createElement("button");
-        button.addEventListener("mousedown", (event) => {
-            event.stop();
-
-            if (ignoreMouseDown)
-                return;
-
-            ignoreMouseDown = true;
-
-            let contextMenu = WI.ContextMenu.createFromEvent(event);
-            contextMenu.addBeforeShowCallback(() => {
-                ignoreMouseDown = false;
-            });
-
+        button.classList.add("search-settings");
+        button.tabIndex = -1;
+        WI.addMouseDownContextMenuHandlers(button, (contextMenu) => {
             if (settings.caseSensitive) {
                 contextMenu.appendCheckboxItem(WI.UIString("Case Sensitive", "Case Sensitive @ Context Menu", "Context menu label for whether searches should be case sensitive."), () => {
                     settings.caseSensitive.value = !settings.caseSensitive.value;
@@ -99,11 +87,7 @@
                     settings.regularExpression.value = !settings.regularExpression.value;
                 }, settings.regularExpression.value);
             }
-
-            contextMenu.show();
         });
-        button.classList.add("search-settings");
-        button.tabIndex = -1;
 
         button.appendChild(WI.ImageUtilities.useSVGSymbol("Images/Gear.svg", "glyph"));
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -113,7 +113,7 @@
 
             let canvasElementButtonNavigationItem = new WI.ButtonNavigationItem("canvas-element", WI.UIString("Canvas Element"), "Images/Markup.svg", 16, 16);
             canvasElementButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
-            canvasElementButtonNavigationItem.element.addEventListener("mousedown", this._handleCanvasElementButtonMouseDown.bind(this));
+            WI.addMouseDownContextMenuHandlers(canvasElementButtonNavigationItem.element, this._populateCanvasElementButtonContextMenu.bind(this));
             navigationBar.addNavigationItem(canvasElementButtonNavigationItem);
 
             navigationBar.addNavigationItem(this._refreshButtonNavigationItem);
@@ -134,12 +134,12 @@
             this._viewShaderButton = document.createElement("img");
             this._viewShaderButton.classList.add("view-shader");
             this._viewShaderButton.title = WI.UIString("View Shader");
-            this._viewShaderButton.addEventListener("mousedown", this._handleViewShaderButtonMouseDown.bind(this));
+            WI.addMouseDownContextMenuHandlers(this._viewShaderButton, this._populateViewShaderButtonContextMenu.bind(this));
 
             this._viewRecordingButton = document.createElement("img");
             this._viewRecordingButton.classList.add("view-recording");
             this._viewRecordingButton.title = WI.UIString("View Recording");
-            this._viewRecordingButton.addEventListener("mousedown", this._handleViewRecordingButtonMouseDown.bind(this));
+            WI.addMouseDownContextMenuHandlers(this._viewRecordingButton, this._populateViewRecordingButtonContextMenu.bind(this));
 
             this._updateViewRelatedItems();
 
@@ -290,18 +290,8 @@
         });
     }
 
-    _handleCanvasElementButtonMouseDown(event)
+    _populateCanvasElementButtonContextMenu(contextMenu)
     {
-        if (this._ignoreCanvasElementButtonMouseDown)
-            return;
-
-        this._ignoreCanvasElementButtonMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreCanvasElementButtonMouseDown = false;
-        });
-
         if (this._canvasNode)
             WI.appendContextMenuItemsForDOMNode(contextMenu, this._canvasNode);
 
@@ -317,8 +307,6 @@
                 WI.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass);
             });
         });
-
-        contextMenu.show();
     }
 
     _showGridButtonClicked()
@@ -405,65 +393,41 @@
             this._viewRelatedItemsContainer.appendChild(this._viewRecordingButton);
     }
 
-    _handleViewShaderButtonMouseDown(event)
+    _populateViewShaderButtonContextMenu(contextMenu, event)
     {
-        if (this._ignoreViewShaderButtonMouseDown)
-            return;
-
         let shaderPrograms = this.representedObject.shaderProgramCollection;
         console.assert(shaderPrograms.size);
         if (!shaderPrograms.size)
             return;
 
-        if (shaderPrograms.size === 1) {
+        if (event.button === 0 && shaderPrograms.size === 1) {
             WI.showRepresentedObject(Array.from(shaderPrograms)[0]);
             return;
         }
 
-        this._ignoreViewShaderButtonMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreViewShaderButtonMouseDown = false;
-        });
-
         for (let shaderProgram of shaderPrograms) {
             contextMenu.appendItem(shaderProgram.displayName, () => {
                 WI.showRepresentedObject(shaderProgram);
             });
         }
-
-        contextMenu.show();
     }
 
-    _handleViewRecordingButtonMouseDown(event)
+    _populateViewRecordingButtonContextMenu(contextMenu, event)
     {
-        if (this._ignoreViewRecordingButtonMouseDown)
-            return;
-
         let recordings = this.representedObject.recordingCollection;
         console.assert(recordings.size);
         if (!recordings.size)
             return;
 
-        if (recordings.size === 1) {
+        if (event.button === 0 && recordings.size === 1) {
             WI.showRepresentedObject(Array.from(recordings)[0]);
             return;
         }
 
-        this._ignoreViewRecordingButtonMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreViewRecordingButtonMouseDown = false;
-        });
-
         for (let recording of recordings) {
             contextMenu.appendItem(recording.displayName, () => {
                 WI.showRepresentedObject(recording);
             });
         }
-
-        contextMenu.show();
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -23,6 +23,36 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WI.addMouseDownContextMenuHandlers = function(element, populateContextMenuCallback)
+{
+    let ignoreMouseDown = false;
+    element.addEventListener("mousedown", (event) => {
+        if (event.button !== 0)
+            return;
+
+        event.stop();
+
+        if (ignoreMouseDown)
+            return;
+
+        ignoreMouseDown = true;
+
+        let contextMenu = WI.ContextMenu.createFromEvent(event);
+        contextMenu.addBeforeShowCallback(() => {
+            ignoreMouseDown = false;
+        });
+
+        populateContextMenuCallback(contextMenu, event);
+
+        contextMenu.show();
+    });
+
+    element.addEventListener("contextmenu", (event) => {
+        let contextMenu = WI.ContextMenu.createFromEvent(event);
+        populateContextMenuCallback(contextMenu, event);
+    });
+};
+
 WI.appendContextMenuItemsForSourceCode = function(contextMenu, sourceCodeOrLocation)
 {
     console.assert(contextMenu instanceof WI.ContextMenu);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -157,7 +157,7 @@
         breakpointNavigationBarWrapper.appendChild(breakpointNavigationBar.element);
 
         this._createBreakpointButton = new WI.ButtonNavigationItem("create-breakpoint", WI.UIString("Create Breakpoint"), "Images/Plus13.svg", 13, 13);
-        this._createBreakpointButton.element.addEventListener("mousedown", this._handleCreateBreakpointMouseDown.bind(this));
+        WI.addMouseDownContextMenuHandlers(this._createBreakpointButton.element, this._populateCreateBreakpointContextMenu.bind(this));
         breakpointNavigationBar.addNavigationItem(this._createBreakpointButton);
 
         let breakpointsGroup = new WI.DetailsSectionGroup([breakpointsRow]);
@@ -1464,18 +1464,8 @@
             setting.value = !!treeElement.parent;
     }
 
-    _handleCreateBreakpointMouseDown(event)
+    _populateCreateBreakpointContextMenu(contextMenu)
     {
-        if (this._ignoreCreateBreakpointMouseDown)
-            return;
-
-        this._ignoreCreateBreakpointMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreCreateBreakpointMouseDown = false;
-        });
-
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
         if (InspectorBackend.domains.Debugger.setPauseOnAssertions) {
             let assertionFailuresBreakpointShown = WI.settings.showAssertionFailuresBreakpoint.value;
@@ -1516,8 +1506,6 @@
                 popover.show(this._createBreakpointButton.element, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MAX_X]);
             });
         }
-
-        contextMenu.show();
     }
 };
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LegacyTabBar.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LegacyTabBar.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LegacyTabBar.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -55,7 +55,6 @@
 
         this._tabPickerTabBarItem = new WI.PinnedTabBarItem("Images/TabPicker.svg", WI.UIString("Show hidden tabs"));
         this._tabPickerTabBarItem.element.classList.add("tab-picker");
-        this._tabPickerTabBarItem.element.addEventListener("contextmenu", this._handleTabPickerTabContextMenu.bind(this));
         this.addTabBarItem(this._tabPickerTabBarItem, {suppressAnimations: true});
     }
 
@@ -850,19 +849,6 @@
         WI.showNewTabTab();
     }
 
-    _handleTabPickerTabContextMenu(event)
-    {
-        if (!this._hiddenTabBarItems.length)
-            return;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        for (let item of this._hiddenTabBarItems) {
-            contextMenu.appendItem(item.title, () => {
-                this.selectedTabBarItem = item;
-            });
-        }
-    }
-
     _handleNewTabMouseEnter(event)
     {
         if (!this._tabAnimatedClosedSinceMouseEnter || !this.element.classList.contains("static-layout") || this.element.classList.contains("animating"))

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -188,7 +188,7 @@
         breakpointNavigationBarWrapper.appendChild(breakpointNavigationBar.element);
 
         this._createBreakpointButton = new WI.ButtonNavigationItem("create-breakpoint", WI.UIString("Create Breakpoint"), "Images/Plus13.svg", 13, 13);
-        this._createBreakpointButton.element.addEventListener("mousedown", this._handleCreateBreakpointMouseDown.bind(this));
+        WI.addMouseDownContextMenuHandlers(this._createBreakpointButton.element, this._populateCreateBreakpointContextMenu.bind(this));
         breakpointNavigationBar.addNavigationItem(this._createBreakpointButton);
 
         let breakpointsGroup = new WI.DetailsSectionGroup([breakpointsRow]);
@@ -219,7 +219,7 @@
 
         let resourceGroupingModeNavigationItem = new WI.ButtonNavigationItem("grouping-mode", WI.UIString("Grouping Mode"), "Images/Gear.svg", 15, 15);
         resourceGroupingModeNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
-        resourceGroupingModeNavigationItem.element.addEventListener("mousedown", this._handleResourceGroupingModeMouseDown.bind(this));
+        WI.addMouseDownContextMenuHandlers(resourceGroupingModeNavigationItem.element, this._populateResourceGroupingModeContextMenu.bind(this));
         this._resourcesNavigationBar.addNavigationItem(resourceGroupingModeNavigationItem);
 
         this._resourcesTreeOutline = this.contentTreeOutline;
@@ -1399,18 +1399,8 @@
         this.updateFilter();
     }
 
-    _handleResourceGroupingModeMouseDown(event)
+    _populateResourceGroupingModeContextMenu(contextMenu)
     {
-        if (this._ignoreResourceGroupingModeMouseDown)
-            return;
-
-        this._ignoreResourceGroupingModeMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreResourceGroupingModeMouseDown = false;
-        });
-
         function addOption(mode, label) {
             contextMenu.appendCheckboxItem(label, () => {
                 WI.settings.resourceGroupingMode.value = mode;
@@ -1418,8 +1408,6 @@
         }
         addOption(WI.Resource.GroupingMode.Path, WI.UIString("Group by Path"));
         addOption(WI.Resource.GroupingMode.Type, WI.UIString("Group by Type"));
-
-        contextMenu.show();
     }
 
     _handleTreeSelectionDidChange(event)
@@ -1518,18 +1506,8 @@
         this.element.style.setProperty("--breakpoints-count", count);
     }
 
-    _handleCreateBreakpointMouseDown(event)
+    _populateCreateBreakpointContextMenu(contextMenu)
     {
-        if (this._ignoreCreateBreakpointMouseDown)
-            return;
-
-        this._ignoreCreateBreakpointMouseDown = true;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        contextMenu.addBeforeShowCallback(() => {
-            this._ignoreCreateBreakpointMouseDown = false;
-        });
-
         // COMPATIBILITY (iOS 10): DebuggerAgent.setPauseOnAssertions did not exist yet.
         if (InspectorBackend.domains.Debugger.setPauseOnAssertions) {
             let assertionFailuresBreakpointShown = WI.settings.showAssertionFailuresBreakpoint.value;
@@ -1570,8 +1548,6 @@
                 popover.show(this._createBreakpointButton.element, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MAX_X]);
             });
         }
-
-        contextMenu.show();
     }
 
     _handleResourceGroupingModeChanged(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js (247802 => 247803)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2019-07-25 00:21:34 UTC (rev 247802)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2019-07-25 00:42:23 UTC (rev 247803)
@@ -48,7 +48,6 @@
 
         this._tabPickerTabBarItem = new WI.PinnedTabBarItem("Images/TabPicker.svg", WI.UIString("Show hidden tabs"));
         this._tabPickerTabBarItem.element.classList.add("tab-picker", "hidden");
-        this._tabPickerTabBarItem.element.addEventListener("contextmenu", this._handleTabPickerTabContextMenu.bind(this));
         this.addTabBarItem(this._tabPickerTabBarItem, {suppressAnimations: true});
     }
 
@@ -810,19 +809,6 @@
             }, checked, disabled);
         }
     }
-
-    _handleTabPickerTabContextMenu(event)
-    {
-        if (!this._hiddenTabBarItems.length)
-            return;
-
-        let contextMenu = WI.ContextMenu.createFromEvent(event);
-        for (let item of this._hiddenTabBarItems) {
-            contextMenu.appendItem(item.title, () => {
-                this.selectedTabBarItem = item;
-            });
-        }
-    }
 };
 
 WI.TabBar.CachedWidthSymbol = Symbol("cached-width");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to