Bug 1852866 - Make LifecycleCallbackArgs::mName a RefPtr<nsAtom>. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D188100
This commit is contained in:
Markus Stange 2023-09-13 18:15:02 +00:00
Родитель 9232a973e4
Коммит 1df2886427
3 изменённых файлов: 9 добавлений и 12 удалений

Просмотреть файл

@ -125,8 +125,7 @@ class CustomElementCallbackReaction final : public CustomElementReaction {
size_t LifecycleCallbackArgs::SizeOfExcludingThis(
MallocSizeOf aMallocSizeOf) const {
size_t n = mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += mOldValue.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
size_t n = mOldValue.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += mNewValue.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += mNamespaceURI.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
return n;
@ -229,8 +228,8 @@ void CustomElementCallback::Call() {
break;
case ElementCallbackType::eAttributeChanged:
static_cast<LifecycleAttributeChangedCallback*>(mCallback.get())
->Call(mThisObject, mArgs.mName, mArgs.mOldValue, mArgs.mNewValue,
mArgs.mNamespaceURI);
->Call(mThisObject, nsDependentAtomString(mArgs.mName),
mArgs.mOldValue, mArgs.mNewValue, mArgs.mNamespaceURI);
break;
case ElementCallbackType::eFormAssociated:
static_cast<LifecycleFormAssociatedCallback*>(mCallback.get())
@ -628,9 +627,7 @@ void CustomElementRegistry::EnqueueLifecycleCallback(
}
if (aType == ElementCallbackType::eAttributeChanged) {
RefPtr<nsAtom> attrName = NS_Atomize(aArgs.mName);
if (definition->mObservedAttributes.IsEmpty() ||
!definition->mObservedAttributes.Contains(attrName)) {
if (!definition->mObservedAttributes.Contains(aArgs.mName)) {
return;
}
}
@ -1330,7 +1327,7 @@ void CustomElementRegistry::Upgrade(Element* aElement,
namespaceURI);
LifecycleCallbackArgs args;
args.mName = nsDependentAtomString(attrName);
args.mName = attrName;
args.mOldValue = VoidString();
args.mNewValue = attrValue;
args.mNamespaceURI =

Просмотреть файл

@ -51,7 +51,7 @@ enum class ElementCallbackType {
struct LifecycleCallbackArgs {
// Used by the attribute changed callback.
nsString mName;
RefPtr<nsAtom> mName;
nsString mOldValue;
nsString mNewValue;
nsString mNamespaceURI;

Просмотреть файл

@ -2620,7 +2620,7 @@ nsresult Element::SetAttrAndNotify(
nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNamespaceID, ns);
LifecycleCallbackArgs args;
aName->ToString(args.mName);
args.mName = aName;
if (aModType == MutationEvent_Binding::ADDITION) {
args.mOldValue = VoidString();
} else {
@ -2806,7 +2806,7 @@ void Element::OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,
nsAutoString value(aValue.String());
LifecycleCallbackArgs args;
aName->ToString(args.mName);
args.mName = aName;
args.mOldValue = value;
args.mNewValue = value;
args.mNamespaceURI = ns.IsEmpty() ? VoidString() : ns;
@ -2921,7 +2921,7 @@ nsresult Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify) {
nsAutoString ns;
nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNameSpaceID, ns);
LifecycleCallbackArgs args;
aName->ToString(args.mName);
args.mName = aName;
oldValue.ToString(args.mOldValue);
args.mNewValue = VoidString();
args.mNamespaceURI = ns.IsEmpty() ? VoidString() : ns;