Bug 1455676 part 16. Mostly stop using nsIDOMNode in browser/. r=mossop

This commit is contained in:
Boris Zbarsky 2018-05-29 22:58:50 -04:00
Родитель 5ae7919fcf
Коммит 87340cbda5
3 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -6,8 +6,6 @@
var EXPORTED_SYMBOLS = [ "TranslationDocument" ];
const TEXT_NODE = Ci.nsIDOMNode.TEXT_NODE;
ChromeUtils.import("resource://services-common/async.js");
Cu.importGlobalProperties(["DOMParser"]);
@ -141,7 +139,7 @@ this.TranslationDocument.prototype = {
let wasLastItemPlaceholder = false;
for (let child of item.nodeRef.childNodes) {
if (child.nodeType == TEXT_NODE) {
if (child.nodeType == child.TEXT_NODE) {
let x = child.nodeValue.trim();
if (x != "") {
item.original.push(x);
@ -409,7 +407,7 @@ function regenerateTextFromOriginalHelper(item) {
function parseResultNode(item, node) {
item.translation = [];
for (let child of node.childNodes) {
if (child.nodeType == TEXT_NODE) {
if (child.nodeType == child.TEXT_NODE) {
item.translation.push(child.nodeValue);
} else if (child.localName == "br") {
item.translation.push(TranslationItem_NodePlaceholder);
@ -558,7 +556,7 @@ function swapTextForItem(item, target) {
// text change instead of two (while also leaving the page closer to
// its original state).
while (curNode &&
curNode.nodeType == TEXT_NODE &&
curNode.nodeType == curNode.TEXT_NODE &&
curNode.nodeValue.trim() == "") {
curNode = curNode.nextSibling;
}
@ -608,7 +606,7 @@ function swapTextForItem(item, target) {
// targetItem for those nodes are handled.
while (curNode &&
(curNode.nodeType != TEXT_NODE ||
(curNode.nodeType != curNode.TEXT_NODE ||
curNode.nodeValue.trim() == "")) {
curNode = curNode.nextSibling;
}
@ -617,7 +615,7 @@ function swapTextForItem(item, target) {
// Finally, if it's a text item, we just need to find the next
// text node to use. Text nodes don't need to be reordered, so
// the first one found can be used.
while (curNode && curNode.nodeType != TEXT_NODE) {
while (curNode && curNode.nodeType != curNode.TEXT_NODE) {
curNode = curNode.nextSibling;
}
@ -654,7 +652,7 @@ function swapTextForItem(item, target) {
function getNextSiblingSkippingEmptyTextNodes(startSibling) {
let item = startSibling.nextSibling;
while (item &&
item.nodeType == TEXT_NODE &&
item.nodeType == item.TEXT_NODE &&
item.nodeValue.trim() == "") {
item = item.nextSibling;
}
@ -664,7 +662,7 @@ function getNextSiblingSkippingEmptyTextNodes(startSibling) {
function clearRemainingNonEmptyTextNodesFromElement(startSibling) {
let item = startSibling;
while (item) {
if (item.nodeType == TEXT_NODE &&
if (item.nodeType == item.TEXT_NODE &&
item.nodeValue != "") {
item.nodeValue = "";
}

Просмотреть файл

@ -326,7 +326,7 @@ var LabelUtils = {
return;
}
if (el.nodeType == Ci.nsIDOMNode.TEXT_NODE || el.childNodes.length == 0) {
if (el.nodeType == el.TEXT_NODE || el.childNodes.length == 0) {
let trimmedText = el.textContent.trim();
if (trimmedText) {
strings.push(trimmedText);
@ -336,7 +336,7 @@ var LabelUtils = {
for (let node of el.childNodes) {
let nodeType = node.nodeType;
if (nodeType != Ci.nsIDOMNode.ELEMENT_NODE && nodeType != Ci.nsIDOMNode.TEXT_NODE) {
if (nodeType != node.ELEMENT_NODE && nodeType != node.TEXT_NODE) {
continue;
}
_extractLabelStrings(node);

Просмотреть файл

@ -336,7 +336,7 @@ class ContextMenu {
let depth = 1;
while (node && depth > 0) {
// See if this node is text.
if (node.nodeType == Ci.nsIDOMNode.TEXT_NODE) {
if (node.nodeType == node.TEXT_NODE) {
// Add this text to our collection.
text += " " + node.data;
} else if (node instanceof this.content.HTMLImageElement) {
@ -535,7 +535,7 @@ class ContextMenu {
// Media related cache info parent needs for saving
let contentType = null;
let contentDisposition = null;
if (aEvent.composedTarget.nodeType == Ci.nsIDOMNode.ELEMENT_NODE &&
if (aEvent.composedTarget.nodeType == aEvent.composedTarget.ELEMENT_NODE &&
aEvent.composedTarget instanceof Ci.nsIImageLoadingContent &&
aEvent.composedTarget.currentURI) {
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.composedTarget);
@ -711,7 +711,7 @@ class ContextMenu {
context.shouldDisplay = true;
if (node.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE ||
if (node.nodeType == node.DOCUMENT_NODE ||
// Don't display for XUL element unless <label class="text-link">
(node.namespaceURI == XUL_NS && !this._isXULTextLinkLabel(node))) {
context.shouldDisplay = false;
@ -791,7 +791,7 @@ class ContextMenu {
_setContextForNodesNoChildren(editFlags) {
const context = this.context;
if (context.target.nodeType == Ci.nsIDOMNode.TEXT_NODE) {
if (context.target.nodeType == context.target.TEXT_NODE) {
// For text nodes, look at the parent node to determine the spellcheck attribute.
context.canSpellCheck = context.target.parentNode &&
this._isSpellCheckEnabled(context.target);
@ -800,7 +800,7 @@ class ContextMenu {
// We only deal with TEXT_NODE and ELEMENT_NODE in this function, so return
// early if we don't have one.
if (context.target.nodeType != Ci.nsIDOMNode.ELEMENT_NODE) {
if (context.target.nodeType != context.target.ELEMENT_NODE) {
return;
}
@ -931,7 +931,7 @@ class ContextMenu {
let elem = context.target;
while (elem) {
if (elem.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
if (elem.nodeType == elem.ELEMENT_NODE) {
// Link?
const XLINK_NS = "http://www.w3.org/1999/xlink";
@ -997,7 +997,7 @@ class ContextMenu {
// See if the user clicked on MathML
const MathML_NS = "http://www.w3.org/1998/Math/MathML";
if ((context.target.nodeType == Ci.nsIDOMNode.TEXT_NODE &&
if ((context.target.nodeType == context.target.TEXT_NODE &&
context.target.parentNode.namespaceURI == MathML_NS) ||
(context.target.namespaceURI == MathML_NS)) {
context.onMathML = true;