diff --git a/dom/html/HTMLAudioElement.cpp b/dom/html/HTMLAudioElement.cpp index 2572f4011849..05735bd0baa2 100644 --- a/dom/html/HTMLAudioElement.cpp +++ b/dom/html/HTMLAudioElement.cpp @@ -23,8 +23,10 @@ nsGenericHTMLElement* NS_NewHTMLAudioElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); mozilla::dom::HTMLAudioElement* element = - new mozilla::dom::HTMLAudioElement(std::move(aNodeInfo)); + new (nim) mozilla::dom::HTMLAudioElement(nodeInfo.forget()); element->Init(); return element; } @@ -36,7 +38,8 @@ nsresult HTMLAudioElement::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; RefPtr ni(aNodeInfo); - HTMLAudioElement* it = new HTMLAudioElement(ni.forget()); + auto* nim = ni->NodeInfoManager(); + HTMLAudioElement* it = new (nim) HTMLAudioElement(ni.forget()); it->Init(); nsCOMPtr kungFuDeathGrip = it; nsresult rv = const_cast(this)->CopyInnerTo(it); diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp index db15e4ca19fb..fdf0e82579b5 100644 --- a/dom/html/HTMLDialogElement.cpp +++ b/dom/html/HTMLDialogElement.cpp @@ -13,11 +13,13 @@ nsGenericHTMLElement* NS_NewHTMLDialogElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); if (!mozilla::dom::HTMLDialogElement::IsDialogEnabled()) { - return new mozilla::dom::HTMLUnknownElement(std::move(aNodeInfo)); + return new (nim) mozilla::dom::HTMLUnknownElement(nodeInfo.forget()); } - return new mozilla::dom::HTMLDialogElement(std::move(aNodeInfo)); + return new (nim) mozilla::dom::HTMLDialogElement(nodeInfo.forget()); } namespace mozilla { diff --git a/dom/html/HTMLElement.cpp b/dom/html/HTMLElement.cpp index 89b5060caa80..e6dc290dbc33 100644 --- a/dom/html/HTMLElement.cpp +++ b/dom/html/HTMLElement.cpp @@ -47,7 +47,9 @@ JSObject* HTMLElement::WrapNode(JSContext* aCx, nsGenericHTMLElement* NS_NewHTMLElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - return new mozilla::dom::HTMLElement(std::move(aNodeInfo)); + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) mozilla::dom::HTMLElement(nodeInfo.forget()); } // Distinct from the above in order to have function pointer that compared @@ -55,5 +57,7 @@ nsGenericHTMLElement* NS_NewHTMLElement( nsGenericHTMLElement* NS_NewCustomElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - return new mozilla::dom::HTMLElement(std::move(aNodeInfo)); + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) mozilla::dom::HTMLElement(nodeInfo.forget()); } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index cf2598861691..4abcd3bae9a6 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -674,7 +674,8 @@ already_AddRefed HTMLImageElement::Image( RefPtr nodeInfo = doc->NodeInfoManager()->GetNodeInfo( nsGkAtoms::img, nullptr, kNameSpaceID_XHTML, ELEMENT_NODE); - RefPtr img = new HTMLImageElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + RefPtr img = new (nim) HTMLImageElement(nodeInfo.forget()); if (aWidth.WasPassed()) { img->SetWidth(aWidth.Value(), aError); diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 50819fe553f0..93c75f18760e 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -1066,8 +1066,8 @@ nsresult HTMLInputElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; - RefPtr it = new HTMLInputElement( - do_AddRef(aNodeInfo), NOT_FROM_PARSER, FromClone::yes); + RefPtr it = new (aNodeInfo->NodeInfoManager()) + HTMLInputElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER, FromClone::yes); nsresult rv = const_cast(this)->CopyInnerTo(it); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/html/HTMLMenuItemElement.cpp b/dom/html/HTMLMenuItemElement.cpp index 0ecb55fce117..ca7ac1e2a83b 100644 --- a/dom/html/HTMLMenuItemElement.cpp +++ b/dom/html/HTMLMenuItemElement.cpp @@ -160,8 +160,8 @@ HTMLMenuItemElement::~HTMLMenuItemElement() = default; nsresult HTMLMenuItemElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; - RefPtr it = - new HTMLMenuItemElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER); + RefPtr it = new (aNodeInfo->NodeInfoManager()) + HTMLMenuItemElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER); nsresult rv = const_cast(this)->CopyInnerTo(it); if (NS_SUCCEEDED(rv)) { switch (mType) { diff --git a/dom/html/HTMLOptionElement.cpp b/dom/html/HTMLOptionElement.cpp index 951714b1f959..bdc1589191b5 100644 --- a/dom/html/HTMLOptionElement.cpp +++ b/dom/html/HTMLOptionElement.cpp @@ -306,7 +306,9 @@ already_AddRefed HTMLOptionElement::Option( RefPtr nodeInfo = doc->NodeInfoManager()->GetNodeInfo( nsGkAtoms::option, nullptr, kNameSpaceID_XHTML, ELEMENT_NODE); - RefPtr option = new HTMLOptionElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + RefPtr option = + new (nim) HTMLOptionElement(nodeInfo.forget()); if (!aText.IsEmpty()) { // Create a new text node and append it to the option diff --git a/dom/html/HTMLPictureElement.cpp b/dom/html/HTMLPictureElement.cpp index 80f36b933f3d..05d4d1a95af4 100644 --- a/dom/html/HTMLPictureElement.cpp +++ b/dom/html/HTMLPictureElement.cpp @@ -12,7 +12,9 @@ nsGenericHTMLElement* NS_NewHTMLPictureElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - return new mozilla::dom::HTMLPictureElement(std::move(aNodeInfo)); + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) mozilla::dom::HTMLPictureElement(nodeInfo.forget()); } namespace mozilla { diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp index 31aa88b62490..4cf9e47781d7 100644 --- a/dom/html/HTMLScriptElement.cpp +++ b/dom/html/HTMLScriptElement.cpp @@ -80,8 +80,8 @@ nsresult HTMLScriptElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; - HTMLScriptElement* it = - new HTMLScriptElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER); + HTMLScriptElement* it = new (aNodeInfo->NodeInfoManager()) + HTMLScriptElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER); nsCOMPtr kungFuDeathGrip = it; nsresult rv = const_cast(this)->CopyInnerTo(it); diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp index 5d0f2082e840..14b602359773 100644 --- a/dom/html/HTMLSlotElement.cpp +++ b/dom/html/HTMLSlotElement.cpp @@ -15,7 +15,9 @@ nsGenericHTMLElement* NS_NewHTMLSlotElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - return new mozilla::dom::HTMLSlotElement(std::move(aNodeInfo)); + RefPtr nodeInfo(std::move(aNodeInfo)); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) mozilla::dom::HTMLSlotElement(nodeInfo.forget()); } namespace mozilla { diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp index c9f861a098af..74a8d3779cc7 100644 --- a/dom/html/HTMLTextAreaElement.cpp +++ b/dom/html/HTMLTextAreaElement.cpp @@ -107,8 +107,8 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLTextAreaElement, nsresult HTMLTextAreaElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; - RefPtr it = - new HTMLTextAreaElement(do_AddRef(aNodeInfo)); + RefPtr it = new (aNodeInfo->NodeInfoManager()) + HTMLTextAreaElement(do_AddRef(aNodeInfo)); nsresult rv = const_cast(this)->CopyInnerTo(it); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index 77c0c74243ed..a5f2c0a1a639 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -42,7 +42,9 @@ extern mozilla::LazyLogModule gTextTrackLog; nsGenericHTMLElement* NS_NewHTMLTrackElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { - return new mozilla::dom::HTMLTrackElement(std::move(aNodeInfo)); + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) mozilla::dom::HTMLTrackElement(nodeInfo.forget()); } namespace mozilla { diff --git a/dom/html/HTMLVideoElement.cpp b/dom/html/HTMLVideoElement.cpp index d51dc76f0d1f..45ab8b901944 100644 --- a/dom/html/HTMLVideoElement.cpp +++ b/dom/html/HTMLVideoElement.cpp @@ -38,8 +38,10 @@ nsGenericHTMLElement* NS_NewHTMLVideoElement( already_AddRefed&& aNodeInfo, mozilla::dom::FromParser aFromParser) { + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); mozilla::dom::HTMLVideoElement* element = - new mozilla::dom::HTMLVideoElement(std::move(aNodeInfo)); + new (nim) mozilla::dom::HTMLVideoElement(nodeInfo.forget()); element->Init(); return element; } @@ -80,7 +82,8 @@ nsresult HTMLVideoElement::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const { *aResult = nullptr; RefPtr ni(aNodeInfo); - HTMLVideoElement* it = new HTMLVideoElement(ni.forget()); + auto* nim = ni->NodeInfoManager(); + HTMLVideoElement* it = new (nim) HTMLVideoElement(ni.forget()); it->Init(); nsCOMPtr kungFuDeathGrip = it; nsresult rv = const_cast(this)->CopyInnerTo(it); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index b19e27486633..b2b159141a9e 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2826,7 +2826,8 @@ void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) { RefPtr ni = NodeInfo()->NodeInfoManager()->GetNodeInfo( nsGkAtoms::br, nullptr, kNameSpaceID_XHTML, ELEMENT_NODE); - RefPtr br = new HTMLBRElement(ni.forget()); + auto* nim = ni->NodeInfoManager(); + RefPtr br = new (nim) HTMLBRElement(ni.forget()); AppendChildTo(br, true); } else { str.Append(*s); diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp index 098608d780cb..ec68972299df 100644 --- a/layout/generic/DetailsFrame.cpp +++ b/layout/generic/DetailsFrame.cpp @@ -95,7 +95,7 @@ nsresult DetailsFrame::CreateAnonymousContent( RefPtr nodeInfo = nodeInfoManager->GetNodeInfo( nsGkAtoms::summary, nullptr, kNameSpaceID_XHTML, nsINode::ELEMENT_NODE); - mDefaultSummary = new HTMLSummaryElement(nodeInfo.forget()); + mDefaultSummary = new (nodeInfoManager) HTMLSummaryElement(nodeInfo.forget()); nsAutoString defaultSummaryText; nsContentUtils::GetMaybeLocalizedString(