From a104d39094a7b48f2137145c1ef7a70fbf0f1940 Mon Sep 17 00:00:00 2001 From: Sean Feng Date: Tue, 17 Mar 2020 14:53:33 +0000 Subject: [PATCH] Bug 1377999 - Make nsXULElement to adapt the DOMArena changes r=smaug Differential Revision: https://phabricator.services.mozilla.com/D57705 --HG-- extra : moz-landing-system : lando --- dom/xul/XULPopupElement.cpp | 4 +++- dom/xul/XULTooltipElement.cpp | 4 +++- dom/xul/nsXULElement.cpp | 16 +++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dom/xul/XULPopupElement.cpp b/dom/xul/XULPopupElement.cpp index 049c5900f3ab..e4ac24e24ce0 100644 --- a/dom/xul/XULPopupElement.cpp +++ b/dom/xul/XULPopupElement.cpp @@ -22,7 +22,9 @@ namespace dom { nsXULElement* NS_NewXULPopupElement( already_AddRefed&& aNodeInfo) { - return new XULPopupElement(std::move(aNodeInfo)); + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) XULPopupElement(nodeInfo.forget()); } JSObject* XULPopupElement::WrapNode(JSContext* aCx, diff --git a/dom/xul/XULTooltipElement.cpp b/dom/xul/XULTooltipElement.cpp index 768480d7e2b8..59d96b0300e1 100644 --- a/dom/xul/XULTooltipElement.cpp +++ b/dom/xul/XULTooltipElement.cpp @@ -16,8 +16,10 @@ namespace dom { nsXULElement* NS_NewXULTooltipElement( already_AddRefed&& aNodeInfo) { + RefPtr nodeInfo(aNodeInfo); + auto* nim = nodeInfo->NodeInfoManager(); RefPtr tooltip = - new XULTooltipElement(std::move(aNodeInfo)); + new (nim) XULTooltipElement(nodeInfo.forget()); NS_ENSURE_SUCCESS(tooltip->Init(), nullptr); return tooltip; } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index fcdffa388689..455cce2aaccf 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -123,7 +123,9 @@ void nsXULElement::MaybeUpdatePrivateLifetime() { /* static */ nsXULElement* NS_NewBasicXULElement( already_AddRefed&& aNodeInfo) { - return new nsXULElement(std::move(aNodeInfo)); + RefPtr nodeInfo(std::move(aNodeInfo)); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) nsXULElement(nodeInfo.forget()); } /* static */ @@ -132,7 +134,8 @@ nsXULElement* nsXULElement::Construct( RefPtr nodeInfo = aNodeInfo; if (nodeInfo->Equals(nsGkAtoms::label) || nodeInfo->Equals(nsGkAtoms::description)) { - return new XULTextElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) XULTextElement(nodeInfo.forget()); } if (nodeInfo->Equals(nsGkAtoms::menupopup) || @@ -148,16 +151,19 @@ nsXULElement* nsXULElement::Construct( if (nodeInfo->Equals(nsGkAtoms::iframe) || nodeInfo->Equals(nsGkAtoms::browser) || nodeInfo->Equals(nsGkAtoms::editor)) { - return new XULFrameElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) XULFrameElement(nodeInfo.forget()); } if (nodeInfo->Equals(nsGkAtoms::menu) || nodeInfo->Equals(nsGkAtoms::menulist)) { - return new XULMenuElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) XULMenuElement(nodeInfo.forget()); } if (nodeInfo->Equals(nsGkAtoms::tree)) { - return new XULTreeElement(nodeInfo.forget()); + auto* nim = nodeInfo->NodeInfoManager(); + return new (nim) XULTreeElement(nodeInfo.forget()); } return NS_NewBasicXULElement(nodeInfo.forget());