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:
Gaming4JC 2020-01-18 20:35:11 -05:00 committed by Roy Tam
commit 76b1eaa538
3 changed files with 52 additions and 31 deletions

View file

@ -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