mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-20 22:27:31 +09:00
Bug 1410790 - Add more assertion in CustomElementData::SetCustomElementDefinition and GetCustomElementDefinition;
This is a follow-up patch for bug 1392970. Since we only set CustomElementDefinition on a custom element which is custom, we could add more assertion to ensure that. Tag UXP Issue #1344
This commit is contained in:
parent
afc180e2f1
commit
76b1eaa538
3 changed files with 52 additions and 31 deletions
|
|
@ -138,6 +138,48 @@ CustomElementData::CustomElementData(nsIAtom* aType, State aState)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomElementData::SetCustomElementDefinition(CustomElementDefinition* aDefinition)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mState == State::eCustom);
|
||||||
|
MOZ_ASSERT(!mCustomElementDefinition);
|
||||||
|
MOZ_ASSERT(aDefinition->mType == mType);
|
||||||
|
|
||||||
|
mCustomElementDefinition = aDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomElementDefinition*
|
||||||
|
CustomElementData::GetCustomElementDefinition()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(mCustomElementDefinition ? mState == State::eCustom
|
||||||
|
: mState != State::eCustom);
|
||||||
|
|
||||||
|
return mCustomElementDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomElementData::Traverse(nsCycleCollectionTraversalCallback& aCb) const
|
||||||
|
{
|
||||||
|
for (uint32_t i = 0; i < mReactionQueue.Length(); i++) {
|
||||||
|
if (mReactionQueue[i]) {
|
||||||
|
mReactionQueue[i]->Traverse(aCb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCustomElementDefinition) {
|
||||||
|
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mCustomElementDefinition");
|
||||||
|
aCb.NoteNativeChild(mCustomElementDefinition,
|
||||||
|
NS_CYCLE_COLLECTION_PARTICIPANT(CustomElementDefinition));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CustomElementData::Unlink()
|
||||||
|
{
|
||||||
|
mReactionQueue.Clear();
|
||||||
|
mCustomElementDefinition = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
// CustomElementRegistry
|
// CustomElementRegistry
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,24 +130,16 @@ struct CustomElementData
|
||||||
// e.g., create an element, insert a node.
|
// e.g., create an element, insert a node.
|
||||||
AutoTArray<UniquePtr<CustomElementReaction>, 3> mReactionQueue;
|
AutoTArray<UniquePtr<CustomElementReaction>, 3> mReactionQueue;
|
||||||
|
|
||||||
RefPtr<CustomElementDefinition> mCustomElementDefinition;
|
void SetCustomElementDefinition(CustomElementDefinition* aDefinition);
|
||||||
|
CustomElementDefinition* GetCustomElementDefinition();
|
||||||
|
|
||||||
void
|
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
|
||||||
SetCustomElementDefinition(CustomElementDefinition* aDefinition)
|
void Unlink();
|
||||||
{
|
|
||||||
MOZ_ASSERT(!mCustomElementDefinition);
|
|
||||||
|
|
||||||
mCustomElementDefinition = aDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
CustomElementDefinition*
|
|
||||||
GetCustomElementDefinition()
|
|
||||||
{
|
|
||||||
return mCustomElementDefinition;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~CustomElementData() {}
|
virtual ~CustomElementData() {}
|
||||||
|
|
||||||
|
RefPtr<CustomElementDefinition> mCustomElementDefinition;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ALEADY_CONSTRUCTED_MARKER nullptr
|
#define ALEADY_CONSTRUCTED_MARKER nullptr
|
||||||
|
|
@ -167,7 +159,8 @@ struct CustomElementDefinition
|
||||||
mozilla::dom::LifecycleCallbacks* aCallbacks,
|
mozilla::dom::LifecycleCallbacks* aCallbacks,
|
||||||
uint32_t aDocOrder);
|
uint32_t aDocOrder);
|
||||||
|
|
||||||
// The type (name) for this custom element.
|
// The type (name) for this custom element, for <button is="x-foo"> or <x-foo>
|
||||||
|
// this would be x-foo.
|
||||||
nsCOMPtr<nsIAtom> mType;
|
nsCOMPtr<nsIAtom> mType;
|
||||||
|
|
||||||
// The localname to (e.g. <button is=type> -- this would be button).
|
// The localname to (e.g. <button is=type> -- this would be button).
|
||||||
|
|
|
||||||
|
|
@ -583,19 +583,7 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||||
cb.NoteXPCOMChild(mExtendedSlots->mXBLInsertionParent.get());
|
cb.NoteXPCOMChild(mExtendedSlots->mXBLInsertionParent.get());
|
||||||
|
|
||||||
if (mExtendedSlots->mCustomElementData) {
|
if (mExtendedSlots->mCustomElementData) {
|
||||||
for (uint32_t i = 0;
|
mExtendedSlots->mCustomElementData->Traverse(cb);
|
||||||
i < mExtendedSlots->mCustomElementData->mReactionQueue.Length(); i++) {
|
|
||||||
if (mExtendedSlots->mCustomElementData->mReactionQueue[i]) {
|
|
||||||
mExtendedSlots->mCustomElementData->mReactionQueue[i]->Traverse(cb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mExtendedSlots->mCustomElementData->mCustomElementDefinition) {
|
|
||||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
|
|
||||||
"mExtendedSlots->mCustomElementData->mCustomElementDefinition");
|
|
||||||
cb.NoteNativeChild(mExtendedSlots->mCustomElementData->mCustomElementDefinition,
|
|
||||||
NS_CYCLE_COLLECTION_PARTICIPANT(CustomElementDefinition));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto iter = mExtendedSlots->mRegisteredIntersectionObservers.Iter();
|
for (auto iter = mExtendedSlots->mRegisteredIntersectionObservers.Iter();
|
||||||
|
|
@ -633,9 +621,7 @@ FragmentOrElement::nsDOMSlots::Unlink()
|
||||||
MOZ_ASSERT(!(mExtendedSlots->mXBLBinding));
|
MOZ_ASSERT(!(mExtendedSlots->mXBLBinding));
|
||||||
mExtendedSlots->mXBLInsertionParent = nullptr;
|
mExtendedSlots->mXBLInsertionParent = nullptr;
|
||||||
if (mExtendedSlots->mCustomElementData) {
|
if (mExtendedSlots->mCustomElementData) {
|
||||||
if (mExtendedSlots->mCustomElementData->mCustomElementDefinition) {
|
mExtendedSlots->mCustomElementData->Unlink();
|
||||||
mExtendedSlots->mCustomElementData->mCustomElementDefinition = nullptr;
|
|
||||||
}
|
|
||||||
mExtendedSlots->mCustomElementData = nullptr;
|
mExtendedSlots->mCustomElementData = nullptr;
|
||||||
}
|
}
|
||||||
mExtendedSlots->mRegisteredIntersectionObservers.Clear();
|
mExtendedSlots->mRegisteredIntersectionObservers.Clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue