diff --git a/parser/html/nsHtml5Parser.cpp b/parser/html/nsHtml5Parser.cpp
index b647d26fef1..0d7cc206c86 100644
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -12,7 +12,7 @@
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5AtomTable.h"
#include "nsHtml5DependentUTF16Buffer.h"
-#include "nsIInputStreamChannel.h"
+#include "nsNetUtil.h"
NS_INTERFACE_TABLE_HEAD(nsHtml5Parser)
NS_INTERFACE_TABLE2(nsHtml5Parser, nsIParser, nsISupportsWeakReference)
@@ -218,7 +218,13 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
mExecutor->SetParser(this);
mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled());
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+ bool isSrcdoc = false;
+ nsCOMPtr channel;
+ rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTokenizer->start();
mExecutor->Start();
@@ -682,7 +688,13 @@ nsHtml5Parser::Initialize(nsIDocument* aDoc,
void
nsHtml5Parser::StartTokenizer(bool aScriptingEnabled) {
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+ bool isSrcdoc = false;
+ nsCOMPtr channel;
+ nsresult rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTreeBuilder->SetPreventScriptExecution(!aScriptingEnabled);
mTreeBuilder->setScriptingEnabled(aScriptingEnabled);
@@ -708,20 +720,3 @@ nsHtml5Parser::ContinueAfterFailedCharsetSwitch()
mStreamParser->ContinueAfterFailedCharsetSwitch();
}
-bool
-nsHtml5Parser::IsSrcdocDocument()
-{
- nsresult rv;
-
- bool isSrcdoc = false;
- nsCOMPtr channel;
- rv = GetChannel(getter_AddRefs(channel));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr isr = do_QueryInterface(channel);
- if (isr) {
- isr->GetIsSrcdocChannel(&isSrcdoc);
- }
- }
- return isSrcdoc;
-}
-
diff --git a/parser/html/nsHtml5Parser.h b/parser/html/nsHtml5Parser.h
index 5d4d30e2a51..a46448e33ca 100644
--- a/parser/html/nsHtml5Parser.h
+++ b/parser/html/nsHtml5Parser.h
@@ -258,8 +258,6 @@ class nsHtml5Parser : public nsIParser,
*/
void ParseUntilBlocked();
- bool IsSrcdocDocument();
-
private:
// State variables
diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp
index cdac25546e5..f6af085ee58 100644
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -26,9 +26,9 @@
#include "nsINestedURI.h"
#include "nsCharsetSource.h"
#include "nsIWyciwygChannel.h"
-#include "nsIInputStreamChannel.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsPrintfCString.h"
+#include "nsNetUtil.h"
#include "mozilla/dom/EncodingUtils.h"
@@ -877,7 +877,14 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
bool scriptingEnabled = mMode == LOAD_AS_DATA ?
false : mExecutor->IsScriptEnabled();
mOwner->StartTokenizer(scriptingEnabled);
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+
+ bool isSrcdoc = false;
+ nsCOMPtr channel;
+ nsresult rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTreeBuilder->setScriptingEnabled(scriptingEnabled);
mTreeBuilder->SetPreventScriptExecution(!((mMode == NORMAL) &&
scriptingEnabled));
@@ -913,7 +920,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
NS_ASSERTION(!mLastBuffer, "How come we have the last buffer set?");
mFirstBuffer = mLastBuffer = newBuf;
- nsresult rv = NS_OK;
+ rv = NS_OK;
// The line below means that the encoding can end up being wrong if
// a view-source URL is loaded without having the encoding hint from a
@@ -1672,20 +1679,3 @@ nsHtml5StreamParser::MarkAsBroken()
NS_WARNING("failed to dispatch executor flush event");
}
}
-
-bool
-nsHtml5StreamParser::IsSrcdocDocument()
-{
- nsresult rv;
-
- bool isSrcdoc = false;
- nsCOMPtr channel;
- rv = GetChannel(getter_AddRefs(channel));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr isr = do_QueryInterface(channel);
- if (isr) {
- isr->GetIsSrcdocChannel(&isSrcdoc);
- }
- }
- return isSrcdoc;
-}
diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h
index 21f4726859a..8ac3f638e6e 100644
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -202,8 +202,6 @@ class nsHtml5StreamParser : public nsIStreamListener,
*/
void SetViewSourceTitle(nsIURI* aURL);
- bool IsSrcdocDocument();
-
private:
#ifdef DEBUG