Bug 11016. Clean up GetSourceDocumentURL() return paths s.t. sourceURL is null and/or error code is set if do_QueryInterface() fails.

This commit is contained in:
waterson%netscape.com 1999-08-18 08:48:33 +00:00
Родитель a099b1e5b6
Коммит d520bcc2ff
2 изменённых файлов: 8 добавлений и 4 удалений

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

@ -1431,6 +1431,8 @@ nsHTMLDocument::GetSourceDocumentURL(JSContext* cx,
// could break if any of the connections along the way change.
// I wish there were a better way.
nsresult result = NS_OK;
*sourceURL = nsnull;
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
if (nsnull != context) {
@ -1438,14 +1440,14 @@ nsHTMLDocument::GetSourceDocumentURL(JSContext* cx,
global = dont_AddRef(context->GetGlobalObject());
if (global) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(global));
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(global, &result));
if (window) {
nsCOMPtr<nsIDOMDocument> document;
result = window->GetDocument(getter_AddRefs(document));
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(document));
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(document, &result));
if (htmlDocument) {
nsAutoString url;

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

@ -1431,6 +1431,8 @@ nsHTMLDocument::GetSourceDocumentURL(JSContext* cx,
// could break if any of the connections along the way change.
// I wish there were a better way.
nsresult result = NS_OK;
*sourceURL = nsnull;
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
if (nsnull != context) {
@ -1438,14 +1440,14 @@ nsHTMLDocument::GetSourceDocumentURL(JSContext* cx,
global = dont_AddRef(context->GetGlobalObject());
if (global) {
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(global));
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(global, &result));
if (window) {
nsCOMPtr<nsIDOMDocument> document;
result = window->GetDocument(getter_AddRefs(document));
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(document));
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(document, &result));
if (htmlDocument) {
nsAutoString url;