Bug 482921 part 5 - Add entry point for new View Source for XML; Make new View Source easy to disable. r=Olli.Pettay.

This commit is contained in:
Henri Sivonen 2011-11-01 13:33:11 +02:00
Родитель 2de2833898
Коммит 088b02553b
2 изменённых файлов: 15 добавлений и 11 удалений

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

@ -161,6 +161,8 @@ const PRInt32 kBackward = 1;
//#define DEBUG_charset
#define NS_USE_NEW_VIEW_SOURCE 1
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
PRUint32 nsHTMLDocument::gWyciwygSessionCnt = 0;
@ -650,7 +652,10 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
bool aReset,
nsIContentSink* aSink)
{
bool loadAsHtml5 = nsHtml5Module::sEnabled;
bool viewSource = aCommand && !nsCRT::strcmp(aCommand, "view-source") &&
NS_USE_NEW_VIEW_SOURCE;
bool loadAsHtml5 = nsHtml5Module::sEnabled || viewSource;
if (aSink) {
loadAsHtml5 = false;
}
@ -658,8 +663,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCAutoString contentType;
aChannel->GetContentType(contentType);
if (contentType.Equals("application/xhtml+xml") &&
(!aCommand || nsCRT::strcmp(aCommand, "view-source") != 0)) {
if (contentType.Equals("application/xhtml+xml") && !viewSource) {
// We're parsing XHTML as XML, remember that.
mIsRegularHTML = false;
@ -673,16 +677,13 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
#endif
if (loadAsHtml5 &&
!(contentType.EqualsLiteral("text/html") &&
aCommand &&
(!nsCRT::strcmp(aCommand, "view") ||
!nsCRT::strcmp(aCommand, "view-source")))) {
if (loadAsHtml5 && !viewSource && !(contentType.EqualsLiteral("text/html") &&
aCommand && !nsCRT::strcmp(aCommand, "view"))) {
loadAsHtml5 = false;
}
// TODO: Proper about:blank treatment is bug 543435
if (loadAsHtml5) {
if (loadAsHtml5 && !viewSource) {
// mDocumentURI hasn't been set, yet, so get the URI from the channel
nsCOMPtr<nsIURI> uri;
aChannel->GetOriginalURI(getter_AddRefs(uri));
@ -730,7 +731,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
if (needsParser) {
if (loadAsHtml5) {
mParser = nsHtml5Module::NewHtml5Parser();
mParser->MarkAsNotScriptCreated(aCommand);
mParser->MarkAsNotScriptCreated((viewSource &&
!contentType.EqualsLiteral("text/html")) ?
"view-source-xml": aCommand);
} else {
mParser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -705,7 +705,8 @@ nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
eParserMode mode = NORMAL;
if (!nsCRT::strcmp(aCommand, "view-source")) {
mode = VIEW_SOURCE_HTML;
// XXX XML view source not implemented yet
} else if (!nsCRT::strcmp(aCommand, "view-source-xml")) {
mode = VIEW_SOURCE_XML;
}
#ifdef DEBUG
else {