new contentsink api's for kipp
git-svn-id: svn://10.0.0.236/trunk@1243 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -127,6 +127,11 @@ public:
|
||||
// Called for text, comments and so on...
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode);
|
||||
|
||||
virtual void WillBuildModel(void);
|
||||
virtual void DidBuildModel(void);
|
||||
virtual void WillInterrupt(void);
|
||||
virtual void WillResume(void);
|
||||
|
||||
protected:
|
||||
|
||||
void StartLayout();
|
||||
@@ -1292,6 +1297,43 @@ nsresult HTMLContentSink::ProcessWBRTag(nsIHTMLContent** aInstancePtrResult,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::DidBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillInterrupt(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillResume(void) {
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult NS_NewHTMLContentSink(nsIHTMLContentSink** aInstancePtrResult,
|
||||
|
||||
@@ -426,5 +426,41 @@ PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::DidBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillInterrupt(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillResume(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -115,6 +115,40 @@ class nsHTMLContentSink : public nsIHTMLContentSink {
|
||||
virtual PRBool CloseTopmostContainer();
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillInterrupt(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void);
|
||||
|
||||
|
||||
PRInt32 NodeAt(PRInt32 aPos) {return mNodeStack[aPos];}
|
||||
PRInt32 TopNode() {return mNodeStack[mNodeStackPos-1];}
|
||||
PRInt32 GetStackPos() {return mNodeStackPos;}
|
||||
|
||||
@@ -516,15 +516,19 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL,eParseMode aMode){
|
||||
mDTD->SetParser(this);
|
||||
mTokenizer=new CTokenizer(aURL, theDelegate, mParseMode);
|
||||
|
||||
mSink->WillBuildModel();
|
||||
#ifdef __INCREMENTAL
|
||||
int iter=-1;
|
||||
for(;;){
|
||||
mSink->WillResume();
|
||||
mTokenizer->TokenizeAvailable(++iter);
|
||||
mSink->WillInterrupt();
|
||||
}
|
||||
#else
|
||||
mTokenizer->Tokenize();
|
||||
#endif
|
||||
result=IterateTokens();
|
||||
mSink->DidBuildModel();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -541,6 +545,11 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL,eParseMode aMode){
|
||||
* @return PR_TRUE if parsing concluded successfully.
|
||||
*/
|
||||
PRBool nsHTMLParser::ResumeParse() {
|
||||
mSink->WillResume();
|
||||
int iter=0;
|
||||
PRInt32 errcode=mTokenizer->TokenizeAvailable(iter);
|
||||
if(kInterrupted==errcode)
|
||||
mSink->WillInterrupt();
|
||||
PRBool result=IterateTokens();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -41,44 +41,79 @@
|
||||
class nsIContentSink : public nsISupports {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This method is used to open a generic container in the sink.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
|
||||
/**
|
||||
* This method is used to open a generic container in the sink.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called by the parser when a close
|
||||
* container tag has been consumed and needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
|
||||
/**
|
||||
* This method gets called by the parser when a close
|
||||
* container tag has been consumed and needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called by the parser when a the
|
||||
* topmost container in the content sink needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseTopmostContainer() = 0;
|
||||
/**
|
||||
* This method gets called by the parser when a the
|
||||
* topmost container in the content sink needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseTopmostContainer() = 0;
|
||||
|
||||
/**
|
||||
* This gets called by the parser when you want to add
|
||||
* a leaf node to the current container in the content
|
||||
* model.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
|
||||
virtual void WillInterrupt(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void)=0;
|
||||
|
||||
/**
|
||||
* This gets called by the parser when you want to add
|
||||
* a leaf node to the current container in the content
|
||||
* model.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult);
|
||||
|
||||
@@ -213,6 +213,39 @@ class nsIHTMLContentSink : public nsIContentSink {
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillInterrupt(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void)=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,34 +40,35 @@ enum eParseMode {
|
||||
eParseMode_other
|
||||
};
|
||||
|
||||
const PRInt32 kEOF = 1000000L;
|
||||
const PRInt32 kNotFound = -1;
|
||||
const PRInt32 kNoError = 0;
|
||||
const PRInt32 kEOF = 1000000L;
|
||||
const PRInt32 kInterrupted = 2;
|
||||
|
||||
const PRUint32 kNewLine = '\n';
|
||||
const PRUint32 kCR = '\r';
|
||||
const PRUint32 kLF = '\n';
|
||||
const PRUint32 kCR = '\r';
|
||||
const PRUint32 kLF = '\n';
|
||||
const PRUint32 kTab = '\t';
|
||||
const PRUint32 kSpace = ' ';
|
||||
const PRUint32 kQuote = '"';
|
||||
const PRUint32 kApostrophe = '\'';
|
||||
const PRUint32 kLessThan = '<';
|
||||
const PRUint32 kLessThan = '<';
|
||||
const PRUint32 kGreaterThan = '>';
|
||||
const PRUint32 kAmpersand = '&';
|
||||
const PRUint32 kForwardSlash = '/';
|
||||
const PRUint32 kForwardSlash = '/';
|
||||
const PRUint32 kEqual = '=';
|
||||
const PRUint32 kMinus = '-';
|
||||
const PRUint32 kPlus = '+';
|
||||
const PRUint32 kExclamation = '!';
|
||||
const PRUint32 kSemicolon = ';';
|
||||
const PRUint32 kHashsign = '#';
|
||||
const PRUint32 kAsterisk = '*';
|
||||
const PRUint32 kUnderbar = '_';
|
||||
const PRUint32 kHashsign = '#';
|
||||
const PRUint32 kAsterisk = '*';
|
||||
const PRUint32 kUnderbar = '_';
|
||||
const PRUint32 kComma = ',';
|
||||
const PRUint32 kLeftParen = '(';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -145,9 +145,9 @@ PRInt32 CTokenizer::TokenizeAvailable(int anIteration) {
|
||||
CToken* theToken=0;
|
||||
PRInt32 result=kNoError;
|
||||
PRBool done=(0==anIteration) ? (!WillTokenize(PR_TRUE)) : PR_FALSE;
|
||||
PRBool moreData=PR_TRUE;
|
||||
|
||||
|
||||
while((PR_FALSE==done) && (PR_TRUE==moreData)) {
|
||||
while((PR_FALSE==done) && (kInterrupted!=kInterrupted)) {
|
||||
result=GetToken(theToken);
|
||||
if(theToken) {
|
||||
if(mDelegate->WillAddToken(*theToken)) {
|
||||
@@ -156,7 +156,7 @@ PRInt32 CTokenizer::TokenizeAvailable(int anIteration) {
|
||||
}
|
||||
else done=PR_TRUE;
|
||||
}
|
||||
if((PR_TRUE==done) && (PR_FALSE==moreData))
|
||||
if((PR_TRUE==done) && (kInterrupted!=result))
|
||||
DidTokenize(PR_TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class CTokenizer {
|
||||
*/
|
||||
PRBool DidTokenize(PRBool aIncremental);
|
||||
|
||||
ITokenizerDelegate* mDelegate;
|
||||
ITokenizerDelegate* mDelegate;
|
||||
CScanner* mScanner;
|
||||
nsDeque mTokenDeque;
|
||||
eParseMode mParseMode;
|
||||
|
||||
@@ -127,6 +127,11 @@ public:
|
||||
// Called for text, comments and so on...
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode);
|
||||
|
||||
virtual void WillBuildModel(void);
|
||||
virtual void DidBuildModel(void);
|
||||
virtual void WillInterrupt(void);
|
||||
virtual void WillResume(void);
|
||||
|
||||
protected:
|
||||
|
||||
void StartLayout();
|
||||
@@ -1292,6 +1297,43 @@ nsresult HTMLContentSink::ProcessWBRTag(nsIHTMLContent** aInstancePtrResult,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::DidBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillInterrupt(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void HTMLContentSink::WillResume(void) {
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult NS_NewHTMLContentSink(nsIHTMLContentSink** aInstancePtrResult,
|
||||
|
||||
@@ -426,5 +426,41 @@ PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::DidBuildModel(void){
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillInterrupt(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
void nsHTMLContentSink::WillResume(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -115,6 +115,40 @@ class nsHTMLContentSink : public nsIHTMLContentSink {
|
||||
virtual PRBool CloseTopmostContainer();
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillInterrupt(void);
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void);
|
||||
|
||||
|
||||
PRInt32 NodeAt(PRInt32 aPos) {return mNodeStack[aPos];}
|
||||
PRInt32 TopNode() {return mNodeStack[mNodeStackPos-1];}
|
||||
PRInt32 GetStackPos() {return mNodeStackPos;}
|
||||
|
||||
@@ -516,15 +516,19 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL,eParseMode aMode){
|
||||
mDTD->SetParser(this);
|
||||
mTokenizer=new CTokenizer(aURL, theDelegate, mParseMode);
|
||||
|
||||
mSink->WillBuildModel();
|
||||
#ifdef __INCREMENTAL
|
||||
int iter=-1;
|
||||
for(;;){
|
||||
mSink->WillResume();
|
||||
mTokenizer->TokenizeAvailable(++iter);
|
||||
mSink->WillInterrupt();
|
||||
}
|
||||
#else
|
||||
mTokenizer->Tokenize();
|
||||
#endif
|
||||
result=IterateTokens();
|
||||
mSink->DidBuildModel();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -541,6 +545,11 @@ PRBool nsHTMLParser::Parse(nsIURL* aURL,eParseMode aMode){
|
||||
* @return PR_TRUE if parsing concluded successfully.
|
||||
*/
|
||||
PRBool nsHTMLParser::ResumeParse() {
|
||||
mSink->WillResume();
|
||||
int iter=0;
|
||||
PRInt32 errcode=mTokenizer->TokenizeAvailable(iter);
|
||||
if(kInterrupted==errcode)
|
||||
mSink->WillInterrupt();
|
||||
PRBool result=IterateTokens();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -41,44 +41,79 @@
|
||||
class nsIContentSink : public nsISupports {
|
||||
public:
|
||||
|
||||
/**
|
||||
* This method is used to open a generic container in the sink.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
|
||||
/**
|
||||
* This method is used to open a generic container in the sink.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool OpenContainer(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called by the parser when a close
|
||||
* container tag has been consumed and needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
|
||||
/**
|
||||
* This method gets called by the parser when a close
|
||||
* container tag has been consumed and needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseContainer(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called by the parser when a the
|
||||
* topmost container in the content sink needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseTopmostContainer() = 0;
|
||||
/**
|
||||
* This method gets called by the parser when a the
|
||||
* topmost container in the content sink needs to be closed.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool CloseTopmostContainer() = 0;
|
||||
|
||||
/**
|
||||
* This gets called by the parser when you want to add
|
||||
* a leaf node to the current container in the content
|
||||
* model.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
|
||||
virtual void WillInterrupt(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void)=0;
|
||||
|
||||
/**
|
||||
* This gets called by the parser when you want to add
|
||||
* a leaf node to the current container in the content
|
||||
* model.
|
||||
*
|
||||
* @update 4/1/98 gess
|
||||
* @param nsIParserNode reference to parser node interface
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult);
|
||||
|
||||
@@ -213,6 +213,39 @@ class nsIHTMLContentSink : public nsIContentSink {
|
||||
* @return PR_TRUE if successful.
|
||||
*/
|
||||
virtual PRBool AddLeaf(const nsIParserNode& aNode)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser begins the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser concludes the process
|
||||
* of building the content model via the content sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void DidBuildModel(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser gets i/o blocked,
|
||||
* and wants to notify the sink that it may be a while before
|
||||
* more data is available.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillInterrupt(void)=0;
|
||||
|
||||
/**
|
||||
* This method gets called when the parser i/o gets unblocked,
|
||||
* and we're about to start dumping content again to the sink.
|
||||
*
|
||||
* @update 5/7/98 gess
|
||||
*/
|
||||
virtual void WillResume(void)=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,34 +40,35 @@ enum eParseMode {
|
||||
eParseMode_other
|
||||
};
|
||||
|
||||
const PRInt32 kEOF = 1000000L;
|
||||
const PRInt32 kNotFound = -1;
|
||||
const PRInt32 kNoError = 0;
|
||||
const PRInt32 kEOF = 1000000L;
|
||||
const PRInt32 kInterrupted = 2;
|
||||
|
||||
const PRUint32 kNewLine = '\n';
|
||||
const PRUint32 kCR = '\r';
|
||||
const PRUint32 kLF = '\n';
|
||||
const PRUint32 kCR = '\r';
|
||||
const PRUint32 kLF = '\n';
|
||||
const PRUint32 kTab = '\t';
|
||||
const PRUint32 kSpace = ' ';
|
||||
const PRUint32 kQuote = '"';
|
||||
const PRUint32 kApostrophe = '\'';
|
||||
const PRUint32 kLessThan = '<';
|
||||
const PRUint32 kLessThan = '<';
|
||||
const PRUint32 kGreaterThan = '>';
|
||||
const PRUint32 kAmpersand = '&';
|
||||
const PRUint32 kForwardSlash = '/';
|
||||
const PRUint32 kForwardSlash = '/';
|
||||
const PRUint32 kEqual = '=';
|
||||
const PRUint32 kMinus = '-';
|
||||
const PRUint32 kPlus = '+';
|
||||
const PRUint32 kExclamation = '!';
|
||||
const PRUint32 kSemicolon = ';';
|
||||
const PRUint32 kHashsign = '#';
|
||||
const PRUint32 kAsterisk = '*';
|
||||
const PRUint32 kUnderbar = '_';
|
||||
const PRUint32 kHashsign = '#';
|
||||
const PRUint32 kAsterisk = '*';
|
||||
const PRUint32 kUnderbar = '_';
|
||||
const PRUint32 kComma = ',';
|
||||
const PRUint32 kLeftParen = '(';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -145,9 +145,9 @@ PRInt32 CTokenizer::TokenizeAvailable(int anIteration) {
|
||||
CToken* theToken=0;
|
||||
PRInt32 result=kNoError;
|
||||
PRBool done=(0==anIteration) ? (!WillTokenize(PR_TRUE)) : PR_FALSE;
|
||||
PRBool moreData=PR_TRUE;
|
||||
|
||||
|
||||
while((PR_FALSE==done) && (PR_TRUE==moreData)) {
|
||||
while((PR_FALSE==done) && (kInterrupted!=kInterrupted)) {
|
||||
result=GetToken(theToken);
|
||||
if(theToken) {
|
||||
if(mDelegate->WillAddToken(*theToken)) {
|
||||
@@ -156,7 +156,7 @@ PRInt32 CTokenizer::TokenizeAvailable(int anIteration) {
|
||||
}
|
||||
else done=PR_TRUE;
|
||||
}
|
||||
if((PR_TRUE==done) && (PR_FALSE==moreData))
|
||||
if((PR_TRUE==done) && (kInterrupted!=result))
|
||||
DidTokenize(PR_TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class CTokenizer {
|
||||
*/
|
||||
PRBool DidTokenize(PRBool aIncremental);
|
||||
|
||||
ITokenizerDelegate* mDelegate;
|
||||
ITokenizerDelegate* mDelegate;
|
||||
CScanner* mScanner;
|
||||
nsDeque mTokenDeque;
|
||||
eParseMode mParseMode;
|
||||
|
||||
Reference in New Issue
Block a user