зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1333014 - Change element.isDisconnected to take container; r=maja_zf
It makes sense for element.isDisconnected to accept a container object with frame and shadowRoot, instead of taking the shadowRoot as an optional third argument, since this is what most consumers start out with. MozReview-Commit-ID: 6kfEIEf8u96 --HG-- extra : rebase_source : 084b39ff6796747470bf49acdab0dbbfc8f67f98
This commit is contained in:
Родитель
fe9efe4a62
Коммит
5688e3c5b4
|
@ -8,6 +8,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Log.jsm");
|
Cu.import("resource://gre/modules/Log.jsm");
|
||||||
|
|
||||||
|
Cu.import("chrome://marionette/content/assert.js");
|
||||||
Cu.import("chrome://marionette/content/atom.js");
|
Cu.import("chrome://marionette/content/atom.js");
|
||||||
Cu.import("chrome://marionette/content/error.js");
|
Cu.import("chrome://marionette/content/error.js");
|
||||||
Cu.import("chrome://marionette/content/wait.js");
|
Cu.import("chrome://marionette/content/wait.js");
|
||||||
|
@ -174,11 +175,14 @@ element.Store = class {
|
||||||
if (container.shadowRoot) {
|
if (container.shadowRoot) {
|
||||||
wrappedShadowRoot = new XPCNativeWrapper(container.shadowRoot);
|
wrappedShadowRoot = new XPCNativeWrapper(container.shadowRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
let wrappedEl = new XPCNativeWrapper(el);
|
let wrappedEl = new XPCNativeWrapper(el);
|
||||||
|
let wrappedContainer = {
|
||||||
|
frame: wrappedFrame,
|
||||||
|
shadowRoot: wrappedShadowRoot,
|
||||||
|
};
|
||||||
if (!el ||
|
if (!el ||
|
||||||
!(wrappedEl.ownerDocument == wrappedFrame.document) ||
|
!(wrappedEl.ownerDocument == wrappedFrame.document) ||
|
||||||
element.isDisconnected(wrappedEl, wrappedFrame, wrappedShadowRoot)) {
|
element.isDisconnected(wrappedEl, wrappedContainer)) {
|
||||||
throw new StaleElementReferenceError(
|
throw new StaleElementReferenceError(
|
||||||
error.pprint`The element reference of ${el} stale: ` +
|
error.pprint`The element reference of ${el} stale: ` +
|
||||||
"either the element is no longer attached to the DOM " +
|
"either the element is no longer attached to the DOM " +
|
||||||
|
@ -723,18 +727,19 @@ element.toJson = function (obj, seenEls) {
|
||||||
*
|
*
|
||||||
* @param {nsIDOMElement} el
|
* @param {nsIDOMElement} el
|
||||||
* Element to be checked.
|
* Element to be checked.
|
||||||
* @param {nsIDOMWindow} frame
|
* @param {Container} container
|
||||||
* Window object that contains the element or the current host
|
* Container with |frame|, which is the window object that contains
|
||||||
* of the shadow root.
|
* the element, and an optional |shadowRoot|.
|
||||||
* @param {ShadowRoot=} shadowRoot
|
|
||||||
* An optional shadow root containing an element.
|
|
||||||
*
|
*
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
* Flag indicating that the element is disconnected.
|
* Flag indicating that the element is disconnected.
|
||||||
*/
|
*/
|
||||||
element.isDisconnected = function (el, frame, shadowRoot = undefined) {
|
element.isDisconnected = function (el, container = {}) {
|
||||||
|
const {frame, shadowRoot} = container;
|
||||||
|
assert.defined(frame);
|
||||||
|
|
||||||
// shadow dom
|
// shadow dom
|
||||||
if (shadowRoot && frame.ShadowRoot) {
|
if (frame.ShadowRoot && shadowRoot) {
|
||||||
if (el.compareDocumentPosition(shadowRoot) &
|
if (el.compareDocumentPosition(shadowRoot) &
|
||||||
DOCUMENT_POSITION_DISCONNECTED) {
|
DOCUMENT_POSITION_DISCONNECTED) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -745,7 +750,9 @@ element.isDisconnected = function (el, frame, shadowRoot = undefined) {
|
||||||
while (parent && !(parent instanceof frame.ShadowRoot)) {
|
while (parent && !(parent instanceof frame.ShadowRoot)) {
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
return element.isDisconnected(shadowRoot.host, frame, parent);
|
return element.isDisconnected(
|
||||||
|
shadowRoot.host,
|
||||||
|
{frame: frame, shadowRoot: parent});
|
||||||
|
|
||||||
// outside shadow dom
|
// outside shadow dom
|
||||||
} else {
|
} else {
|
||||||
|
@ -989,7 +996,7 @@ element.getPointerInteractablePaintTree = function (el) {
|
||||||
const win = doc.defaultView;
|
const win = doc.defaultView;
|
||||||
|
|
||||||
// pointer-interactable elements tree, step 1
|
// pointer-interactable elements tree, step 1
|
||||||
if (element.isDisconnected(el, win)) {
|
if (element.isDisconnected(el, {frame: win})) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче