diff --git a/dom/base/DOMImplementation.cpp b/dom/base/DOMImplementation.cpp index cc329848b57f..4c2a8174a730 100644 --- a/dom/base/DOMImplementation.cpp +++ b/dom/base/DOMImplementation.cpp @@ -160,7 +160,8 @@ nsresult DOMImplementation::CreateHTMLDocument(const nsAString& aTitle, rv = head->AppendChildTo(title, false); NS_ENSURE_SUCCESS(rv, rv); - RefPtr titleText = new nsTextNode(doc->NodeInfoManager()); + RefPtr titleText = + new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager()); rv = titleText->SetText(aTitle, false); NS_ENSURE_SUCCESS(rv, rv); rv = title->AppendChildTo(titleText, false); diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 8e29030dcfda..e9f75d204b19 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -7757,13 +7757,13 @@ already_AddRefed Document::CreateXULElement( } already_AddRefed Document::CreateEmptyTextNode() const { - RefPtr text = new nsTextNode(mNodeInfoManager); + RefPtr text = new (mNodeInfoManager) nsTextNode(mNodeInfoManager); return text.forget(); } already_AddRefed Document::CreateTextNode( const nsAString& aData) const { - RefPtr text = new nsTextNode(mNodeInfoManager); + RefPtr text = new (mNodeInfoManager) nsTextNode(mNodeInfoManager); // Don't notify; this node is still being created. text->SetText(aData, false); return text.forget(); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 8ae99087e4fa..ea1b8c1b9586 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5120,8 +5120,8 @@ nsresult nsContentUtils::SetNodeTextContent(nsIContent* aContent, return NS_OK; } - RefPtr textContent = - new nsTextNode(aContent->NodeInfo()->NodeInfoManager()); + RefPtr textContent = new (aContent->NodeInfo()->NodeInfoManager()) + nsTextNode(aContent->NodeInfo()->NodeInfoManager()); textContent->SetText(aValue, true); diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index f72684b9fddd..aee45df32375 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -49,8 +49,8 @@ class nsAttributeTextNode final : public nsTextNode, virtual already_AddRefed CloneDataNode( mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override { - RefPtr it = - new nsAttributeTextNode(do_AddRef(aNodeInfo), mNameSpaceID, mAttrName); + RefPtr it = new (aNodeInfo->NodeInfoManager()) + nsAttributeTextNode(do_AddRef(aNodeInfo), mNameSpaceID, mAttrName); if (aCloneText) { it->mText = mText; } @@ -94,7 +94,8 @@ bool nsTextNode::IsNodeOfType(uint32_t aFlags) const { return false; } already_AddRefed nsTextNode::CloneDataNode( mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const { - RefPtr it = new nsTextNode(do_AddRef(aNodeInfo)); + RefPtr it = + new (aNodeInfo->NodeInfoManager()) nsTextNode(do_AddRef(aNodeInfo)); if (aCloneText) { it->mText = mText; } @@ -182,8 +183,8 @@ nsresult NS_NewAttributeContent(nsNodeInfoManager* aNodeInfoManager, RefPtr ni = aNodeInfoManager->GetTextNodeInfo(); - RefPtr textNode = - new nsAttributeTextNode(ni.forget(), aNameSpaceID, aAttrName); + RefPtr textNode = new (aNodeInfoManager) + nsAttributeTextNode(ni.forget(), aNameSpaceID, aAttrName); textNode.forget(aResult); return NS_OK; diff --git a/dom/html/HTMLOptionElement.cpp b/dom/html/HTMLOptionElement.cpp index bdc1589191b5..d522bad897f6 100644 --- a/dom/html/HTMLOptionElement.cpp +++ b/dom/html/HTMLOptionElement.cpp @@ -312,8 +312,8 @@ already_AddRefed HTMLOptionElement::Option( if (!aText.IsEmpty()) { // Create a new text node and append it to the option - RefPtr textContent = - new nsTextNode(option->NodeInfo()->NodeInfoManager()); + RefPtr textContent = new (option->NodeInfo()->NodeInfoManager()) + nsTextNode(option->NodeInfo()->NodeInfoManager()); textContent->SetText(aText, false); diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index b2b159141a9e..7196b9476bdb 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2814,8 +2814,8 @@ void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) { } if (s == end || *s == '\r' || *s == '\n') { if (!str.IsEmpty()) { - RefPtr textContent = - new nsTextNode(NodeInfo()->NodeInfoManager()); + RefPtr textContent = new (NodeInfo()->NodeInfoManager()) + nsTextNode(NodeInfo()->NodeInfoManager()); textContent->SetText(str, true); AppendChildTo(textContent, true); } diff --git a/dom/prototype/PrototypeDocumentContentSink.cpp b/dom/prototype/PrototypeDocumentContentSink.cpp index f02395da0914..e1f84a9132c7 100644 --- a/dom/prototype/PrototypeDocumentContentSink.cpp +++ b/dom/prototype/PrototypeDocumentContentSink.cpp @@ -546,7 +546,8 @@ nsresult PrototypeDocumentContentSink::ResumeWalkInternal() { case nsXULPrototypeNode::eType_Text: { // A simple text node. - RefPtr text = new nsTextNode(mNodeInfoManager); + RefPtr text = + new (mNodeInfoManager) nsTextNode(mNodeInfoManager); nsXULPrototypeText* textproto = static_cast(childproto); diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index d4c3edb94b19..0ddf54f9f944 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -749,7 +749,8 @@ nsresult nsXMLContentSink::FlushText(bool aReleaseTextNode) { mTextLength = 0; } else { - RefPtr textContent = new nsTextNode(mNodeInfoManager); + RefPtr textContent = + new (mNodeInfoManager) nsTextNode(mNodeInfoManager); mLastTextNode = textContent; diff --git a/dom/xslt/xslt/txEXSLTFunctions.cpp b/dom/xslt/xslt/txEXSLTFunctions.cpp index 7d3a3afc08c6..06612ca85fd5 100644 --- a/dom/xslt/xslt/txEXSLTFunctions.cpp +++ b/dom/xslt/xslt/txEXSLTFunctions.cpp @@ -90,7 +90,8 @@ static nsresult createTextNode(txIEvalContext* aContext, nsString& aValue, return NS_ERROR_UNEXPECTED; } - RefPtr text = new nsTextNode(doc->NodeInfoManager()); + RefPtr text = + new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager()); nsresult rv = text->SetText(aValue, false); NS_ENSURE_SUCCESS(rv, rv); @@ -109,7 +110,8 @@ static nsresult createAndAddToResult(nsAtom* aName, const nsAString& aValue, doc->CreateElem(nsDependentAtomString(aName), nullptr, kNameSpaceID_None); NS_ENSURE_TRUE(elem, NS_ERROR_NULL_POINTER); - RefPtr text = new nsTextNode(doc->NodeInfoManager()); + RefPtr text = + new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager()); nsresult rv = text->SetText(aValue, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/xslt/xslt/txMozillaTextOutput.cpp b/dom/xslt/xslt/txMozillaTextOutput.cpp index a082c5b5d1a9..62633e29681b 100644 --- a/dom/xslt/xslt/txMozillaTextOutput.cpp +++ b/dom/xslt/xslt/txMozillaTextOutput.cpp @@ -62,7 +62,8 @@ nsresult txMozillaTextOutput::comment(const nsString& aData) { return NS_OK; } nsresult txMozillaTextOutput::endDocument(nsresult aResult) { NS_ENSURE_TRUE(mDocument && mTextParent, NS_ERROR_FAILURE); - RefPtr text = new nsTextNode(mDocument->NodeInfoManager()); + RefPtr text = new (mDocument->NodeInfoManager()) + nsTextNode(mDocument->NodeInfoManager()); text->SetText(mText, false); nsresult rv = mTextParent->AppendChildTo(text, true); diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp index 58d0095f01f5..e255ce5a153a 100644 --- a/dom/xslt/xslt/txMozillaXMLOutput.cpp +++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp @@ -548,7 +548,8 @@ nsresult txMozillaXMLOutput::closePrevious(bool aFlushText) { rv = createTxWrapper(); NS_ENSURE_SUCCESS(rv, rv); } - RefPtr text = new nsTextNode(mNodeInfoManager); + RefPtr text = + new (mNodeInfoManager) nsTextNode(mNodeInfoManager); rv = text->SetText(mText, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index fc2606821793..cba8b73daafe 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1473,7 +1473,8 @@ struct nsGenConInitializer { already_AddRefed nsCSSFrameConstructor::CreateGenConTextNode( nsFrameConstructorState& aState, const nsString& aString, UniquePtr aInitializer) { - RefPtr content = new nsTextNode(mDocument->NodeInfoManager()); + RefPtr content = new (mDocument->NodeInfoManager()) + nsTextNode(mDocument->NodeInfoManager()); content->SetText(aString, false); if (aInitializer) { aInitializer->mNode->mText = content; diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index e4f5654dd02c..f919cc8d8568 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -1152,7 +1152,7 @@ nsresult nsComboboxControlFrame::CreateAnonymousContent( nsNodeInfoManager* nimgr = mContent->NodeInfo()->NodeInfoManager(); - mDisplayContent = new nsTextNode(nimgr); + mDisplayContent = new (nimgr) nsTextNode(nimgr); // set the value of the text node mDisplayedIndex = mListControlFrame->GetSelectedIndex(); diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 9f6f601b480b..cfa53c29d71b 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -220,8 +220,8 @@ static already_AddRefed MakeAnonButton(Document* aDoc, // Set the browse button text. It's a bit of a pain to do because we want to // make sure we are not notifying. - RefPtr textContent = - new nsTextNode(button->NodeInfo()->NodeInfoManager()); + RefPtr textContent = new (button->NodeInfo()->NodeInfoManager()) + nsTextNode(button->NodeInfo()->NodeInfoManager()); textContent->SetText(buttonTxt, false); @@ -267,7 +267,8 @@ nsresult nsFileControlFrame::CreateAnonymousContent( // NOTE: SetIsNativeAnonymousRoot() has to be called before setting any // attribute. mTextContent->SetIsNativeAnonymousRoot(); - RefPtr text = new nsTextNode(doc->NodeInfoManager()); + RefPtr text = + new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager()); mTextContent->AppendChildTo(text, false); // Update the displayed text to reflect the current element's value. diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index fa4219a5308f..3135c8a77aa9 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -47,7 +47,8 @@ nsresult nsGfxButtonControlFrame::CreateAnonymousContent( NS_ENSURE_SUCCESS(rv, rv); // Add a child text content node for the label - mTextContent = new nsTextNode(mContent->NodeInfo()->NodeInfoManager()); + mTextContent = new (mContent->NodeInfo()->NodeInfoManager()) + nsTextNode(mContent->NodeInfo()->NodeInfoManager()); // set the value of the text node and add it to the child list mTextContent->SetText(label, false); diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 2083ea1bc95e..ff5e332a66ef 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -394,8 +394,8 @@ nsTextControlFrame::CreateEmptyAnonymousDivWithTextNode( RefPtr divElement = CreateEmptyAnonymousDiv(aAnonymousDivType); // Create the text node for the anonymous
element. - RefPtr textNode = - new nsTextNode(divElement->OwnerDoc()->NodeInfoManager()); + RefPtr textNode = new (divElement->OwnerDoc()->NodeInfoManager()) + nsTextNode(divElement->OwnerDoc()->NodeInfoManager()); // If the anonymous div element is not for the placeholder, we should // mark the text node as "maybe modified frequently" for avoiding ASCII // range checks at every input. @@ -1257,8 +1257,8 @@ nsresult nsTextControlFrame::UpdateValueDisplay(bool aNotify, Text* textContent; if (!childContent) { // Set up a textnode with our value - RefPtr textNode = - new nsTextNode(mContent->NodeInfo()->NodeInfoManager()); + RefPtr textNode = new (mContent->NodeInfo()->NodeInfoManager()) + nsTextNode(mContent->NodeInfo()->NodeInfoManager()); textNode->MarkAsMaybeModifiedFrequently(); if (IsPasswordTextControl()) { textNode->MarkAsMaybeMasked(); diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp index ec68972299df..2ec1807ca5e9 100644 --- a/layout/generic/DetailsFrame.cpp +++ b/layout/generic/DetailsFrame.cpp @@ -101,7 +101,8 @@ nsresult DetailsFrame::CreateAnonymousContent( nsContentUtils::GetMaybeLocalizedString( nsContentUtils::eFORMS_PROPERTIES, "DefaultSummary", GetContent()->OwnerDoc(), defaultSummaryText); - RefPtr description = new nsTextNode(nodeInfoManager); + RefPtr description = + new (nodeInfoManager) nsTextNode(nodeInfoManager); description->SetText(defaultSummaryText, false); mDefaultSummary->AppendChildTo(description, false); diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 14a30297650e..5d5147ba2435 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -233,7 +233,7 @@ nsresult nsHtml5TreeOperation::AppendText(const char16_t* aBuffer, } nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager(); - RefPtr text = new nsTextNode(nodeInfoManager); + RefPtr text = new (nodeInfoManager) nsTextNode(nodeInfoManager); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv); @@ -652,7 +652,7 @@ nsresult nsHtml5TreeOperation::FosterParentText( nsNodeInfoManager* nodeInfoManager = aStackParent->OwnerDoc()->NodeInfoManager(); - RefPtr text = new nsTextNode(nodeInfoManager); + RefPtr text = new (nodeInfoManager) nsTextNode(nodeInfoManager); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv);