Bug 651072 - Support HTML parsing in XMLHttpRequest. r=smaug.

This commit is contained in:
Henri Sivonen
2011-11-16 09:38:51 +02:00
parent 8c00f0b7d1
commit 0d3eb749d1
23 changed files with 399 additions and 60 deletions

View File

@@ -699,7 +699,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
// TODO: Proper about:blank treatment is bug 543435
if (loadAsHtml5 && !viewSource) {
if (loadAsHtml5 && aCommand && !nsCRT::strcmp(aCommand, "view")) {
// mDocumentURI hasn't been set, yet, so get the URI from the channel
nsCOMPtr<nsIURI> uri;
aChannel->GetOriginalURI(getter_AddRefs(uri));
@@ -771,9 +771,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// and parentContentViewer
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
// No support yet for docshell-less HTML
NS_ENSURE_TRUE(docShell || !IsHTML(), NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
@@ -810,9 +807,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
}
nsCAutoString scheme;
uri->GetScheme(scheme);
nsCAutoString urlSpec;
uri->GetSpec(urlSpec);
#ifdef DEBUG_charset
@@ -830,8 +824,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
if (!IsHTML()) {
charsetSource = kCharsetFromDocTypeDefault;
if (!IsHTML() || !docShell) { // no docshell for text/html XHR
charsetSource = IsHTML() ? kCharsetFromWeakDocTypeDefault
: kCharsetFromDocTypeDefault;
charset.AssignLiteral("UTF-8");
TryChannelCharset(aChannel, charsetSource, charset);
parserCharsetSource = charsetSource;
@@ -946,6 +941,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
"not nsICachingChannel");
rv = cachingChan->SetCacheTokenCachedCharset(charset);
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "cannot SetMetaDataElement");
rv = NS_OK; // don't propagate error
}
// Set the parser as the stream listener for the document loader...