Bug 1377999 - Make TextNode to adapt the DOMArena changes r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D62353

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Sean Feng 2020-03-17 14:53:54 +00:00
parent 8e65109ea6
commit 908efe692e
18 changed files with 45 additions and 33 deletions

View File

@ -160,7 +160,8 @@ nsresult DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
rv = head->AppendChildTo(title, false);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<nsTextNode> titleText = new nsTextNode(doc->NodeInfoManager());
RefPtr<nsTextNode> titleText =
new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager());
rv = titleText->SetText(aTitle, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = title->AppendChildTo(titleText, false);

View File

@ -7757,13 +7757,13 @@ already_AddRefed<Element> Document::CreateXULElement(
}
already_AddRefed<nsTextNode> Document::CreateEmptyTextNode() const {
RefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
RefPtr<nsTextNode> text = new (mNodeInfoManager) nsTextNode(mNodeInfoManager);
return text.forget();
}
already_AddRefed<nsTextNode> Document::CreateTextNode(
const nsAString& aData) const {
RefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
RefPtr<nsTextNode> text = new (mNodeInfoManager) nsTextNode(mNodeInfoManager);
// Don't notify; this node is still being created.
text->SetText(aData, false);
return text.forget();

View File

@ -5120,8 +5120,8 @@ nsresult nsContentUtils::SetNodeTextContent(nsIContent* aContent,
return NS_OK;
}
RefPtr<nsTextNode> textContent =
new nsTextNode(aContent->NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> textContent = new (aContent->NodeInfo()->NodeInfoManager())
nsTextNode(aContent->NodeInfo()->NodeInfoManager());
textContent->SetText(aValue, true);

View File

@ -49,8 +49,8 @@ class nsAttributeTextNode final : public nsTextNode,
virtual already_AddRefed<CharacterData> CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override {
RefPtr<nsAttributeTextNode> it =
new nsAttributeTextNode(do_AddRef(aNodeInfo), mNameSpaceID, mAttrName);
RefPtr<nsAttributeTextNode> 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<CharacterData> nsTextNode::CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
RefPtr<nsTextNode> it = new nsTextNode(do_AddRef(aNodeInfo));
RefPtr<nsTextNode> it =
new (aNodeInfo->NodeInfoManager()) nsTextNode(do_AddRef(aNodeInfo));
if (aCloneText) {
it->mText = mText;
}
@ -182,8 +183,8 @@ nsresult NS_NewAttributeContent(nsNodeInfoManager* aNodeInfoManager,
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetTextNodeInfo();
RefPtr<nsAttributeTextNode> textNode =
new nsAttributeTextNode(ni.forget(), aNameSpaceID, aAttrName);
RefPtr<nsAttributeTextNode> textNode = new (aNodeInfoManager)
nsAttributeTextNode(ni.forget(), aNameSpaceID, aAttrName);
textNode.forget(aResult);
return NS_OK;

View File

@ -312,8 +312,8 @@ already_AddRefed<HTMLOptionElement> HTMLOptionElement::Option(
if (!aText.IsEmpty()) {
// Create a new text node and append it to the option
RefPtr<nsTextNode> textContent =
new nsTextNode(option->NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> textContent = new (option->NodeInfo()->NodeInfoManager())
nsTextNode(option->NodeInfo()->NodeInfoManager());
textContent->SetText(aText, false);

View File

@ -2814,8 +2814,8 @@ void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
}
if (s == end || *s == '\r' || *s == '\n') {
if (!str.IsEmpty()) {
RefPtr<nsTextNode> textContent =
new nsTextNode(NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> textContent = new (NodeInfo()->NodeInfoManager())
nsTextNode(NodeInfo()->NodeInfoManager());
textContent->SetText(str, true);
AppendChildTo(textContent, true);
}

View File

@ -546,7 +546,8 @@ nsresult PrototypeDocumentContentSink::ResumeWalkInternal() {
case nsXULPrototypeNode::eType_Text: {
// A simple text node.
RefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
RefPtr<nsTextNode> text =
new (mNodeInfoManager) nsTextNode(mNodeInfoManager);
nsXULPrototypeText* textproto =
static_cast<nsXULPrototypeText*>(childproto);

View File

@ -749,7 +749,8 @@ nsresult nsXMLContentSink::FlushText(bool aReleaseTextNode) {
mTextLength = 0;
} else {
RefPtr<nsTextNode> textContent = new nsTextNode(mNodeInfoManager);
RefPtr<nsTextNode> textContent =
new (mNodeInfoManager) nsTextNode(mNodeInfoManager);
mLastTextNode = textContent;

View File

@ -90,7 +90,8 @@ static nsresult createTextNode(txIEvalContext* aContext, nsString& aValue,
return NS_ERROR_UNEXPECTED;
}
RefPtr<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
RefPtr<nsTextNode> 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<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
RefPtr<nsTextNode> text =
new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager());
nsresult rv = text->SetText(aValue, false);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -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<nsTextNode> text = new nsTextNode(mDocument->NodeInfoManager());
RefPtr<nsTextNode> text = new (mDocument->NodeInfoManager())
nsTextNode(mDocument->NodeInfoManager());
text->SetText(mText, false);
nsresult rv = mTextParent->AppendChildTo(text, true);

View File

@ -548,7 +548,8 @@ nsresult txMozillaXMLOutput::closePrevious(bool aFlushText) {
rv = createTxWrapper();
NS_ENSURE_SUCCESS(rv, rv);
}
RefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
RefPtr<nsTextNode> text =
new (mNodeInfoManager) nsTextNode(mNodeInfoManager);
rv = text->SetText(mText, false);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1473,7 +1473,8 @@ struct nsGenConInitializer {
already_AddRefed<nsIContent> nsCSSFrameConstructor::CreateGenConTextNode(
nsFrameConstructorState& aState, const nsString& aString,
UniquePtr<nsGenConInitializer> aInitializer) {
RefPtr<nsTextNode> content = new nsTextNode(mDocument->NodeInfoManager());
RefPtr<nsTextNode> content = new (mDocument->NodeInfoManager())
nsTextNode(mDocument->NodeInfoManager());
content->SetText(aString, false);
if (aInitializer) {
aInitializer->mNode->mText = content;

View File

@ -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();

View File

@ -220,8 +220,8 @@ static already_AddRefed<Element> 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<nsTextNode> textContent =
new nsTextNode(button->NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> 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<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
RefPtr<nsTextNode> text =
new (doc->NodeInfoManager()) nsTextNode(doc->NodeInfoManager());
mTextContent->AppendChildTo(text, false);
// Update the displayed text to reflect the current element's value.

View File

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

View File

@ -394,8 +394,8 @@ nsTextControlFrame::CreateEmptyAnonymousDivWithTextNode(
RefPtr<Element> divElement = CreateEmptyAnonymousDiv(aAnonymousDivType);
// Create the text node for the anonymous <div> element.
RefPtr<nsTextNode> textNode =
new nsTextNode(divElement->OwnerDoc()->NodeInfoManager());
RefPtr<nsTextNode> 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<nsTextNode> textNode =
new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
RefPtr<nsTextNode> textNode = new (mContent->NodeInfo()->NodeInfoManager())
nsTextNode(mContent->NodeInfo()->NodeInfoManager());
textNode->MarkAsMaybeModifiedFrequently();
if (IsPasswordTextControl()) {
textNode->MarkAsMaybeMasked();

View File

@ -101,7 +101,8 @@ nsresult DetailsFrame::CreateAnonymousContent(
nsContentUtils::GetMaybeLocalizedString(
nsContentUtils::eFORMS_PROPERTIES, "DefaultSummary",
GetContent()->OwnerDoc(), defaultSummaryText);
RefPtr<nsTextNode> description = new nsTextNode(nodeInfoManager);
RefPtr<nsTextNode> description =
new (nodeInfoManager) nsTextNode(nodeInfoManager);
description->SetText(defaultSummaryText, false);
mDefaultSummary->AppendChildTo(description, false);

View File

@ -233,7 +233,7 @@ nsresult nsHtml5TreeOperation::AppendText(const char16_t* aBuffer,
}
nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager();
RefPtr<nsTextNode> text = new nsTextNode(nodeInfoManager);
RefPtr<nsTextNode> 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<nsTextNode> text = new nsTextNode(nodeInfoManager);
RefPtr<nsTextNode> text = new (nodeInfoManager) nsTextNode(nodeInfoManager);
NS_ASSERTION(text, "Infallible malloc failed?");
rv = text->SetText(aBuffer, aLength, false);
NS_ENSURE_SUCCESS(rv, rv);