Bug 1569830 - Port Bug 1120967 "Broken middle/right click on links via about:preferences pages" to SeaMonkey. r=frg a=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Wed, 31 Jul 2019 21:56:04 +0200
changeset 32257 7f9f81bab5610f028e80c9f2b90412c66085f51c
parent 32256 d40072488eaea90bd58f1336f0b32d2a0e228730
child 32258 2375c07411d59718c1323a98ab08eb603cec5d27
push id208
push userfrgrahl@gmx.net
push dateWed, 31 Jul 2019 19:58:37 +0000
treeherdercomm-esr60@2375c07411d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg, frg
bugs1569830, 1120967
Bug 1569830 - Port Bug 1120967 "Broken middle/right click on links via about:preferences pages" to SeaMonkey. r=frg a=frg
suite/base/content/nsContextMenu.js
--- a/suite/base/content/nsContextMenu.js
+++ b/suite/base/content/nsContextMenu.js
@@ -527,17 +527,19 @@ nsContextMenu.prototype = {
   },
 
   // Set various context menu attributes based on the state of the world.
   setTarget: function(aNode, aRangeParent, aRangeOffset) {
     // Currently "isRemote" is always false.
     //this.isRemote = gContextMenuContentData && gContextMenuContentData.isRemote;
 
     const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
-    if (aNode.namespaceURI == xulNS) {
+    if (aNode.nodeType == Node.DOCUMENT_NODE ||
+        // Not display on XUL element but relax for <label class="text-link">
+        (aNode.namespaceURI == xulNS && !isXULTextLinkLabel(aNode))) {
       this.shouldDisplay = false;
       return;
     }
 
     // Initialize contextual info.
     this.onImage               = false;
     this.onLoadedImage         = false;
     this.onStandaloneImage     = false;
@@ -691,17 +693,18 @@ nsContextMenu.prototype = {
     // Bubble out, looking for items of interest
     const NS_MathML = "http://www.w3.org/1998/Math/MathML";
     const XMLNS = "http://www.w3.org/XML/1998/namespace";
     var elem = this.target;
     while (elem) {
       if (elem.nodeType == Node.ELEMENT_NODE) {
         // Link?
         if (!this.onLink &&
-            ((elem instanceof HTMLAnchorElement && elem.href) ||
+            (isXULTextLinkLabel(elem) ||
+             (elem instanceof HTMLAnchorElement && elem.href) ||
              (elem instanceof HTMLAreaElement && elem.href) ||
              elem instanceof HTMLLinkElement ||
              (elem.namespaceURI == NS_MathML && elem.hasAttribute("href")) ||
              elem.getAttributeNS("http://www.w3.org/1999/xlink", "type") == "simple")) {
           // Clicked on a link.
           this.onLink = true;
           this.onMetaDataItem = true;
           // Remember corresponding element.
@@ -779,16 +782,23 @@ nsContextMenu.prototype = {
                                 .getInterface(Ci.nsIEditingSession);
         InlineSpellCheckerUI.init(editingSession.getEditorForWindow(win));
         InlineSpellCheckerUI.initFromEvent(aRangeParent, aRangeOffset);
         var canSpell = InlineSpellCheckerUI.canSpellCheck && this.canSpellCheck;
         this.showItem("spell-check-enabled", canSpell);
         this.showItem("spell-separator", canSpell);
       }
     }
+
+    function isXULTextLinkLabel(node) {
+      return node.namespaceURI == xulNS &&
+             node.tagName == "label" &&
+             node.classList.contains('text-link') &&
+             node.href;
+    }
   },
 
   initPopupPrincipal: function() {
     // quick check: if no opener, it can't be a popup
     if (!window.content.opener)
       return;
     try {
       var show = false;