зеркало из https://github.com/mozilla/gecko-dev.git
Bug 857102 part 2 - Make NS_NewTextNode and nsIDocument::CreateTextNode infallible; r=bz
This commit is contained in:
Родитель
8813767de7
Коммит
5925b452a5
|
@ -30,12 +30,6 @@ NS_NewElement(nsIContent** aResult,
|
|||
nsresult
|
||||
NS_NewXMLElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewTextNode(nsIContent **aResult, nsNodeInfoManager *aNodeInfoManager);
|
||||
|
||||
/**
|
||||
* aNodeInfoManager must not be null.
|
||||
*/
|
||||
|
|
|
@ -1952,8 +1952,7 @@ public:
|
|||
mozilla::ErrorResult& rv);
|
||||
already_AddRefed<mozilla::dom::DocumentFragment>
|
||||
CreateDocumentFragment(mozilla::ErrorResult& rv) const;
|
||||
already_AddRefed<nsTextNode> CreateTextNode(const nsAString& aData,
|
||||
mozilla::ErrorResult& rv) const;
|
||||
already_AddRefed<nsTextNode> CreateTextNode(const nsAString& aData) const;
|
||||
already_AddRefed<mozilla::dom::Comment>
|
||||
CreateComment(const nsAString& aData, mozilla::ErrorResult& rv) const;
|
||||
already_AddRefed<mozilla::dom::ProcessingInstruction>
|
||||
|
|
|
@ -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<nsIContent> titleText;
|
||||
rv = NS_NewTextNode(getter_AddRefs(titleText), doc->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> titleText = new nsTextNode(doc->NodeInfoManager());
|
||||
rv = titleText->SetText(aTitle, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = title->AppendChildTo(titleText, false);
|
||||
|
|
|
@ -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<nsIContent> textContent;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(textContent),
|
||||
aContent->NodeInfo()->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> 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;
|
||||
}
|
||||
|
|
|
@ -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<nsTextNode>
|
||||
nsIDocument::CreateTextNode(const nsAString& aData, ErrorResult& rv) const
|
||||
nsIDocument::CreateTextNode(const nsAString& aData) const
|
||||
{
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsresult res = NS_NewTextNode(getter_AddRefs(content), mNodeInfoManager);
|
||||
if (NS_FAILED(res)) {
|
||||
rv.Throw(res);
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
|
||||
// Don't notify; this node is still being created.
|
||||
content->SetText(aData, false);
|
||||
return static_cast<nsTextNode*>(content.forget().get());
|
||||
text->SetText(aData, false);
|
||||
return text.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -90,29 +90,6 @@ private:
|
|||
nsCOMPtr<nsIAtom> mAttrName;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewTextNode(nsIContent** aInstancePtrResult,
|
||||
nsNodeInfoManager *aNodeInfoManager)
|
||||
{
|
||||
NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager");
|
||||
|
||||
*aInstancePtrResult = nullptr;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> 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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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<nsINodeInfo> 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<nsINodeInfo> aNodeInfo)
|
||||
: mozilla::dom::Text(aNodeInfo)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
nsTextNode(nsNodeInfoManager* aNodeInfoManager)
|
||||
: mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo())
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
virtual ~nsTextNode();
|
||||
|
||||
// nsISupports
|
||||
|
|
|
@ -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<nsIContent> textContent;
|
||||
aError = NS_NewTextNode(getter_AddRefs(textContent),
|
||||
option->NodeInfo()->NodeInfoManager());
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<nsTextNode> textContent =
|
||||
new nsTextNode(option->NodeInfo()->NodeInfoManager());
|
||||
|
||||
textContent->SetText(aText.Value(), false);
|
||||
|
||||
|
|
|
@ -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<nsIContent> text;
|
||||
rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfo->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> text = new nsTextNode(mNodeInfo->NodeInfoManager());
|
||||
|
||||
rv = element->AppendChildTo(text, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -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<nsIContent> 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<nsTextNode> placeholderText = new nsTextNode(pNodeInfoManager);
|
||||
|
||||
rv = mPlaceholderDiv->AppendChildTo(placeholderText, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -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<nsIContent> textContent;
|
||||
rv = NS_NewTextNode(getter_AddRefs(textContent),
|
||||
mSink->mNodeInfoManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> textContent =
|
||||
new nsTextNode(mSink->mNodeInfoManager);
|
||||
|
||||
mLastTextNode = textContent;
|
||||
|
||||
|
|
|
@ -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<nsIContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent),
|
||||
realElement->NodeInfo()->NodeInfoManager());
|
||||
if (!textContent) {
|
||||
continue;
|
||||
}
|
||||
nsRefPtr<nsTextNode> 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<nsIContent> textContent;
|
||||
NS_NewTextNode(getter_AddRefs(textContent),
|
||||
realElement->NodeInfo()->NodeInfoManager());
|
||||
if (!textContent) {
|
||||
continue;
|
||||
}
|
||||
nsRefPtr<nsTextNode> 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);
|
||||
|
|
|
@ -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<nsIContent> textContent;
|
||||
rv = NS_NewTextNode(getter_AddRefs(textContent),
|
||||
mNodeInfoManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> textContent = new nsTextNode(mNodeInfoManager);
|
||||
|
||||
mLastTextNode = textContent;
|
||||
|
||||
|
|
|
@ -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<nsIContent> text;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIContent> 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<nsIContent> text;
|
||||
rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
|
||||
|
||||
rv = text->SetText(aValue, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -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<nsIContent> text;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(text),
|
||||
mDocument->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> 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)) {
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsError.h"
|
||||
#include "nsIFrame.h"
|
||||
#include <algorithm>
|
||||
#include "nsTextNode.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
@ -599,9 +600,7 @@ txMozillaXMLOutput::closePrevious(bool aFlushText)
|
|||
rv = createTxWrapper();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
nsCOMPtr<nsIContent> text;
|
||||
rv = NS_NewTextNode(getter_AddRefs(text), mNodeInfoManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
|
||||
|
||||
rv = text->SetText(mText, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -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 <overlay> get ignored.
|
||||
|
||||
nsCOMPtr<nsIContent> text;
|
||||
rv = NS_NewTextNode(getter_AddRefs(text),
|
||||
mNodeInfoManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> text =
|
||||
new nsTextNode(mNodeInfoManager);
|
||||
|
||||
nsXULPrototypeText* textproto =
|
||||
static_cast<nsXULPrototypeText*>(childproto);
|
||||
|
|
|
@ -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<nsIContent> content;
|
||||
rv = NS_NewTextNode(getter_AddRefs(content),
|
||||
mRoot->NodeInfo()->NodeInfoManager());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsRefPtr<nsTextNode> content =
|
||||
new nsTextNode(mRoot->NodeInfo()->NodeInfoManager());
|
||||
|
||||
content->SetText(value, false);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<nsIDOMCharacterData>* aText,
|
||||
nsGenConInitializer* aInitializer)
|
||||
{
|
||||
nsCOMPtr<nsIContent> 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<nsTextNode> content = new nsTextNode(mDocument->NodeInfoManager());
|
||||
content->SetText(aString, false);
|
||||
if (aText) {
|
||||
*aText = do_QueryInterface(content);
|
||||
*aText = content;
|
||||
}
|
||||
if (aInitializer) {
|
||||
content->SetProperty(nsGkAtoms::genConInitializerProperty, aInitializer,
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nsContentList.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include <algorithm>
|
||||
#include "nsTextNode.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -1191,9 +1192,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& 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();
|
||||
|
|
|
@ -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<ContentInfo>& 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<nsIContent> textContent;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(textContent),
|
||||
mBrowse->NodeInfo()->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> 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
|
||||
|
|
|
@ -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<ContentInfo>& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<nsIContent> textNode;
|
||||
nsresult rv = NS_NewTextNode(getter_AddRefs(textNode),
|
||||
mContent->NodeInfo()->NodeInfoManager());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTextNode> textNode =
|
||||
new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
|
||||
|
||||
NS_ASSERTION(textNode, "Must have textcontent!\n");
|
||||
|
||||
|
|
|
@ -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<nsIContent> text;
|
||||
NS_NewTextNode(getter_AddRefs(text), aBuilder->GetNodeInfoManager());
|
||||
nsRefPtr<nsTextNode> 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<nsIContent> optionText;
|
||||
NS_NewTextNode(getter_AddRefs(optionText),
|
||||
aBuilder->GetNodeInfoManager());
|
||||
nsRefPtr<nsTextNode> 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<nsIContent> text;
|
||||
NS_NewTextNode(getter_AddRefs(text), aBuilder->GetNodeInfoManager());
|
||||
nsRefPtr<nsTextNode> text =
|
||||
new nsTextNode(aBuilder->GetNodeInfoManager());
|
||||
NS_ASSERTION(text, "Infallible malloc failed?");
|
||||
rv = text->SetText(buffer, length, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче