diff --git a/content/base/public/nsContentCreatorFunctions.h b/content/base/public/nsContentCreatorFunctions.h index 051f167ff13..4b7e62f0c0d 100644 --- a/content/base/public/nsContentCreatorFunctions.h +++ b/content/base/public/nsContentCreatorFunctions.h @@ -30,12 +30,6 @@ NS_NewElement(nsIContent** aResult, nsresult NS_NewXMLElement(nsIContent** aResult, already_AddRefed aNodeInfo); -/** - * aNodeInfoManager must not be null. - */ -nsresult -NS_NewTextNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager); - /** * aNodeInfoManager must not be null. */ diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index a77f3f65b16..b13bb4c3d9b 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -1952,8 +1952,7 @@ public: mozilla::ErrorResult& rv); already_AddRefed CreateDocumentFragment(mozilla::ErrorResult& rv) const; - already_AddRefed CreateTextNode(const nsAString& aData, - mozilla::ErrorResult& rv) const; + already_AddRefed CreateTextNode(const nsAString& aData) const; already_AddRefed CreateComment(const nsAString& aData, mozilla::ErrorResult& rv) const; already_AddRefed diff --git a/content/base/src/DOMImplementation.cpp b/content/base/src/DOMImplementation.cpp index 52c73e8a142..200ab130615 100644 --- a/content/base/src/DOMImplementation.cpp +++ b/content/base/src/DOMImplementation.cpp @@ -9,6 +9,7 @@ #include "nsContentUtils.h" #include "nsDOMClassInfoID.h" #include "DocumentType.h" +#include "nsTextNode.h" namespace mozilla { namespace dom { @@ -219,9 +220,7 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle, rv = head->AppendChildTo(title, false); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr titleText; - rv = NS_NewTextNode(getter_AddRefs(titleText), doc->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr titleText = new nsTextNode(doc->NodeInfoManager()); rv = titleText->SetText(aTitle, false); NS_ENSURE_SUCCESS(rv, rv); rv = title->AppendChildTo(titleText, false); diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 785fe6d149f..1accabaed73 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -157,6 +157,7 @@ #include "nsSVGFeatures.h" #include "nsTextEditorState.h" #include "nsTextFragment.h" +#include "nsTextNode.h" #include "nsThreadUtils.h" #include "nsUnicharUtilCIID.h" #include "nsUnicodeProperties.h" @@ -4478,14 +4479,12 @@ nsContentUtils::SetNodeTextContent(nsIContent* aContent, return NS_OK; } - nsCOMPtr textContent; - nsresult rv = NS_NewTextNode(getter_AddRefs(textContent), - aContent->NodeInfo()->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr textContent = + new nsTextNode(aContent->NodeInfo()->NodeInfoManager()); textContent->SetText(aValue, true); - rv = aContent->AppendChildTo(textContent, true); + nsresult rv = aContent->AppendChildTo(textContent, true); mb.NodesAdded(); return rv; } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index b7ae4f80f63..53c2abae531 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -4775,31 +4775,17 @@ nsIDocument::CreateElementNS(const nsAString& aNamespaceURI, NS_IMETHODIMP nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn) { - ErrorResult rv; - *aReturn = nsIDocument::CreateTextNode(aData, rv).get(); - return rv.ErrorCode(); -} - -nsresult -nsDocument::CreateTextNode(const nsAString& aData, nsIContent** aReturn) -{ - ErrorResult rv; - *aReturn = nsIDocument::CreateTextNode(aData, rv).get(); - return rv.ErrorCode(); + *aReturn = nsIDocument::CreateTextNode(aData).get(); + return NS_OK; } already_AddRefed -nsIDocument::CreateTextNode(const nsAString& aData, ErrorResult& rv) const +nsIDocument::CreateTextNode(const nsAString& aData) const { - nsCOMPtr content; - nsresult res = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager); - if (NS_FAILED(res)) { - rv.Throw(res); - return nullptr; - } + nsRefPtr text = new nsTextNode(mNodeInfoManager); // Don't notify; this node is still being created. - content->SetText(aData, false); - return static_cast(content.forget().get()); + text->SetText(aData, false); + return text.forget(); } NS_IMETHODIMP diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 40c3d837ce0..fef6ff75d7a 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -817,8 +817,6 @@ public: int32_t aNamespaceID, nsIContent **aResult); - nsresult CreateTextNode(const nsAString& aData, nsIContent** aReturn); - virtual NS_HIDDEN_(nsresult) Sanitize(); virtual NS_HIDDEN_(void) EnumerateSubDocuments(nsSubDocEnumFunc aCallback, diff --git a/content/base/src/nsTextNode.cpp b/content/base/src/nsTextNode.cpp index 037e0f0262c..9ba11c4ddb6 100644 --- a/content/base/src/nsTextNode.cpp +++ b/content/base/src/nsTextNode.cpp @@ -90,29 +90,6 @@ private: nsCOMPtr mAttrName; }; -nsresult -NS_NewTextNode(nsIContent** aInstancePtrResult, - nsNodeInfoManager *aNodeInfoManager) -{ - NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager"); - - *aInstancePtrResult = nullptr; - - nsCOMPtr ni = aNodeInfoManager->GetTextNodeInfo(); - if (!ni) { - return NS_ERROR_OUT_OF_MEMORY; - } - - nsTextNode *instance = new nsTextNode(ni.forget()); - if (!instance) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aInstancePtrResult = instance); - - return NS_OK; -} - nsTextNode::~nsTextNode() { } diff --git a/content/base/src/nsTextNode.h b/content/base/src/nsTextNode.h index 41f13d85000..e30908496de 100644 --- a/content/base/src/nsTextNode.h +++ b/content/base/src/nsTextNode.h @@ -14,21 +14,35 @@ #include "nsIDOMText.h" #include "nsDebug.h" +class nsNodeInfoManager; + /** * Class used to implement DOM text nodes */ class nsTextNode : public mozilla::dom::Text, public nsIDOMText { -public: - nsTextNode(already_AddRefed aNodeInfo) - : mozilla::dom::Text(aNodeInfo) +private: + void Init() { NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE, "Bad NodeType in aNodeInfo"); SetIsDOMBinding(); } +public: + nsTextNode(already_AddRefed aNodeInfo) + : mozilla::dom::Text(aNodeInfo) + { + Init(); + } + + nsTextNode(nsNodeInfoManager* aNodeInfoManager) + : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) + { + Init(); + } + virtual ~nsTextNode(); // nsISupports diff --git a/content/html/content/src/HTMLOptionElement.cpp b/content/html/content/src/HTMLOptionElement.cpp index 4d82c0d75dd..6c54815a881 100644 --- a/content/html/content/src/HTMLOptionElement.cpp +++ b/content/html/content/src/HTMLOptionElement.cpp @@ -27,6 +27,7 @@ #include "nsEventStates.h" #include "nsContentCreatorFunctions.h" #include "mozAutoDocUpdate.h" +#include "nsTextNode.h" /** * Implementation of <option> @@ -384,12 +385,8 @@ HTMLOptionElement::Option(const GlobalObject& aGlobal, if (aText.WasPassed()) { // Create a new text node and append it to the option - nsCOMPtr textContent; - aError = NS_NewTextNode(getter_AddRefs(textContent), - option->NodeInfo()->NodeInfoManager()); - if (aError.Failed()) { - return nullptr; - } + nsRefPtr textContent = + new nsTextNode(option->NodeInfo()->NodeInfoManager()); textContent->SetText(aText.Value(), false); diff --git a/content/html/content/src/HTMLSelectElement.cpp b/content/html/content/src/HTMLSelectElement.cpp index 118416f0543..0bd3043fec1 100644 --- a/content/html/content/src/HTMLSelectElement.cpp +++ b/content/html/content/src/HTMLSelectElement.cpp @@ -32,6 +32,7 @@ #include "nsRuleData.h" #include "nsServiceManagerUtils.h" #include "nsStyleConsts.h" +#include "nsTextNode.h" NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Select) DOMCI_NODE_DATA(HTMLSelectElement, mozilla::dom::HTMLSelectElement) @@ -745,9 +746,7 @@ HTMLSelectElement::SetLength(uint32_t aLength) return NS_ERROR_OUT_OF_MEMORY; } - nsCOMPtr text; - rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr text = new nsTextNode(mNodeInfo->NodeInfoManager()); rv = element->AppendChildTo(text, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index a5842aecfad..3525ee1d5ba 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -39,6 +39,7 @@ #include "nsEventListenerManager.h" #include "nsContentUtils.h" #include "mozilla/Preferences.h" +#include "nsTextNode.h" using namespace mozilla; using namespace mozilla::dom; @@ -1645,7 +1646,6 @@ be called if @placeholder is the empty string when trimmed from line breaks"); NS_ENSURE_TRUE(pNodeInfoManager, NS_ERROR_OUT_OF_MEMORY); nsresult rv; - nsCOMPtr placeholderText; // Create a DIV for the placeholder // and add it to the anonymous content child list @@ -1659,8 +1659,7 @@ be called if @placeholder is the empty string when trimmed from line breaks"); NS_ENSURE_SUCCESS(rv, rv); // Create the text node for the placeholder text before doing anything else - rv = NS_NewTextNode(getter_AddRefs(placeholderText), pNodeInfoManager); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr placeholderText = new nsTextNode(pNodeInfoManager); rv = mPlaceholderDiv->AppendChildTo(placeholderText, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 506f1559afd..6544793b397 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -81,6 +81,7 @@ #include "nsNodeInfoManager.h" #include "nsContentCreatorFunctions.h" #include "mozAutoDocUpdate.h" +#include "nsTextNode.h" using namespace mozilla; using namespace mozilla::dom; @@ -1166,10 +1167,8 @@ SinkContext::FlushText(bool* aDidFlush, bool aReleaseLast) didFlush = true; } } else { - nsCOMPtr textContent; - rv = NS_NewTextNode(getter_AddRefs(textContent), - mSink->mNodeInfoManager); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr textContent = + new nsTextNode(mSink->mNodeInfoManager); mLastTextNode = textContent; diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index b65f7446062..a113f67b0a4 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -35,6 +35,7 @@ #include "nsCRT.h" #include "nsContentUtils.h" #include "nsTextFragment.h" +#include "nsTextNode.h" #include "nsIScriptContext.h" #include "nsIScriptError.h" @@ -514,12 +515,8 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, nsAutoString value; aChangedElement->GetAttr(aNameSpaceID, aAttribute, value); if (!value.IsEmpty()) { - nsCOMPtr textContent; - NS_NewTextNode(getter_AddRefs(textContent), - realElement->NodeInfo()->NodeInfoManager()); - if (!textContent) { - continue; - } + nsRefPtr textContent = + new nsTextNode(realElement->NodeInfo()->NodeInfoManager()); textContent->SetText(value, true); realElement->AppendChildTo(textContent, true); @@ -890,12 +887,8 @@ bool SetAttrs(nsHashKey* aKey, void* aData, void* aClosure) kNameSpaceID_XUL) && dst == nsGkAtoms::value && !value.IsEmpty())) { - nsCOMPtr textContent; - NS_NewTextNode(getter_AddRefs(textContent), - realElement->NodeInfo()->NodeInfoManager()); - if (!textContent) { - continue; - } + nsRefPtr textContent = + new nsTextNode(realElement->NodeInfo()->NodeInfoManager()); textContent->SetText(value, false); realElement->AppendChildTo(textContent, false); @@ -1689,7 +1682,7 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream, namespaceID == XBLBinding_Serialize_CommentNode) { switch (namespaceID) { case XBLBinding_Serialize_TextNode: - rv = NS_NewTextNode(getter_AddRefs(content), aNim); + content = new nsTextNode(aNim); break; case XBLBinding_Serialize_CDATANode: rv = NS_NewXMLCDATASection(getter_AddRefs(content), aNim); diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index c69da4e8c6b..ee7cc08c64f 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -56,6 +56,7 @@ #include "mozAutoDocUpdate.h" #include "nsMimeTypes.h" #include "nsHtml5SVGLoadDispatcher.h" +#include "nsTextNode.h" using namespace mozilla::dom; @@ -798,10 +799,7 @@ nsXMLContentSink::FlushText(bool aReleaseTextNode) mTextLength = 0; } } else { - nsCOMPtr textContent; - rv = NS_NewTextNode(getter_AddRefs(textContent), - mNodeInfoManager); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr textContent = new nsTextNode(mNodeInfoManager); mLastTextNode = textContent; diff --git a/content/xslt/src/xslt/txEXSLTFunctions.cpp b/content/xslt/src/xslt/txEXSLTFunctions.cpp index 36ae22d922b..a5be4b6da6e 100644 --- a/content/xslt/src/xslt/txEXSLTFunctions.cpp +++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp @@ -22,6 +22,7 @@ #include "nsIContent.h" #include "nsIDOMDocumentFragment.h" #include "txMozillaXMLOutput.h" +#include "nsTextNode.h" using namespace mozilla; @@ -84,11 +85,9 @@ createTextNode(txIEvalContext *aContext, nsString& aValue, const txXPathNode& document = es->getSourceDocument(); nsIDocument *doc = txXPathNativeNode::getDocument(document); - nsCOMPtr text; - nsresult rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr text = new nsTextNode(doc->NodeInfoManager()); - rv = text->SetText(aValue, false); + nsresult rv = text->SetText(aValue, false); NS_ENSURE_SUCCESS(rv, rv); *aResult = txXPathNativeNode::createXPathNode(text, true); @@ -133,9 +132,7 @@ createAndAddToResult(nsIAtom* aName, const nsSubstring& aValue, getter_AddRefs(elem)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr text; - rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr text = new nsTextNode(doc->NodeInfoManager()); rv = text->SetText(aValue, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xslt/src/xslt/txMozillaTextOutput.cpp b/content/xslt/src/xslt/txMozillaTextOutput.cpp index ee452117603..c5fd8f104ef 100644 --- a/content/xslt/src/xslt/txMozillaTextOutput.cpp +++ b/content/xslt/src/xslt/txMozillaTextOutput.cpp @@ -18,6 +18,7 @@ #include "nsContentUtils.h" #include "nsGkAtoms.h" #include "mozilla/dom/EncodingUtils.h" +#include "nsTextNode.h" using namespace mozilla::dom; @@ -74,13 +75,10 @@ txMozillaTextOutput::endDocument(nsresult aResult) { NS_ENSURE_TRUE(mDocument && mTextParent, NS_ERROR_FAILURE); - nsCOMPtr text; - nsresult rv = NS_NewTextNode(getter_AddRefs(text), - mDocument->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr text = new nsTextNode(mDocument->NodeInfoManager()); text->SetText(mText, false); - rv = mTextParent->AppendChildTo(text, true); + nsresult rv = mTextParent->AppendChildTo(text, true); NS_ENSURE_SUCCESS(rv, rv); if (NS_SUCCEEDED(aResult)) { diff --git a/content/xslt/src/xslt/txMozillaXMLOutput.cpp b/content/xslt/src/xslt/txMozillaXMLOutput.cpp index ef8a2c2d577..e882ad261dd 100644 --- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp +++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp @@ -40,6 +40,7 @@ #include "nsError.h" #include "nsIFrame.h" #include +#include "nsTextNode.h" using namespace mozilla::dom; @@ -599,9 +600,7 @@ txMozillaXMLOutput::closePrevious(bool aFlushText) rv = createTxWrapper(); NS_ENSURE_SUCCESS(rv, rv); } - nsCOMPtr text; - rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr text = new nsTextNode(mNodeInfoManager); rv = text->SetText(mText, false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp index 8e84ca16a6f..dc850946dea 100644 --- a/content/xul/document/src/XULDocument.cpp +++ b/content/xul/document/src/XULDocument.cpp @@ -89,6 +89,7 @@ #include "mozilla/dom/Element.h" #include "mozilla/dom/XULDocumentBinding.h" #include "mozilla/Preferences.h" +#include "nsTextNode.h" using namespace mozilla; using namespace mozilla::dom; @@ -3049,10 +3050,8 @@ XULDocument::ResumeWalk() // This does mean that text nodes that are direct children // of get ignored. - nsCOMPtr text; - rv = NS_NewTextNode(getter_AddRefs(text), - mNodeInfoManager); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr text = + new nsTextNode(mNodeInfoManager); nsXULPrototypeText* textproto = static_cast(childproto); diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 8e5f4ef72e0..5026400d8c5 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -31,6 +31,7 @@ #include "nsAttrName.h" #include "nsNodeUtils.h" #include "mozAutoDocUpdate.h" +#include "nsTextNode.h" #include "jsapi.h" #include "pldhash.h" @@ -619,10 +620,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = SubstituteText(aChild, attrValue, value); if (NS_FAILED(rv)) return rv; - nsCOMPtr content; - rv = NS_NewTextNode(getter_AddRefs(content), - mRoot->NodeInfo()->NodeInfoManager()); - if (NS_FAILED(rv)) return rv; + nsRefPtr content = + new nsTextNode(mRoot->NodeInfo()->NodeInfoManager()); content->SetText(value, false); diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 56f156d6dff..367596b0d39 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -48,7 +48,7 @@ interface Document : Node { Element createElementNS(DOMString? namespace, DOMString qualifiedName); [Creator, Throws] DocumentFragment createDocumentFragment(); - [Creator, Throws] + [Creator] Text createTextNode(DOMString data); [Creator, Throws] Comment createComment(DOMString data); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 1e3eb982122..d983add1dd9 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -125,6 +125,7 @@ #include "nsRefreshDriver.h" #include "nsRuleProcessorData.h" #include "GeckoProfiler.h" +#include "nsTextNode.h" using namespace mozilla; using namespace mozilla::dom; @@ -1526,17 +1527,10 @@ nsCSSFrameConstructor::CreateGenConTextNode(nsFrameConstructorState& aState, nsCOMPtr* aText, nsGenConInitializer* aInitializer) { - nsCOMPtr content; - NS_NewTextNode(getter_AddRefs(content), mDocument->NodeInfoManager()); - if (!content) { - // XXX The quotes/counters code doesn't like the text pointer - // being null in case of dynamic changes! - NS_ASSERTION(!aText, "this OOM case isn't handled very well"); - return nullptr; - } + nsRefPtr content = new nsTextNode(mDocument->NodeInfoManager()); content->SetText(aString, false); if (aText) { - *aText = do_QueryInterface(content); + *aText = content; } if (aInitializer) { content->SetProperty(nsGkAtoms::genConInitializerProperty, aInitializer, diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index c0c34f59229..80f2f08ae63 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -56,6 +56,7 @@ #include "nsContentList.h" #include "mozilla/Likely.h" #include +#include "nsTextNode.h" using namespace mozilla; @@ -1191,9 +1192,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsTArray& aElements) nsNodeInfoManager *nimgr = mContent->NodeInfo()->NodeInfoManager(); - NS_NewTextNode(getter_AddRefs(mDisplayContent), nimgr); - if (!mDisplayContent) - return NS_ERROR_OUT_OF_MEMORY; + mDisplayContent = new 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 270844222b0..4744082b091 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -50,6 +50,7 @@ #include "nsIDOMDragEvent.h" #include "nsContentList.h" #include "nsIDOMMutationEvent.h" +#include "nsTextNode.h" using namespace mozilla; using namespace mozilla::dom; @@ -123,14 +124,12 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) // Set the browse button text. It's a bit of a pain to do because we want to // make sure we are not notifying. - nsCOMPtr textContent; - nsresult rv = NS_NewTextNode(getter_AddRefs(textContent), - mBrowse->NodeInfo()->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr textContent = + new nsTextNode(mBrowse->NodeInfo()->NodeInfoManager()); textContent->SetText(buttonTxt, false); - rv = mBrowse->AppendChildTo(textContent, false); + nsresult rv = mBrowse->AppendChildTo(textContent, false); NS_ENSURE_SUCCESS(rv, rv); // Make sure access key and tab order for the element actually redirect to the diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 6240c8fe231..63264874fa2 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -22,6 +22,7 @@ #include "nsNodeInfoManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsContentList.h" +#include "nsTextNode.h" const nscoord kSuggestedNotSet = -1; @@ -67,15 +68,12 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsTArray& aElements GetLabel(label); // Add a child text content node for the label - NS_NewTextNode(getter_AddRefs(mTextContent), - mContent->NodeInfo()->NodeInfoManager()); - if (!mTextContent) - return NS_ERROR_OUT_OF_MEMORY; + mTextContent = new nsTextNode(mContent->NodeInfo()->NodeInfoManager()); // set the value of the text node and add it to the child list mTextContent->SetText(label, false); - if (!aElements.AppendElement(mTextContent)) - return NS_ERROR_OUT_OF_MEMORY; + aElements.AppendElement(mTextContent); + return NS_OK; } diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index d9d944b472f..c64cf3d3b00 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -74,6 +74,7 @@ #include "nsAttrValueInlines.h" #include "mozilla/Selection.h" #include "nsContentUtils.h" +#include "nsTextNode.h" #define DEFAULT_COLUMN_WIDTH 20 @@ -1324,10 +1325,8 @@ nsTextControlFrame::UpdateValueDisplay(bool aNotify, nsIContent *textContent = rootNode->GetChildAt(0); if (!textContent) { // Set up a textnode with our value - nsCOMPtr textNode; - nsresult rv = NS_NewTextNode(getter_AddRefs(textNode), - mContent->NodeInfo()->NodeInfoManager()); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr textNode = + new nsTextNode(mContent->NodeInfo()->NodeInfoManager()); NS_ASSERTION(textNode, "Must have textcontent!\n"); diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index e2564df5d1d..12762016646 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -38,6 +38,7 @@ #include "nsNetUtil.h" #include "nsIHTMLDocument.h" #include "mozilla/Likely.h" +#include "nsTextNode.h" namespace dom = mozilla::dom; @@ -162,8 +163,7 @@ nsHtml5TreeOperation::AppendText(const PRUnichar* aBuffer, aBuilder); } - nsCOMPtr text; - NS_NewTextNode(getter_AddRefs(text), aBuilder->GetNodeInfoManager()); + nsRefPtr text = new nsTextNode(aBuilder->GetNodeInfoManager()); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(aBuffer, aLength, false); NS_ENSURE_SUCCESS(rv, rv); @@ -393,9 +393,8 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, : (aBuilder->BelongsToStringParser() ? dom::FROM_PARSER_FRAGMENT : dom::FROM_PARSER_DOCUMENT_WRITE))); - nsCOMPtr optionText; - NS_NewTextNode(getter_AddRefs(optionText), - aBuilder->GetNodeInfoManager()); + nsRefPtr optionText = + new nsTextNode(aBuilder->GetNodeInfoManager()); (void) optionText->SetText(theContent[i], false); optionElt->AppendChildTo(optionText, false); newContent->AppendChildTo(optionElt, false); @@ -498,8 +497,8 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder, aBuilder); } - nsCOMPtr text; - NS_NewTextNode(getter_AddRefs(text), aBuilder->GetNodeInfoManager()); + nsRefPtr text = + new nsTextNode(aBuilder->GetNodeInfoManager()); NS_ASSERTION(text, "Infallible malloc failed?"); rv = text->SetText(buffer, length, false); NS_ENSURE_SUCCESS(rv, rv);