Bug 1334043 - Part 2: Make nsContentUtils::EnqueueLifecycleCallback static.

We make nsContentUtils::EnqueueLifecycleCallback static so that it can be called without a window object. To achive this, we also make CustomElementReaction not taking a CustomElementRegistry in the constructor, as it can call Upgrade statically.

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-05 15:59:26 -05:00 committed by Roy Tam
commit befa1027e3
5 changed files with 41 additions and 75 deletions

View file

@ -1684,13 +1684,11 @@ Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
SetSubtreeRootPointer(aParent->SubtreeRoot());
}
nsIDocument* composedDoc = GetComposedDoc();
if (CustomElementRegistry::IsCustomElementEnabled() && composedDoc) {
if (CustomElementRegistry::IsCustomElementEnabled() && IsInComposedDoc()) {
// Connected callback must be enqueued whenever a custom element becomes
// connected.
if (GetCustomElementData()) {
nsContentUtils::EnqueueLifecycleCallback(
composedDoc, nsIDocument::eConnected, this);
nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eConnected, this);
}
}
@ -1989,8 +1987,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
// the document and this document has a browsing context.
if (GetCustomElementData() && document->GetDocShell()) {
// Enqueue a detached callback for the custom element.
nsContentUtils::EnqueueLifecycleCallback(
document, nsIDocument::eDetached, this);
nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eDetached, this);
}
}
@ -2605,7 +2602,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
};
nsContentUtils::EnqueueLifecycleCallback(
OwnerDoc(), nsIDocument::eAttributeChanged, this, &args, definition);
nsIDocument::eAttributeChanged, this, &args, definition);
}
}
}
@ -2870,7 +2867,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
};
nsContentUtils::EnqueueLifecycleCallback(
OwnerDoc(), nsIDocument::eAttributeChanged, this, &args, definition);
nsIDocument::eAttributeChanged, this, &args, definition);
}
}
}