Bug 1410796 - Drop element.isSVGElement. r=whimboo

This drops the now-superfluous element.isSVGElement.  SVG elements
are matched with element.isDOMElement because there is no special
need to distinguish them from other elements, apart from chrome elements.

MozReview-Commit-ID: 3AgEtyaAsPU

--HG--
extra : rebase_source : 7ec52aa9a7b7404eff5b6daf8ebe8259f06265da
This commit is contained in:
Andreas Tolfsen 2017-10-31 19:57:40 +00:00
Родитель b91e906a0c
Коммит e944eb5cdb
3 изменённых файлов: 11 добавлений и 42 удалений

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

@ -32,7 +32,6 @@ const {
ORDERED_NODE_ITERATOR_TYPE, ORDERED_NODE_ITERATOR_TYPE,
} = Ci.nsIDOMXPathResult; } = Ci.nsIDOMXPathResult;
const SVGNS = "http://www.w3.org/2000/svg";
const XBLNS = "http://www.mozilla.org/xbl"; const XBLNS = "http://www.mozilla.org/xbl";
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -143,14 +142,14 @@ element.Store = class {
*/ */
add(el) { add(el) {
const isDOMElement = element.isDOMElement(el); const isDOMElement = element.isDOMElement(el);
const isSVGElement = element.isSVGElement(el);
const isDOMWindow = element.isDOMWindow(el); const isDOMWindow = element.isDOMWindow(el);
const isXULElement = element.isXULElement(el); const isXULElement = element.isXULElement(el);
const context = isXULElement ? "chrome" : "content"; const context = isXULElement ? "chrome" : "content";
if (!(isDOMElement || isSVGElement || isDOMWindow || isXULElement)) { if (!(isDOMElement || isDOMWindow || isXULElement)) {
throw new TypeError("Expected Element, SVGElement, " + throw new TypeError(
pprint`WindowProxy, or XULElement, got: ${el}`); "Expected an element or WindowProxy, " +
pprint`got: ${el}`);
} }
for (let i in this.els) { for (let i in this.els) {
@ -1058,16 +1057,14 @@ element.scrollIntoView = function(el) {
* Ascertains whether <var>node</var> is a DOM-, SVG-, or XUL element. * Ascertains whether <var>node</var> is a DOM-, SVG-, or XUL element.
* *
* @param {*} node * @param {*} node
* Element thought to be an <code>Element</code>, * Element thought to be an <code>Element</code> or
* <code>SVGElement</code>, or <code>XULElement</code>. * <code>XULElement</code>.
* *
* @return {boolean} * @return {boolean}
* True if <var>node</var> is an element, false otherwise. * True if <var>node</var> is an element, false otherwise.
*/ */
element.isElement = function(node) { element.isElement = function(node) {
return element.isDOMElement(node) || return element.isDOMElement(node) || element.isXULElement(node);
element.isSVGElement(node) ||
element.isXULElement(node);
}; };
/** /**
@ -1082,26 +1079,11 @@ element.isElement = function(node) {
element.isDOMElement = function(node) { element.isDOMElement = function(node) {
return typeof node == "object" && return typeof node == "object" &&
node !== null && node !== null &&
"nodeType" in node &&
node.nodeType === node.ELEMENT_NODE && node.nodeType === node.ELEMENT_NODE &&
!element.isXULElement(node); !element.isXULElement(node);
}; };
/**
* Ascertains whether <var>node</var> is an SVG element.
*
* @param {*} node
* Object thought to be an <code>SVGElement</code>.
*
* @return {boolean}
* True if <var>node</var> is an SVG element, false otherwise.
*/
element.isSVGElement = function(node) {
return typeof node == "object" &&
node !== null &&
node.nodeType === node.ELEMENT_NODE &&
node.namespaceURI === SVGNS;
};
/** /**
* Ascertains whether <var>el</var> is a XUL- or XBL element. * Ascertains whether <var>el</var> is a XUL- or XBL element.
* *
@ -1252,7 +1234,7 @@ class WebElement {
static from(node) { static from(node) {
const uuid = WebElement.generateUUID(); const uuid = WebElement.generateUUID();
if (element.isDOMElement(node) || element.isSVGElement(node)) { if (element.isDOMElement(node)) {
return new ContentWebElement(uuid); return new ContentWebElement(uuid);
} else if (element.isDOMWindow(node)) { } else if (element.isDOMWindow(node)) {
if (node.parent === node) { if (node.parent === node) {

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

@ -265,7 +265,7 @@ evaluate.toJSON = function(obj, seenEls) {
if (t == "[object Undefined]" || t == "[object Null]") { if (t == "[object Undefined]" || t == "[object Null]") {
return null; return null;
// literals // primitives
} else if (t == "[object Boolean]" || } else if (t == "[object Boolean]" ||
t == "[object Number]" || t == "[object Number]" ||
t == "[object String]") { t == "[object String]") {
@ -279,7 +279,7 @@ evaluate.toJSON = function(obj, seenEls) {
} else if (WebElement.isReference(obj)) { } else if (WebElement.isReference(obj)) {
return obj; return obj;
// Element, SVGElement, XULElement // Element (HTMLElement, SVGElement, XULElement, &c.)
} else if (element.isElement(obj)) { } else if (element.isElement(obj)) {
let webEl = seenEls.add(obj); let webEl = seenEls.add(obj);
return webEl.toJSON(); return webEl.toJSON();

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

@ -149,19 +149,6 @@ add_test(function test_isDOMElement() {
run_next_test(); run_next_test();
}); });
add_test(function test_isSVGElement() {
ok(element.isSVGElement(svgEl));
ok(!element.isSVGElement(domEl));
ok(!element.isSVGElement(xulEl));
ok(!element.isSVGElement(domWin));
ok(!element.isSVGElement(domFrame));
for (let typ of [true, 42, {}, [], undefined, null]) {
ok(!element.isSVGElement(typ));
}
run_next_test();
});
add_test(function test_isXULElement() { add_test(function test_isXULElement() {
ok(element.isXULElement(xulEl)); ok(element.isXULElement(xulEl));
ok(element.isXULElement(xblEl)); ok(element.isXULElement(xblEl));