diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp
index dd5cfc470acc..715d3704aec9 100644
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -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,
diff --git a/htmlparser/src/nsHTMLContentSink.cpp b/htmlparser/src/nsHTMLContentSink.cpp
index 511ec3b90665..0fdc9911d6b3 100644
--- a/htmlparser/src/nsHTMLContentSink.cpp
+++ b/htmlparser/src/nsHTMLContentSink.cpp
@@ -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) {
+}
diff --git a/htmlparser/src/nsHTMLContentSink.h b/htmlparser/src/nsHTMLContentSink.h
index acf8e99b1c9e..c445934760d7 100644
--- a/htmlparser/src/nsHTMLContentSink.h
+++ b/htmlparser/src/nsHTMLContentSink.h
@@ -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;}
diff --git a/htmlparser/src/nsHTMLParser.cpp b/htmlparser/src/nsHTMLParser.cpp
index ae804a8f24ea..1ae4b440993b 100644
--- a/htmlparser/src/nsHTMLParser.cpp
+++ b/htmlparser/src/nsHTMLParser.cpp
@@ -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;
}
diff --git a/htmlparser/src/nsIContentSink.h b/htmlparser/src/nsIContentSink.h
index 0965108a0e2a..d5df0f037248 100644
--- a/htmlparser/src/nsIContentSink.h
+++ b/htmlparser/src/nsIContentSink.h
@@ -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);
diff --git a/htmlparser/src/nsIHTMLContentSink.h b/htmlparser/src/nsIHTMLContentSink.h
index 6a238b0eb3b6..9359dfbcffb4 100644
--- a/htmlparser/src/nsIHTMLContentSink.h
+++ b/htmlparser/src/nsIHTMLContentSink.h
@@ -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;
};
diff --git a/htmlparser/src/nsParserTypes.h b/htmlparser/src/nsParserTypes.h
index b38ac6edb814..660076e441e9 100644
--- a/htmlparser/src/nsParserTypes.h
+++ b/htmlparser/src/nsParserTypes.h
@@ -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
diff --git a/htmlparser/src/nsTokenizer.cpp b/htmlparser/src/nsTokenizer.cpp
index 2868f217bc1f..0cbf3079016a 100644
--- a/htmlparser/src/nsTokenizer.cpp
+++ b/htmlparser/src/nsTokenizer.cpp
@@ -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;
}
diff --git a/htmlparser/src/nsTokenizer.h b/htmlparser/src/nsTokenizer.h
index bd725f8ee4a7..bfb4324d16b8 100644
--- a/htmlparser/src/nsTokenizer.h
+++ b/htmlparser/src/nsTokenizer.h
@@ -147,7 +147,7 @@ class CTokenizer {
*/
PRBool DidTokenize(PRBool aIncremental);
- ITokenizerDelegate* mDelegate;
+ ITokenizerDelegate* mDelegate;
CScanner* mScanner;
nsDeque mTokenDeque;
eParseMode mParseMode;
diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp
index dd5cfc470acc..715d3704aec9 100644
--- a/layout/html/document/src/nsHTMLContentSink.cpp
+++ b/layout/html/document/src/nsHTMLContentSink.cpp
@@ -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,
diff --git a/parser/htmlparser/src/nsHTMLContentSink.cpp b/parser/htmlparser/src/nsHTMLContentSink.cpp
index 511ec3b90665..0fdc9911d6b3 100644
--- a/parser/htmlparser/src/nsHTMLContentSink.cpp
+++ b/parser/htmlparser/src/nsHTMLContentSink.cpp
@@ -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) {
+}
diff --git a/parser/htmlparser/src/nsHTMLContentSink.h b/parser/htmlparser/src/nsHTMLContentSink.h
index acf8e99b1c9e..c445934760d7 100644
--- a/parser/htmlparser/src/nsHTMLContentSink.h
+++ b/parser/htmlparser/src/nsHTMLContentSink.h
@@ -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;}
diff --git a/parser/htmlparser/src/nsHTMLParser.cpp b/parser/htmlparser/src/nsHTMLParser.cpp
index ae804a8f24ea..1ae4b440993b 100644
--- a/parser/htmlparser/src/nsHTMLParser.cpp
+++ b/parser/htmlparser/src/nsHTMLParser.cpp
@@ -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;
}
diff --git a/parser/htmlparser/src/nsIContentSink.h b/parser/htmlparser/src/nsIContentSink.h
index 0965108a0e2a..d5df0f037248 100644
--- a/parser/htmlparser/src/nsIContentSink.h
+++ b/parser/htmlparser/src/nsIContentSink.h
@@ -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);
diff --git a/parser/htmlparser/src/nsIHTMLContentSink.h b/parser/htmlparser/src/nsIHTMLContentSink.h
index 6a238b0eb3b6..9359dfbcffb4 100644
--- a/parser/htmlparser/src/nsIHTMLContentSink.h
+++ b/parser/htmlparser/src/nsIHTMLContentSink.h
@@ -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;
};
diff --git a/parser/htmlparser/src/nsParserTypes.h b/parser/htmlparser/src/nsParserTypes.h
index b38ac6edb814..660076e441e9 100644
--- a/parser/htmlparser/src/nsParserTypes.h
+++ b/parser/htmlparser/src/nsParserTypes.h
@@ -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
diff --git a/parser/htmlparser/src/nsTokenizer.cpp b/parser/htmlparser/src/nsTokenizer.cpp
index 2868f217bc1f..0cbf3079016a 100644
--- a/parser/htmlparser/src/nsTokenizer.cpp
+++ b/parser/htmlparser/src/nsTokenizer.cpp
@@ -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;
}
diff --git a/parser/htmlparser/src/nsTokenizer.h b/parser/htmlparser/src/nsTokenizer.h
index bd725f8ee4a7..bfb4324d16b8 100644
--- a/parser/htmlparser/src/nsTokenizer.h
+++ b/parser/htmlparser/src/nsTokenizer.h
@@ -147,7 +147,7 @@ class CTokenizer {
*/
PRBool DidTokenize(PRBool aIncremental);
- ITokenizerDelegate* mDelegate;
+ ITokenizerDelegate* mDelegate;
CScanner* mScanner;
nsDeque mTokenDeque;
eParseMode mParseMode;