Bug 1245751 - Part 12: Retrieve href from both None & XLink namespace in Browser & Android. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 07 Jul 2016 17:07:14 +0800
changeset 407863 8250770d3bb22123a3a881fd8c2fa9a42841b1a5
parent 407862 bc5c68ea10fb547099dd973e9799e7868f20a429
child 407864 5b9936110a070f4c6b6f48b130057484a9fd0b46
push id28064
push userbmo:boris.chiou@gmail.com
push dateWed, 31 Aug 2016 04:26:14 +0000
bugs1245751
milestone51.0a1
Bug 1245751 - Part 12: Retrieve href from both None & XLink namespace in Browser & Android. MozReview-Commit-ID: dSyuTRh5MY
browser/base/content/browser.js
browser/base/content/content.js
browser/base/content/nsContextMenu.js
mobile/android/chrome/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5393,17 +5393,19 @@ function hrefAndLinkNodeForClickEvent(ev
 
   // If there is no linkNode, try simple XLink.
   let href, baseURI;
   node = event.target;
   while (node && !href) {
     if (node.nodeType == Node.ELEMENT_NODE &&
         (node.localName == "a" ||
          node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
-      href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+      href = node.getAttribute("href") ||
+             node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+
       if (href) {
         baseURI = node.baseURI;
         break;
       }
     }
     node = node.parentNode;
   }
 
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -588,17 +588,18 @@ var ClickEventHandler = {
 
     // If there is no linkNode, try simple XLink.
     let href, baseURI;
     node = event.target;
     while (node && !href) {
       if (node.nodeType == content.Node.ELEMENT_NODE &&
           (node.localName == "a" ||
            node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
-        href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
+        href = node.getAttribute("href") ||
+               node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
         if (href) {
           baseURI = node.ownerDocument.baseURIObject;
           break;
         }
       }
       node = node.parentNode;
     }
 
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1561,18 +1561,18 @@ nsContextMenu.prototype = {
   },
 
   // Generate fully qualified URL for clicked-on link.
   getLinkURL: function() {
     var href = this.link.href;
     if (href)
       return href;
 
-    href = this.link.getAttributeNS("http://www.w3.org/1999/xlink",
-                                    "href");
+    href = this.link.getAttribute("href") ||
+           this.link.getAttributeNS("http://www.w3.org/1999/xlink", "href");
 
     if (!href || !href.match(/\S/)) {
       // Without this we try to save as the current doc,
       // for example, HTML case also throws if empty
       throw "Empty href";
     }
 
     return makeURLAbsolute(this.link.baseURI, href);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2993,17 +2993,18 @@ var NativeWindow = {
       };
     },
 
     _getLinkURL: function ch_getLinkURL(aLink) {
       let href = aLink.href;
       if (href)
         return href;
 
-      href = aLink.getAttributeNS(kXLinkNamespace, "href");
+      href = aLink.getAttribute("href") ||
+             aLink.getAttributeNS(kXLinkNamespace, "href");
       if (!href || !href.match(/\S/)) {
         // Without this we try to save as the current doc,
         // for example, HTML case also throws if empty
         throw "Empty href";
       }
 
       return this.makeURLAbsolute(aLink.baseURI, href);
     },