deCOMtaminate nsIDocument by changing methods to use return value instead of out-params, eliminating unused nsresult return values, moving some members to nsIDocument and inlining the getters/setters. Bug 222134, r=bzbarsky, sr=jst.

This commit is contained in:
bryner%brianryner.com 2005-11-02 07:41:29 +00:00
Родитель b9f4e41b49
Коммит 35815f1fe7
6 изменённых файлов: 19 добавлений и 37 удалений

Просмотреть файл

@ -298,7 +298,7 @@ PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode)
}
if (!principal) {
doc->GetPrincipal(getter_AddRefs(principal));
principal = doc->GetPrincipal();
}
if (!principal) {
@ -336,22 +336,18 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
return;
}
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsIChannel> channel;
sourceDoc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
nsCOMPtr<nsILoadGroup> loadGroup = sourceDoc->GetDocumentLoadGroup();
nsCOMPtr<nsIIOService> serv = do_GetService(NS_IOSERVICE_CONTRACTID);
if (serv) {
// Create a temporary channel to get nsIDocument->Reset to
// do the right thing. We want the output document to get
// much of the input document's characteristics.
nsCOMPtr<nsIURI> docURL;
sourceDoc->GetDocumentURL(getter_AddRefs(docURL));
serv->NewChannelFromURI(docURL, getter_AddRefs(channel));
serv->NewChannelFromURI(sourceDoc->GetDocumentURL(),
getter_AddRefs(channel));
}
aNewDoc->Reset(channel, loadGroup);
nsCOMPtr<nsIURI> baseURL;
sourceDoc->GetBaseURL(getter_AddRefs(baseURL));
aNewDoc->SetBaseURL(baseURL);
aNewDoc->SetBaseURL(sourceDoc->GetBaseURL());
}

Просмотреть файл

@ -81,10 +81,8 @@ txParseDocumentFromURI(const nsAString& aHref, const nsAString& aReferrer,
nsCOMPtr<nsIDOMDocument> theDocument;
nsCOMPtr<nsIDocument> loaderDocument =
do_QueryInterface(aLoader->getNSObj());
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsIURI> loaderUri;
loaderDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
loaderDocument->GetDocumentURL(getter_AddRefs(loaderUri));
nsCOMPtr<nsILoadGroup> loadGroup = loaderDocument->GetDocumentLoadGroup();
nsIURI *loaderUri = loaderDocument->GetDocumentURL();
NS_ENSURE_TRUE(loaderUri, NS_ERROR_FAILURE);
nsCOMPtr<nsIChannel> channel;

Просмотреть файл

@ -34,6 +34,7 @@ REQUIRES = string \
ifndef TX_EXE
REQUIRES += dom \
content \
necko \
widget \
xpconnect \
js \

Просмотреть файл

@ -756,8 +756,7 @@ TX_CompileStylesheet(nsIDOMNode* aNode, txStylesheet** aStylesheet)
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
nsCOMPtr<nsIURI> uri;
doc->GetBaseURL(getter_AddRefs(uri));
nsIURI *uri = doc->GetBaseURL();
nsCAutoString baseURI;
uri->GetSpec(baseURI);

Просмотреть файл

@ -168,23 +168,19 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
}
// Reset and set up document
nsCOMPtr<nsILoadGroup> loadGroup;
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsIDocument> sourceDoc = do_QueryInterface(aSourceDocument);
sourceDoc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
nsCOMPtr<nsILoadGroup> loadGroup = sourceDoc->GetDocumentLoadGroup();
nsCOMPtr<nsIIOService> serv = do_GetService(NS_IOSERVICE_CONTRACTID);
if (serv) {
// Create a temporary channel to get nsIDocument->Reset to
// do the right thing. We want the output document to get
// much of the input document's characteristics.
nsCOMPtr<nsIURI> docURL;
sourceDoc->GetDocumentURL(getter_AddRefs(docURL));
serv->NewChannelFromURI(docURL, getter_AddRefs(channel));
serv->NewChannelFromURI(sourceDoc->GetDocumentURL(),
getter_AddRefs(channel));
}
doc->Reset(channel, loadGroup);
nsCOMPtr<nsIURI> baseURL;
sourceDoc->GetBaseURL(getter_AddRefs(baseURL));
doc->SetBaseURL(baseURL);
doc->SetBaseURL(sourceDoc->GetBaseURL());
// Notify the contentsink that the document is created
nsCOMPtr<nsITransformObserver> observer = do_QueryReferent(mObserver);
@ -236,11 +232,7 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
return;
}
rv = doc->SetRootContent(rootContent);
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to set the root content");
if (NS_FAILED(rv)) {
return;
}
doc->SetRootContent(rootContent);
mDocument->CreateElementNS(XHTML_NSURI,
NS_LITERAL_STRING("head"),

Просмотреть файл

@ -208,16 +208,14 @@ void txMozillaXMLOutput::endDocument()
if (!mRefreshString.IsEmpty()) {
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
nsCOMPtr<nsIScriptGlobalObject> sgo;
doc->GetScriptGlobalObject(getter_AddRefs(sgo));
nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
if (sgo) {
nsCOMPtr<nsIDocShell> docShell;
sgo->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIRefreshURI> refURI = do_QueryInterface(docShell);
if (refURI) {
nsCOMPtr<nsIURI> baseURI;
doc->GetBaseURL(getter_AddRefs(baseURI));
refURI->SetupRefreshURIFromHeader(baseURI, mRefreshString);
refURI->SetupRefreshURIFromHeader(doc->GetBaseURL(),
mRefreshString);
}
}
}
@ -739,8 +737,7 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, PRInt32 aNsID,
}
// Set up script loader of the result document.
nsCOMPtr<nsIScriptLoader> loader;
doc->GetScriptLoader(getter_AddRefs(loader));
nsIScriptLoader *loader = doc->GetScriptLoader();
if (loader) {
if (mNotifier) {
loader->AddObserver(mNotifier);
@ -904,9 +901,8 @@ txTransformNotifier::SignalTransformEnd()
// XXX Need a better way to determine transform success/failure
if (mDocument) {
nsCOMPtr<nsIScriptLoader> loader;
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
doc->GetScriptLoader(getter_AddRefs(loader));
nsIScriptLoader *loader = doc->GetScriptLoader();
if (loader) {
loader->RemoveObserver(this);
}