зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1455676 part 16. Mostly stop using nsIDOMNode in browser/. r=mossop
This commit is contained in:
Родитель
5ae7919fcf
Коммит
87340cbda5
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [ "TranslationDocument" ];
|
var EXPORTED_SYMBOLS = [ "TranslationDocument" ];
|
||||||
|
|
||||||
const TEXT_NODE = Ci.nsIDOMNode.TEXT_NODE;
|
|
||||||
|
|
||||||
ChromeUtils.import("resource://services-common/async.js");
|
ChromeUtils.import("resource://services-common/async.js");
|
||||||
Cu.importGlobalProperties(["DOMParser"]);
|
Cu.importGlobalProperties(["DOMParser"]);
|
||||||
|
|
||||||
|
@ -141,7 +139,7 @@ this.TranslationDocument.prototype = {
|
||||||
let wasLastItemPlaceholder = false;
|
let wasLastItemPlaceholder = false;
|
||||||
|
|
||||||
for (let child of item.nodeRef.childNodes) {
|
for (let child of item.nodeRef.childNodes) {
|
||||||
if (child.nodeType == TEXT_NODE) {
|
if (child.nodeType == child.TEXT_NODE) {
|
||||||
let x = child.nodeValue.trim();
|
let x = child.nodeValue.trim();
|
||||||
if (x != "") {
|
if (x != "") {
|
||||||
item.original.push(x);
|
item.original.push(x);
|
||||||
|
@ -409,7 +407,7 @@ function regenerateTextFromOriginalHelper(item) {
|
||||||
function parseResultNode(item, node) {
|
function parseResultNode(item, node) {
|
||||||
item.translation = [];
|
item.translation = [];
|
||||||
for (let child of node.childNodes) {
|
for (let child of node.childNodes) {
|
||||||
if (child.nodeType == TEXT_NODE) {
|
if (child.nodeType == child.TEXT_NODE) {
|
||||||
item.translation.push(child.nodeValue);
|
item.translation.push(child.nodeValue);
|
||||||
} else if (child.localName == "br") {
|
} else if (child.localName == "br") {
|
||||||
item.translation.push(TranslationItem_NodePlaceholder);
|
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
|
// text change instead of two (while also leaving the page closer to
|
||||||
// its original state).
|
// its original state).
|
||||||
while (curNode &&
|
while (curNode &&
|
||||||
curNode.nodeType == TEXT_NODE &&
|
curNode.nodeType == curNode.TEXT_NODE &&
|
||||||
curNode.nodeValue.trim() == "") {
|
curNode.nodeValue.trim() == "") {
|
||||||
curNode = curNode.nextSibling;
|
curNode = curNode.nextSibling;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +606,7 @@ function swapTextForItem(item, target) {
|
||||||
// targetItem for those nodes are handled.
|
// targetItem for those nodes are handled.
|
||||||
|
|
||||||
while (curNode &&
|
while (curNode &&
|
||||||
(curNode.nodeType != TEXT_NODE ||
|
(curNode.nodeType != curNode.TEXT_NODE ||
|
||||||
curNode.nodeValue.trim() == "")) {
|
curNode.nodeValue.trim() == "")) {
|
||||||
curNode = curNode.nextSibling;
|
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
|
// 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
|
// text node to use. Text nodes don't need to be reordered, so
|
||||||
// the first one found can be used.
|
// the first one found can be used.
|
||||||
while (curNode && curNode.nodeType != TEXT_NODE) {
|
while (curNode && curNode.nodeType != curNode.TEXT_NODE) {
|
||||||
curNode = curNode.nextSibling;
|
curNode = curNode.nextSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +652,7 @@ function swapTextForItem(item, target) {
|
||||||
function getNextSiblingSkippingEmptyTextNodes(startSibling) {
|
function getNextSiblingSkippingEmptyTextNodes(startSibling) {
|
||||||
let item = startSibling.nextSibling;
|
let item = startSibling.nextSibling;
|
||||||
while (item &&
|
while (item &&
|
||||||
item.nodeType == TEXT_NODE &&
|
item.nodeType == item.TEXT_NODE &&
|
||||||
item.nodeValue.trim() == "") {
|
item.nodeValue.trim() == "") {
|
||||||
item = item.nextSibling;
|
item = item.nextSibling;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +662,7 @@ function getNextSiblingSkippingEmptyTextNodes(startSibling) {
|
||||||
function clearRemainingNonEmptyTextNodesFromElement(startSibling) {
|
function clearRemainingNonEmptyTextNodesFromElement(startSibling) {
|
||||||
let item = startSibling;
|
let item = startSibling;
|
||||||
while (item) {
|
while (item) {
|
||||||
if (item.nodeType == TEXT_NODE &&
|
if (item.nodeType == item.TEXT_NODE &&
|
||||||
item.nodeValue != "") {
|
item.nodeValue != "") {
|
||||||
item.nodeValue = "";
|
item.nodeValue = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ var LabelUtils = {
|
||||||
return;
|
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();
|
let trimmedText = el.textContent.trim();
|
||||||
if (trimmedText) {
|
if (trimmedText) {
|
||||||
strings.push(trimmedText);
|
strings.push(trimmedText);
|
||||||
|
@ -336,7 +336,7 @@ var LabelUtils = {
|
||||||
|
|
||||||
for (let node of el.childNodes) {
|
for (let node of el.childNodes) {
|
||||||
let nodeType = node.nodeType;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
_extractLabelStrings(node);
|
_extractLabelStrings(node);
|
||||||
|
|
|
@ -336,7 +336,7 @@ class ContextMenu {
|
||||||
let depth = 1;
|
let depth = 1;
|
||||||
while (node && depth > 0) {
|
while (node && depth > 0) {
|
||||||
// See if this node is text.
|
// 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.
|
// Add this text to our collection.
|
||||||
text += " " + node.data;
|
text += " " + node.data;
|
||||||
} else if (node instanceof this.content.HTMLImageElement) {
|
} else if (node instanceof this.content.HTMLImageElement) {
|
||||||
|
@ -535,7 +535,7 @@ class ContextMenu {
|
||||||
// Media related cache info parent needs for saving
|
// Media related cache info parent needs for saving
|
||||||
let contentType = null;
|
let contentType = null;
|
||||||
let contentDisposition = 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 instanceof Ci.nsIImageLoadingContent &&
|
||||||
aEvent.composedTarget.currentURI) {
|
aEvent.composedTarget.currentURI) {
|
||||||
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.composedTarget);
|
disableSetDesktopBg = this._disableSetDesktopBackground(aEvent.composedTarget);
|
||||||
|
@ -711,7 +711,7 @@ class ContextMenu {
|
||||||
|
|
||||||
context.shouldDisplay = true;
|
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">
|
// Don't display for XUL element unless <label class="text-link">
|
||||||
(node.namespaceURI == XUL_NS && !this._isXULTextLinkLabel(node))) {
|
(node.namespaceURI == XUL_NS && !this._isXULTextLinkLabel(node))) {
|
||||||
context.shouldDisplay = false;
|
context.shouldDisplay = false;
|
||||||
|
@ -791,7 +791,7 @@ class ContextMenu {
|
||||||
_setContextForNodesNoChildren(editFlags) {
|
_setContextForNodesNoChildren(editFlags) {
|
||||||
const context = this.context;
|
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.
|
// For text nodes, look at the parent node to determine the spellcheck attribute.
|
||||||
context.canSpellCheck = context.target.parentNode &&
|
context.canSpellCheck = context.target.parentNode &&
|
||||||
this._isSpellCheckEnabled(context.target);
|
this._isSpellCheckEnabled(context.target);
|
||||||
|
@ -800,7 +800,7 @@ class ContextMenu {
|
||||||
|
|
||||||
// We only deal with TEXT_NODE and ELEMENT_NODE in this function, so return
|
// We only deal with TEXT_NODE and ELEMENT_NODE in this function, so return
|
||||||
// early if we don't have one.
|
// early if we don't have one.
|
||||||
if (context.target.nodeType != Ci.nsIDOMNode.ELEMENT_NODE) {
|
if (context.target.nodeType != context.target.ELEMENT_NODE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -931,7 +931,7 @@ class ContextMenu {
|
||||||
let elem = context.target;
|
let elem = context.target;
|
||||||
|
|
||||||
while (elem) {
|
while (elem) {
|
||||||
if (elem.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
|
if (elem.nodeType == elem.ELEMENT_NODE) {
|
||||||
// Link?
|
// Link?
|
||||||
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
||||||
|
|
||||||
|
@ -997,7 +997,7 @@ class ContextMenu {
|
||||||
// See if the user clicked on MathML
|
// See if the user clicked on MathML
|
||||||
const MathML_NS = "http://www.w3.org/1998/Math/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.parentNode.namespaceURI == MathML_NS) ||
|
||||||
(context.target.namespaceURI == MathML_NS)) {
|
(context.target.namespaceURI == MathML_NS)) {
|
||||||
context.onMathML = true;
|
context.onMathML = true;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче