mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
Bug 1334044: Replace detached callback (v0) with disconnected callback (v1).
Tag UXP Issue #1344
This commit is contained in:
parent
b477c03089
commit
659204631b
9 changed files with 28 additions and 84 deletions
|
|
@ -57,8 +57,8 @@ CustomElementCallback::Call()
|
|||
case nsIDocument::eConnected:
|
||||
static_cast<LifecycleConnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
break;
|
||||
case nsIDocument::eDetached:
|
||||
static_cast<LifecycleDetachedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
case nsIDocument::eDisconnected:
|
||||
static_cast<LifecycleDisconnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
|
||||
break;
|
||||
case nsIDocument::eAttributeChanged:
|
||||
static_cast<LifecycleAttributeChangedCallback *>(mCallback.get())->Call(mThisObject,
|
||||
|
|
@ -354,9 +354,9 @@ CustomElementRegistry::CreateCustomElementCallback(
|
|||
}
|
||||
break;
|
||||
|
||||
case nsIDocument::eDetached:
|
||||
if (aDefinition->mCallbacks->mDetachedCallback.WasPassed()) {
|
||||
func = aDefinition->mCallbacks->mDetachedCallback.Value();
|
||||
case nsIDocument::eDisconnected:
|
||||
if (aDefinition->mCallbacks->mDisconnectedCallback.WasPassed()) {
|
||||
func = aDefinition->mCallbacks->mDisconnectedCallback.Value();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1025,14 +1025,14 @@ CustomElementReactionsStack::Enqueue(Element* aElement,
|
|||
|
||||
// Add element to the current element queue.
|
||||
if (!mReactionsStack.IsEmpty()) {
|
||||
mReactionsStack.LastElement()->AppendElement(do_GetWeakReference(aElement));
|
||||
mReactionsStack.LastElement()->AppendElement(aElement);
|
||||
elementData->mReactionQueue.AppendElement(aReaction);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the custom element reactions stack is empty, then:
|
||||
// Add element to the backup element queue.
|
||||
mBackupQueue.AppendElement(do_GetWeakReference(aElement));
|
||||
mBackupQueue.AppendElement(aElement);
|
||||
elementData->mReactionQueue.AppendElement(aReaction);
|
||||
|
||||
if (mIsBackupQueueProcessing) {
|
||||
|
|
@ -1070,14 +1070,18 @@ CustomElementReactionsStack::InvokeReactions(ElementQueue* aElementQueue,
|
|||
|
||||
// Note: It's possible to re-enter this method.
|
||||
for (uint32_t i = 0; i < aElementQueue->Length(); ++i) {
|
||||
nsCOMPtr<Element> element = do_QueryReferent(aElementQueue->ElementAt(i));
|
||||
Element* element = aElementQueue->ElementAt(i);
|
||||
|
||||
if (!element) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RefPtr<CustomElementData> elementData = element->GetCustomElementData();
|
||||
MOZ_ASSERT(elementData, "CustomElementData should exist");
|
||||
if (!elementData) {
|
||||
// This happens when the document is destroyed and the element is already
|
||||
// unlinked, no need to fire the callbacks in this case.
|
||||
return;
|
||||
}
|
||||
|
||||
auto& reactions = elementData->mReactionQueue;
|
||||
for (uint32_t j = 0; j < reactions.Length(); ++j) {
|
||||
|
|
@ -1132,9 +1136,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementDefinition)
|
|||
cb.NoteXPCOMChild(callbacks->mConnectedCallback.Value());
|
||||
}
|
||||
|
||||
if (callbacks->mDetachedCallback.WasPassed()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCallbacks->mDetachedCallback");
|
||||
cb.NoteXPCOMChild(callbacks->mDetachedCallback.Value());
|
||||
if (callbacks->mDisconnectedCallback.WasPassed()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCallbacks->mDisconnectedCallback");
|
||||
cb.NoteXPCOMChild(callbacks->mDisconnectedCallback.Value());
|
||||
}
|
||||
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mConstructor");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue