Title: [295161] trunk/Source/WebInspectorUI/UserInterface
Revision
295161
Author
drou...@apple.com
Date
2022-06-02 17:48:41 -0700 (Thu, 02 Jun 2022)

Log Message

Web Inspector: reference page links don't open externally when inspecting that reference page
https://bugs.webkit.org/show_bug.cgi?id=241246

Reviewed by Patrick Angle.

* Source/WebInspectorUI/UserInterface/Base/ReferencePage.js:
(WI.ReferencePage.prototype.createLinkElement):

* Source/WebInspectorUI/UserInterface/Base/Main.js:
(WI.handlePossibleLinkClick):
(WI.openURL):
* Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js:
(WI.appendContextMenuItemsForURL):
* Source/WebInspectorUI/UserInterface/Views/DOMDetailsSidebarPanel.js:
(WI.DOMDetailsSidebarPanel.prototype._mouseWasClicked):
* Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView.prototype._mouseWasClicked.followLink):
* Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js:
(WI.ResourceContentView.prototype._mouseWasClicked):
Drive-by: Refactor `WI.openURL` (and `WI.handlePossibleLinkClick`) to have `frame` be in `options`.

Canonical link: https://commits.webkit.org/251247@main

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -1060,7 +1060,7 @@
     return true;
 };
 
-WI.handlePossibleLinkClick = function(event, frame, options = {})
+WI.handlePossibleLinkClick = function(event, options = {})
 {
     let anchorElement = event.target.closest("a");
     if (!anchorElement || !anchorElement.href)
@@ -1075,7 +1075,7 @@
     event.preventDefault();
     event.stopPropagation();
 
-    WI.openURL(anchorElement.href, frame, {
+    WI.openURL(anchorElement.href, {
         ...options,
         lineNumber: anchorElement.lineNumber,
         ignoreSearchTab: !WI.isShowingSearchTab(),
@@ -1084,19 +1084,17 @@
     return true;
 };
 
-WI.openURL = function(url, frame, options = {})
+WI.openURL = function(url, {alwaysOpenExternally, frame, ...options} = {})
 {
     console.assert(url);
     if (!url)
         return;
 
-    console.assert(typeof options.lineNumber === "undefined" || typeof options.lineNumber === "number", "lineNumber should be a number.");
-
     // If alwaysOpenExternally is not defined, base it off the command/meta key for the current event.
-    if (options.alwaysOpenExternally === undefined || options.alwaysOpenExternally === null)
-        options.alwaysOpenExternally = window.event ? window.event.metaKey : false;
+    if (alwaysOpenExternally === undefined || alwaysOpenExternally === null)
+        alwaysOpenExternally = window.event?.metaKey ?? false;
 
-    if (options.alwaysOpenExternally) {
+    if (alwaysOpenExternally) {
         InspectorFrontendHost.openURLExternally(url);
         return;
     }
@@ -1119,6 +1117,8 @@
         // Context menu selections may go through this code path; don't clobber the previously-set hint.
         if (!options.initiatorHint)
             options.initiatorHint = WI.TabBrowser.TabNavigationInitiator.LinkClick;
+
+        console.assert(typeof options.lineNumber === "undefined" || typeof options.lineNumber === "number");
         let positionToReveal = new WI.SourceCodePosition(options.lineNumber, 0);
         WI.showSourceCode(resource, {...options, positionToReveal});
         return;

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/ReferencePage.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Base/ReferencePage.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/ReferencePage.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -56,7 +56,13 @@
         link.className = "reference-page-link";
         link.href = "" = url;
         link.textContent = "?";
+        link.addEventListener("click", (event) => {
+            event.preventDefault();
+            event.stopPropagation();
 
+            WI.openURL(link.href, {alwaysOpenExternally: true});
+        });
+
         return wrapper;
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -233,13 +233,12 @@
         else if (options.sourceCode)
             WI.showSourceCode(options.sourceCode, options);
         else
-            WI.openURL(url, options.frame, options);
+            WI.openURL(url, options);
     }
 
     if (!url.startsWith("_javascript_:") && !url.startsWith("data:")) {
         contextMenu.appendItem(WI.UIString("Open in New Window", "Open in New Window @ Context Menu Item", "Context menu item for opening the target item in a new window."), () => {
-            const frame = null;
-            WI.openURL(url, frame, {alwaysOpenExternally: true});
+            WI.openURL(url, {alwaysOpenExternally: true});
         });
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMDetailsSidebarPanel.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMDetailsSidebarPanel.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMDetailsSidebarPanel.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -101,18 +101,17 @@
 
     _mouseWasClicked(event)
     {
-        let parentFrame = null;
+        let options = {
+            ignoreNetworkTab: true,
+            ignoreSearchTab: true,
+        };
 
         if (this._domNode && this._domNode.ownerDocument) {
             let mainResource = WI.networkManager.resourcesForURL(this._domNode.ownerDocument.documentURL).firstValue;
             if (mainResource)
-                parentFrame = mainResource.parentFrame;
+                options.frame = mainResource.parentFrame;
         }
 
-        const options = {
-            ignoreNetworkTab: true,
-            ignoreSearchTab: true,
-        };
-        WI.handlePossibleLinkClick(event, parentFrame, options);
+        WI.handlePossibleLinkClick(event, options);
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -583,12 +583,13 @@
             // to see if the command key is down like it normally would. So we need to do that check
             // before calling WI.openURL.
             const options = {
-                alwaysOpenExternally: event ? event.metaKey : false,
+                alwaysOpenExternally: event?.metaKey ?? false,
+                frame: this._frame,
                 lineNumber: anchorElement.lineNumber,
                 ignoreNetworkTab: true,
                 ignoreSearchTab: true,
             };
-            WI.openURL(anchorElement.href, this._frame, options);
+            WI.openURL(anchorElement.href, options);
         }
 
         // Start a timeout since this is a single click, if the timeout is canceled before it fires,

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js (295160 => 295161)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js	2022-06-03 00:44:35 UTC (rev 295160)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js	2022-06-03 00:48:41 UTC (rev 295161)
@@ -436,7 +436,7 @@
 
     _mouseWasClicked(event)
     {
-        WI.handlePossibleLinkClick(event, this._resource.parentFrame);
+        WI.handlePossibleLinkClick(event, {frame: this._resource.parentFrame});
     }
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to