diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index 01ff2564849..4ad8b4540ea 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -62,6 +62,7 @@ #include "nsIDOMElement.h" #include "nsIDOMText.h" #include "nsIBaseWindow.h" +#include "nsIDOMWindow.h" #include "nsIDOMCDATASection.h" #include "nsIDOMProcessingInstruction.h" #include "nsIDOMDocumentType.h" @@ -376,6 +377,30 @@ nsXMLDocument::EvaluateXPointer(const nsAString& aExpression, return nsXPointer::Evaluate(this, aExpression, aResult); } +nsresult +nsXMLDocument::GetLoadGroup(nsILoadGroup **aLoadGroup) +{ + NS_ENSURE_ARG_POINTER(aLoadGroup); + *aLoadGroup = nsnull; + + if (mScriptContext) { + nsCOMPtr global; + mScriptContext->GetGlobalObject(getter_AddRefs(global)); + nsCOMPtr window = do_QueryInterface(global); + if (window) { + nsCOMPtr domdoc; + window->GetDocument(getter_AddRefs(domdoc)); + nsCOMPtr doc = do_QueryInterface(domdoc); + if (doc) { + doc->GetDocumentLoadGroup(aLoadGroup); + } + } + } + + return NS_OK; +} + + NS_IMETHODIMP nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) { @@ -440,7 +465,16 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) mCrossSiteAccessEnabled = crossSiteAccessEnabled; // Create a channel - rv = NS_NewChannel(getter_AddRefs(channel), uri, nsnull, nsnull, this); + // When we are called from JS we can find the load group for the page, + // and add ourselves to it. This way any pending requests + // will be automatically aborted if the user leaves the page. + nsCOMPtr loadGroup; + GetLoadGroup(getter_AddRefs(loadGroup)); + + // nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, + // which in turn keeps STOP button from becoming active + rv = NS_NewChannel(getter_AddRefs(channel), uri, nsnull, loadGroup, this, + nsIRequest::LOAD_BACKGROUND); if (NS_FAILED(rv)) return rv; // Set a principal for this document @@ -471,7 +505,7 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) // Prepare for loading the XML document "into oneself" nsCOMPtr listener; if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel, - nsnull, nsnull, + loadGroup, nsnull, getter_AddRefs(listener), PR_FALSE))) { NS_ERROR("nsXMLDocument::Load: Failed to start the document load."); diff --git a/mozilla/content/xml/document/src/nsXMLDocument.h b/mozilla/content/xml/document/src/nsXMLDocument.h index b159014fe1d..72241eefc73 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.h +++ b/mozilla/content/xml/document/src/nsXMLDocument.h @@ -147,6 +147,8 @@ protected: virtual PRInt32 InternalGetNumberOfStyleSheets(); nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult); + + virtual nsresult GetLoadGroup(nsILoadGroup **aLoadGroup); // For HTML elements in our content model // XXX This is not clean, but is there a better way? diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index beb7a5bdf53..83393be9b8f 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -1969,8 +1969,6 @@ nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { { mParserContext->SetMimeType(contentType); } - else - NS_NOTREACHED("parser needs a content type to find a dtd"); #ifdef rickgdebug gOutFile= new fstream("c:/temp/out.file",ios::trunc); diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index beb7a5bdf53..83393be9b8f 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -1969,8 +1969,6 @@ nsresult nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext) { { mParserContext->SetMimeType(contentType); } - else - NS_NOTREACHED("parser needs a content type to find a dtd"); #ifdef rickgdebug gOutFile= new fstream("c:/temp/out.file",ios::trunc);