Skip to content

Commit

Permalink
Bug 819650 - Remove nsContentUtils::CreateDocument. r=sicking
Browse files Browse the repository at this point in the history
  • Loading branch information
vyv03354 committed Dec 10, 2012
1 parent 0d339d0 commit 58cec5c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 85 deletions.
28 changes: 0 additions & 28 deletions content/base/public/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1181,34 +1181,6 @@ class nsContentUtils
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.
Expand Down
24 changes: 12 additions & 12 deletions content/base/src/DOMImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
35 changes: 10 additions & 25 deletions content/base/src/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions content/base/src/nsDOMParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
10 changes: 5 additions & 5 deletions content/base/src/nsXMLHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 10 additions & 9 deletions parser/html/nsParserUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 58cec5c

Please sign in to comment.