зеркало из https://github.com/mozilla/pjs.git
changed SetContentSink to do proper ref counting
This commit is contained in:
Родитель
17a3991909
Коммит
55f7be5e3e
|
@ -31,6 +31,7 @@
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kClassIID, NS_IHTML_PARSER_IID);
|
static NS_DEFINE_IID(kClassIID, NS_IHTML_PARSER_IID);
|
||||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||||
|
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTMLCONTENTSINK_IID);
|
||||||
|
|
||||||
|
|
||||||
/**-------------------------------------------------------
|
/**-------------------------------------------------------
|
||||||
|
@ -107,6 +108,7 @@ nsHTMLParser::~nsHTMLParser() {
|
||||||
if(mDTD)
|
if(mDTD)
|
||||||
delete mDTD;
|
delete mDTD;
|
||||||
mDTD=0;
|
mDTD=0;
|
||||||
|
NS_IF_RELEASE(mSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,13 +272,20 @@ CDefaultTokenHandler* nsHTMLParser::AddTokenHandler(CDefaultTokenHandler* aHandl
|
||||||
* @param nsIContentSink interface for node receiver
|
* @param nsIContentSink interface for node receiver
|
||||||
* @return
|
* @return
|
||||||
*------------------------------------------------------*/
|
*------------------------------------------------------*/
|
||||||
nsIContentSink* nsHTMLParser::SetContentSink(nsIContentSink* aSink) {
|
void nsHTMLParser::SetContentSink(nsIContentSink* aSink) {
|
||||||
NS_PRECONDITION(0!=aSink,"sink cannot be null!");
|
NS_PRECONDITION(0!=aSink,"sink cannot be null!");
|
||||||
nsIContentSink* old=mSink;
|
|
||||||
if(aSink) {
|
if(aSink) {
|
||||||
mSink=(nsHTMLContentSink*)(aSink);
|
nsIHTMLContentSink* htmlSink;
|
||||||
|
if (NS_OK == aSink->QueryInterface(kIHTMLContentSinkIID, (void**)&htmlSink)) {
|
||||||
|
if ((nsHTMLContentSink*)(htmlSink) != mSink) {
|
||||||
|
NS_IF_RELEASE(mSink);
|
||||||
|
mSink = (nsHTMLContentSink*)(htmlSink);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NS_RELEASE(htmlSink);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return old;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**-------------------------------------------------------
|
/**-------------------------------------------------------
|
||||||
|
@ -301,7 +310,7 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL){
|
||||||
mTokenizer=new CTokenizer(aURL, delegate);
|
mTokenizer=new CTokenizer(aURL, delegate);
|
||||||
mTokenizer->Tokenize();
|
mTokenizer->Tokenize();
|
||||||
|
|
||||||
#define VERBOSE_DEBUG
|
//#define VERBOSE_DEBUG
|
||||||
#ifdef VERBOSE_DEBUG
|
#ifdef VERBOSE_DEBUG
|
||||||
mTokenizer->DebugDumpTokens(cout);
|
mTokenizer->DebugDumpTokens(cout);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,7 +82,7 @@ friend class CDefaultTokenHandler;
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
nsHTMLParser();
|
nsHTMLParser();
|
||||||
~nsHTMLParser();
|
~nsHTMLParser();
|
||||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
virtual void SetContentSink(nsIContentSink* aSink);
|
||||||
virtual PRBool Parse(nsIURL* aURL);
|
virtual PRBool Parse(nsIURL* aURL);
|
||||||
virtual PRBool ResumeParse();
|
virtual PRBool ResumeParse();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class nsIParser : public nsISupports {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
|
virtual void SetContentSink(nsIContentSink* aContentSink)=0;
|
||||||
virtual PRBool Parse(nsIURL* aURL)=0;
|
virtual PRBool Parse(nsIURL* aURL)=0;
|
||||||
virtual PRBool ResumeParse()=0;
|
virtual PRBool ResumeParse()=0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
static NS_DEFINE_IID(kClassIID, NS_IHTML_PARSER_IID);
|
static NS_DEFINE_IID(kClassIID, NS_IHTML_PARSER_IID);
|
||||||
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
|
||||||
|
static NS_DEFINE_IID(kIHTMLContentSinkIID, NS_IHTMLCONTENTSINK_IID);
|
||||||
|
|
||||||
|
|
||||||
/**-------------------------------------------------------
|
/**-------------------------------------------------------
|
||||||
|
@ -107,6 +108,7 @@ nsHTMLParser::~nsHTMLParser() {
|
||||||
if(mDTD)
|
if(mDTD)
|
||||||
delete mDTD;
|
delete mDTD;
|
||||||
mDTD=0;
|
mDTD=0;
|
||||||
|
NS_IF_RELEASE(mSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -270,13 +272,20 @@ CDefaultTokenHandler* nsHTMLParser::AddTokenHandler(CDefaultTokenHandler* aHandl
|
||||||
* @param nsIContentSink interface for node receiver
|
* @param nsIContentSink interface for node receiver
|
||||||
* @return
|
* @return
|
||||||
*------------------------------------------------------*/
|
*------------------------------------------------------*/
|
||||||
nsIContentSink* nsHTMLParser::SetContentSink(nsIContentSink* aSink) {
|
void nsHTMLParser::SetContentSink(nsIContentSink* aSink) {
|
||||||
NS_PRECONDITION(0!=aSink,"sink cannot be null!");
|
NS_PRECONDITION(0!=aSink,"sink cannot be null!");
|
||||||
nsIContentSink* old=mSink;
|
|
||||||
if(aSink) {
|
if(aSink) {
|
||||||
mSink=(nsHTMLContentSink*)(aSink);
|
nsIHTMLContentSink* htmlSink;
|
||||||
|
if (NS_OK == aSink->QueryInterface(kIHTMLContentSinkIID, (void**)&htmlSink)) {
|
||||||
|
if ((nsHTMLContentSink*)(htmlSink) != mSink) {
|
||||||
|
NS_IF_RELEASE(mSink);
|
||||||
|
mSink = (nsHTMLContentSink*)(htmlSink);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NS_RELEASE(htmlSink);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return old;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**-------------------------------------------------------
|
/**-------------------------------------------------------
|
||||||
|
@ -301,7 +310,7 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL){
|
||||||
mTokenizer=new CTokenizer(aURL, delegate);
|
mTokenizer=new CTokenizer(aURL, delegate);
|
||||||
mTokenizer->Tokenize();
|
mTokenizer->Tokenize();
|
||||||
|
|
||||||
#define VERBOSE_DEBUG
|
//#define VERBOSE_DEBUG
|
||||||
#ifdef VERBOSE_DEBUG
|
#ifdef VERBOSE_DEBUG
|
||||||
mTokenizer->DebugDumpTokens(cout);
|
mTokenizer->DebugDumpTokens(cout);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -82,7 +82,7 @@ friend class CDefaultTokenHandler;
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
nsHTMLParser();
|
nsHTMLParser();
|
||||||
~nsHTMLParser();
|
~nsHTMLParser();
|
||||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
virtual void SetContentSink(nsIContentSink* aSink);
|
||||||
virtual PRBool Parse(nsIURL* aURL);
|
virtual PRBool Parse(nsIURL* aURL);
|
||||||
virtual PRBool ResumeParse();
|
virtual PRBool ResumeParse();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class nsIParser : public nsISupports {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
|
virtual void SetContentSink(nsIContentSink* aContentSink)=0;
|
||||||
virtual PRBool Parse(nsIURL* aURL)=0;
|
virtual PRBool Parse(nsIURL* aURL)=0;
|
||||||
virtual PRBool ResumeParse()=0;
|
virtual PRBool ResumeParse()=0;
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче