Skip to content

Commit

Permalink
Adding the ablity to disable view source. r=bz,sr=darin,b=199335
Browse files Browse the repository at this point in the history
  • Loading branch information
dougt%meer.net committed Jul 30, 2003
1 parent d1105ed commit 0a33548
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 20 deletions.
1 change: 1 addition & 0 deletions config/autoconf.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ ENABLE_TESTS = @ENABLE_TESTS@
IBMBIDI = @IBMBIDI@
SUNCTL = @SUNCTL@
ACCESSIBILITY = @ACCESSIBILITY@
MOZ_VIEW_SOURCE = @MOZ_VIEW_SOURCE@
MOZ_XPINSTALL = @MOZ_XPINSTALL@
MOZ_JSLOADER = @MOZ_JSLOADER@
MOZ_USE_NATIVE_UCONV = @MOZ_USE_NATIVE_UCONV@
Expand Down
14 changes: 14 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,19 @@ MOZ_ARG_ENABLE_BOOL(ctl,
SUNCTL=1,
SUNCTL= )

dnl ========================================================
dnl view source support on by default
dnl ========================================================
MOZ_VIEW_SOURCE=1
MOZ_ARG_DISABLE_BOOL(view-source,
[ --disable-view-source Disable view source support],
MOZ_VIEW_SOURCE=,
MOZ_VIEW_SOURCE=1 )
if test "$MOZ_VIEW_SOURCE"; then
AC_DEFINE(MOZ_VIEW_SOURCE)
fi


dnl ========================================================
dnl accessibility support on by default
dnl ========================================================
Expand Down Expand Up @@ -5065,6 +5078,7 @@ AC_SUBST(IBMBIDI)
AC_SUBST(SUNCTL)
AC_SUBST(ACCESSIBILITY)
AC_SUBST(MOZ_XPINSTALL)
AC_SUBST(MOZ_VIEW_SOURCE)
AC_SUBST(MOZ_SINGLE_PROFILE)
AC_SUBST(MOZ_XPFE_COMPONENTS)
AC_SUBST(MOZ_USER_DIR)
Expand Down
1 change: 0 additions & 1 deletion htmlparser/src/CNavDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#include "nsDTDUtils.h"
#include "nsHTMLTokenizer.h"
#include "nsTime.h"
#include "nsViewSourceHTML.h"
#include "nsParserNode.h"
#include "nsHTMLEntities.h"
#include "nsLinebreakConverter.h"
Expand Down
4 changes: 1 addition & 3 deletions htmlparser/src/COtherDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@
#include "nsDTDUtils.h"
#include "nsHTMLTokenizer.h"
#include "nsTime.h"
#include "nsViewSourceHTML.h"
#include "nsParserNode.h"
#include "nsHTMLEntities.h"
#include "nsLinebreakConverter.h"
#include "nsUnicharUtils.h"

#include "prmem.h"


static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
Expand Down Expand Up @@ -299,7 +297,7 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
}
}
}
}
}
return result;
}

Expand Down
8 changes: 6 additions & 2 deletions htmlparser/src/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -74,10 +73,15 @@ CPPSRCS = \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsViewSourceHTML.cpp\
nsParserMsgUtils.cpp\
$(NULL)

ifdef MOZ_VIEW_SOURCE
CPPSRCS += \
nsViewSourceHTML.cpp \
$(NULL)
endif

ifdef MOZ_DEBUG
CPPSRCS += \
nsLoggingSink.cpp \
Expand Down
7 changes: 6 additions & 1 deletion htmlparser/src/nsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "nsCRT.h"
#include "nsScanner.h"
#include "plstr.h"
#include "nsViewSourceHTML.h"
#include "nsIStringStream.h"
#include "nsIChannel.h"
#include "nsICachingChannel.h"
Expand All @@ -67,6 +66,10 @@
#include "nsIServiceManager.h"
//#define rickgdebug

#ifdef MOZ_VIEW_SOURCE
#include "nsViewSourceHTML.h"
#endif

#define NS_PARSER_FLAG_DTD_VERIFICATION 0x00000001
#define NS_PARSER_FLAG_PARSER_ENABLED 0x00000002
#define NS_PARSER_FLAG_OBSERVERS_ENABLED 0x00000004
Expand Down Expand Up @@ -1154,13 +1157,15 @@ FindSuitableDTD(CParserContext& aParserContext,
sharedObjects->mDTDDeque.Push(theDTD);
sharedObjects->mHasXMLDTD = PR_TRUE;
}
#ifdef MOZ_VIEW_SOURCE
else if (!sharedObjects->mHasViewSourceDTD) {
rv = NS_NewViewSourceHTML(&theDTD); //do this so all non-html files can be viewed...
NS_ENSURE_SUCCESS(rv, rv);

sharedObjects->mDTDDeque.Push(theDTD);
sharedObjects->mHasViewSourceDTD = PR_TRUE;
}
#endif
}
}

Expand Down
12 changes: 10 additions & 2 deletions htmlparser/src/nsParserModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
#include "nsParser.h"
#include "CNavDTD.h"
#include "COtherDTD.h"
#include "nsViewSourceHTML.h"
#include "nsHTMLEntities.h"
#include "nsHTMLTokenizer.h"
//#include "nsTextTokenizer.h"
#include "nsElementTable.h"
#include "nsParserService.h"

#ifdef MOZ_VIEW_SOURCE
#include "nsViewSourceHTML.h"
#endif

#ifdef NS_DEBUG
#include "nsLoggingSink.h"
#include "nsExpatDriver.h"
Expand All @@ -69,9 +72,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsExpatDriver)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CTransitionalDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)

#ifdef MOZ_VIEW_SOURCE
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
#endif

static const nsModuleComponentInfo gComponents[] = {

#ifdef NS_DEBUG
Expand All @@ -83,7 +89,9 @@ static const nsModuleComponentInfo gComponents[] = {
{ "Navigator HTML DTD", NS_CNAVDTD_CID, NULL, CNavDTDConstructor },
{ "Transitional DTD", NS_CTRANSITIONAL_DTD_CID, NULL,
CTransitionalDTDConstructor },
#ifdef MOZ_VIEW_SOURCE
{ "ViewSource DTD", NS_VIEWSOURCE_DTD_CID, NULL, CViewSourceHTMLConstructor },
#endif
{ "ParserService",
NS_PARSERSERVICE_CID,
NS_PARSER_CONTRACTID_PREFIX "/parser-service;1",
Expand Down
6 changes: 4 additions & 2 deletions layout/build/nsContentDLF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ static const char* const gHTMLTypes[] = {
"text/css",
"text/javascript",
"application/x-javascript",
#ifdef MOZ_VIEW_SOURCE
"application/x-view-source", //XXX I wish I could just use nsMimeTypes.h here
#endif
"application/xhtml+xml",
0
};
Expand Down Expand Up @@ -162,7 +164,7 @@ nsContentDLF::CreateInstance(const char* aCommand,
EnsureUAStyleSheet();

// Are we viewing source?

#ifdef MOZ_VIEW_SOURCE
nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel);
if (viewSourceChannel)
{
Expand Down Expand Up @@ -212,7 +214,7 @@ nsContentDLF::CreateInstance(const char* aCommand,
aChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
aContentType = "text/plain";
}

#endif
// Try html
int typeIndex=0;
while(gHTMLTypes[typeIndex]) {
Expand Down
1 change: 0 additions & 1 deletion parser/htmlparser/src/CNavDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#include "nsDTDUtils.h"
#include "nsHTMLTokenizer.h"
#include "nsTime.h"
#include "nsViewSourceHTML.h"
#include "nsParserNode.h"
#include "nsHTMLEntities.h"
#include "nsLinebreakConverter.h"
Expand Down
4 changes: 1 addition & 3 deletions parser/htmlparser/src/COtherDTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@
#include "nsDTDUtils.h"
#include "nsHTMLTokenizer.h"
#include "nsTime.h"
#include "nsViewSourceHTML.h"
#include "nsParserNode.h"
#include "nsHTMLEntities.h"
#include "nsLinebreakConverter.h"
#include "nsUnicharUtils.h"

#include "prmem.h"


static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
Expand Down Expand Up @@ -299,7 +297,7 @@ COtherDTD::CanParse(CParserContext& aParserContext, const nsString& aBuffer,
}
}
}
}
}
return result;
}

Expand Down
8 changes: 6 additions & 2 deletions parser/htmlparser/src/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -74,10 +73,15 @@ CPPSRCS = \
nsParserNode.cpp \
nsScanner.cpp \
nsToken.cpp \
nsViewSourceHTML.cpp\
nsParserMsgUtils.cpp\
$(NULL)

ifdef MOZ_VIEW_SOURCE
CPPSRCS += \
nsViewSourceHTML.cpp \
$(NULL)
endif

ifdef MOZ_DEBUG
CPPSRCS += \
nsLoggingSink.cpp \
Expand Down
7 changes: 6 additions & 1 deletion parser/htmlparser/src/nsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "nsCRT.h"
#include "nsScanner.h"
#include "plstr.h"
#include "nsViewSourceHTML.h"
#include "nsIStringStream.h"
#include "nsIChannel.h"
#include "nsICachingChannel.h"
Expand All @@ -67,6 +66,10 @@
#include "nsIServiceManager.h"
//#define rickgdebug

#ifdef MOZ_VIEW_SOURCE
#include "nsViewSourceHTML.h"
#endif

#define NS_PARSER_FLAG_DTD_VERIFICATION 0x00000001
#define NS_PARSER_FLAG_PARSER_ENABLED 0x00000002
#define NS_PARSER_FLAG_OBSERVERS_ENABLED 0x00000004
Expand Down Expand Up @@ -1154,13 +1157,15 @@ FindSuitableDTD(CParserContext& aParserContext,
sharedObjects->mDTDDeque.Push(theDTD);
sharedObjects->mHasXMLDTD = PR_TRUE;
}
#ifdef MOZ_VIEW_SOURCE
else if (!sharedObjects->mHasViewSourceDTD) {
rv = NS_NewViewSourceHTML(&theDTD); //do this so all non-html files can be viewed...
NS_ENSURE_SUCCESS(rv, rv);

sharedObjects->mDTDDeque.Push(theDTD);
sharedObjects->mHasViewSourceDTD = PR_TRUE;
}
#endif
}
}

Expand Down
12 changes: 10 additions & 2 deletions parser/htmlparser/src/nsParserModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
#include "nsParser.h"
#include "CNavDTD.h"
#include "COtherDTD.h"
#include "nsViewSourceHTML.h"
#include "nsHTMLEntities.h"
#include "nsHTMLTokenizer.h"
//#include "nsTextTokenizer.h"
#include "nsElementTable.h"
#include "nsParserService.h"

#ifdef MOZ_VIEW_SOURCE
#include "nsViewSourceHTML.h"
#endif

#ifdef NS_DEBUG
#include "nsLoggingSink.h"
#include "nsExpatDriver.h"
Expand All @@ -69,9 +72,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsExpatDriver)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CTransitionalDTD)
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)

#ifdef MOZ_VIEW_SOURCE
NS_GENERIC_FACTORY_CONSTRUCTOR(CViewSourceHTML)
#endif

static const nsModuleComponentInfo gComponents[] = {

#ifdef NS_DEBUG
Expand All @@ -83,7 +89,9 @@ static const nsModuleComponentInfo gComponents[] = {
{ "Navigator HTML DTD", NS_CNAVDTD_CID, NULL, CNavDTDConstructor },
{ "Transitional DTD", NS_CTRANSITIONAL_DTD_CID, NULL,
CTransitionalDTDConstructor },
#ifdef MOZ_VIEW_SOURCE
{ "ViewSource DTD", NS_VIEWSOURCE_DTD_CID, NULL, CViewSourceHTMLConstructor },
#endif
{ "ParserService",
NS_PARSERSERVICE_CID,
NS_PARSER_CONTRACTID_PREFIX "/parser-service;1",
Expand Down

0 comments on commit 0a33548

Please sign in to comment.