mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Not all documents have a channel, so we need to synthesize one as needed. Bug
322683, r=sicking, sr=bryner
This commit is contained in:
parent
aef4030125
commit
3c68eefc06
@ -207,6 +207,7 @@ void
|
||||
URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
|
||||
{
|
||||
if (!aSourceNode) {
|
||||
// XXXbz passing nsnull as the first arg to Reset is illegal
|
||||
aNewDoc->Reset(nsnull, nsnull);
|
||||
return;
|
||||
}
|
||||
@ -219,13 +220,31 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
|
||||
}
|
||||
if (!sourceDoc) {
|
||||
NS_ASSERTION(0, "no source document found");
|
||||
// XXXbz passing nsnull as the first arg to Reset is illegal
|
||||
aNewDoc->Reset(nsnull, nsnull);
|
||||
return;
|
||||
}
|
||||
|
||||
nsIPrincipal* sourcePrincipal = sourceDoc->GetPrincipal();
|
||||
if (!sourcePrincipal) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy the channel and loadgroup from the source document.
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = sourceDoc->GetDocumentLoadGroup();
|
||||
aNewDoc->Reset(sourceDoc->GetChannel(), loadGroup);
|
||||
nsCOMPtr<nsIChannel> channel = sourceDoc->GetChannel();
|
||||
if (!channel) {
|
||||
// Need to synthesize one
|
||||
if (NS_FAILED(NS_NewChannel(getter_AddRefs(channel),
|
||||
sourceDoc->GetDocumentURI(),
|
||||
nsnull,
|
||||
loadGroup))) {
|
||||
return;
|
||||
}
|
||||
channel->SetOwner(sourcePrincipal);
|
||||
}
|
||||
aNewDoc->Reset(channel, loadGroup);
|
||||
aNewDoc->SetPrincipal(sourcePrincipal);
|
||||
aNewDoc->SetBaseURI(sourceDoc->GetBaseURI());
|
||||
|
||||
// Copy charset
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
static NS_DEFINE_CID(kXMLDocumentCID, NS_XMLDOCUMENT_CID);
|
||||
|
||||
@ -173,9 +174,26 @@ void txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
|
||||
|
||||
// Reset and set up document
|
||||
nsCOMPtr<nsIDocument> sourceDoc = do_QueryInterface(aSourceDocument);
|
||||
nsIPrincipal* sourcePrincipal = sourceDoc->GetPrincipal();
|
||||
if (!sourcePrincipal) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = sourceDoc->GetDocumentLoadGroup();
|
||||
nsCOMPtr<nsIChannel> channel = sourceDoc->GetChannel();
|
||||
if (!channel) {
|
||||
// Need to synthesize one
|
||||
if (NS_FAILED(NS_NewChannel(getter_AddRefs(channel),
|
||||
sourceDoc->GetDocumentURI(),
|
||||
nsnull,
|
||||
loadGroup))) {
|
||||
return;
|
||||
}
|
||||
channel->SetOwner(sourcePrincipal);
|
||||
}
|
||||
// Copy the channel and loadgroup from the source document.
|
||||
doc->Reset(sourceDoc->GetChannel(), loadGroup);
|
||||
doc->Reset(channel, loadGroup);
|
||||
doc->SetPrincipal(sourcePrincipal);
|
||||
doc->SetBaseURI(sourceDoc->GetBaseURI());
|
||||
|
||||
// Set the charset
|
||||
|
Loading…
Reference in New Issue
Block a user