Bug 1389650 - Change nsIDOMHTMLAnchorElement instanceof checks to getClassName; r=bz
MozReview-Commit-ID: Il2Ig98BHYP
--- a/browser/modules/PluginContent.jsm
+++ b/browser/modules/PluginContent.jsm
@@ -170,17 +170,17 @@ PluginContent.prototype = {
},
getPluginUI(plugin, anonid) {
return plugin.ownerDocument.
getAnonymousElementByAttribute(plugin, "anonid", anonid);
},
_getPluginInfo(pluginElement) {
- if (pluginElement instanceof Ci.nsIDOMHTMLAnchorElement) {
+ if (ChromeUtils.getClassName(pluginElement) === "HTMLAnchorElement") {
// Anchor elements are our place holders, and we only have them for Flash
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
return {
pluginName: "Shockwave Flash",
mimetype: FLASH_MIME_TYPE,
permissionString: pluginHost.getPermissionStringForType(FLASH_MIME_TYPE)
};
}
@@ -644,17 +644,17 @@ PluginContent.prototype = {
this.global.content.location.reload();
},
// Event listener for click-to-play plugins.
_handleClickToPlayEvent(plugin) {
let doc = plugin.ownerDocument;
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
let permissionString;
- if (plugin instanceof Ci.nsIDOMHTMLAnchorElement) {
+ if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") {
// We only have replacement content for Flash installs
permissionString = pluginHost.getPermissionStringForType(FLASH_MIME_TYPE);
} else {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
// guard against giving pluginHost.getPermissionStringForType a type
// not associated with any known plugin
if (!this.isKnownPlugin(objLoadingContent))
return;
@@ -679,17 +679,17 @@ PluginContent.prototype = {
},
onOverlayClick(event) {
let document = event.target.ownerDocument;
let plugin = document.getBindingParent(event.target);
let contentWindow = plugin.ownerGlobal.top;
let overlay = this.getPluginUI(plugin, "main");
// Have to check that the target is not the link to update the plugin
- if (!(event.originalTarget instanceof contentWindow.HTMLAnchorElement) &&
+ if (!(ChromeUtils.getClassName(event.originalTarget) === "HTMLAnchorElement") &&
(event.originalTarget.getAttribute("anonid") != "closeIcon") &&
!overlay.hasAttribute("dismissed") &&
event.button == 0 &&
event.isTrusted) {
this._showClickToPlayNotification(plugin, true);
event.stopPropagation();
event.preventDefault();
}
@@ -725,17 +725,17 @@ PluginContent.prototype = {
let placeHolderFound = false;
for (let plugin of plugins) {
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (!this.isKnownPlugin(plugin)) {
continue;
}
if (pluginInfo.permissionString == pluginHost.getPermissionStringForType(plugin.actualType)) {
let overlay = this.getPluginUI(plugin, "main");
- if (plugin instanceof Ci.nsIDOMHTMLAnchorElement) {
+ if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") {
placeHolderFound = true;
} else {
pluginFound = true;
}
if (newState == "block") {
if (overlay) {
overlay.addEventListener("click", this, true);
}
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -661,17 +661,17 @@ BrowserElementChild.prototype = {
state: e.state,
};
sendAsyncMsg('scrollviewchange', detail);
},
_ClickHandler: function(e) {
let isHTMLLink = node =>
- ((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) ||
+ ((ChromeUtils.getClassName(node) === "HTMLAnchorElement" && node.href) ||
(node instanceof Ci.nsIDOMHTMLAreaElement && node.href) ||
node instanceof Ci.nsIDOMHTMLLinkElement);
// Open in a new tab if middle click or ctrl/cmd-click,
// and e.target is a link or inside a link.
if ((Services.appinfo.OS == 'Darwin' && e.metaKey) ||
(Services.appinfo.OS != 'Darwin' && e.ctrlKey) ||
e.button == 1) {
@@ -850,17 +850,17 @@ BrowserElementChild.prototype = {
} else {
this._ctxHandlers = {};
}
},
_getSystemCtxMenuData: function(elem) {
let documentURI =
docShell.QueryInterface(Ci.nsIWebNavigation).currentURI.spec;
- if ((elem instanceof Ci.nsIDOMHTMLAnchorElement && elem.href) ||
+ if ((ChromeUtils.getClassName(elem) === "HTMLAnchorElement" && elem.href) ||
(elem instanceof Ci.nsIDOMHTMLAreaElement && elem.href)) {
return {uri: elem.href,
documentURI: documentURI,
text: elem.textContent.substring(0, kLongestReturnedString)};
}
if (elem instanceof Ci.nsIImageLoadingContent && elem.currentURI) {
return {uri: elem.currentURI.spec, documentURI: documentURI};
}
--- a/dom/ipc/remote-test.js
+++ b/dom/ipc/remote-test.js
@@ -21,17 +21,17 @@ var dshell = content.QueryInterface(Ci.n
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIDocShell);
addEventListener("click",
function(e) {
dump(e.target + "\n");
- if (e.target instanceof Components.interfaces.nsIDOMHTMLAnchorElement &&
+ if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" &&
dshell == docShell) {
var retval = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIContentFrameMessageManager).
sendSyncMessage("linkclick", { href: e.target.href });
dump(uneval(retval[0]) + "\n");
// Test here also that both retvals are the same
sendAsyncMessage("linkclick-reply-object", uneval(retval[0]) == uneval(retval[1]) ? retval[0] : "");
}
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2730,17 +2730,17 @@ var NativeWindow = {
return false;
},
/* Returns a label to be shown in a tabbed ui if there are multiple "contexts". For instance, if this
* is an image inside an <a> tag, we may have a "link" context and an "image" one.
*/
_getContextType: function(element) {
// For anchor nodes, we try to use the scheme to pick a string
- if (element instanceof Ci.nsIDOMHTMLAnchorElement) {
+ if (ChromeUtils.getClassName(element) === "HTMLAnchorElement") {
let uri = this.makeURI(this._getLinkURL(element));
try {
return Strings.browser.GetStringFromName("browser.menu.context." + uri.scheme);
} catch(ex) { }
}
// Otherwise we try the nodeName
try {
@@ -2815,17 +2815,17 @@ var NativeWindow = {
if (node.hasAttribute && node.hasAttribute("title")) {
return node.getAttribute("title");
}
return this._getUrl(node);
},
// Returns a url associated with a node
_getUrl: function(node) {
- if ((node instanceof Ci.nsIDOMHTMLAnchorElement && node.href) ||
+ if ((ChromeUtils.getClassName(node) === "HTMLAnchorElement" && node.href) ||
(node instanceof Ci.nsIDOMHTMLAreaElement && node.href)) {
return this._getLinkURL(node);
} else if (node instanceof Ci.nsIImageLoadingContent && node.currentURI) {
// The image is blocked by Tap-to-load Images
let originalURL = node.getAttribute("data-ctv-src");
if (originalURL) {
return originalURL;
}
@@ -3046,17 +3046,17 @@ var NativeWindow = {
},
makeURI: function makeURI(aURL, aOriginCharset, aBaseURI) {
return Services.io.newURI(aURL, aOriginCharset, aBaseURI);
},
_getLink: function(aElement) {
if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
- ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) ||
+ ((ChromeUtils.getClassName(aElement) === "HTMLAnchorElement" && aElement.href) ||
(aElement instanceof Ci.nsIDOMHTMLAreaElement && aElement.href) ||
aElement instanceof Ci.nsIDOMHTMLLinkElement ||
aElement.getAttributeNS(kXLinkNamespace, "type") == "simple")) {
try {
let url = this._getLinkURL(aElement);
return Services.io.newURI(url);
} catch (e) {}
}
@@ -4770,17 +4770,17 @@ var BrowserEventHandler = {
null);
} catch (e) {}
}
this._doTapHighlight(target);
},
_getLinkURI: function(aElement) {
if (aElement.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
- ((aElement instanceof Ci.nsIDOMHTMLAnchorElement && aElement.href) ||
+ ((ChromeUtils.getClassName(aElement) === "HTMLAnchorElement" && aElement.href) ||
(aElement instanceof Ci.nsIDOMHTMLAreaElement && aElement.href))) {
try {
return Services.io.newURI(aElement.href);
} catch (e) {}
}
return null;
},