Bug 819650 - Remove nsContentUtils::CreateDocument. r=sicking

This commit is contained in:
Masatoshi Kimura 2012-12-10 09:05:33 -05:00
parent d777fcb4f5
commit 89a4119635
6 changed files with 43 additions and 85 deletions

View File

@ -1181,34 +1181,6 @@ public:
uint32_t aFlags,
uint32_t aWrapCol);
/**
* Creates a new XML document, which is marked to be loaded as data.
*
* @param aNamespaceURI Namespace for the root element to create and insert in
* the document. Only used if aQualifiedName is not
* empty.
* @param aQualifiedName Qualified name for the root element to create and
* insert in the document. If empty no root element will
* be created.
* @param aDoctype Doctype node to insert in the document.
* @param aDocumentURI URI of the document. Must not be null.
* @param aBaseURI Base URI of the document. Must not be null.
* @param aPrincipal Prinicpal of the document. Must not be null.
* @param aScriptObject The object from which the context for event handling
* can be got.
* @param aFlavor Select the kind of document to create.
* @param aResult [out] The document that was created.
*/
static nsresult CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aScriptObject,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult);
/**
* Sets the text contents of a node by replacing all existing children
* with a single text child.

View File

@ -119,12 +119,12 @@ DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
nsCOMPtr<nsIDOMDocument> document;
rv = nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject,
DocumentFlavorLegacyGuess,
getter_AddRefs(document));
rv = NS_NewDOMDocument(getter_AddRefs(document),
aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
true, scriptHandlingObject,
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
@ -186,12 +186,12 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
nsCOMPtr<nsIDOMDocument> document;
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject,
DocumentFlavorLegacyGuess,
getter_AddRefs(document));
rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
true, scriptHandlingObject,
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);

View File

@ -4274,15 +4274,16 @@ nsContentUtils::ConvertToPlainText(const nsAString& aSourceBuffer,
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance(NS_NULLPRINCIPAL_CONTRACTID);
nsCOMPtr<nsIDOMDocument> domDocument;
nsresult rv = nsContentUtils::CreateDocument(EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
nullptr,
DocumentFlavorHTML,
getter_AddRefs(domDocument));
nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
true,
nullptr,
DocumentFlavorHTML);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
@ -4301,22 +4302,6 @@ nsContentUtils::ConvertToPlainText(const nsAString& aSourceBuffer,
return encoder->EncodeToString(aResultBuffer);
}
/* static */
nsresult
nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype,
nsIURI* aDocumentURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
nsIScriptGlobalObject* aEventObject,
DocumentFlavor aFlavor,
nsIDOMDocument** aResult)
{
return NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
true, aEventObject, aFlavor);
}
/* static */
nsresult
nsContentUtils::SetNodeTextContent(nsIContent* aContent,

View File

@ -501,10 +501,10 @@ nsDOMParser::SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult)
// work if the document has a null principal, so use
// mOriginalPrincipal when creating the document, then reset the
// principal.
return nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nullptr,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
scriptHandlingObject,
aFlavor,
aResult);
return NS_NewDOMDocument(aResult, EmptyString(), EmptyString(), nullptr,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
true,
scriptHandlingObject,
aFlavor);
}

View File

@ -2186,11 +2186,11 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
const nsAString& emptyStr = EmptyString();
nsCOMPtr<nsIScriptGlobalObject> global = do_QueryInterface(GetOwner());
nsCOMPtr<nsIDOMDocument> responseDoc;
rv = nsContentUtils::CreateDocument(emptyStr, emptyStr, nullptr, docURI,
baseURI, mPrincipal, global,
mIsHtml ? DocumentFlavorHTML :
DocumentFlavorLegacyGuess,
getter_AddRefs(responseDoc));
rv = NS_NewDOMDocument(getter_AddRefs(responseDoc),
emptyStr, emptyStr, nullptr, docURI,
baseURI, mPrincipal, true, global,
mIsHtml ? DocumentFlavorHTML :
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
mResponseXML = do_QueryInterface(responseDoc);
mResponseXML->SetPrincipal(documentPrincipal);

View File

@ -79,15 +79,16 @@ nsParserUtils::Sanitize(const nsAString& aFromStr,
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance("@mozilla.org/nullprincipal;1");
nsCOMPtr<nsIDOMDocument> domDocument;
nsresult rv = nsContentUtils::CreateDocument(EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
nullptr,
DocumentFlavorHTML,
getter_AddRefs(domDocument));
nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
true,
nullptr,
DocumentFlavorHTML);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);