mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Converted parser into a module. NS_NewFoo routines are temporarily inlined to call component manager. Introduced nsIParserService for temporary replacement of nsHTMLTags and nsHTMLEntities static methods. RickG to do complete review.
This commit is contained in:
parent
004521b2e6
commit
0ac77d091f
@ -37,6 +37,7 @@
|
||||
#include "nsIElementObserver.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <direct.h> //this is here for debug reasons...
|
||||
@ -208,26 +209,6 @@ nsresult CNavDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is defined in nsIParser. It is used to
|
||||
* cause the COM-like construction of an nsParser.
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param nsIParser** ptr to newly instantiated parser
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
CNavDTD* it = new CNavDTD();
|
||||
|
||||
if (it == 0) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kClassIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(CNavDTD)
|
||||
NS_IMPL_RELEASE(CNavDTD)
|
||||
|
||||
@ -1827,6 +1808,18 @@ NS_IMETHODIMP CNavDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CNavDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aIntTag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CNavDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the necessary intermediate tags should be propagated
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
@ -395,6 +395,9 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* The following set of methods are used to partially construct
|
||||
@ -527,7 +530,14 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
inline nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
||||
return nsComponentManager::CreateInstance(kNavDTDCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDTD),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -315,6 +315,16 @@ NS_IMETHODIMP COtherDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) con
|
||||
return CNavDTD::StringTagToIntTag(aTag, aIntTag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP COtherDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return CNavDTD::IntTagToStringTag(aIntTag, aTag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP COtherDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return CNavDTD::ConvertEntityToUnicode(aEntity, aUnicode);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
|
@ -127,6 +127,10 @@ class COtherDTD : public CNavDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag)const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
|
@ -377,6 +377,16 @@ NS_IMETHODIMP CRtfDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CRtfDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CRtfDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
|
@ -356,6 +356,10 @@ class CRtfDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -29,3 +29,4 @@ nsExpatDTD.h
|
||||
nsIExpatTokenizer.h
|
||||
nsParserError.h
|
||||
nsIElementObserver.h
|
||||
nsIParserService.h
|
||||
|
@ -24,6 +24,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = htmlparser
|
||||
LIBRARY_NAME = raptorhtmlpars
|
||||
IS_COMPONENT = 1
|
||||
|
||||
REQUIRES = xpcom netlib raptor
|
||||
|
||||
@ -43,7 +44,7 @@ CPPSRCS = \
|
||||
nsLoggingSink.cpp \
|
||||
nsParser.cpp \
|
||||
CParserContext.cpp \
|
||||
nsParserFactory.cpp \
|
||||
nsParserModule.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
@ -98,6 +99,7 @@ EXPORTS = \
|
||||
nsExpatDTD.h \
|
||||
nsParserError.h \
|
||||
nsIElementObserver.h \
|
||||
nsIParserService.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
@ -28,6 +28,7 @@ DEFINES = $(DEFINES) -DRAPTOR_PERF_METRICS
|
||||
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor netlib
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS= \
|
||||
nsDTDUtils.cpp \
|
||||
@ -46,7 +47,6 @@ CPPSRCS= \
|
||||
nsLoggingSink.cpp \
|
||||
nsParser.cpp \
|
||||
CParserContext.cpp \
|
||||
nsParserFactory.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
@ -59,6 +59,7 @@ CPPSRCS= \
|
||||
nsXIFDTD.cpp \
|
||||
nsExpatDTD.cpp \
|
||||
prstrm.cpp \
|
||||
nsParserModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
@ -78,7 +79,6 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsLoggingSink.obj \
|
||||
.\$(OBJDIR)\nsParser.obj \
|
||||
.\$(OBJDIR)\CParserContext.obj \
|
||||
.\$(OBJDIR)\nsParserFactory.obj \
|
||||
.\$(OBJDIR)\nsParserNode.obj \
|
||||
.\$(OBJDIR)\nsScanner.obj \
|
||||
.\$(OBJDIR)\nsToken.obj \
|
||||
@ -91,6 +91,7 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXIFDTD.obj \
|
||||
.\$(OBJDIR)\nsExpatDTD.obj \
|
||||
.\$(OBJDIR)\prstrm.obj \
|
||||
.\$(OBJDIR)\nsParserModule.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
@ -125,6 +126,7 @@ EXPORTS= \
|
||||
nsParserCIID.h \
|
||||
nsParserError.h \
|
||||
nsIElementObserver.h \
|
||||
nsIParserService.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@ -170,7 +172,7 @@ include <$(DEPTH)\config\rules.mak>
|
||||
# $(MAKE_INSTALL) $(XPDIST)\include
|
||||
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsExpatTokenizer.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "prtypes.h" //this is here for debug reasons...
|
||||
@ -405,6 +406,18 @@ NS_IMETHODIMP nsExpatDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) co
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExpatDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExpatDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
// XXX Needed since the XML content sink reduces entities as well
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -231,6 +231,10 @@ class nsExpatDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* Retrieve a ptr to the global token recycler...
|
||||
* @update gess8/4/98
|
||||
|
@ -48,6 +48,7 @@
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentSinkStreamIID, NS_IHTMLCONTENTSINKSTREAM_IID);
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
@ -228,6 +229,9 @@ nsHTMLContentSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
else if(aIID.Equals(kIHTMLContentSinkIID)) {
|
||||
*aInstancePtr = (nsIHTMLContentSink*)(this);
|
||||
}
|
||||
else if(aIID.Equals(kIHTMLContentSinkStreamIID)) {
|
||||
*aInstancePtr = (nsIHTMLContentSinkStream*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
@ -241,55 +245,6 @@ NS_IMPL_ADDREF(nsHTMLContentSinkStream)
|
||||
NS_IMPL_RELEASE(nsHTMLContentSinkStream)
|
||||
|
||||
|
||||
/**
|
||||
* Create an new sink
|
||||
*
|
||||
* @update gpk 05/01/99
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsHTMLContentSinkStream* it = new nsHTMLContentSinkStream(aOutStream,
|
||||
nsnull,
|
||||
aCharsetOverride,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kIHTMLContentSinkIID, (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an new sink
|
||||
*
|
||||
* @update gpk 05/01/99
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsHTMLContentSinkStream* it = new nsHTMLContentSinkStream(nsnull,
|
||||
aOutString,
|
||||
nsnull,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kIHTMLContentSinkIID, (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inits the encoder instance variable for the sink based on the charset
|
||||
*
|
||||
@ -346,10 +301,7 @@ nsresult nsHTMLContentSinkStream::InitEncoder(const nsString& aCharset)
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
nsHTMLContentSinkStream::nsHTMLContentSinkStream()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mLowerCaseTags = PR_TRUE;
|
||||
@ -357,6 +309,18 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
mHTMLStackPos = 0;
|
||||
mColPos = 0;
|
||||
mIndent = 0;
|
||||
mBuffer = nsnull;
|
||||
mBufferSize = 0;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mInBody = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
mDoFormat = (aFlags & nsIDocumentEncoder::OutputFormatted) ? PR_TRUE
|
||||
: PR_FALSE;
|
||||
mBodyOnly = (aFlags & nsIDocumentEncoder::OutputBodyOnly) ? PR_TRUE
|
||||
@ -364,16 +328,13 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
mDoHeader = (!mBodyOnly) && (mDoFormat) &&
|
||||
((aFlags & nsIDocumentEncoder::OutputNoDoctype) ? PR_FALSE
|
||||
: PR_TRUE);
|
||||
mBuffer = nsnull;
|
||||
mBufferSize = 0;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
mInBody = PR_FALSE;
|
||||
if (aCharsetOverride != nsnull)
|
||||
mCharsetOverride = *aCharsetOverride;
|
||||
}
|
||||
mCharsetOverride = *aCharsetOverride;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tells the sink whether or not it is
|
||||
|
@ -43,9 +43,10 @@
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define NS_HTMLCONTENTSINK_STREAM_IID \
|
||||
#define NS_IHTMLCONTENTSINKSTREAM_IID \
|
||||
{0xa39c6bff, 0x15f0, 0x11d2, \
|
||||
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
|
||||
|
||||
@ -56,7 +57,19 @@ class ostream;
|
||||
class nsIUnicodeEncoder;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
class nsIHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENTSINKSTREAM_IID)
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLCONTENTSINKSTREAM_CID)
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags) = 0;
|
||||
};
|
||||
|
||||
class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@ -67,10 +80,7 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
* @param aOutStream -- stream where you want output sent
|
||||
* @param aOutStream -- ref to string where you want output sent
|
||||
*/
|
||||
nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
nsHTMLContentSinkStream();
|
||||
|
||||
/**
|
||||
* virtual destructor
|
||||
@ -80,6 +90,13 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIHTMLContentSinkStream
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* The following methods are inherited from nsIContentSink.
|
||||
@ -170,15 +187,59 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
inline nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContentSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLContentSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(aOutStream,
|
||||
nsnull,
|
||||
aCharsetOverride,
|
||||
aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString, PRUint32 aFlags);
|
||||
nsString* aOutString, PRUint32 aFlags)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContentSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLContentSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(nsnull,
|
||||
aOutString,
|
||||
nsnull,
|
||||
aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -133,6 +133,9 @@ nsHTMLToTXTSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
else if(aIID.Equals(NS_GET_IID(nsIHTMLContentSink))) {
|
||||
*aInstancePtr = (nsIHTMLContentSink*)(this);
|
||||
}
|
||||
else if(aIID.Equals(NS_GET_IID(nsIHTMLToTXTSinkStream))) {
|
||||
*aInstancePtr = (nsIHTMLToTXTSinkStream*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
@ -146,54 +149,6 @@ NS_IMPL_ADDREF(nsHTMLToTXTSinkStream)
|
||||
NS_IMPL_RELEASE(nsHTMLToTXTSinkStream)
|
||||
|
||||
|
||||
/**
|
||||
* This method creates a new sink, it sets the stream used
|
||||
* for the sink to aStream
|
||||
*
|
||||
* @update gpk 04/30/99
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aWrapColumn, PRUint32 aFlags)
|
||||
{
|
||||
NS_ASSERTION(aStream != nsnull, "a valid stream is required");
|
||||
nsHTMLToTXTSinkStream* it = new nsHTMLToTXTSinkStream(aStream, nsnull,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
if (aCharsetOverride != nsnull)
|
||||
it->SetCharsetOverride(aCharsetOverride);
|
||||
return it->QueryInterface(NS_GET_IID(nsIHTMLContentSink), (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method creates a new sink, it sets the stream used
|
||||
* for the sink to aStream
|
||||
*
|
||||
* @update gpk 04/30/99
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aString,
|
||||
PRUint32 aWrapColumn, PRUint32 aFlags)
|
||||
{
|
||||
NS_ASSERTION(aString != nsnull, "a valid stream is required");
|
||||
nsHTMLToTXTSinkStream* it = new nsHTMLToTXTSinkStream(nsnull, aString,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
nsAutoString ucs2("ucs2");
|
||||
it->SetCharsetOverride(&ucs2);
|
||||
return it->QueryInterface(NS_GET_IID(nsIHTMLContentSink), (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
// Someday may want to make this non-const:
|
||||
static const PRUint32 TagStackSize = 500;
|
||||
static const PRUint32 OLStackSize = 100;
|
||||
@ -204,12 +159,9 @@ static const PRUint32 OLStackSize = 100;
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream(nsIOutputStream* aStream,
|
||||
nsString* aString,
|
||||
PRUint32 aFlags)
|
||||
nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mStream = aStream;
|
||||
mColPos = 0;
|
||||
mIndent = 0;
|
||||
mDoOutput = PR_FALSE;
|
||||
@ -217,9 +169,6 @@ nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream(nsIOutputStream* aStream,
|
||||
mBufferLength = 0;
|
||||
mBuffer = nsnull;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mStream = aStream;
|
||||
mString = aString;
|
||||
mFlags = aFlags;
|
||||
mWrapColumn = 72; // XXX magic number, we expect someone to reset this
|
||||
|
||||
// initialize the tag stack to zero:
|
||||
@ -246,6 +195,24 @@ nsHTMLToTXTSinkStream::~nsHTMLToTXTSinkStream()
|
||||
NS_IF_RELEASE(mUnicodeEncoder);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
mFlags = aFlags;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
|
@ -40,8 +40,10 @@
|
||||
#include "nsIHTMLContentSink.h"
|
||||
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_HTMLTOTEXTSINK_STREAM_CID \
|
||||
#define NS_IHTMLTOTEXTSINKSTREAM_IID \
|
||||
{0xa39c6bff, 0x15f0, 0x11d2, \
|
||||
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
|
||||
|
||||
@ -49,7 +51,19 @@
|
||||
class nsIUnicodeEncoder;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
class nsIHTMLToTXTSinkStream : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLTOTEXTSINKSTREAM_IID)
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLTOTXTSINKSTREAM_CID)
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset) = 0;
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWrapCol) = 0;
|
||||
};
|
||||
|
||||
class nsHTMLToTXTSinkStream : public nsIHTMLToTXTSinkStream
|
||||
{
|
||||
public:
|
||||
|
||||
@ -57,8 +71,7 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
* Standard constructor
|
||||
* @update gpk02/03/99
|
||||
*/
|
||||
nsHTMLToTXTSinkStream(nsIOutputStream* aOutStream, nsString* aOutString,
|
||||
PRUint32 aFlags);
|
||||
nsHTMLToTXTSinkStream();
|
||||
|
||||
/**
|
||||
* virtual destructor
|
||||
@ -66,6 +79,10 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
*/
|
||||
virtual ~nsHTMLToTXTSinkStream();
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset);
|
||||
|
||||
|
||||
@ -150,16 +167,62 @@ protected:
|
||||
nsString mCharsetOverride;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
inline nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride=nsnull,
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0);
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLToTXTSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLToTXTSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLToTXTSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(aOutStream, nsnull, aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
if (aCharsetOverride != nsnull) {
|
||||
it->SetCharsetOverride(aCharsetOverride);
|
||||
}
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString,
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0);
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLToTXTSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLToTXTSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLToTXTSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(nsnull, aOutString, aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
nsAutoString ucs2("ucs2");
|
||||
it->SetCharsetOverride(&ucs2);
|
||||
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -220,6 +220,9 @@ class nsIDTD : public nsISupports {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const =0;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const =0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,10 +27,6 @@
|
||||
#define NS_ILOGGING_SINK_IID \
|
||||
{0xa6cf9061, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Class IID for the logging sink
|
||||
#define NS_LOGGING_SINK_IID \
|
||||
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsILoggingSink : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream) =0;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports {
|
||||
class nsIParser : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; }
|
||||
@ -164,6 +164,14 @@ CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports {
|
||||
virtual nsresult CreateTagStack(nsITagStack** aTagStack)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHOD GetDTD(nsIDTD** aDTD) = 0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Parse methods always begin with an input source, and perform conversions
|
||||
* until you wind up being emitted to the given contentsink (which may or may not
|
||||
|
39
htmlparser/src/nsIParserService.h
Normal file
39
htmlparser/src/nsIParserService.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IPARSERSERVICE_IID \
|
||||
{ 0xa6cf9111, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
|
||||
class nsIParserService : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
|
||||
|
||||
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const =0;
|
||||
|
||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const =0;
|
||||
|
||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const =0;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsLoggingSink.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -65,60 +65,6 @@ ostream& operator<<(ostream& os,const nsString& aString) {
|
||||
return os;
|
||||
}
|
||||
|
||||
class nsLoggingSink : public nsILoggingSink {
|
||||
public:
|
||||
nsLoggingSink();
|
||||
virtual ~nsLoggingSink();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel();
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt();
|
||||
NS_IMETHOD WillResume();
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD SetTitle(const nsString& aValue);
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
// nsILoggingSink
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream);
|
||||
|
||||
nsresult OpenNode(const char* aKind, const nsIParserNode& aNode);
|
||||
nsresult CloseNode(const char* aKind);
|
||||
nsresult LeafNode(const nsIParserNode& aNode);
|
||||
nsresult WriteAttributes(const nsIParserNode& aNode);
|
||||
nsresult QuoteText(const nsString& aValue, nsString& aResult);
|
||||
PRBool WillWriteAttributes(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
ostream* mOutput;
|
||||
int mLevel;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLLoggingSink(nsIContentSink** aInstancePtrResult)
|
||||
|
80
htmlparser/src/nsLoggingSink.h
Normal file
80
htmlparser/src/nsLoggingSink.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NS_LOGGING_SINK_H__
|
||||
#define NS_LOGGING_SINK_H__
|
||||
|
||||
#include "nsILoggingSink.h"
|
||||
|
||||
class nsLoggingSink : public nsILoggingSink {
|
||||
public:
|
||||
nsLoggingSink();
|
||||
virtual ~nsLoggingSink();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel();
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt();
|
||||
NS_IMETHOD WillResume();
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD SetTitle(const nsString& aValue);
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
// nsILoggingSink
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream);
|
||||
|
||||
nsresult OpenNode(const char* aKind, const nsIParserNode& aNode);
|
||||
nsresult CloseNode(const char* aKind);
|
||||
nsresult LeafNode(const nsIParserNode& aNode);
|
||||
nsresult WriteAttributes(const nsIParserNode& aNode);
|
||||
nsresult QuoteText(const nsString& aValue, nsString& aResult);
|
||||
PRBool WillWriteAttributes(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
ostream* mOutput;
|
||||
int mLevel;
|
||||
};
|
||||
|
||||
#endif
|
@ -1543,3 +1543,20 @@ nsresult nsParser::CreateTagStack(nsITagStack** aTagStack){
|
||||
return NS_OK;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsParser::GetDTD(nsIDTD** aDTD)
|
||||
{
|
||||
if (mParserContext) {
|
||||
*aDTD = mParserContext->mDTD;
|
||||
NS_IF_ADDREF(mParserContext->mDTD);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -282,6 +282,14 @@ friend class CTokenHandler;
|
||||
*/
|
||||
virtual nsresult CreateTagStack(nsITagStack** aTagStack);
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHOD GetDTD(nsIDTD** aDTD);
|
||||
|
||||
/**
|
||||
* Call this to access observer dictionary ( internal to parser )
|
||||
* @update harishd 06/27/99
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
// XXX Should be _CID and not _IID
|
||||
#define NS_PARSER_IID \
|
||||
{0x2ce606b0, 0xbee6, 0x11d1, \
|
||||
{0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
|
||||
@ -41,4 +42,24 @@
|
||||
#define NS_CNAVDTD_CID \
|
||||
{ 0xa6cf9107, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// Class IID for the logging sink
|
||||
#define NS_LOGGING_SINK_CID \
|
||||
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// {a6cf910e-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_XIF_DTD_CID \
|
||||
{ 0xa6cf910e, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf910f-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_HTMLCONTENTSINKSTREAM_CID \
|
||||
{ 0xa6cf910f, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf9110-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_HTMLTOTXTSINKSTREAM_CID \
|
||||
{ 0xa6cf9110, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf9112-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_PARSERSERVICE_CID \
|
||||
{ 0xa6cf9112, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCParser, NS_PARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserNode, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kCNavDTDCID, NS_CNAVDTD_CID);
|
||||
|
||||
|
@ -21,17 +21,76 @@
|
||||
#include "nsIModule.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsParser.h"
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsLoggingSink.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "CNavDTD.h"
|
||||
#include "nsXIFDTD.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLToTXTSinkStream.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsIParserService.h"
|
||||
|
||||
static NS_DEFINE_IID(kParserCID, NS_PARSER_IID);
|
||||
static NS_DEFINE_IID(kParserNodeCID, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kIParserServiceIID, NS_IPARSERSERVICE_IID);
|
||||
|
||||
class nsParserService : public nsIParserService {
|
||||
public:
|
||||
nsParserService();
|
||||
virtual ~nsParserService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const;
|
||||
|
||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const;
|
||||
};
|
||||
|
||||
nsParserService::nsParserService()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsParserService::~nsParserService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsParserService, kIParserServiceIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const
|
||||
{
|
||||
*aId = nsHTMLTags::LookupTag(aTag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const
|
||||
{
|
||||
aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aId);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const
|
||||
{
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID);
|
||||
static NS_DEFINE_CID(kParserNodeCID, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_CID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
||||
static NS_DEFINE_CID(kXIFDTDCID, NS_XIF_DTD_CID);
|
||||
static NS_DEFINE_CID(kHTMLContentSinkStreamCID, NS_HTMLCONTENTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kHTMLToTXTSinkStreamCID, NS_HTMLTOTXTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
struct Components {
|
||||
const char* mDescription;
|
||||
@ -45,157 +104,22 @@ static Components gComponents[] = {
|
||||
{ "Well formed DTD", &kWellFormedDTDCID },
|
||||
{ "Navigator HTML DTD", &kNavDTDCID },
|
||||
{ "XIF DTD", &kXIFDTDCID },
|
||||
{ "HTML Content Sink Stream", &kHTMLContentSinkStreamCID },
|
||||
{ "HTML To Text Sink Stream", &kHTMLToTXTSinkStreamCID },
|
||||
{ "ParserService", &kParserServiceCID },
|
||||
};
|
||||
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]));
|
||||
|
||||
// Factory method to create new instances of nsParser
|
||||
static nsresult
|
||||
CreateNewParser(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsParser* inst = new nsParser();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsParserNode
|
||||
static nsresult
|
||||
CreateNewParserNode(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsCParserNode* inst = new nsCParserNode();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsILoggingSink
|
||||
static nsresult
|
||||
CreateNewLoggingSink(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIContentSink* inst;
|
||||
nsresult rv = NS_NewHTMLLoggingSink(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsWellFormedDTD
|
||||
static nsresult
|
||||
CreateNewWellFormedDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewWellFormed_DTD(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsNavHTMLDTD
|
||||
static nsresult
|
||||
CreateNewNavHTMLDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewNavHTMLDTD(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsXIFDTD
|
||||
static nsresult
|
||||
CreateNewXIFDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewXIFDTD(&inst);
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCParserNode)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLoggingSink)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CWellFormedDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXIFDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLContentSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLToTXTSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@ -214,6 +138,15 @@ protected:
|
||||
void Shutdown();
|
||||
|
||||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIGenericFactory> mParserFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mParserNodeFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mLoggingSinkFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mWellFormedDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mNavHTMLDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mXIFDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mHTMLContentSinkStreamFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mHTMLToTXTSinkStreamFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mParserServiceFactory;
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
|
||||
@ -234,12 +167,22 @@ NS_IMPL_ISUPPORTS(nsParserModule, kIModuleIID)
|
||||
nsresult
|
||||
nsParserModule::Initialize()
|
||||
{
|
||||
if (!mInitialized) {
|
||||
nsHTMLTags::AddRefTable();
|
||||
nsHTMLEntities::AddRefTable();
|
||||
mInitialized = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsParserModule::Shutdown()
|
||||
{
|
||||
if (mInitialized) {
|
||||
nsHTMLTags::ReleaseTable();
|
||||
nsHTMLEntities::ReleaseTable();
|
||||
mInitialized = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -261,22 +204,67 @@ nsParserModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
nsCOMPtr<nsIGenericFactory> fact;
|
||||
|
||||
if (aClass.Equals(kParserCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewParser);
|
||||
if (!mParserFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserFactory),
|
||||
&nsParserConstructor);
|
||||
}
|
||||
fact = mParserFactory;
|
||||
}
|
||||
else if (aClass.Equals(kParserNodeCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewParserNode);
|
||||
if (!mParserNodeFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserNodeFactory),
|
||||
&nsCParserNodeConstructor);
|
||||
}
|
||||
fact = mParserNodeFactory;
|
||||
}
|
||||
else if (aClass.Equals(kLoggingSinkCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewLoggingSink);
|
||||
if (!mLoggingSinkFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mLoggingSinkFactory),
|
||||
&nsLoggingSinkConstructor);
|
||||
}
|
||||
fact = mLoggingSinkFactory;
|
||||
}
|
||||
else if (aClass.Equals(kWellFormedDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewWellFormedDTD);
|
||||
if (!mWellFormedDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mWellFormedDTDFactory),
|
||||
&CWellFormedDTDConstructor);
|
||||
}
|
||||
fact = mWellFormedDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kNavDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewNavHTMLDTD);
|
||||
if (!mNavHTMLDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mNavHTMLDTDFactory),
|
||||
&CNavDTDConstructor);
|
||||
}
|
||||
fact = mNavHTMLDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kXIFDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXIFDTD);
|
||||
if (!mXIFDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mXIFDTDFactory),
|
||||
&nsXIFDTDConstructor);
|
||||
}
|
||||
fact = mXIFDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kHTMLContentSinkStreamCID)) {
|
||||
if (!mHTMLContentSinkStreamFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mHTMLContentSinkStreamFactory),
|
||||
&nsHTMLContentSinkStreamConstructor);
|
||||
}
|
||||
fact = mHTMLContentSinkStreamFactory;
|
||||
}
|
||||
else if (aClass.Equals(kHTMLToTXTSinkStreamCID)) {
|
||||
if (!mHTMLToTXTSinkStreamFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mHTMLToTXTSinkStreamFactory),
|
||||
&nsHTMLToTXTSinkStreamConstructor);
|
||||
}
|
||||
fact = mHTMLToTXTSinkStreamFactory;
|
||||
}
|
||||
else if (aClass.Equals(kParserServiceCID)) {
|
||||
if (!mParserServiceFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserServiceFactory),
|
||||
&nsParserServiceConstructor);
|
||||
}
|
||||
fact = mParserServiceFactory;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
@ -346,7 +334,6 @@ nsParserModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
static nsParserModule *gModule = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
@ -373,4 +360,3 @@ extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
gModule = m; // WARNING: Weak Reference
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
@ -305,6 +305,15 @@ NS_IMETHODIMP CValidDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) con
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CValidDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CValidDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
|
@ -249,6 +249,9 @@ class CValidDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -569,6 +569,16 @@ NS_IMETHODIMP CViewSourceHTML::StringTagToIntTag(nsString &aTag, PRInt32* aIntTa
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CViewSourceHTML::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CViewSourceHTML::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -232,6 +232,10 @@ class CViewSourceHTML: public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -423,6 +423,16 @@ NS_IMETHODIMP CWellFormedDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWellFormedDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWellFormedDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -234,7 +234,10 @@ class CWellFormedDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
protected:
|
||||
/*
|
||||
NS_IMETHODIMP ConsumeTag(PRUnichar aChar,nsScanner& aScanner,CToken*& aToken);
|
||||
|
@ -215,25 +215,6 @@ nsresult nsXIFDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is defined in nsIParser. It is used to
|
||||
* cause the COM-like construction of an nsHTMLParser.
|
||||
*
|
||||
* @update gpk 06/18/98
|
||||
* @param nsIParser** ptr to newly instantiated parser
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
nsXIFDTD* it = new nsXIFDTD();
|
||||
|
||||
if (it == 0) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kClassIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsXIFDTD)
|
||||
NS_IMPL_RELEASE(nsXIFDTD)
|
||||
@ -948,6 +929,16 @@ NS_IMETHODIMP nsXIFDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) cons
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXIFDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXIFDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
|
@ -35,11 +35,7 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
|
||||
#define NS_XIF_DTD_CID \
|
||||
{0xc2edf770, 0x06d5, 0x11d2, \
|
||||
{0xbc, 0x4a, 0x00, 0xaa, 0x00, 0x53, 0x3d, 0x6d}}
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
|
||||
class nsParser;
|
||||
@ -273,6 +269,10 @@ class nsXIFDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* Set this to TRUE if you want the DTD to verify its
|
||||
* context stack.
|
||||
@ -581,8 +581,14 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
inline nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
NS_DEFINE_CID(kXIFDTDCID, NS_XIF_DTD_CID);
|
||||
return nsComponentManager::CreateInstance(kXIFDTDCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDTD),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "nsIElementObserver.h"
|
||||
#include "nsViewSourceHTML.h"
|
||||
#include "nsParserNode.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <direct.h> //this is here for debug reasons...
|
||||
@ -208,26 +209,6 @@ nsresult CNavDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method is defined in nsIParser. It is used to
|
||||
* cause the COM-like construction of an nsParser.
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param nsIParser** ptr to newly instantiated parser
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
CNavDTD* it = new CNavDTD();
|
||||
|
||||
if (it == 0) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kClassIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(CNavDTD)
|
||||
NS_IMPL_RELEASE(CNavDTD)
|
||||
|
||||
@ -1827,6 +1808,18 @@ NS_IMETHODIMP CNavDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CNavDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aIntTag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CNavDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the necessary intermediate tags should be propagated
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
#define NS_INAVHTML_DTD_IID \
|
||||
{0x5c5cce40, 0xcfd6, 0x11d1, \
|
||||
@ -395,6 +395,9 @@ CLASS_EXPORT_HTMLPARS CNavDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* The following set of methods are used to partially construct
|
||||
@ -527,7 +530,14 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult);
|
||||
inline nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
||||
return nsComponentManager::CreateInstance(kNavDTDCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDTD),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -315,6 +315,16 @@ NS_IMETHODIMP COtherDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) con
|
||||
return CNavDTD::StringTagToIntTag(aTag, aIntTag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP COtherDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return CNavDTD::IntTagToStringTag(aIntTag, aTag);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP COtherDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return CNavDTD::ConvertEntityToUnicode(aEntity, aUnicode);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
|
@ -127,6 +127,10 @@ class COtherDTD : public CNavDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag)const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called when a start token has been consumed and needs
|
||||
* to be handled (possibly added to content model via sink).
|
||||
|
@ -377,6 +377,16 @@ NS_IMETHODIMP CRtfDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CRtfDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CRtfDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
|
@ -356,6 +356,10 @@ class CRtfDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -29,3 +29,4 @@ nsExpatDTD.h
|
||||
nsIExpatTokenizer.h
|
||||
nsParserError.h
|
||||
nsIElementObserver.h
|
||||
nsIParserService.h
|
||||
|
@ -24,6 +24,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = htmlparser
|
||||
LIBRARY_NAME = raptorhtmlpars
|
||||
IS_COMPONENT = 1
|
||||
|
||||
REQUIRES = xpcom netlib raptor
|
||||
|
||||
@ -43,7 +44,7 @@ CPPSRCS = \
|
||||
nsLoggingSink.cpp \
|
||||
nsParser.cpp \
|
||||
CParserContext.cpp \
|
||||
nsParserFactory.cpp \
|
||||
nsParserModule.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
@ -98,6 +99,7 @@ EXPORTS = \
|
||||
nsExpatDTD.h \
|
||||
nsParserError.h \
|
||||
nsIElementObserver.h \
|
||||
nsIParserService.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
@ -28,6 +28,7 @@ DEFINES = $(DEFINES) -DRAPTOR_PERF_METRICS
|
||||
|
||||
MODULE=raptor
|
||||
REQUIRES=xpcom raptor netlib
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS= \
|
||||
nsDTDUtils.cpp \
|
||||
@ -46,7 +47,6 @@ CPPSRCS= \
|
||||
nsLoggingSink.cpp \
|
||||
nsParser.cpp \
|
||||
CParserContext.cpp \
|
||||
nsParserFactory.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
@ -59,6 +59,7 @@ CPPSRCS= \
|
||||
nsXIFDTD.cpp \
|
||||
nsExpatDTD.cpp \
|
||||
prstrm.cpp \
|
||||
nsParserModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
@ -78,7 +79,6 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsLoggingSink.obj \
|
||||
.\$(OBJDIR)\nsParser.obj \
|
||||
.\$(OBJDIR)\CParserContext.obj \
|
||||
.\$(OBJDIR)\nsParserFactory.obj \
|
||||
.\$(OBJDIR)\nsParserNode.obj \
|
||||
.\$(OBJDIR)\nsScanner.obj \
|
||||
.\$(OBJDIR)\nsToken.obj \
|
||||
@ -91,6 +91,7 @@ CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsXIFDTD.obj \
|
||||
.\$(OBJDIR)\nsExpatDTD.obj \
|
||||
.\$(OBJDIR)\prstrm.obj \
|
||||
.\$(OBJDIR)\nsParserModule.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
@ -125,6 +126,7 @@ EXPORTS= \
|
||||
nsParserCIID.h \
|
||||
nsParserError.h \
|
||||
nsIElementObserver.h \
|
||||
nsIParserService.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@ -170,7 +172,7 @@ include <$(DEPTH)\config\rules.mak>
|
||||
# $(MAKE_INSTALL) $(XPDIST)\include
|
||||
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nsExpatTokenizer.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
|
||||
#include "prenv.h" //this is here for debug reasons...
|
||||
#include "prtypes.h" //this is here for debug reasons...
|
||||
@ -405,6 +406,18 @@ NS_IMETHODIMP nsExpatDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) co
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExpatDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExpatDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
// XXX Needed since the XML content sink reduces entities as well
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -231,6 +231,10 @@ class nsExpatDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* Retrieve a ptr to the global token recycler...
|
||||
* @update gess8/4/98
|
||||
|
@ -48,6 +48,7 @@
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTML_CONTENT_SINK_IID);
|
||||
static NS_DEFINE_IID(kIHTMLContentSinkStreamIID, NS_IHTMLCONTENTSINKSTREAM_IID);
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
@ -228,6 +229,9 @@ nsHTMLContentSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
else if(aIID.Equals(kIHTMLContentSinkIID)) {
|
||||
*aInstancePtr = (nsIHTMLContentSink*)(this);
|
||||
}
|
||||
else if(aIID.Equals(kIHTMLContentSinkStreamIID)) {
|
||||
*aInstancePtr = (nsIHTMLContentSinkStream*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
@ -241,55 +245,6 @@ NS_IMPL_ADDREF(nsHTMLContentSinkStream)
|
||||
NS_IMPL_RELEASE(nsHTMLContentSinkStream)
|
||||
|
||||
|
||||
/**
|
||||
* Create an new sink
|
||||
*
|
||||
* @update gpk 05/01/99
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsHTMLContentSinkStream* it = new nsHTMLContentSinkStream(aOutStream,
|
||||
nsnull,
|
||||
aCharsetOverride,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kIHTMLContentSinkIID, (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an new sink
|
||||
*
|
||||
* @update gpk 05/01/99
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsHTMLContentSinkStream* it = new nsHTMLContentSinkStream(nsnull,
|
||||
aOutString,
|
||||
nsnull,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kIHTMLContentSinkIID, (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Inits the encoder instance variable for the sink based on the charset
|
||||
*
|
||||
@ -346,10 +301,7 @@ nsresult nsHTMLContentSinkStream::InitEncoder(const nsString& aCharset)
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
nsHTMLContentSinkStream::nsHTMLContentSinkStream()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mLowerCaseTags = PR_TRUE;
|
||||
@ -357,6 +309,18 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
mHTMLStackPos = 0;
|
||||
mColPos = 0;
|
||||
mIndent = 0;
|
||||
mBuffer = nsnull;
|
||||
mBufferSize = 0;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mInBody = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLContentSinkStream::Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
mDoFormat = (aFlags & nsIDocumentEncoder::OutputFormatted) ? PR_TRUE
|
||||
: PR_FALSE;
|
||||
mBodyOnly = (aFlags & nsIDocumentEncoder::OutputBodyOnly) ? PR_TRUE
|
||||
@ -364,16 +328,13 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
mDoHeader = (!mBodyOnly) && (mDoFormat) &&
|
||||
((aFlags & nsIDocumentEncoder::OutputNoDoctype) ? PR_FALSE
|
||||
: PR_TRUE);
|
||||
mBuffer = nsnull;
|
||||
mBufferSize = 0;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
mInBody = PR_FALSE;
|
||||
if (aCharsetOverride != nsnull)
|
||||
mCharsetOverride = *aCharsetOverride;
|
||||
}
|
||||
mCharsetOverride = *aCharsetOverride;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tells the sink whether or not it is
|
||||
|
@ -43,9 +43,10 @@
|
||||
#include "nsIHTMLContentSink.h"
|
||||
#include "nshtmlpars.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
|
||||
#define NS_HTMLCONTENTSINK_STREAM_IID \
|
||||
#define NS_IHTMLCONTENTSINKSTREAM_IID \
|
||||
{0xa39c6bff, 0x15f0, 0x11d2, \
|
||||
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
|
||||
|
||||
@ -56,7 +57,19 @@ class ostream;
|
||||
class nsIUnicodeEncoder;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
class nsIHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENTSINKSTREAM_IID)
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLCONTENTSINKSTREAM_CID)
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags) = 0;
|
||||
};
|
||||
|
||||
class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@ -67,10 +80,7 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
* @param aOutStream -- stream where you want output sent
|
||||
* @param aOutStream -- ref to string where you want output sent
|
||||
*/
|
||||
nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
nsHTMLContentSinkStream();
|
||||
|
||||
/**
|
||||
* virtual destructor
|
||||
@ -80,6 +90,13 @@ class nsHTMLContentSinkStream : public nsIHTMLContentSink {
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIHTMLContentSinkStream
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* The following methods are inherited from nsIContentSink.
|
||||
@ -170,15 +187,59 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
inline nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aFlags);
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContentSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLContentSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(aOutStream,
|
||||
nsnull,
|
||||
aCharsetOverride,
|
||||
aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString, PRUint32 aFlags);
|
||||
nsString* aOutString, PRUint32 aFlags)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContentSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLContentSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(nsnull,
|
||||
aOutString,
|
||||
nsnull,
|
||||
aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -133,6 +133,9 @@ nsHTMLToTXTSinkStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
else if(aIID.Equals(NS_GET_IID(nsIHTMLContentSink))) {
|
||||
*aInstancePtr = (nsIHTMLContentSink*)(this);
|
||||
}
|
||||
else if(aIID.Equals(NS_GET_IID(nsIHTMLToTXTSinkStream))) {
|
||||
*aInstancePtr = (nsIHTMLToTXTSinkStream*)(this);
|
||||
}
|
||||
else {
|
||||
*aInstancePtr=0;
|
||||
return NS_NOINTERFACE;
|
||||
@ -146,54 +149,6 @@ NS_IMPL_ADDREF(nsHTMLToTXTSinkStream)
|
||||
NS_IMPL_RELEASE(nsHTMLToTXTSinkStream)
|
||||
|
||||
|
||||
/**
|
||||
* This method creates a new sink, it sets the stream used
|
||||
* for the sink to aStream
|
||||
*
|
||||
* @update gpk 04/30/99
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aStream,
|
||||
const nsString* aCharsetOverride,
|
||||
PRUint32 aWrapColumn, PRUint32 aFlags)
|
||||
{
|
||||
NS_ASSERTION(aStream != nsnull, "a valid stream is required");
|
||||
nsHTMLToTXTSinkStream* it = new nsHTMLToTXTSinkStream(aStream, nsnull,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
if (aCharsetOverride != nsnull)
|
||||
it->SetCharsetOverride(aCharsetOverride);
|
||||
return it->QueryInterface(NS_GET_IID(nsIHTMLContentSink), (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method creates a new sink, it sets the stream used
|
||||
* for the sink to aStream
|
||||
*
|
||||
* @update gpk 04/30/99
|
||||
*/
|
||||
NS_HTMLPARS nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aString,
|
||||
PRUint32 aWrapColumn, PRUint32 aFlags)
|
||||
{
|
||||
NS_ASSERTION(aString != nsnull, "a valid stream is required");
|
||||
nsHTMLToTXTSinkStream* it = new nsHTMLToTXTSinkStream(nsnull, aString,
|
||||
aFlags);
|
||||
if (nsnull == it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
nsAutoString ucs2("ucs2");
|
||||
it->SetCharsetOverride(&ucs2);
|
||||
return it->QueryInterface(NS_GET_IID(nsIHTMLContentSink), (void **)aInstancePtrResult);
|
||||
}
|
||||
|
||||
// Someday may want to make this non-const:
|
||||
static const PRUint32 TagStackSize = 500;
|
||||
static const PRUint32 OLStackSize = 100;
|
||||
@ -204,12 +159,9 @@ static const PRUint32 OLStackSize = 100;
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream(nsIOutputStream* aStream,
|
||||
nsString* aString,
|
||||
PRUint32 aFlags)
|
||||
nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mStream = aStream;
|
||||
mColPos = 0;
|
||||
mIndent = 0;
|
||||
mDoOutput = PR_FALSE;
|
||||
@ -217,9 +169,6 @@ nsHTMLToTXTSinkStream::nsHTMLToTXTSinkStream(nsIOutputStream* aStream,
|
||||
mBufferLength = 0;
|
||||
mBuffer = nsnull;
|
||||
mUnicodeEncoder = nsnull;
|
||||
mStream = aStream;
|
||||
mString = aString;
|
||||
mFlags = aFlags;
|
||||
mWrapColumn = 72; // XXX magic number, we expect someone to reset this
|
||||
|
||||
// initialize the tag stack to zero:
|
||||
@ -246,6 +195,24 @@ nsHTMLToTXTSinkStream::~nsHTMLToTXTSinkStream()
|
||||
NS_IF_RELEASE(mUnicodeEncoder);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsHTMLToTXTSinkStream::Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
mStream = aOutStream;
|
||||
mString = aOutString;
|
||||
mFlags = aFlags;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gpk04/30/99
|
||||
|
@ -40,8 +40,10 @@
|
||||
#include "nsIHTMLContentSink.h"
|
||||
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_HTMLTOTEXTSINK_STREAM_CID \
|
||||
#define NS_IHTMLTOTEXTSINKSTREAM_IID \
|
||||
{0xa39c6bff, 0x15f0, 0x11d2, \
|
||||
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
|
||||
|
||||
@ -49,7 +51,19 @@
|
||||
class nsIUnicodeEncoder;
|
||||
class nsIOutputStream;
|
||||
|
||||
class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
class nsIHTMLToTXTSinkStream : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLTOTEXTSINKSTREAM_IID)
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLTOTXTSINKSTREAM_CID)
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset) = 0;
|
||||
NS_IMETHOD SetWrapColumn(PRUint32 aWrapCol) = 0;
|
||||
};
|
||||
|
||||
class nsHTMLToTXTSinkStream : public nsIHTMLToTXTSinkStream
|
||||
{
|
||||
public:
|
||||
|
||||
@ -57,8 +71,7 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
* Standard constructor
|
||||
* @update gpk02/03/99
|
||||
*/
|
||||
nsHTMLToTXTSinkStream(nsIOutputStream* aOutStream, nsString* aOutString,
|
||||
PRUint32 aFlags);
|
||||
nsHTMLToTXTSinkStream();
|
||||
|
||||
/**
|
||||
* virtual destructor
|
||||
@ -66,6 +79,10 @@ class nsHTMLToTXTSinkStream : public nsIHTMLContentSink
|
||||
*/
|
||||
virtual ~nsHTMLToTXTSinkStream();
|
||||
|
||||
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
|
||||
nsString* aOutString,
|
||||
PRUint32 aFlags);
|
||||
|
||||
NS_IMETHOD SetCharsetOverride(const nsString* aCharset);
|
||||
|
||||
|
||||
@ -150,16 +167,62 @@ protected:
|
||||
nsString mCharsetOverride;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
inline nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsIOutputStream* aOutStream,
|
||||
const nsString* aCharsetOverride=nsnull,
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0);
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLToTXTSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
extern NS_HTMLPARS nsresult
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLToTXTSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLToTXTSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(aOutStream, nsnull, aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
if (aCharsetOverride != nsnull) {
|
||||
it->SetCharsetOverride(aCharsetOverride);
|
||||
}
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
NS_New_HTMLToTXT_SinkStream(nsIHTMLContentSink** aInstancePtrResult,
|
||||
nsString* aOutString,
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0);
|
||||
PRUint32 aWrapColumn=0, PRUint32 aFlags=0)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLToTXTSinkStream> it;
|
||||
nsresult rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(nsIHTMLToTXTSinkStream::GetCID(),
|
||||
nsnull,
|
||||
nsIHTMLToTXTSinkStream::GetIID(),
|
||||
getter_AddRefs(it));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = it->Initialize(nsnull, aOutString, aFlags);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
it->SetWrapColumn(aWrapColumn);
|
||||
nsAutoString ucs2("ucs2");
|
||||
it->SetCharsetOverride(&ucs2);
|
||||
|
||||
rv = it->QueryInterface(nsIHTMLContentSink::GetIID(),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -220,6 +220,9 @@ class nsIDTD : public nsISupports {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const =0;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const =0;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const =0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,10 +27,6 @@
|
||||
#define NS_ILOGGING_SINK_IID \
|
||||
{0xa6cf9061, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// Class IID for the logging sink
|
||||
#define NS_LOGGING_SINK_IID \
|
||||
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
class nsILoggingSink : public nsIHTMLContentSink {
|
||||
public:
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream) =0;
|
||||
|
@ -99,7 +99,7 @@ public:
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports {
|
||||
class nsIParser : public nsISupports {
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IPARSER_IID; return iid; }
|
||||
@ -164,6 +164,14 @@ CLASS_EXPORT_HTMLPARS nsIParser : public nsISupports {
|
||||
virtual nsresult CreateTagStack(nsITagStack** aTagStack)=0;
|
||||
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHOD GetDTD(nsIDTD** aDTD) = 0;
|
||||
|
||||
/******************************************************************************************
|
||||
* Parse methods always begin with an input source, and perform conversions
|
||||
* until you wind up being emitted to the given contentsink (which may or may not
|
||||
|
39
parser/htmlparser/src/nsIParserService.h
Normal file
39
parser/htmlparser/src/nsIParserService.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IPARSERSERVICE_IID \
|
||||
{ 0xa6cf9111, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
|
||||
class nsIParserService : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
|
||||
|
||||
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const =0;
|
||||
|
||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const =0;
|
||||
|
||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const =0;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsLoggingSink.h"
|
||||
#include "nsHTMLTags.h"
|
||||
#include "nsString.h"
|
||||
|
||||
@ -65,60 +65,6 @@ ostream& operator<<(ostream& os,const nsString& aString) {
|
||||
return os;
|
||||
}
|
||||
|
||||
class nsLoggingSink : public nsILoggingSink {
|
||||
public:
|
||||
nsLoggingSink();
|
||||
virtual ~nsLoggingSink();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel();
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt();
|
||||
NS_IMETHOD WillResume();
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD SetTitle(const nsString& aValue);
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
// nsILoggingSink
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream);
|
||||
|
||||
nsresult OpenNode(const char* aKind, const nsIParserNode& aNode);
|
||||
nsresult CloseNode(const char* aKind);
|
||||
nsresult LeafNode(const nsIParserNode& aNode);
|
||||
nsresult WriteAttributes(const nsIParserNode& aNode);
|
||||
nsresult QuoteText(const nsString& aValue, nsString& aResult);
|
||||
PRBool WillWriteAttributes(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
ostream* mOutput;
|
||||
int mLevel;
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewHTMLLoggingSink(nsIContentSink** aInstancePtrResult)
|
||||
|
80
parser/htmlparser/src/nsLoggingSink.h
Normal file
80
parser/htmlparser/src/nsLoggingSink.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are Copyright (C) 1998
|
||||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NS_LOGGING_SINK_H__
|
||||
#define NS_LOGGING_SINK_H__
|
||||
|
||||
#include "nsILoggingSink.h"
|
||||
|
||||
class nsLoggingSink : public nsILoggingSink {
|
||||
public:
|
||||
nsLoggingSink();
|
||||
virtual ~nsLoggingSink();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel();
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt();
|
||||
NS_IMETHOD WillResume();
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(const nsParserError* aError);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
|
||||
|
||||
// nsIHTMLContentSink
|
||||
NS_IMETHOD SetTitle(const nsString& aValue);
|
||||
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
|
||||
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
NS_IMETHOD BeginContext(PRInt32 aPosition);
|
||||
NS_IMETHOD EndContext(PRInt32 aPosition);
|
||||
|
||||
// nsILoggingSink
|
||||
NS_IMETHOD SetOutputStream(ostream& aStream);
|
||||
|
||||
nsresult OpenNode(const char* aKind, const nsIParserNode& aNode);
|
||||
nsresult CloseNode(const char* aKind);
|
||||
nsresult LeafNode(const nsIParserNode& aNode);
|
||||
nsresult WriteAttributes(const nsIParserNode& aNode);
|
||||
nsresult QuoteText(const nsString& aValue, nsString& aResult);
|
||||
PRBool WillWriteAttributes(const nsIParserNode& aNode);
|
||||
|
||||
protected:
|
||||
ostream* mOutput;
|
||||
int mLevel;
|
||||
};
|
||||
|
||||
#endif
|
@ -1543,3 +1543,20 @@ nsresult nsParser::CreateTagStack(nsITagStack** aTagStack){
|
||||
return NS_OK;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsParser::GetDTD(nsIDTD** aDTD)
|
||||
{
|
||||
if (mParserContext) {
|
||||
*aDTD = mParserContext->mDTD;
|
||||
NS_IF_ADDREF(mParserContext->mDTD);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -282,6 +282,14 @@ friend class CTokenHandler;
|
||||
*/
|
||||
virtual nsresult CreateTagStack(nsITagStack** aTagStack);
|
||||
|
||||
/**
|
||||
* Get the DTD associated with this parser
|
||||
* @update vidur 9/29/99
|
||||
* @param aDTD out param that will contain the result
|
||||
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
|
||||
*/
|
||||
NS_IMETHOD GetDTD(nsIDTD** aDTD);
|
||||
|
||||
/**
|
||||
* Call this to access observer dictionary ( internal to parser )
|
||||
* @update harishd 06/27/99
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
// XXX Should be _CID and not _IID
|
||||
#define NS_PARSER_IID \
|
||||
{0x2ce606b0, 0xbee6, 0x11d1, \
|
||||
{0xaa, 0xd9, 0x00, 0x80, 0x5f, 0x8a, 0x3e, 0x14}}
|
||||
@ -41,4 +42,24 @@
|
||||
#define NS_CNAVDTD_CID \
|
||||
{ 0xa6cf9107, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// Class IID for the logging sink
|
||||
#define NS_LOGGING_SINK_CID \
|
||||
{0xa6cf9060, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
// {a6cf910e-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_XIF_DTD_CID \
|
||||
{ 0xa6cf910e, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf910f-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_HTMLCONTENTSINKSTREAM_CID \
|
||||
{ 0xa6cf910f, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf9110-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_HTMLTOTXTSINKSTREAM_CID \
|
||||
{ 0xa6cf9110, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
// {a6cf9112-15b3-11d2-932e-00805f8add32}
|
||||
#define NS_PARSERSERVICE_CID \
|
||||
{ 0xa6cf9112, 0x15b3, 0x11d2, { 0x93, 0x2e, 0x0, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_IID(kCParser, NS_PARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserNode, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kCNavDTDCID, NS_CNAVDTD_CID);
|
||||
|
||||
|
@ -21,17 +21,76 @@
|
||||
#include "nsIModule.h"
|
||||
#include "nsParserCIID.h"
|
||||
#include "nsParser.h"
|
||||
#include "nsILoggingSink.h"
|
||||
#include "nsLoggingSink.h"
|
||||
#include "nsWellFormedDTD.h"
|
||||
#include "CNavDTD.h"
|
||||
#include "nsXIFDTD.h"
|
||||
#include "nsHTMLContentSinkStream.h"
|
||||
#include "nsHTMLToTXTSinkStream.h"
|
||||
#include "nsHTMLEntities.h"
|
||||
#include "nsIParserService.h"
|
||||
|
||||
static NS_DEFINE_IID(kParserCID, NS_PARSER_IID);
|
||||
static NS_DEFINE_IID(kParserNodeCID, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_IID(kLoggingSinkCID, NS_LOGGING_SINK_IID);
|
||||
static NS_DEFINE_IID(kIParserServiceIID, NS_IPARSERSERVICE_IID);
|
||||
|
||||
class nsParserService : public nsIParserService {
|
||||
public:
|
||||
nsParserService();
|
||||
virtual ~nsParserService();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const;
|
||||
|
||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const;
|
||||
};
|
||||
|
||||
nsParserService::nsParserService()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsParserService::~nsParserService()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsParserService, kIParserServiceIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const
|
||||
{
|
||||
*aId = nsHTMLTags::LookupTag(aTag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const
|
||||
{
|
||||
aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aId);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsParserService::HTMLConvertEntityToUnicode(const nsString& aEntity,
|
||||
PRInt32* aUnicode) const
|
||||
{
|
||||
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_CID(kParserCID, NS_PARSER_IID);
|
||||
static NS_DEFINE_CID(kParserNodeCID, NS_PARSER_NODE_IID);
|
||||
static NS_DEFINE_CID(kLoggingSinkCID, NS_LOGGING_SINK_CID);
|
||||
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
|
||||
static NS_DEFINE_CID(kNavDTDCID, NS_CNAVDTD_CID);
|
||||
static NS_DEFINE_CID(kXIFDTDCID, NS_XIF_DTD_CID);
|
||||
static NS_DEFINE_CID(kHTMLContentSinkStreamCID, NS_HTMLCONTENTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kHTMLToTXTSinkStreamCID, NS_HTMLTOTXTSINKSTREAM_CID);
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
struct Components {
|
||||
const char* mDescription;
|
||||
@ -45,157 +104,22 @@ static Components gComponents[] = {
|
||||
{ "Well formed DTD", &kWellFormedDTDCID },
|
||||
{ "Navigator HTML DTD", &kNavDTDCID },
|
||||
{ "XIF DTD", &kXIFDTDCID },
|
||||
{ "HTML Content Sink Stream", &kHTMLContentSinkStreamCID },
|
||||
{ "HTML To Text Sink Stream", &kHTMLToTXTSinkStreamCID },
|
||||
{ "ParserService", &kParserServiceCID },
|
||||
};
|
||||
|
||||
#define NUM_COMPONENTS (sizeof(gComponents) / sizeof(gComponents[0]));
|
||||
|
||||
// Factory method to create new instances of nsParser
|
||||
static nsresult
|
||||
CreateNewParser(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsParser* inst = new nsParser();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsParserNode
|
||||
static nsresult
|
||||
CreateNewParserNode(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsCParserNode* inst = new nsCParserNode();
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
delete inst;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsILoggingSink
|
||||
static nsresult
|
||||
CreateNewLoggingSink(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIContentSink* inst;
|
||||
nsresult rv = NS_NewHTMLLoggingSink(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsWellFormedDTD
|
||||
static nsresult
|
||||
CreateNewWellFormedDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewWellFormed_DTD(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsNavHTMLDTD
|
||||
static nsresult
|
||||
CreateNewNavHTMLDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewNavHTMLDTD(&inst);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Factory method to create new instances of nsXIFDTD
|
||||
static nsresult
|
||||
CreateNewXIFDTD(nsISupports* aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
if (aOuter) {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
nsIDTD* inst;
|
||||
nsresult rv = NS_NewXIFDTD(&inst);
|
||||
if (!inst) {
|
||||
*aResult = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = inst->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
NS_RELEASE(inst); // get rid of extra refcnt
|
||||
return rv;
|
||||
}
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParser)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCParserNode)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLoggingSink)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CWellFormedDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CNavDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXIFDTD)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLContentSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLToTXTSinkStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserService)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@ -214,6 +138,15 @@ protected:
|
||||
void Shutdown();
|
||||
|
||||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIGenericFactory> mParserFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mParserNodeFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mLoggingSinkFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mWellFormedDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mNavHTMLDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mXIFDTDFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mHTMLContentSinkStreamFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mHTMLToTXTSinkStreamFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mParserServiceFactory;
|
||||
};
|
||||
|
||||
static NS_DEFINE_IID(kIModuleIID, NS_IMODULE_IID);
|
||||
@ -234,12 +167,22 @@ NS_IMPL_ISUPPORTS(nsParserModule, kIModuleIID)
|
||||
nsresult
|
||||
nsParserModule::Initialize()
|
||||
{
|
||||
if (!mInitialized) {
|
||||
nsHTMLTags::AddRefTable();
|
||||
nsHTMLEntities::AddRefTable();
|
||||
mInitialized = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsParserModule::Shutdown()
|
||||
{
|
||||
if (mInitialized) {
|
||||
nsHTMLTags::ReleaseTable();
|
||||
nsHTMLEntities::ReleaseTable();
|
||||
mInitialized = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -261,22 +204,67 @@ nsParserModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
nsCOMPtr<nsIGenericFactory> fact;
|
||||
|
||||
if (aClass.Equals(kParserCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewParser);
|
||||
if (!mParserFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserFactory),
|
||||
&nsParserConstructor);
|
||||
}
|
||||
fact = mParserFactory;
|
||||
}
|
||||
else if (aClass.Equals(kParserNodeCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewParserNode);
|
||||
if (!mParserNodeFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserNodeFactory),
|
||||
&nsCParserNodeConstructor);
|
||||
}
|
||||
fact = mParserNodeFactory;
|
||||
}
|
||||
else if (aClass.Equals(kLoggingSinkCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewLoggingSink);
|
||||
if (!mLoggingSinkFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mLoggingSinkFactory),
|
||||
&nsLoggingSinkConstructor);
|
||||
}
|
||||
fact = mLoggingSinkFactory;
|
||||
}
|
||||
else if (aClass.Equals(kWellFormedDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewWellFormedDTD);
|
||||
if (!mWellFormedDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mWellFormedDTDFactory),
|
||||
&CWellFormedDTDConstructor);
|
||||
}
|
||||
fact = mWellFormedDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kNavDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewNavHTMLDTD);
|
||||
if (!mNavHTMLDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mNavHTMLDTDFactory),
|
||||
&CNavDTDConstructor);
|
||||
}
|
||||
fact = mNavHTMLDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kXIFDTDCID)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXIFDTD);
|
||||
if (!mXIFDTDFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mXIFDTDFactory),
|
||||
&nsXIFDTDConstructor);
|
||||
}
|
||||
fact = mXIFDTDFactory;
|
||||
}
|
||||
else if (aClass.Equals(kHTMLContentSinkStreamCID)) {
|
||||
if (!mHTMLContentSinkStreamFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mHTMLContentSinkStreamFactory),
|
||||
&nsHTMLContentSinkStreamConstructor);
|
||||
}
|
||||
fact = mHTMLContentSinkStreamFactory;
|
||||
}
|
||||
else if (aClass.Equals(kHTMLToTXTSinkStreamCID)) {
|
||||
if (!mHTMLToTXTSinkStreamFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mHTMLToTXTSinkStreamFactory),
|
||||
&nsHTMLToTXTSinkStreamConstructor);
|
||||
}
|
||||
fact = mHTMLToTXTSinkStreamFactory;
|
||||
}
|
||||
else if (aClass.Equals(kParserServiceCID)) {
|
||||
if (!mParserServiceFactory) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mParserServiceFactory),
|
||||
&nsParserServiceConstructor);
|
||||
}
|
||||
fact = mParserServiceFactory;
|
||||
}
|
||||
else {
|
||||
rv = NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
@ -346,7 +334,6 @@ nsParserModule::CanUnload(nsIComponentManager *aCompMgr, PRBool *okToUnload)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
static nsParserModule *gModule = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
@ -373,4 +360,3 @@ extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
|
||||
gModule = m; // WARNING: Weak Reference
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
@ -305,6 +305,15 @@ NS_IMETHODIMP CValidDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) con
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CValidDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CValidDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
|
@ -249,6 +249,9 @@ class CValidDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -569,6 +569,16 @@ NS_IMETHODIMP CViewSourceHTML::StringTagToIntTag(nsString &aTag, PRInt32* aIntTa
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CViewSourceHTML::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CViewSourceHTML::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -232,6 +232,10 @@ class CViewSourceHTML: public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -423,6 +423,16 @@ NS_IMETHODIMP CWellFormedDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWellFormedDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWellFormedDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
|
@ -234,7 +234,10 @@ class CWellFormedDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
protected:
|
||||
/*
|
||||
NS_IMETHODIMP ConsumeTag(PRUnichar aChar,nsScanner& aScanner,CToken*& aToken);
|
||||
|
@ -215,25 +215,6 @@ nsresult nsXIFDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is defined in nsIParser. It is used to
|
||||
* cause the COM-like construction of an nsHTMLParser.
|
||||
*
|
||||
* @update gpk 06/18/98
|
||||
* @param nsIParser** ptr to newly instantiated parser
|
||||
* @return NS_xxx error result
|
||||
*/
|
||||
NS_HTMLPARS nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
nsXIFDTD* it = new nsXIFDTD();
|
||||
|
||||
if (it == 0) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return it->QueryInterface(kClassIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(nsXIFDTD)
|
||||
NS_IMPL_RELEASE(nsXIFDTD)
|
||||
@ -948,6 +929,16 @@ NS_IMETHODIMP nsXIFDTD::StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) cons
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXIFDTD::IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXIFDTD::ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
|
@ -35,11 +35,7 @@
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
|
||||
#define NS_XIF_DTD_CID \
|
||||
{0xc2edf770, 0x06d5, 0x11d2, \
|
||||
{0xbc, 0x4a, 0x00, 0xaa, 0x00, 0x53, 0x3d, 0x6d}}
|
||||
#include "nsParserCIID.h"
|
||||
|
||||
|
||||
class nsParser;
|
||||
@ -273,6 +269,10 @@ class nsXIFDTD : public nsIDTD {
|
||||
*/
|
||||
NS_IMETHOD StringTagToIntTag(nsString &aTag, PRInt32* aIntTag) const;
|
||||
|
||||
NS_IMETHOD IntTagToStringTag(PRInt32 aIntTag, nsString& aTag) const;
|
||||
|
||||
NS_IMETHOD ConvertEntityToUnicode(const nsString& aEntity, PRInt32* aUnicode) const;
|
||||
|
||||
/**
|
||||
* Set this to TRUE if you want the DTD to verify its
|
||||
* context stack.
|
||||
@ -581,8 +581,14 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult);
|
||||
|
||||
inline nsresult NS_NewXIFDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
NS_DEFINE_CID(kXIFDTDCID, NS_XIF_DTD_CID);
|
||||
return nsComponentManager::CreateInstance(kXIFDTDCID,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDTD),
|
||||
(void**)aInstancePtrResult);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user