Parser regression test. Triggered by PARSER_DUMP_CONTENT env. flag

under NS_DEBUG.

r=rickg
a=rickg


git-svn-id: svn://10.0.0.236/trunk@70917 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
harishd%netscape.com 2000-05-26 19:45:26 +00:00
parent 2a47902cce
commit d2f44f024a
4 changed files with 82 additions and 0 deletions

View File

@ -49,6 +49,9 @@
#define NS_IPARSER_BUNDLE_IID \
{ 0x8b6a98a0, 0x260e, 0x11d4, { 0x81, 0x53, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } };
// {41421C60-310A-11d4-816F-000064657374}
#define NS_IDEBUG_DUMP_CONTENT_IID \
{ 0x41421c60, 0x310a, 0x11d4, { 0x81, 0x6f, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
class nsIContentSink;
class nsIStreamObserver;
@ -105,6 +108,20 @@ public:
virtual PRUint32 GetSize(void)=0;
};
/**
* FOR DEBUG PURPOSE ONLY
*
* Use this interface to query objects that contain content information.
* Ex. Parser can trigger dump content by querying the sink that has
* access to the content.
*
* @update harishd 05/25/00
*/
class nsIDebugDumpContent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDEBUG_DUMP_CONTENT_IID; return iid; }
NS_IMETHOD DumpContentModel()=0;
};
class nsISupportsParserBundle : public nsISupports {
public:

View File

@ -198,6 +198,8 @@ void nsParser::FreeSharedObjects(void) {
}
}
static PRBool gDumpContent=PR_FALSE;
/**
* default constructor
*
@ -207,6 +209,13 @@ void nsParser::FreeSharedObjects(void) {
*/
nsParser::nsParser(nsITokenObserver* anObserver) {
NS_INIT_REFCNT();
#ifdef NS_DEBUG
if(!gDumpContent) {
gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE;
}
#endif
mCharset.AssignWithConversion("ISO-8859-1");
mParserFilter = 0;
mObserver = 0;
@ -236,6 +245,21 @@ nsParser::nsParser(nsITokenObserver* anObserver) {
* @return
*/
nsParser::~nsParser() {
#ifdef NS_DEBUG
if(gDumpContent) {
if(mSink) {
// Sink ( HTMLContentSink at this time) supports nsIDebugDumpContent
// interface. We can get to the content model through the sink.
nsresult result=NS_OK;
nsCOMPtr<nsIDebugDumpContent> trigger=do_QueryInterface(mSink,&result);
if(NS_SUCCEEDED(result)) {
trigger->DumpContentModel();
}
}
}
#endif
NS_IF_RELEASE(mObserver);
NS_IF_RELEASE(mProgressEventSink);
NS_IF_RELEASE(mSink);

View File

@ -49,6 +49,9 @@
#define NS_IPARSER_BUNDLE_IID \
{ 0x8b6a98a0, 0x260e, 0x11d4, { 0x81, 0x53, 0x0, 0x10, 0xa4, 0xe0, 0xc7, 0x6 } };
// {41421C60-310A-11d4-816F-000064657374}
#define NS_IDEBUG_DUMP_CONTENT_IID \
{ 0x41421c60, 0x310a, 0x11d4, { 0x81, 0x6f, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } };
class nsIContentSink;
class nsIStreamObserver;
@ -105,6 +108,20 @@ public:
virtual PRUint32 GetSize(void)=0;
};
/**
* FOR DEBUG PURPOSE ONLY
*
* Use this interface to query objects that contain content information.
* Ex. Parser can trigger dump content by querying the sink that has
* access to the content.
*
* @update harishd 05/25/00
*/
class nsIDebugDumpContent : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDEBUG_DUMP_CONTENT_IID; return iid; }
NS_IMETHOD DumpContentModel()=0;
};
class nsISupportsParserBundle : public nsISupports {
public:

View File

@ -198,6 +198,8 @@ void nsParser::FreeSharedObjects(void) {
}
}
static PRBool gDumpContent=PR_FALSE;
/**
* default constructor
*
@ -207,6 +209,13 @@ void nsParser::FreeSharedObjects(void) {
*/
nsParser::nsParser(nsITokenObserver* anObserver) {
NS_INIT_REFCNT();
#ifdef NS_DEBUG
if(!gDumpContent) {
gDumpContent=(PR_GetEnv("PARSER_DUMP_CONTENT"))? PR_TRUE:PR_FALSE;
}
#endif
mCharset.AssignWithConversion("ISO-8859-1");
mParserFilter = 0;
mObserver = 0;
@ -236,6 +245,21 @@ nsParser::nsParser(nsITokenObserver* anObserver) {
* @return
*/
nsParser::~nsParser() {
#ifdef NS_DEBUG
if(gDumpContent) {
if(mSink) {
// Sink ( HTMLContentSink at this time) supports nsIDebugDumpContent
// interface. We can get to the content model through the sink.
nsresult result=NS_OK;
nsCOMPtr<nsIDebugDumpContent> trigger=do_QueryInterface(mSink,&result);
if(NS_SUCCEEDED(result)) {
trigger->DumpContentModel();
}
}
}
#endif
NS_IF_RELEASE(mObserver);
NS_IF_RELEASE(mProgressEventSink);
NS_IF_RELEASE(mSink);