Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1122)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js

Issue 2512013002: [DevTools] Handle external link clicks and context menu separately. (Closed)
Patch Set: rebased Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/main/module.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js b/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
index 1823ed260b3ad2695c772943bc22ccb204992dae..8396c4c0c5fbdd2dcf2da32b862e9b900e591c77 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js
@@ -1912,9 +1912,10 @@ UI.ThemeSupport.ColorUsage = {
* @param {string} url
* @param {string=} linkText
* @param {string=} className
+ * @param {boolean=} preventClick
* @return {!Element}
*/
-UI.createExternalLink = function(url, linkText, className) {
+UI.createExternalLink = function(url, linkText, className, preventClick) {
if (!linkText)
linkText = url;
@@ -1927,6 +1928,12 @@ UI.createExternalLink = function(url, linkText, className) {
if (href !== null) {
a.href = href;
a.classList.add('webkit-html-external-link');
+ a.addEventListener('click', (event) => {
+ event.consume(true);
+ if (!preventClick)
+ InspectorFrontendHost.openInNewTab(/** @type {string} */ (href));
+ }, false);
+ a[UI._externalLinkSymbol] = true;
}
if (linkText !== url)
a.title = url;
@@ -1936,6 +1943,31 @@ UI.createExternalLink = function(url, linkText, className) {
return a;
};
+UI._externalLinkSymbol = Symbol('UI._externalLink');
+
+/**
+ * @implements {UI.ContextMenu.Provider}
+ * @unrestricted
+ */
+UI.ExternaLinkContextMenuProvider = class {
+ /**
+ * @override
+ * @param {!Event} event
+ * @param {!UI.ContextMenu} contextMenu
+ * @param {!Object} target
+ */
+ appendApplicableItems(event, contextMenu, target) {
+ var targetNode = /** @type {!Node} */ (target);
+ while (targetNode && !targetNode[UI._externalLinkSymbol])
+ targetNode = targetNode.parentNodeOrShadowHost();
+ if (!targetNode || !targetNode.href)
+ return;
+ contextMenu.appendItem(UI.openLinkExternallyLabel(), () => InspectorFrontendHost.openInNewTab(targetNode.href));
+ contextMenu.appendItem(UI.copyLinkAddressLabel(), () => InspectorFrontendHost.copyText(targetNode.href));
+ }
+};
+
+
/**
* @param {string} article
* @param {string} title
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/main/module.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698