propagation is now online, aren't DTD's cool?
git-svn-id: svn://10.0.0.236/trunk@670 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -33,7 +33,7 @@ static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||
static NS_DEFINE_IID(kClassIID, NS_INAVHTML_DTD_IID);
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* This method gets called as part of our COM-like interfaces.
|
||||
* Its purpose is to create an interface to parser object
|
||||
* of some type.
|
||||
@@ -42,7 +42,7 @@ static NS_DEFINE_IID(kClassIID, NS_INAVHTML_DTD_IID);
|
||||
* @param nsIID id of object to discover
|
||||
* @param aInstancePtr ptr to newly discovered interface
|
||||
* @return NS_xxx result code
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
nsresult CNavDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
@@ -66,14 +66,14 @@ nsresult CNavDTD::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 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();
|
||||
@@ -90,27 +90,28 @@ NS_IMPL_ADDREF(CNavDTD)
|
||||
NS_IMPL_RELEASE(CNavDTD)
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
CNavDTD::CNavDTD() : nsIDTD() {
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* Default destructor
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
CNavDTD::~CNavDTD(){
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -118,11 +119,11 @@ CNavDTD::~CNavDTD(){
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
//tagset1 has 61 members...
|
||||
//tagset1 has 64 members...
|
||||
static char gTagSet1[]={
|
||||
eHTMLTag_a, eHTMLTag_acronym, eHTMLTag_address, eHTMLTag_applet,
|
||||
eHTMLTag_bold, eHTMLTag_basefont, eHTMLTag_bdo, eHTMLTag_big,
|
||||
@@ -132,29 +133,39 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
eHTMLTag_font, eHTMLTag_form, eHTMLTag_h1, eHTMLTag_h2,
|
||||
eHTMLTag_h3, eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6,
|
||||
eHTMLTag_hr, eHTMLTag_italic, eHTMLTag_iframe, eHTMLTag_img,
|
||||
eHTMLTag_input, eHTMLTag_isindex, eHTMLTag_kbd, eHTMLTag_label,
|
||||
eHTMLTag_map, eHTMLTag_menu, eHTMLTag_noframes, eHTMLTag_noscript,
|
||||
eHTMLTag_input, eHTMLTag_isindex,
|
||||
|
||||
eHTMLTag_kbd, eHTMLTag_label,
|
||||
eHTMLTag_map, eHTMLTag_menu, eHTMLTag_newline, //JUST ADDED!
|
||||
eHTMLTag_noframes, eHTMLTag_noscript,
|
||||
eHTMLTag_object, eHTMLTag_ol, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_table, eHTMLTag_textarea,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_ul, eHTMLTag_userdefined,
|
||||
eHTMLTag_var, 0};
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_table, eHTMLTag_text,
|
||||
|
||||
eHTMLTag_textarea, eHTMLTag_tt, eHTMLTag_u, eHTMLTag_ul,
|
||||
eHTMLTag_userdefined, eHTMLTag_var,
|
||||
eHTMLTag_whitespace, //JUST ADDED!
|
||||
0};
|
||||
|
||||
//tagset2 has 37 members...
|
||||
//tagset2 has 43 members...
|
||||
static char gTagSet2[]={
|
||||
eHTMLTag_a, eHTMLTag_acronym, eHTMLTag_applet, eHTMLTag_bold,
|
||||
eHTMLTag_basefont, eHTMLTag_bdo, eHTMLTag_big, eHTMLTag_br,
|
||||
eHTMLTag_button, eHTMLTag_cite, eHTMLTag_code, eHTMLTag_dfn,
|
||||
eHTMLTag_em, eHTMLTag_font, eHTMLTag_hr, eHTMLTag_italic,
|
||||
eHTMLTag_iframe, eHTMLTag_img, eHTMLTag_input, eHTMLTag_kbd,
|
||||
eHTMLTag_label, eHTMLTag_map, eHTMLTag_object, eHTMLTag_paragraph,
|
||||
|
||||
eHTMLTag_label, eHTMLTag_map, eHTMLTag_newline, //JUST ADDED!
|
||||
eHTMLTag_object, eHTMLTag_paragraph,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_script,
|
||||
eHTMLTag_select, eHTMLTag_small, eHTMLTag_span, eHTMLTag_strong,
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_tt, eHTMLTag_textarea,
|
||||
eHTMLTag_u, eHTMLTag_var,0};
|
||||
eHTMLTag_sub, eHTMLTag_sup, eHTMLTag_text, eHTMLTag_textarea,
|
||||
eHTMLTag_tt, eHTMLTag_u, eHTMLTag_userdefined, eHTMLTag_var,
|
||||
eHTMLTag_whitespace,//JUST ADDED!
|
||||
0};
|
||||
|
||||
//tagset3 has 53 members...
|
||||
//tagset3 has 57 members...
|
||||
static char gTagSet3[]={
|
||||
eHTMLTag_a, eHTMLTag_acronym, eHTMLTag_applet, eHTMLTag_bold,
|
||||
eHTMLTag_bdo, eHTMLTag_big, eHTMLTag_br, eHTMLTag_blockquote,
|
||||
@@ -164,12 +175,19 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
eHTMLTag_font, eHTMLTag_form, eHTMLTag_h1, eHTMLTag_h2,
|
||||
eHTMLTag_h3, eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6,
|
||||
eHTMLTag_italic, eHTMLTag_iframe, eHTMLTag_ins, eHTMLTag_kbd,
|
||||
eHTMLTag_label, eHTMLTag_legend, eHTMLTag_listitem, eHTMLTag_noframes,
|
||||
|
||||
eHTMLTag_label, eHTMLTag_legend,
|
||||
eHTMLTag_listitem, eHTMLTag_newline, //JUST ADDED!
|
||||
|
||||
eHTMLTag_noframes,
|
||||
eHTMLTag_noscript, eHTMLTag_object, eHTMLTag_paragraph, eHTMLTag_pre,
|
||||
eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp, eHTMLTag_small,
|
||||
eHTMLTag_span, eHTMLTag_strong, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_td, eHTMLTag_th, eHTMLTag_tt, eHTMLTag_u,
|
||||
eHTMLTag_var,0};
|
||||
eHTMLTag_td, eHTMLTag_text,
|
||||
|
||||
eHTMLTag_th, eHTMLTag_tt, eHTMLTag_u, eHTMLTag_userdefined,
|
||||
eHTMLTag_var, eHTMLTag_whitespace, //JUST ADDED!
|
||||
0};
|
||||
|
||||
//This hack code is here because we don't yet know what to do
|
||||
//with userdefined tags... XXX Hack
|
||||
@@ -295,7 +313,7 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_hr:
|
||||
case eHTMLTag_hr:
|
||||
break; //singletons can't contain anything...
|
||||
|
||||
case eHTMLTag_html:
|
||||
@@ -431,11 +449,19 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
case eHTMLTag_thead:
|
||||
result=PRBool(eHTMLTag_tr==aChild); break;
|
||||
|
||||
case eHTMLTag_td:
|
||||
case eHTMLTag_th:
|
||||
result=PRBool(0!=strchr(gTagSet1,aChild));
|
||||
break;
|
||||
|
||||
case eHTMLTag_td:
|
||||
{
|
||||
static char extraTags[]={eHTMLTag_newline,0};
|
||||
result=PRBool(0!=strchr(extraTags,aChild));
|
||||
if(PR_FALSE==result)
|
||||
result=PRBool(0!=strchr(gTagSet1,aChild));
|
||||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_textarea:
|
||||
case eHTMLTag_title:
|
||||
break; //nothing but plain text...
|
||||
@@ -465,7 +491,7 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -473,7 +499,7 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool CNavDTD::CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -511,22 +537,28 @@ PRBool CNavDTD::CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
switch((eHTMLTags)aParent) {
|
||||
case eHTMLTag_html:
|
||||
case eHTMLTag_body:
|
||||
case eHTMLTag_head:
|
||||
case eHTMLTag_title:
|
||||
|
||||
case eHTMLTag_tr:
|
||||
// case eHTMLTag_td:
|
||||
case eHTMLTag_table:
|
||||
case eHTMLTag_thead:
|
||||
case eHTMLTag_tfoot:
|
||||
case eHTMLTag_tfoot:
|
||||
case eHTMLTag_tbody:
|
||||
case eHTMLTag_col:
|
||||
case eHTMLTag_colgroup:
|
||||
@@ -542,14 +574,14 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -566,6 +598,9 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
|
||||
case eHTMLTag_style: case eHTMLTag_spacer:
|
||||
case eHTMLTag_wbr:
|
||||
case eHTMLTag_form:
|
||||
case eHTMLTag_newline:
|
||||
case eHTMLTag_whitespace:
|
||||
case eHTMLTag_text:
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
|
||||
@@ -575,17 +610,21 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
/**
|
||||
* This method does two things: 1st, help construct
|
||||
* our own internal model of the content-stack; and
|
||||
* 2nd, pass this message on to the sink.
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aNode -- next node to be added to model
|
||||
* @return TRUE if ok, FALSE if error
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
PRInt32 CNavDTD::GetDefaultParentTagFor(PRInt32 aTag) const{
|
||||
eHTMLTags result=eHTMLTag_unknown;
|
||||
switch(aTag) {
|
||||
|
||||
case eHTMLTag_text:
|
||||
result=eHTMLTag_paragraph; break;
|
||||
|
||||
case eHTMLTag_html:
|
||||
result=(eHTMLTags)kNotFound; break;
|
||||
|
||||
@@ -610,9 +649,11 @@ PRInt32 CNavDTD::GetDefaultParentTagFor(PRInt32 aTag) const{
|
||||
case eHTMLTag_tbody:
|
||||
case eHTMLTag_tfoot:
|
||||
case eHTMLTag_thead:
|
||||
case eHTMLTag_tr:
|
||||
result=eHTMLTag_table; break;
|
||||
|
||||
case eHTMLTag_tr:
|
||||
result=eHTMLTag_tbody; break;
|
||||
|
||||
case eHTMLTag_td:
|
||||
case eHTMLTag_th:
|
||||
result=eHTMLTag_tr; break;
|
||||
@@ -651,17 +692,17 @@ PRInt32 CNavDTD::GetDefaultParentTagFor(PRInt32 aTag) const{
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method gets called at various times by the parser
|
||||
* whenever we want to verify a valid context stack. This
|
||||
* method also gives us a hook to add debugging metrics.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aStack[] array of ints (tokens)
|
||||
* @param aCount number of elements in given array
|
||||
* @return TRUE if stack is valid, else FALSE
|
||||
*/ //-----------------------------------------------------
|
||||
PRBool CNavDTD::VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const {
|
||||
*/
|
||||
PRBool CNavDTD::VerifyContextVector(PRInt32* aVector,PRInt32 aCount) const {
|
||||
PRBool result=PR_TRUE;
|
||||
|
||||
if(aCount>0) {
|
||||
@@ -671,34 +712,73 @@ PRBool CNavDTD::VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const {
|
||||
}
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* This method tries to design a context map (without actually
|
||||
/**
|
||||
* This method tries to design a context vector (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aVector is the string where we store our output vector
|
||||
* in bottom-up order.
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
PRInt32 CNavDTD::ForwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRInt32 result=0;
|
||||
* @return TRUE if propagation closes; false otherwise
|
||||
*/
|
||||
PRBool CNavDTD::ForwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
switch(aParentTag) {
|
||||
case eHTMLTag_table:
|
||||
case eHTMLTag_tr:
|
||||
if(PR_TRUE==CanContain(eHTMLTag_td,aChildTag)) {
|
||||
aVector.Append((PRUnichar)eHTMLTag_td);
|
||||
result=BackwardPropagate(aVector,aParentTag,eHTMLTag_td);
|
||||
// result=PR_TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case eHTMLTag_th:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}//switch
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aVector is the string where we store our output vector
|
||||
* in bottom-up order.
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
PRInt32 CNavDTD::BackwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRInt32 result=0;
|
||||
return result;
|
||||
* @return TRUE if propagation closes; false otherwise
|
||||
*/
|
||||
PRBool CNavDTD::BackwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const {
|
||||
|
||||
PRBool result=PR_FALSE;
|
||||
eHTMLTags theParentTag=(eHTMLTags)aChildTag;
|
||||
|
||||
// aVector.Truncate();
|
||||
|
||||
//create the necessary stack of parent tags...
|
||||
//continue your search until you run out of known parents,
|
||||
//or you find the specific parent you were given (aParentTag).
|
||||
// aVector.Append((PRUnichar)aChildTag);
|
||||
do {
|
||||
theParentTag=(eHTMLTags)GetDefaultParentTagFor(theParentTag);
|
||||
if(theParentTag!=kNotFound) {
|
||||
aVector.Append((PRUnichar)theParentTag);
|
||||
}
|
||||
} while((theParentTag!=kNotFound) && (theParentTag!=aParentTag));
|
||||
|
||||
return PRBool(aParentTag==theParentTag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
class CNavDTD : public nsIDTD {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -108,7 +108,7 @@ class CNavDTD : public nsIDTD {
|
||||
* This method does two things: 1st, help construct
|
||||
* our own internal model of the content-stack; and
|
||||
* 2nd, pass this message on to the sink.
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aNode -- next node to be added to model
|
||||
* @return TRUE if ok, FALSE if error
|
||||
*/
|
||||
@@ -120,40 +120,40 @@ class CNavDTD : public nsIDTD {
|
||||
* whenever we want to verify a valid context stack. This
|
||||
* method also gives us a hook to add debugging metrics.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aStack[] array of ints (tokens)
|
||||
* @param aCount number of elements in given array
|
||||
* @return TRUE if stack is valid, else FALSE
|
||||
*/
|
||||
virtual PRBool VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const;
|
||||
virtual PRBool VerifyContextVector(PRInt32* aVector,PRInt32 aCount) const;
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRInt32 ForwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const;
|
||||
virtual PRBool ForwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const;
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRInt32 BackwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const;
|
||||
virtual PRBool BackwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ static char gIdentChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY
|
||||
* @return
|
||||
*/
|
||||
CNavDelegate::CNavDelegate() :
|
||||
ITokenizerDelegate(), mTokenDeque() {
|
||||
ITokenizerDelegate(), mTokenDeque() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ CNavDelegate::CNavDelegate(CNavDelegate& aDelegate) :
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess4/11/98
|
||||
* @update gess4/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ eParseMode CNavDelegate::GetParseMode() const {
|
||||
/**
|
||||
* Cause delegate to create and return a new DTD.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @update gess4/22/98
|
||||
* @return new DTD or null
|
||||
*/
|
||||
nsIDTD* CNavDelegate::GetDTD(void) const{
|
||||
@@ -86,7 +86,7 @@ nsIDTD* CNavDelegate::GetDTD(void) const{
|
||||
* @return
|
||||
*/
|
||||
CToken* CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
CToken* result=0;
|
||||
CToken* result=0;
|
||||
nsAutoString empty("");
|
||||
anErrorCode=anErrorCode=aScanner.GetChar(aChar);
|
||||
|
||||
@@ -130,19 +130,19 @@ CToken* CNavDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anE
|
||||
* @return
|
||||
*/
|
||||
void CNavDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
PRBool done=PR_FALSE;
|
||||
PRBool done=PR_FALSE;
|
||||
nsAutoString as("");
|
||||
anErrorCode=kNoError;
|
||||
while((!done) && (anErrorCode==kNoError)) {
|
||||
CToken* result = new CAttributeToken(as);
|
||||
CToken* result = new CAttributeToken(as);
|
||||
if(result){
|
||||
anErrorCode= result->Consume(aChar,aScanner); //tell new token to finish consuming text...
|
||||
mTokenDeque.Push(result);
|
||||
}
|
||||
aScanner.Peek(aChar);
|
||||
aScanner.Peek(aChar);
|
||||
if(aChar==kGreaterThan) { //you just ate the '>'
|
||||
aScanner.GetChar(aChar); //skip the '>'
|
||||
done=PR_TRUE;
|
||||
aScanner.GetChar(aChar); //skip the '>'
|
||||
done=PR_TRUE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -181,7 +181,7 @@ CToken* CNavDelegate::ConsumeContentToEndTag(const nsString& aString,PRUnichar a
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* CNavDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
CStartToken* result=new CStartToken(nsAutoString(""));
|
||||
CStartToken* result=new CStartToken(nsAutoString(""));
|
||||
if(result) {
|
||||
anErrorCode= result->Consume(aChar,aScanner); //tell new token to finish consuming text...
|
||||
if(result->IsAttributed()) {
|
||||
@@ -292,7 +292,7 @@ CToken* CNavDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,PRI
|
||||
CToken* result=new CTextToken(aString);
|
||||
if(result) {
|
||||
PRUnichar ch;
|
||||
anErrorCode=result->Consume(ch,aScanner);
|
||||
anErrorCode=result->Consume(ch,aScanner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -307,9 +307,9 @@ CToken* CNavDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,PRI
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* CNavDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode){
|
||||
CToken* result=new CNewlineToken(nsAutoString(""));
|
||||
CToken* result=new CNewlineToken(nsAutoString(""));
|
||||
if(result) {
|
||||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -327,15 +327,15 @@ CToken* CNavDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32&
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* CNavDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode){
|
||||
CToken* result=0;
|
||||
CToken* result=0;
|
||||
PRUnichar aChar;
|
||||
|
||||
if(mTokenDeque.GetSize()>0) {
|
||||
return (CToken*)mTokenDeque.Pop();
|
||||
}
|
||||
|
||||
while(!aScanner.Eof()) {
|
||||
anErrorCode=aScanner.GetChar(aChar);
|
||||
while(!aScanner.Eof()) {
|
||||
anErrorCode=aScanner.GetChar(aChar);
|
||||
switch(aChar) {
|
||||
case kAmpersand:
|
||||
return ConsumeEntity(aChar,aScanner,anErrorCode);
|
||||
@@ -356,13 +356,13 @@ CToken* CNavDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode){
|
||||
} //switch
|
||||
if(anErrorCode==kEOF)
|
||||
anErrorCode=0;
|
||||
} //while
|
||||
return result;
|
||||
} //while
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess4/11/98
|
||||
* @update gess4/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@@ -396,8 +396,8 @@ PRBool CNavDelegate::WillAddToken(CToken& /*aToken*/) {
|
||||
* @return TRUE if preinitialization completed successfully
|
||||
*/
|
||||
PRBool CNavDelegate::WillTokenize() {
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,7 +409,7 @@ PRBool CNavDelegate::WillTokenize() {
|
||||
* @return TRUE if preinitialization completed successfully
|
||||
*/
|
||||
PRBool CNavDelegate::DidTokenize() {
|
||||
PRBool result=PR_TRUE;
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -429,3 +429,5 @@ void CNavDelegate::SelfTest(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
* scanner.stream, and produces an HTML specific CToken.
|
||||
*/
|
||||
|
||||
#ifndef _NAV_DELEGATE
|
||||
#define _NAV_DELEGATE
|
||||
#ifndef _NAV_DELEGATE
|
||||
#define _NAV_DELEGATE
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsITokenizerDelegate.h"
|
||||
@@ -45,15 +45,15 @@
|
||||
#include "nsIDTD.h"
|
||||
|
||||
class CNavDelegate : public ITokenizerDelegate {
|
||||
public:
|
||||
CNavDelegate();
|
||||
CNavDelegate(CNavDelegate& aDelegate);
|
||||
public:
|
||||
CNavDelegate();
|
||||
CNavDelegate(CNavDelegate& aDelegate);
|
||||
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual PRBool WillAddToken(CToken& aToken);
|
||||
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
|
||||
virtual eParseMode GetParseMode() const;
|
||||
virtual nsIDTD* GetDTD(void) const;
|
||||
@@ -63,14 +63,14 @@ class CNavDelegate : public ITokenizerDelegate {
|
||||
|
||||
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType);
|
||||
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
|
||||
//the only special case method...
|
||||
virtual CToken* ConsumeContentToEndTag(const nsString& aString,PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
@@ -81,3 +81,5 @@ class CNavDelegate : public ITokenizerDelegate {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static NS_DEFINE_IID(kIDTDIID, NS_IDTD_IID);
|
||||
static NS_DEFINE_IID(kClassIID, NS_IOtherHTML_DTD_IID);
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* This method gets called as part of our COM-like interfaces.
|
||||
* Its purpose is to create an interface to parser object
|
||||
* of some type.
|
||||
@@ -42,7 +42,7 @@ static NS_DEFINE_IID(kClassIID, NS_IOtherHTML_DTD_IID);
|
||||
* @param nsIID id of object to discover
|
||||
* @param aInstancePtr ptr to newly discovered interface
|
||||
* @return NS_xxx result code
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
nsresult COtherDTD::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
@@ -66,14 +66,14 @@ nsresult COtherDTD::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 gess 4/8/98
|
||||
* @param nsIParser** ptr to newly instantiated parser
|
||||
* @return NS_xxx error result
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
NS_HTMLPARS nsresult NS_NewOtherHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
{
|
||||
COtherDTD* it = new COtherDTD();
|
||||
@@ -90,27 +90,27 @@ NS_IMPL_ADDREF(COtherDTD)
|
||||
NS_IMPL_RELEASE(COtherDTD)
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* Default constructor
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
COtherDTD::COtherDTD() : nsIDTD() {
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* Default destructor
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
COtherDTD::~COtherDTD(){
|
||||
}
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -118,7 +118,7 @@ COtherDTD::~COtherDTD(){
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -295,7 +295,7 @@ PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_hr:
|
||||
case eHTMLTag_hr:
|
||||
break; //singletons can't contain anything...
|
||||
|
||||
case eHTMLTag_html:
|
||||
@@ -465,7 +465,7 @@ PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -473,7 +473,7 @@ PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool COtherDTD::CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -511,14 +511,14 @@ PRBool COtherDTD::CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool COtherDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -542,14 +542,14 @@ PRBool COtherDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 4/8/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
PRBool COtherDTD::IsContainer(PRInt32 aTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
@@ -575,14 +575,14 @@ PRBool COtherDTD::IsContainer(PRInt32 aTag) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------
|
||||
/**
|
||||
* This method does two things: 1st, help construct
|
||||
* our own internal model of the content-stack; and
|
||||
* 2nd, pass this message on to the sink.
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aNode -- next node to be added to model
|
||||
* @return TRUE if ok, FALSE if error
|
||||
*------------------------------------------------------*/
|
||||
*/
|
||||
PRInt32 COtherDTD::GetDefaultParentTagFor(PRInt32 aTag) const{
|
||||
eHTMLTags result=eHTMLTag_unknown;
|
||||
switch(aTag) {
|
||||
@@ -651,17 +651,17 @@ PRInt32 COtherDTD::GetDefaultParentTagFor(PRInt32 aTag) const{
|
||||
}
|
||||
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method gets called at various times by the parser
|
||||
* whenever we want to verify a valid context stack. This
|
||||
* method also gives us a hook to add debugging metrics.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aStack[] array of ints (tokens)
|
||||
* @param aCount number of elements in given array
|
||||
* @return TRUE if stack is valid, else FALSE
|
||||
*/ //-----------------------------------------------------
|
||||
PRBool COtherDTD::VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const {
|
||||
*/
|
||||
PRBool COtherDTD::VerifyContextVector(PRInt32* aVector,PRInt32 aCount) const {
|
||||
PRBool result=PR_TRUE;
|
||||
|
||||
if(aCount>0) {
|
||||
@@ -671,35 +671,37 @@ PRBool COtherDTD::VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
PRInt32 COtherDTD::ForwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRInt32 result=0;
|
||||
*/
|
||||
PRBool COtherDTD::ForwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
PRInt32 COtherDTD::BackwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRInt32 result=0;
|
||||
*/
|
||||
PRBool COtherDTD::BackwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const {
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,30 +40,30 @@
|
||||
|
||||
class COtherDTD : public nsIDTD {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //------------------------------------------------------
|
||||
COtherDTD();
|
||||
*/
|
||||
COtherDTD();
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 4/9/98
|
||||
* @param
|
||||
* @return
|
||||
*/ //------------------------------------------------------
|
||||
*/
|
||||
virtual ~COtherDTD();
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -71,10 +71,10 @@ class COtherDTD : public nsIDTD {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -82,79 +82,81 @@ class COtherDTD : public nsIDTD {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanOmit(PRInt32 aParent,PRInt32 aChild)const;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool IsContainer(PRInt32 aTags) const;
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method does two things: 1st, help construct
|
||||
* our own internal model of the content-stack; and
|
||||
* 2nd, pass this message on to the sink.
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aNode -- next node to be added to model
|
||||
* @return TRUE if ok, FALSE if error
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRInt32 GetDefaultParentTagFor(PRInt32 aTag) const;
|
||||
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method gets called at various times by the parser
|
||||
* whenever we want to verify a valid context stack. This
|
||||
* method also gives us a hook to add debugging metrics.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aStack[] array of ints (tokens)
|
||||
* @param aCount number of elements in given array
|
||||
* @return TRUE if stack is valid, else FALSE
|
||||
*/ //-----------------------------------------------------
|
||||
virtual PRBool VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const;
|
||||
*/
|
||||
virtual PRBool VerifyContextVector(PRInt32* aVector,PRInt32 aCount) const;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
virtual ForwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const;
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool ForwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
virtual PRInt32 BackwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const;
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool BackwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ static char gIdentChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY
|
||||
* @return
|
||||
*/
|
||||
COtherDelegate::COtherDelegate() :
|
||||
ITokenizerDelegate(), mTokenDeque() {
|
||||
ITokenizerDelegate(), mTokenDeque() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ COtherDelegate::COtherDelegate(COtherDelegate& aDelegate) :
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess4/11/98
|
||||
* @update gess4/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ eParseMode COtherDelegate::GetParseMode() const {
|
||||
/**
|
||||
* Cause delegate to create and return a new DTD.
|
||||
*
|
||||
* @update gess4/22/98
|
||||
* @update gess4/22/98
|
||||
* @return new DTD or null
|
||||
*/
|
||||
nsIDTD* COtherDelegate::GetDTD(void) const{
|
||||
@@ -86,7 +86,7 @@ nsIDTD* COtherDelegate::GetDTD(void) const{
|
||||
* @return
|
||||
*/
|
||||
CToken* COtherDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
CToken* result=0;
|
||||
CToken* result=0;
|
||||
nsAutoString empty("");
|
||||
anErrorCode=anErrorCode=aScanner.GetChar(aChar);
|
||||
|
||||
@@ -130,19 +130,19 @@ CToken* COtherDelegate::ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& a
|
||||
* @return
|
||||
*/
|
||||
void COtherDelegate::ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
PRBool done=PR_FALSE;
|
||||
PRBool done=PR_FALSE;
|
||||
nsAutoString as("");
|
||||
anErrorCode=kNoError;
|
||||
while((!done) && (anErrorCode==kNoError)) {
|
||||
CToken* result = new CAttributeToken(as);
|
||||
CToken* result = new CAttributeToken(as);
|
||||
if(result){
|
||||
anErrorCode= result->Consume(aChar,aScanner); //tell new token to finish consuming text...
|
||||
mTokenDeque.Push(result);
|
||||
}
|
||||
aScanner.Peek(aChar);
|
||||
aScanner.Peek(aChar);
|
||||
if(aChar==kGreaterThan) { //you just ate the '>'
|
||||
aScanner.GetChar(aChar); //skip the '>'
|
||||
done=PR_TRUE;
|
||||
aScanner.GetChar(aChar); //skip the '>'
|
||||
done=PR_TRUE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -181,7 +181,7 @@ CToken* COtherDelegate::ConsumeContentToEndTag(const nsString& aString,PRUnichar
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* COtherDelegate::ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode) {
|
||||
CStartToken* result=new CStartToken(nsAutoString(""));
|
||||
CStartToken* result=new CStartToken(nsAutoString(""));
|
||||
if(result) {
|
||||
anErrorCode= result->Consume(aChar,aScanner); //tell new token to finish consuming text...
|
||||
if(result->IsAttributed()) {
|
||||
@@ -292,7 +292,7 @@ CToken* COtherDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,P
|
||||
CToken* result=new CTextToken(aString);
|
||||
if(result) {
|
||||
PRUnichar ch;
|
||||
anErrorCode=result->Consume(ch,aScanner);
|
||||
anErrorCode=result->Consume(ch,aScanner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -307,9 +307,9 @@ CToken* COtherDelegate::ConsumeText(const nsString& aString,CScanner& aScanner,P
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* COtherDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode){
|
||||
CToken* result=new CNewlineToken(nsAutoString(""));
|
||||
CToken* result=new CNewlineToken(nsAutoString(""));
|
||||
if(result) {
|
||||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
anErrorCode=result->Consume(aChar,aScanner);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -327,15 +327,15 @@ CToken* COtherDelegate::ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt3
|
||||
* @return new token or null
|
||||
*/
|
||||
CToken* COtherDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode){
|
||||
CToken* result=0;
|
||||
CToken* result=0;
|
||||
PRUnichar aChar;
|
||||
|
||||
if(mTokenDeque.GetSize()>0) {
|
||||
return (CToken*)mTokenDeque.Pop();
|
||||
}
|
||||
|
||||
while(!aScanner.Eof()) {
|
||||
anErrorCode=aScanner.GetChar(aChar);
|
||||
while(!aScanner.Eof()) {
|
||||
anErrorCode=aScanner.GetChar(aChar);
|
||||
switch(aChar) {
|
||||
case kAmpersand:
|
||||
return ConsumeEntity(aChar,aScanner,anErrorCode);
|
||||
@@ -356,13 +356,13 @@ CToken* COtherDelegate::GetToken(CScanner& aScanner,PRInt32& anErrorCode){
|
||||
} //switch
|
||||
if(anErrorCode==kEOF)
|
||||
anErrorCode=0;
|
||||
} //while
|
||||
return result;
|
||||
} //while
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess4/11/98
|
||||
* @update gess4/11/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@@ -396,8 +396,8 @@ PRBool COtherDelegate::WillAddToken(CToken& /*aToken*/) {
|
||||
* @return TRUE if preinitialization completed successfully
|
||||
*/
|
||||
PRBool COtherDelegate::WillTokenize() {
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,7 +409,7 @@ PRBool COtherDelegate::WillTokenize() {
|
||||
* @return TRUE if preinitialization completed successfully
|
||||
*/
|
||||
PRBool COtherDelegate::DidTokenize() {
|
||||
PRBool result=PR_TRUE;
|
||||
PRBool result=PR_TRUE;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -429,3 +429,5 @@ void COtherDelegate::SelfTest(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
* scanner.stream, and produces an HTML specific CToken.
|
||||
*/
|
||||
|
||||
#ifndef _OTHER_DELEGATE
|
||||
#define _OTHER_DELEGATE
|
||||
#ifndef _OTHER_DELEGATE
|
||||
#define _OTHER_DELEGATE
|
||||
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsITokenizerDelegate.h"
|
||||
@@ -45,15 +45,15 @@
|
||||
#include "nsIDTD.h"
|
||||
|
||||
class COtherDelegate : public ITokenizerDelegate {
|
||||
public:
|
||||
COtherDelegate();
|
||||
COtherDelegate(COtherDelegate& aDelegate);
|
||||
public:
|
||||
COtherDelegate();
|
||||
COtherDelegate(COtherDelegate& aDelegate);
|
||||
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode);
|
||||
virtual PRBool WillAddToken(CToken& aToken);
|
||||
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
virtual PRBool WillTokenize();
|
||||
virtual PRBool DidTokenize();
|
||||
|
||||
virtual eParseMode GetParseMode() const;
|
||||
virtual nsIDTD* GetDTD(void) const;
|
||||
@@ -63,14 +63,14 @@ class COtherDelegate : public ITokenizerDelegate {
|
||||
|
||||
virtual CToken* CreateTokenOfType(eHTMLTokenTypes aType);
|
||||
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeStartTag(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
void ConsumeAttributes(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeText(const nsString& aString,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeEntity(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeWhitespace(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeComment(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
CToken* ConsumeNewline(PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
|
||||
//the only special case method...
|
||||
virtual CToken* ConsumeContentToEndTag(const nsString& aString,PRUnichar aChar,CScanner& aScanner,PRInt32& anErrorCode);
|
||||
@@ -81,3 +81,5 @@ class COtherDelegate : public ITokenizerDelegate {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,30 +21,30 @@ LIBRARY_NAME = raptorhtmlpars
|
||||
|
||||
DEFINES = -D_IMPL_NS_HTMLPARS
|
||||
|
||||
CPPSRCS = \
|
||||
nsHTMLContentSink.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenizer.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
CNavDelegate.cpp \
|
||||
CNavDTD.cpp \
|
||||
COtherDelegate.cpp \
|
||||
COtherDTD.cpp \
|
||||
nsHTMLParser.cpp \
|
||||
nsHTMLTokens.cpp \
|
||||
$(NULL)
|
||||
CPPSRCS = \
|
||||
nsHTMLContentSink.cpp \
|
||||
nsParserNode.cpp \
|
||||
nsScanner.cpp \
|
||||
nsToken.cpp \
|
||||
nsTokenizer.cpp \
|
||||
nsTokenHandler.cpp \
|
||||
CNavDelegate.cpp \
|
||||
CNavDTD.cpp \
|
||||
COtherDelegate.cpp \
|
||||
COtherDTD.cpp \
|
||||
nsHTMLParser.cpp \
|
||||
nsHTMLTokens.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nshtmlpars.h \
|
||||
nsIContentSink.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsHTMLTokens.h \
|
||||
nsIParserNode.h \
|
||||
nsIParser.h \
|
||||
nsToken.h \
|
||||
$(NULL)
|
||||
EXPORTS = \
|
||||
nshtmlpars.h \
|
||||
nsIContentSink.h \
|
||||
nsIHTMLContentSink.h \
|
||||
nsHTMLTokens.h \
|
||||
nsIParserNode.h \
|
||||
nsIParser.h \
|
||||
nsToken.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ PRBool compareFiles(const char* file1,const char* file2,int& failpos) {
|
||||
char ch1,ch2;
|
||||
int eof1,eof2;
|
||||
|
||||
ifstream input1(file1,ios::in && ios::binary,filebuf::openprot);
|
||||
ifstream input2(file2,ios::in && ios::binary,filebuf::openprot);
|
||||
ifstream input1(file1,ios::in && ios::binary,filebuf::openprot);
|
||||
ifstream input2(file2,ios::in && ios::binary,filebuf::openprot);
|
||||
input1.setmode(filebuf::binary);
|
||||
input2.setmode(filebuf::binary);
|
||||
failpos=-1;
|
||||
@@ -79,7 +79,7 @@ PRBool compareFiles(const char* file1,const char* file2,int& failpos) {
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* LAST MODS: gess
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
@@ -116,7 +116,7 @@ void parseFile (const char* aFilename,int size)
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* LAST MODS: gess
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
@@ -167,7 +167,7 @@ int walkDirectoryTree(char* aPath) {
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
* LAST MODS: gess
|
||||
* LAST MODS: gess
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
@@ -175,7 +175,7 @@ int walkDirectoryTree(char* aPath) {
|
||||
int main(int argc, char* argv [])
|
||||
{
|
||||
int result=0;
|
||||
char buffer[_MAX_PATH];
|
||||
char buffer[_MAX_PATH];
|
||||
|
||||
if(argc==2)
|
||||
strcpy(buffer,argv[1]);
|
||||
@@ -186,3 +186,5 @@ int main(int argc, char* argv [])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -53,18 +53,18 @@ LCFLAGS = \
|
||||
$(NULL)
|
||||
|
||||
# These are the libraries we need to link with to create the dll
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
rm -f $(DIST)\lib\$(DLLNAME).lib
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
rm -f $(DIST)\lib\$(DLLNAME).lib
|
||||
|
||||
@@ -115,7 +115,7 @@ CStartTokenHandler::CStartTokenHandler() : CDefaultTokenHandler(eToken_start) {
|
||||
*------------------------------------------------------*/
|
||||
CStartTokenHandler::~CStartTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -165,7 +165,7 @@ CEndTokenHandler::CEndTokenHandler(): CDefaultTokenHandler(eToken_end) {
|
||||
*------------------------------------------------------*/
|
||||
CEndTokenHandler::~CEndTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -215,7 +215,7 @@ CCommentTokenHandler::CCommentTokenHandler() : CDefaultTokenHandler(eToken_comme
|
||||
*------------------------------------------------------*/
|
||||
CCommentTokenHandler::~CCommentTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -264,7 +264,7 @@ CEntityTokenHandler::CEntityTokenHandler() : CDefaultTokenHandler(eToken_entity)
|
||||
*------------------------------------------------------*/
|
||||
CEntityTokenHandler::~CEntityTokenHandler() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -313,7 +313,7 @@ CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CDefaultTokenHandler(eToken
|
||||
*------------------------------------------------------*/
|
||||
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -363,7 +363,7 @@ CNewlineTokenHandler::CNewlineTokenHandler() : CDefaultTokenHandler(eToken_newli
|
||||
*------------------------------------------------------*/
|
||||
CNewlineTokenHandler::~CNewlineTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -412,7 +412,7 @@ CTextTokenHandler::CTextTokenHandler() : CDefaultTokenHandler(eToken_text) {
|
||||
*------------------------------------------------------*/
|
||||
CTextTokenHandler::~CTextTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -460,7 +460,7 @@ CAttributeTokenHandler::CAttributeTokenHandler() : CDefaultTokenHandler(eToken_a
|
||||
*------------------------------------------------------*/
|
||||
CAttributeTokenHandler::~CAttributeTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -509,7 +509,7 @@ CScriptTokenHandler::CScriptTokenHandler() : CDefaultTokenHandler(eToken_script)
|
||||
*------------------------------------------------------*/
|
||||
CScriptTokenHandler::~CScriptTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -558,7 +558,7 @@ CStyleTokenHandler::CStyleTokenHandler() : CDefaultTokenHandler(eToken_style) {
|
||||
*------------------------------------------------------*/
|
||||
CStyleTokenHandler::~CStyleTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -607,7 +607,7 @@ CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CDefaultTokenHandle
|
||||
*------------------------------------------------------*/
|
||||
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -635,3 +635,5 @@ PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,23 +36,23 @@ class nsHTMLParser;
|
||||
|
||||
class CDefaultTokenHandler : public CITokenHandler {
|
||||
public:
|
||||
CDefaultTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
|
||||
CDefaultTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
|
||||
virtual ~CDefaultTokenHandler();
|
||||
|
||||
|
||||
virtual eHTMLTokenTypes GetTokenType(void);
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
|
||||
protected:
|
||||
eHTMLTokenTypes mType;
|
||||
eHTMLTokenTypes mType;
|
||||
};
|
||||
|
||||
|
||||
class CStartTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CStartTokenHandler();
|
||||
CStartTokenHandler();
|
||||
virtual ~CStartTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -60,9 +60,9 @@ public:
|
||||
|
||||
class CEndTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CEndTokenHandler();
|
||||
CEndTokenHandler();
|
||||
virtual ~CEndTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -70,9 +70,9 @@ public:
|
||||
|
||||
class CCommentTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CCommentTokenHandler();
|
||||
CCommentTokenHandler();
|
||||
virtual ~CCommentTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
|
||||
class CEntityTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CEntityTokenHandler();
|
||||
CEntityTokenHandler();
|
||||
virtual ~CEntityTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -90,9 +90,9 @@ public:
|
||||
|
||||
class CWhitespaceTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CWhitespaceTokenHandler();
|
||||
CWhitespaceTokenHandler();
|
||||
virtual ~CWhitespaceTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -100,9 +100,9 @@ public:
|
||||
|
||||
class CNewlineTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CNewlineTokenHandler();
|
||||
CNewlineTokenHandler();
|
||||
virtual ~CNewlineTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
|
||||
class CTextTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CTextTokenHandler();
|
||||
CTextTokenHandler();
|
||||
virtual ~CTextTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -120,9 +120,9 @@ public:
|
||||
|
||||
class CAttributeTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CAttributeTokenHandler();
|
||||
CAttributeTokenHandler();
|
||||
virtual ~CAttributeTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -130,9 +130,9 @@ public:
|
||||
|
||||
class CScriptTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CScriptTokenHandler();
|
||||
CScriptTokenHandler();
|
||||
virtual ~CScriptTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -140,9 +140,9 @@ public:
|
||||
|
||||
class CStyleTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CStyleTokenHandler();
|
||||
CStyleTokenHandler();
|
||||
virtual ~CStyleTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -150,12 +150,14 @@ public:
|
||||
|
||||
class CSkippedContentTokenHandler : public CDefaultTokenHandler {
|
||||
public:
|
||||
CSkippedContentTokenHandler();
|
||||
CSkippedContentTokenHandler();
|
||||
virtual ~CSkippedContentTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -426,3 +426,5 @@ PRBool nsHTMLContentSink::AddLeaf(const nsIParserNode& aNode){
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
* are going to be handled. Stay tuned.
|
||||
*/
|
||||
|
||||
#ifndef NS_HTMLCONTENTSINK
|
||||
#define NS_HTMLCONTENTSINK
|
||||
#ifndef NS_HTMLCONTENTSINK
|
||||
#define NS_HTMLCONTENTSINK
|
||||
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsIHTMLContentSink.h"
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
|
||||
class nsHTMLContentSink : public nsIHTMLContentSink {
|
||||
public:
|
||||
public:
|
||||
|
||||
enum eSection {eNone=0,eHTML,eHead,eBody,eContainer};
|
||||
|
||||
@@ -129,3 +129,5 @@ class nsHTMLContentSink : public nsIHTMLContentSink {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -77,11 +77,11 @@ class nsIDTD;
|
||||
|
||||
class nsHTMLParser : public nsIParser {
|
||||
|
||||
public:
|
||||
public:
|
||||
friend class CTokenHandler;
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
nsHTMLParser();
|
||||
nsHTMLParser();
|
||||
~nsHTMLParser();
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aSink);
|
||||
virtual PRBool Parse(nsIURL* aURL);
|
||||
@@ -92,10 +92,8 @@ friend class CTokenHandler;
|
||||
PRBool HandleStartToken(CToken* aToken);
|
||||
PRBool HandleEndToken(CToken* aToken);
|
||||
PRBool HandleEntityToken(CToken* aToken);
|
||||
PRBool HandleNewlineToken(CToken* aToken);
|
||||
PRBool HandleCommentToken(CToken* aToken);
|
||||
PRBool HandleWhitespaceToken(CToken* aToken);
|
||||
PRBool HandleTextToken(CToken* aToken);
|
||||
PRBool HandleSimpleContentToken(CToken* aToken);
|
||||
PRBool HandleSkippedContentToken(CToken* aToken);
|
||||
PRBool HandleAttributeToken(CToken* aToken);
|
||||
PRBool HandleScriptToken(CToken* aToken);
|
||||
@@ -142,6 +140,7 @@ friend class CTokenHandler;
|
||||
PRInt32 GetTopmostIndex(eHTMLTags aTag) const;
|
||||
PRBool ReduceContextStackFor(PRInt32 aChildTag);
|
||||
PRBool CreateContextStackFor(PRInt32 aChildTag);
|
||||
PRBool HandleDefaultStartToken(CToken* aToken,eHTMLTags aTag,nsCParserNode& aNode);
|
||||
|
||||
nsIHTMLContentSink* mSink;
|
||||
CTokenizer* mTokenizer;
|
||||
@@ -160,3 +159,5 @@ friend class CTokenHandler;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ static const char* kNullScanner = "Error: Scanner is null.";
|
||||
const PRInt32 kMAXNAMELEN=10;
|
||||
struct StrToUnicodeStruct
|
||||
{
|
||||
char fName[kMAXNAMELEN+1];
|
||||
char fName[kMAXNAMELEN+1];
|
||||
PRInt32 fValue;
|
||||
};
|
||||
|
||||
|
||||
// KEEP THIS LIST SORTED!
|
||||
// KEEP THIS LIST SORTED!
|
||||
// NOTE: This names table is sorted in ascii collating order. If you
|
||||
// add a new entry, make sure you put it in the right spot otherwise
|
||||
// the binary search code above will break!
|
||||
@@ -77,8 +77,8 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
|
||||
{"euml", 0x00eb}, {"frac12",0x00bd}, {"frac14",0x00bc},
|
||||
{"frac34",0x00be}, {"gt", 0x003e}, {"iacute",0x00ed},
|
||||
{"icirc", 0x00ee}, {"iexcl", 0x00a1}, {"igrave",0x00ec},
|
||||
{"iquest",0x00bf}, {"iuml", 0x00ef}, {"laquo", 0x00ab},
|
||||
{"lt", 0x003c}, {"macr", 0x00af}, {"micro", 0x00b5},
|
||||
{"iquest",0x00bf}, {"iuml", 0x00ef}, {"laquo", 0x00ab},
|
||||
{"lt", 0x003c}, {"macr", 0x00af}, {"micro", 0x00b5},
|
||||
{"middot",0x00b7}, {"nbsp", 0x00a0}, {"not", 0x00ac},
|
||||
{"ntilde",0x00f1}, {"oacute",0x00f3}, {"ocirc", 0x00f4},
|
||||
{"ograve",0x00f2}, {"ordf", 0x00aa}, {"ordm", 0x00ba},
|
||||
@@ -97,95 +97,99 @@ static StrToUnicodeStruct gStrToUnicodeTable[] =
|
||||
|
||||
struct HTMLTagEntry
|
||||
{
|
||||
char fName[12];
|
||||
eHTMLTags fTagID;
|
||||
char fName[12];
|
||||
eHTMLTags fTagID;
|
||||
};
|
||||
|
||||
|
||||
// KEEP THIS LIST SORTED!
|
||||
// KEEP THIS LIST SORTED!
|
||||
// NOTE: This table is sorted in ascii collating order. If you
|
||||
// add a new entry, make sure you put it in the right spot otherwise
|
||||
// the binary search code above will break!
|
||||
HTMLTagEntry gHTMLTagTable[] =
|
||||
{
|
||||
{"!DOCTYPE", eHTMLTag_doctype}, {"A", eHTMLTag_a},
|
||||
{"ACRONYM", eHTMLTag_acronym}, {"ADDRESS", eHTMLTag_address},
|
||||
{"APPLET", eHTMLTag_applet}, {"AREA", eHTMLTag_area},
|
||||
{"!DOCTYPE", eHTMLTag_doctype}, {"A", eHTMLTag_a},
|
||||
{"ACRONYM", eHTMLTag_acronym}, {"ADDRESS", eHTMLTag_address},
|
||||
{"APPLET", eHTMLTag_applet}, {"AREA", eHTMLTag_area},
|
||||
|
||||
{"B", eHTMLTag_bold}, {"BASE", eHTMLTag_base},
|
||||
{"BASEFONT", eHTMLTag_basefont}, {"BDO", eHTMLTag_bdo},
|
||||
{"BIG", eHTMLTag_big}, {"BLINK", eHTMLTag_blink},
|
||||
{"BLOCKQUOTE",eHTMLTag_blockquote}, {"BODY", eHTMLTag_body},
|
||||
{"BR", eHTMLTag_br}, {"BUTTON", eHTMLTag_button},
|
||||
{"B", eHTMLTag_bold}, {"BASE", eHTMLTag_base},
|
||||
{"BASEFONT", eHTMLTag_basefont}, {"BDO", eHTMLTag_bdo},
|
||||
{"BIG", eHTMLTag_big}, {"BLINK", eHTMLTag_blink},
|
||||
{"BLOCKQUOTE", eHTMLTag_blockquote}, {"BODY", eHTMLTag_body},
|
||||
{"BR", eHTMLTag_br}, {"BUTTON", eHTMLTag_button},
|
||||
|
||||
{"CAPTION", eHTMLTag_caption}, {"CENTER", eHTMLTag_center},
|
||||
{"CERTIFICATE",eHTMLTag_certificate},
|
||||
{"CITE", eHTMLTag_cite}, {"CODE", eHTMLTag_code},
|
||||
{"COL", eHTMLTag_col}, {"COLGROUP", eHTMLTag_colgroup},
|
||||
{"CAPTION", eHTMLTag_caption}, {"CENTER", eHTMLTag_center},
|
||||
{"CERTIFICATE", eHTMLTag_certificate},
|
||||
{"CITE", eHTMLTag_cite}, {"CODE", eHTMLTag_code},
|
||||
{"COL", eHTMLTag_col}, {"COLGROUP", eHTMLTag_colgroup},
|
||||
|
||||
{"DD", eHTMLTag_dd}, {"DEL", eHTMLTag_del},
|
||||
{"DFN", eHTMLTag_dfn}, {"DIR", eHTMLTag_dir},
|
||||
{"DIV", eHTMLTag_div}, {"DL", eHTMLTag_dl},
|
||||
{"DT", eHTMLTag_dt},
|
||||
{"DD", eHTMLTag_dd}, {"DEL", eHTMLTag_del},
|
||||
{"DFN", eHTMLTag_dfn}, {"DIR", eHTMLTag_dir},
|
||||
{"DIV", eHTMLTag_div}, {"DL", eHTMLTag_dl},
|
||||
{"DT", eHTMLTag_dt},
|
||||
|
||||
{"EM", eHTMLTag_em}, {"EMBED", eHTMLTag_embed},
|
||||
{"EM", eHTMLTag_em}, {"EMBED", eHTMLTag_embed},
|
||||
|
||||
{"FIELDSET", eHTMLTag_fieldset}, {"FONT", eHTMLTag_font},
|
||||
{"FOOTER", eHTMLTag_footer}, {"FORM", eHTMLTag_form},
|
||||
{"FRAME", eHTMLTag_frame}, {"FRAMESET", eHTMLTag_frameset},
|
||||
{"FIELDSET", eHTMLTag_fieldset}, {"FONT", eHTMLTag_font},
|
||||
{"FOOTER", eHTMLTag_footer}, {"FORM", eHTMLTag_form},
|
||||
{"FRAME", eHTMLTag_frame}, {"FRAMESET", eHTMLTag_frameset},
|
||||
|
||||
{"H1", eHTMLTag_h1}, {"H2", eHTMLTag_h2},
|
||||
{"H3", eHTMLTag_h3}, {"H4", eHTMLTag_h4},
|
||||
{"H5", eHTMLTag_h5}, {"H6", eHTMLTag_h6},
|
||||
{"HEAD", eHTMLTag_head}, {"HEADER", eHTMLTag_header},
|
||||
{"HR", eHTMLTag_hr}, {"HTML", eHTMLTag_html},
|
||||
{"H1", eHTMLTag_h1}, {"H2", eHTMLTag_h2},
|
||||
{"H3", eHTMLTag_h3}, {"H4", eHTMLTag_h4},
|
||||
{"H5", eHTMLTag_h5}, {"H6", eHTMLTag_h6},
|
||||
{"HEAD", eHTMLTag_head}, {"HEADER", eHTMLTag_header},
|
||||
{"HR", eHTMLTag_hr}, {"HTML", eHTMLTag_html},
|
||||
|
||||
{"I", eHTMLTag_italic}, {"IFRAME", eHTMLTag_iframe},
|
||||
{"ILAYER", eHTMLTag_ilayer}, {"IMG", eHTMLTag_img},
|
||||
{"INPUT", eHTMLTag_input}, {"INS", eHTMLTag_ins},
|
||||
{"ISINDEX", eHTMLTag_isindex},
|
||||
{"I", eHTMLTag_italic}, {"IFRAME", eHTMLTag_iframe},
|
||||
{"ILAYER", eHTMLTag_ilayer}, {"IMG", eHTMLTag_img},
|
||||
{"INPUT", eHTMLTag_input}, {"INS", eHTMLTag_ins},
|
||||
{"ISINDEX", eHTMLTag_isindex},
|
||||
|
||||
{"KBD", eHTMLTag_kbd}, {"KEYGEN", eHTMLTag_keygen},
|
||||
{"KBD", eHTMLTag_kbd}, {"KEYGEN", eHTMLTag_keygen},
|
||||
|
||||
{"LABEL", eHTMLTag_label}, {"LAYER", eHTMLTag_layer},
|
||||
{"LEGEND", eHTMLTag_legend}, {"LI", eHTMLTag_listitem},
|
||||
{"LINK", eHTMLTag_link}, {"LISTING", eHTMLTag_listing},
|
||||
{"LABEL", eHTMLTag_label}, {"LAYER", eHTMLTag_layer},
|
||||
{"LEGEND", eHTMLTag_legend}, {"LI", eHTMLTag_listitem},
|
||||
{"LINK", eHTMLTag_link}, {"LISTING", eHTMLTag_listing},
|
||||
|
||||
{"MAP", eHTMLTag_map}, {"MARQUEE", eHTMLTag_marquee},
|
||||
{"MENU", eHTMLTag_menu}, {"META", eHTMLTag_meta},
|
||||
{"MAP", eHTMLTag_map}, {"MARQUEE", eHTMLTag_marquee},
|
||||
{"MENU", eHTMLTag_menu}, {"META", eHTMLTag_meta},
|
||||
|
||||
{"NEWLINE", eHTMLTag_newline},
|
||||
{"NEWLINE", eHTMLTag_newline},
|
||||
|
||||
{"NOEMBED", eHTMLTag_noembed}, {"NOFRAMES", eHTMLTag_noframes},
|
||||
{"NOLAYER", eHTMLTag_nolayer}, {"NOSCRIPT", eHTMLTag_noscript},
|
||||
{"NOEMBED", eHTMLTag_noembed}, {"NOFRAMES", eHTMLTag_noframes},
|
||||
{"NOLAYER", eHTMLTag_nolayer}, {"NOSCRIPT", eHTMLTag_noscript},
|
||||
|
||||
{"OBJECT", eHTMLTag_object}, {"OL", eHTMLTag_ol},
|
||||
{"OPTION", eHTMLTag_option},
|
||||
{"OBJECT", eHTMLTag_object}, {"OL", eHTMLTag_ol},
|
||||
{"OPTION", eHTMLTag_option},
|
||||
|
||||
{"P", eHTMLTag_paragraph}, {"PARAM", eHTMLTag_param},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext},
|
||||
{"P", eHTMLTag_paragraph}, {"PARAM", eHTMLTag_param},
|
||||
{"PLAINTEXT", eHTMLTag_plaintext},
|
||||
|
||||
{"PRE", eHTMLTag_pre},
|
||||
{"PRE", eHTMLTag_pre},
|
||||
|
||||
{"Q", eHTMLTag_quotation},
|
||||
{"Q", eHTMLTag_quotation},
|
||||
|
||||
{"S", eHTMLTag_strike}, {"SAMP", eHTMLTag_samp},
|
||||
{"SCRIPT", eHTMLTag_script}, {"SELECT", eHTMLTag_select},
|
||||
{"SERVER", eHTMLTag_server}, {"SMALL", eHTMLTag_small},
|
||||
{"SPACER", eHTMLTag_spacer},
|
||||
{"SPAN", eHTMLTag_span}, {"STRIKE", eHTMLTag_strike},
|
||||
{"STRONG", eHTMLTag_strong}, {"STYLE", eHTMLTag_style},
|
||||
{"SUB", eHTMLTag_sub}, {"SUP", eHTMLTag_sup},
|
||||
{"S", eHTMLTag_strike}, {"SAMP", eHTMLTag_samp},
|
||||
{"SCRIPT", eHTMLTag_script}, {"SELECT", eHTMLTag_select},
|
||||
{"SERVER", eHTMLTag_server}, {"SMALL", eHTMLTag_small},
|
||||
{"SPACER", eHTMLTag_spacer},
|
||||
{"SPAN", eHTMLTag_span}, {"STRIKE", eHTMLTag_strike},
|
||||
{"STRONG", eHTMLTag_strong}, {"STYLE", eHTMLTag_style},
|
||||
{"SUB", eHTMLTag_sub}, {"SUP", eHTMLTag_sup},
|
||||
|
||||
{"TABLE", eHTMLTag_table}, {"TBODY", eHTMLTag_tbody},
|
||||
{"TD", eHTMLTag_td}, {"TEXTAREA", eHTMLTag_textarea},
|
||||
{"TFOOT", eHTMLTag_tfoot}, {"TH", eHTMLTag_th},
|
||||
{"THEAD", eHTMLTag_thead}, {"TITLE", eHTMLTag_title},
|
||||
{"TR", eHTMLTag_tr}, {"TT", eHTMLTag_tt},
|
||||
{"TABLE", eHTMLTag_table}, {"TBODY", eHTMLTag_tbody},
|
||||
{"TD", eHTMLTag_td},
|
||||
|
||||
{"TEXT", eHTMLTag_text},
|
||||
|
||||
{"U", eHTMLTag_u}, {"UL", eHTMLTag_ul},
|
||||
{"VAR", eHTMLTag_var}, {"WBR", eHTMLTag_wbr},
|
||||
{"WS", eHTMLTag_whitespace},
|
||||
{"TEXTAREA", eHTMLTag_textarea},
|
||||
{"TFOOT", eHTMLTag_tfoot}, {"TH", eHTMLTag_th},
|
||||
{"THEAD", eHTMLTag_thead}, {"TITLE", eHTMLTag_title},
|
||||
{"TR", eHTMLTag_tr}, {"TT", eHTMLTag_tt},
|
||||
|
||||
{"U", eHTMLTag_u}, {"UL", eHTMLTag_ul},
|
||||
{"VAR", eHTMLTag_var}, {"WBR", eHTMLTag_wbr},
|
||||
{"WS", eHTMLTag_whitespace},
|
||||
|
||||
|
||||
};
|
||||
@@ -193,55 +197,55 @@ HTMLTagEntry gHTMLTagTable[] =
|
||||
|
||||
struct HTMLAttrEntry
|
||||
{
|
||||
char fName[11];
|
||||
eHTMLAttributes fAttrID;
|
||||
char fName[11];
|
||||
eHTMLAttributes fAttrID;
|
||||
};
|
||||
|
||||
HTMLAttrEntry gHTMLAttributeTable[] =
|
||||
{
|
||||
{"ABBREV", eHTMLAttr_abbrev}, {"ABOVE", eHTMLAttr_above},
|
||||
{"ALT", eHTMLAttr_alt}, {"ARRAY", eHTMLAttr_array},
|
||||
{"ABBREV", eHTMLAttr_abbrev}, {"ABOVE", eHTMLAttr_above},
|
||||
{"ALT", eHTMLAttr_alt}, {"ARRAY", eHTMLAttr_array},
|
||||
{"AU", eHTMLAttr_author},
|
||||
|
||||
{"BACKGROUND",eHTMLAttr_background}, {"BANNER", eHTMLAttr_banner},
|
||||
{"BELOW", eHTMLAttr_below}, {"BGSOUND", eHTMLAttr_bgsound},
|
||||
{"BOX", eHTMLAttr_box}, {"BT", eHTMLAttr_bt},
|
||||
{"BACKGROUND",eHTMLAttr_background}, {"BANNER", eHTMLAttr_banner},
|
||||
{"BELOW", eHTMLAttr_below}, {"BGSOUND", eHTMLAttr_bgsound},
|
||||
{"BOX", eHTMLAttr_box}, {"BT", eHTMLAttr_bt},
|
||||
|
||||
{"CLASS", eHTMLAttr_class}, {"COMMENT", eHTMLAttr_comment},
|
||||
{"CREDIT", eHTMLAttr_credit},
|
||||
|
||||
{"DIR", eHTMLAttr_dir},
|
||||
|
||||
{"FIG", eHTMLAttr_figure}, {"FIGURE", eHTMLAttr_figure},
|
||||
{"FOOTNOTE", eHTMLAttr_footnote},
|
||||
{"FIG", eHTMLAttr_figure}, {"FIGURE", eHTMLAttr_figure},
|
||||
{"FOOTNOTE", eHTMLAttr_footnote},
|
||||
|
||||
{"HEIGHT", eHTMLAttr_height},
|
||||
{"HEIGHT", eHTMLAttr_height},
|
||||
|
||||
{"ID", eHTMLAttr_id},
|
||||
{"ID", eHTMLAttr_id},
|
||||
|
||||
{"LANG", eHTMLAttr_lang},
|
||||
|
||||
{"MATH", eHTMLAttr_math},
|
||||
{"MATH", eHTMLAttr_math},
|
||||
|
||||
{"NAME", eHTMLAttr_name}, {"NEXTID", eHTMLAttr_nextid},
|
||||
{"NAME", eHTMLAttr_name}, {"NEXTID", eHTMLAttr_nextid},
|
||||
{"NOBR", eHTMLAttr_nobreak},
|
||||
|
||||
{"NOTE", eHTMLAttr_note},
|
||||
{"NOTE", eHTMLAttr_note},
|
||||
|
||||
{"OPTION", eHTMLAttr_option}, {"OVERLAY", eHTMLAttr_overlay},
|
||||
{"OPTION", eHTMLAttr_option}, {"OVERLAY", eHTMLAttr_overlay},
|
||||
|
||||
{"PERSON", eHTMLAttr_person}, {"PUBLIC", eHTMLAttr_public},
|
||||
{"PERSON", eHTMLAttr_person}, {"PUBLIC", eHTMLAttr_public},
|
||||
|
||||
{"RANGE", eHTMLAttr_range}, {"ROOT", eHTMLAttr_root},
|
||||
{"RANGE", eHTMLAttr_range}, {"ROOT", eHTMLAttr_root},
|
||||
|
||||
{"SGML", eHTMLAttr_sgml}, {"SQRT", eHTMLAttr_sqrt},
|
||||
{"SRC", eHTMLAttr_src}, {"STYLE", eHTMLAttr_style},
|
||||
{"SGML", eHTMLAttr_sgml}, {"SQRT", eHTMLAttr_sqrt},
|
||||
{"SRC", eHTMLAttr_src}, {"STYLE", eHTMLAttr_style},
|
||||
|
||||
{"TEXT", eHTMLAttr_text}, {"TITLE", eHTMLAttr_title},
|
||||
{"TEXT", eHTMLAttr_text}, {"TITLE", eHTMLAttr_title},
|
||||
|
||||
{"WBR", eHTMLAttr_wordbreak}, {"WIDTH", eHTMLAttr_width},
|
||||
{"WBR", eHTMLAttr_wordbreak}, {"WIDTH", eHTMLAttr_width},
|
||||
|
||||
{"XMP", eHTMLAttr_xmp}
|
||||
{"XMP", eHTMLAttr_xmp}
|
||||
};
|
||||
|
||||
|
||||
@@ -310,7 +314,7 @@ eHTMLTags CStartToken::GetHTMLTag(){
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CStartToken::GetClassName(void) {
|
||||
const char* CStartToken::GetClassName(void) {
|
||||
return "start";
|
||||
}
|
||||
|
||||
@@ -357,12 +361,12 @@ PRBool CStartToken::IsAttributed(void) {
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
|
||||
//if you're here, we've already Consumed the < char, and are
|
||||
//if you're here, we've already Consumed the < char, and are
|
||||
//ready to Consume the rest of the open tag identifier.
|
||||
//Stop consuming as soon as you see a space or a '>'.
|
||||
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
|
||||
|
||||
mTextValue=aChar;
|
||||
mTextValue=aChar;
|
||||
PRInt32 result=aScanner.ReadWhile(mTextValue,gIdentChars,PR_FALSE);
|
||||
|
||||
//Good. Now, let's skip whitespace after the identifier,
|
||||
@@ -372,7 +376,7 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
aScanner.SkipWhite();
|
||||
result=aScanner.GetChar(aChar);
|
||||
if(kGreaterThan!=aChar) { //look for '>'
|
||||
//push that char back, since we apparently have attributes...
|
||||
//push that char back, since we apparently have attributes...
|
||||
aScanner.PutBack(aChar);
|
||||
mAttributed=PR_TRUE;
|
||||
}
|
||||
@@ -389,7 +393,7 @@ PRInt32 CStartToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
*------------------------------------------------------*/
|
||||
void CStartToken::DebugDumpSource(ostream& out) {
|
||||
char* cp=mTextValue.ToNewCString();
|
||||
out << "<" << *cp;
|
||||
out << "<" << *cp;
|
||||
if(!mAttributed)
|
||||
out << ">";
|
||||
delete cp;
|
||||
@@ -417,7 +421,7 @@ CEndToken::CEndToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CEndToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
|
||||
//if you're here, we've already Consumed the <! chars, and are
|
||||
//if you're here, we've already Consumed the <! chars, and are
|
||||
//ready to Consume the rest of the open tag identifier.
|
||||
//Stop consuming as soon as you see a space or a '>'.
|
||||
//NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
|
||||
@@ -452,7 +456,7 @@ eHTMLTags CEndToken::GetHTMLTag(){
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CEndToken::GetClassName(void) {
|
||||
const char* CEndToken::GetClassName(void) {
|
||||
return "/end";
|
||||
}
|
||||
|
||||
@@ -476,7 +480,7 @@ PRInt32 CEndToken::GetTokenType(void) {
|
||||
*------------------------------------------------------*/
|
||||
void CEndToken::DebugDumpSource(ostream& out) {
|
||||
char* cp=mTextValue.ToNewCString();
|
||||
out << "</" << *cp << ">";
|
||||
out << "</" << *cp << ">";
|
||||
delete cp;
|
||||
}
|
||||
|
||||
@@ -490,6 +494,7 @@ void CEndToken::DebugDumpSource(ostream& out) {
|
||||
*------------------------------------------------------*/
|
||||
CTextToken::CTextToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_text;
|
||||
mTagType=eHTMLTag_text;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
@@ -499,7 +504,7 @@ CTextToken::CTextToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CTextToken::GetClassName(void) {
|
||||
const char* CTextToken::GetClassName(void) {
|
||||
return "text";
|
||||
}
|
||||
|
||||
@@ -561,8 +566,8 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
if(kMinus==ch) {
|
||||
aScanner.GetChar(ch2);
|
||||
if(kMinus==ch2) {
|
||||
//in this case, we're reading a long-form comment <-- xxx -->
|
||||
mTextValue+="--";
|
||||
//in this case, we're reading a long-form comment <-- xxx -->
|
||||
mTextValue+="--";
|
||||
PRInt32 findpos=-1;
|
||||
while((findpos==kNotFound) && (!result)) {
|
||||
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
|
||||
@@ -571,7 +576,7 @@ PRInt32 CCommentToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//if you're here, we're consuming a "short-form" comment
|
||||
//if you're here, we're consuming a "short-form" comment
|
||||
mTextValue+=ch;
|
||||
result=aScanner.ReadUntil(mTextValue,terminals,PR_TRUE);
|
||||
return result;
|
||||
@@ -608,6 +613,7 @@ PRInt32 CCommentToken::GetTokenType(void) {
|
||||
*------------------------------------------------------*/
|
||||
CNewlineToken::CNewlineToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_newline;
|
||||
mTagType=eHTMLTag_newline;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
@@ -617,7 +623,7 @@ CNewlineToken::CNewlineToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CNewlineToken::GetClassName(void) {
|
||||
const char* CNewlineToken::GetClassName(void) {
|
||||
return "crlf";
|
||||
}
|
||||
|
||||
@@ -668,7 +674,7 @@ CAttributeToken::CAttributeToken(const nsString& aName) : CHTMLToken(aName),
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CAttributeToken::GetClassName(void) {
|
||||
const char* CAttributeToken::GetClassName(void) {
|
||||
return "attr";
|
||||
}
|
||||
|
||||
@@ -692,7 +698,7 @@ PRInt32 CAttributeToken::GetTokenType(void) {
|
||||
*------------------------------------------------------*/
|
||||
void CAttributeToken::DebugDumpToken(ostream& out) {
|
||||
char* cp=mTextKey.ToNewCString();
|
||||
out << "[" << GetClassName() << "] " << *cp << "=";
|
||||
out << "[" << GetClassName() << "] " << *cp << "=";
|
||||
delete cp;
|
||||
char* cp2=mTextValue.ToNewCString();
|
||||
out << *cp2 << ": " << mOrdinalValue << endl;
|
||||
@@ -761,12 +767,12 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
PRInt32 result=aScanner.Peek(aChar);
|
||||
if(kEOF!=result) {
|
||||
if(kQuote==aChar) { //if you're here, handle quoted key...
|
||||
aScanner.GetChar(aChar); //skip the quote sign...
|
||||
aScanner.GetChar(aChar); //skip the quote sign...
|
||||
mTextKey=aChar;
|
||||
result=ConsumeQuotedString(aChar,mTextKey,aScanner);
|
||||
}
|
||||
else if(kHashsign==aChar) {
|
||||
aScanner.GetChar(aChar); //skip the hash sign...
|
||||
aScanner.GetChar(aChar); //skip the hash sign...
|
||||
mTextKey=aChar;
|
||||
result=aScanner.ReadWhile(mTextKey,gDigits,PR_TRUE);
|
||||
}
|
||||
@@ -783,7 +789,7 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
if(kEqual==aChar){
|
||||
aScanner.GetChar(aChar); //skip the equal sign...
|
||||
aScanner.SkipWhite(); //now skip any intervening whitespace
|
||||
aScanner.GetChar(aChar); //and grab the next char.
|
||||
aScanner.GetChar(aChar); //and grab the next char.
|
||||
|
||||
if((kQuote==aChar) || (kApostrophe==aChar)) {
|
||||
mTextValue=aChar;
|
||||
@@ -813,7 +819,7 @@ PRInt32 CAttributeToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
*------------------------------------------------------*/
|
||||
void CAttributeToken::DebugDumpSource(ostream& out) {
|
||||
char* cp=mTextKey.ToNewCString();
|
||||
out << " " << *cp;
|
||||
out << " " << *cp;
|
||||
delete cp;
|
||||
if(mTextValue.Length()) {
|
||||
cp=mTextValue.ToNewCString();
|
||||
@@ -833,6 +839,7 @@ void CAttributeToken::DebugDumpSource(ostream& out) {
|
||||
*------------------------------------------------------*/
|
||||
CWhitespaceToken::CWhitespaceToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
mOrdinalValue=eToken_whitespace;
|
||||
mTagType=eHTMLTag_whitespace;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
@@ -842,7 +849,7 @@ CWhitespaceToken::CWhitespaceToken(const nsString& aName) : CHTMLToken(aName) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CWhitespaceToken::GetClassName(void) {
|
||||
const char* CWhitespaceToken::GetClassName(void) {
|
||||
return "ws";
|
||||
}
|
||||
|
||||
@@ -912,7 +919,7 @@ PRInt32 CEntityToken::Consume(PRUnichar aChar, CScanner& aScanner) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CEntityToken::GetClassName(void) {
|
||||
const char* CEntityToken::GetClassName(void) {
|
||||
return "&entity";
|
||||
}
|
||||
|
||||
@@ -996,7 +1003,7 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) {
|
||||
* @return PR_TRUE if valid (ordered correctly)
|
||||
*------------------------------------------------------*/
|
||||
PRBool CEntityToken::VerifyEntityTable(){
|
||||
PRInt32 count=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 count=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
@@ -1018,32 +1025,32 @@ PRBool CEntityToken::VerifyEntityTable(){
|
||||
* @return integer offset of string in table, or kNotFound
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CEntityToken::FindEntityIndex(const char* aBuffer,PRInt32 aBufLen) {
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
PRInt32 result=kNotFound;
|
||||
PRInt32 cnt=sizeof(gStrToUnicodeTable)/sizeof(StrToUnicodeStruct);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if(kNotFound==aBufLen) {
|
||||
aBufLen=strlen(aBuffer);
|
||||
}
|
||||
|
||||
|
||||
if (aBuffer && aBufLen && cnt) {
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
// result=strncmp(aBuffer,gStrToUnicodeTable[middle].fName,aBufLen);
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].fName);
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
// result=strncmp(aBuffer,gStrToUnicodeTable[middle].fName,aBufLen);
|
||||
result=strcmp(aBuffer,gStrToUnicodeTable[middle].fName);
|
||||
if (result==0) {
|
||||
return middle;
|
||||
return middle;
|
||||
}
|
||||
if (result<0) {
|
||||
high=middle-1;
|
||||
high=middle-1;
|
||||
}
|
||||
else low=middle+1;
|
||||
}
|
||||
else low=middle+1;
|
||||
}
|
||||
}
|
||||
return kNotFound;
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
|
||||
@@ -1091,7 +1098,7 @@ PRInt32 CEntityToken::ReduceEntities(nsString& aString) {
|
||||
*------------------------------------------------------*/
|
||||
void CEntityToken::DebugDumpSource(ostream& out) {
|
||||
char* cp=mTextValue.ToNewCString();
|
||||
out << "&" << *cp;
|
||||
out << "&" << *cp;
|
||||
delete cp;
|
||||
}
|
||||
|
||||
@@ -1102,7 +1109,7 @@ void CEntityToken::DebugDumpSource(ostream& out) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CScriptToken::GetClassName(void) {
|
||||
const char* CScriptToken::GetClassName(void) {
|
||||
return "script";
|
||||
}
|
||||
|
||||
@@ -1124,7 +1131,7 @@ PRInt32 CScriptToken::GetTokenType(void) {
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CStyleToken::GetClassName(void) {
|
||||
const char* CStyleToken::GetClassName(void) {
|
||||
return "style";
|
||||
}
|
||||
|
||||
@@ -1159,7 +1166,7 @@ CSkippedContentToken::CSkippedContentToken(const nsString& aName) : CAttributeTo
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
const char* CSkippedContentToken::GetClassName(void) {
|
||||
const char* CSkippedContentToken::GetClassName(void) {
|
||||
return "skipped";
|
||||
}
|
||||
|
||||
@@ -1210,7 +1217,7 @@ PRInt32 CSkippedContentToken::Consume(PRUnichar aChar,CScanner& aScanner) {
|
||||
class CTagTableVerifier {
|
||||
public:
|
||||
CTagTableVerifier::CTagTableVerifier(){
|
||||
PRInt32 count=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
|
||||
PRInt32 count=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
@@ -1229,7 +1236,7 @@ public:
|
||||
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
@@ -1247,23 +1254,23 @@ eHTMLTokenTypes DetermineTokenType(const nsString& aString){
|
||||
*------------------------------------------------------*/
|
||||
eHTMLTags DetermineHTMLTagType(const nsString& aString)
|
||||
{
|
||||
PRInt32 result=-1;
|
||||
PRInt32 cnt=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
PRInt32 result=-1;
|
||||
PRInt32 cnt=sizeof(gHTMLTagTable)/sizeof(HTMLTagEntry);
|
||||
PRInt32 low=0;
|
||||
PRInt32 high=cnt-1;
|
||||
PRInt32 middle=kNotFound;
|
||||
|
||||
if (0 != cnt)
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=aString.Compare(gHTMLTagTable[middle].fName, PR_TRUE);
|
||||
if (result==0)
|
||||
return gHTMLTagTable[middle].fTagID;
|
||||
if (result<0)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
}
|
||||
if (0 != cnt)
|
||||
while(low<=high)
|
||||
{
|
||||
middle=(PRInt32)(low+high)/2;
|
||||
result=aString.Compare(gHTMLTagTable[middle].fName, PR_TRUE);
|
||||
if (result==0)
|
||||
return gHTMLTagTable[middle].fTagID;
|
||||
if (result<0)
|
||||
high=middle-1;
|
||||
else low=middle+1;
|
||||
}
|
||||
return eHTMLTag_userdefined;
|
||||
}
|
||||
|
||||
@@ -1280,7 +1287,7 @@ eHTMLTags DetermineHTMLTagType(const nsString& aString)
|
||||
class CAttributeTableVerifier {
|
||||
public:
|
||||
CAttributeTableVerifier::CAttributeTableVerifier(){
|
||||
PRInt32 count=sizeof(gHTMLAttributeTable)/sizeof(HTMLAttrEntry);
|
||||
PRInt32 count=sizeof(gHTMLAttributeTable)/sizeof(HTMLAttrEntry);
|
||||
PRInt32 i,j;
|
||||
for(i=1;i<count-1;i++)
|
||||
{
|
||||
@@ -1305,3 +1312,5 @@ public:
|
||||
CAttributeTableVerifier gAttributeTableVerifier;
|
||||
CTagTableVerifier gTableVerifier;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -65,9 +65,10 @@ enum eHTMLTags
|
||||
eHTMLTag_form, eHTMLTag_frame, eHTMLTag_frameset,
|
||||
eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3, eHTMLTag_h4,
|
||||
eHTMLTag_h5, eHTMLTag_h6, eHTMLTag_head, eHTMLTag_header,
|
||||
eHTMLTag_hr, eHTMLTag_html, eHTMLTag_iframe, eHTMLTag_ilayer,
|
||||
eHTMLTag_hr, eHTMLTag_html, eHTMLTag_iframe, eHTMLTag_ilayer,
|
||||
eHTMLTag_italic, eHTMLTag_img, eHTMLTag_ins, eHTMLTag_input,
|
||||
eHTMLTag_isindex, eHTMLTag_kbd, eHTMLTag_keygen,
|
||||
eHTMLTag_isindex,
|
||||
eHTMLTag_kbd, eHTMLTag_keygen,
|
||||
eHTMLTag_label, eHTMLTag_layer, eHTMLTag_legend, eHTMLTag_listitem,
|
||||
eHTMLTag_link, eHTMLTag_listing, eHTMLTag_map, eHTMLTag_marquee,
|
||||
eHTMLTag_math, eHTMLTag_menu, eHTMLTag_meta, eHTMLTag_newline,
|
||||
@@ -75,10 +76,15 @@ enum eHTMLTags
|
||||
eHTMLTag_note, eHTMLTag_object, eHTMLTag_ol,
|
||||
eHTMLTag_option, eHTMLTag_paragraph, eHTMLTag_param, eHTMLTag_plaintext,
|
||||
eHTMLTag_pre, eHTMLTag_quotation, eHTMLTag_strike, eHTMLTag_samp,
|
||||
eHTMLTag_script, eHTMLTag_select, eHTMLTag_server, eHTMLTag_small,
|
||||
eHTMLTag_script, eHTMLTag_select,
|
||||
eHTMLTag_server, eHTMLTag_small,
|
||||
eHTMLTag_spacer, eHTMLTag_span,
|
||||
eHTMLTag_strong, eHTMLTag_style, eHTMLTag_sub, eHTMLTag_sup,
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td, eHTMLTag_tfoot,
|
||||
eHTMLTag_table, eHTMLTag_tbody, eHTMLTag_td,
|
||||
|
||||
eHTMLTag_text, //used for plain text; this is not really a tag.
|
||||
|
||||
eHTMLTag_tfoot,
|
||||
eHTMLTag_thead, eHTMLTag_th, eHTMLTag_tr, eHTMLTag_textarea,
|
||||
eHTMLTag_title, eHTMLTag_tt, eHTMLTag_monofont, eHTMLTag_u,
|
||||
eHTMLTag_ul, eHTMLTag_var, eHTMLTag_wbr, eHTMLTag_whitespace,
|
||||
@@ -111,7 +117,7 @@ eHTMLTokenTypes DetermineTokenType(const nsString& aString);
|
||||
|
||||
/** -----------------------------------------------------
|
||||
* This declares the basic token type used in the html-
|
||||
* parser.
|
||||
* parser.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
@@ -133,14 +139,14 @@ protected:
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CStartToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CStartToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual eHTMLTags GetHTMLTag();
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
void SetAttributed(PRBool aValue);
|
||||
PRBool IsAttributed(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
void SetAttributed(PRBool aValue);
|
||||
PRBool IsAttributed(void);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
|
||||
protected:
|
||||
@@ -157,12 +163,12 @@ class CStartToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CEndToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CEndToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual eHTMLTags GetHTMLTag();
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
};
|
||||
|
||||
@@ -176,11 +182,11 @@ class CEndToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CCommentToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CCommentToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
char mLeadingChar;
|
||||
};
|
||||
|
||||
@@ -193,18 +199,18 @@ class CCommentToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CEntityToken : public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CEntityToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
PRInt32 TranslateToUnicodeStr(nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
static PRInt32 ConsumeEntity(PRUnichar aChar,nsString& aString,CScanner& aScanner);
|
||||
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
|
||||
static PRInt32 FindEntityIndex(const char* aBuffer,PRInt32 aBufLen=-1);
|
||||
static PRBool VerifyEntityTable(void);
|
||||
static PRInt32 ReduceEntities(nsString& aString);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
|
||||
private:
|
||||
static PRInt32 mEntityTokenCount;
|
||||
@@ -219,11 +225,11 @@ class CEntityToken : public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CWhitespaceToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CWhitespaceToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
|
||||
/** -----------------------------------------------------
|
||||
@@ -234,11 +240,11 @@ class CWhitespaceToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CTextToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CTextToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -251,18 +257,18 @@ class CTextToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CAttributeToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CAttributeToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual nsString& GetKey(void) {return mTextKey;}
|
||||
virtual void DebugDumpToken(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
PRBool mLastAttribute;
|
||||
|
||||
protected:
|
||||
nsString mTextKey;
|
||||
nsString mTextKey;
|
||||
};
|
||||
|
||||
|
||||
@@ -273,11 +279,11 @@ class CAttributeToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CNewlineToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -291,11 +297,11 @@ class CNewlineToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CScriptToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
|
||||
CScriptToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -309,10 +315,10 @@ class CScriptToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CStyleToken: public CHTMLToken {
|
||||
public:
|
||||
public:
|
||||
CStyleToken(const nsString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -324,11 +330,11 @@ class CStyleToken: public CHTMLToken {
|
||||
* @update gess 3/25/98
|
||||
*/ //---------------------------------------------------
|
||||
class CSkippedContentToken: public CAttributeToken {
|
||||
public:
|
||||
public:
|
||||
CSkippedContentToken(const nsString& aString);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
protected:
|
||||
};
|
||||
|
||||
@@ -336,3 +342,5 @@ class CSkippedContentToken: public CAttributeToken {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ICONTENTSINK
|
||||
#define ICONTENTSINK
|
||||
#ifndef ICONTENTSINK
|
||||
#define ICONTENTSINK
|
||||
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsISupports.h"
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
class nsIContentSink : public nsISupports {
|
||||
public:
|
||||
public:
|
||||
|
||||
/**
|
||||
* This method is used to open a generic container in the sink.
|
||||
@@ -86,3 +86,5 @@ extern nsresult NS_NewHTMLContentSink(nsIContentSink** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#define NS_IDTD_IID \
|
||||
{0x75634940, 0xcfdc, 0x11d1, \
|
||||
@@ -38,9 +38,9 @@
|
||||
|
||||
class nsIDTD : public nsISupports {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -48,10 +48,10 @@ class nsIDTD : public nsISupports {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanContain(PRInt32 aParent,PRInt32 aChild) const =0;
|
||||
|
||||
/**-------------------------------------------------------
|
||||
/**
|
||||
* This method is called to determine whether or not a tag
|
||||
* of one type can contain a tag of another type.
|
||||
*
|
||||
@@ -59,20 +59,20 @@ class nsIDTD : public nsISupports {
|
||||
* @param aParent -- tag enum of parent container
|
||||
* @param aChild -- tag enum of child container
|
||||
* @return PR_TRUE if parent can contain child
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanContainIndirect(PRInt32 aParent,PRInt32 aChild) const=0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag is itself a container
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aTag -- tag to test for containership
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool IsContainer(PRInt32 aTags)const=0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method gets called to determine whether a given
|
||||
* tag can contain newlines. Most do not.
|
||||
*
|
||||
@@ -80,58 +80,59 @@ class nsIDTD : public nsISupports {
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return PR_TRUE if given tag can contain other tags
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRBool CanOmit(PRInt32 aParent,PRInt32 aChild)const=0;
|
||||
|
||||
/** ------------------------------------------------------
|
||||
/**
|
||||
* This method gets called at various times by the parser
|
||||
* whenever we want to verify a valid context stack. This
|
||||
* method also gives us a hook to add debugging metrics.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aStack[] array of ints (tokens)
|
||||
* @param aCount number of elements in given array
|
||||
* @return TRUE if stack is valid, else FALSE
|
||||
*/ //-----------------------------------------------------
|
||||
virtual PRBool VerifyContextStack(PRInt32 aStack[],PRInt32 aCount) const=0;
|
||||
*/
|
||||
virtual PRBool VerifyContextVector(PRInt32* aStack,PRInt32 aCount) const=0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method does two things: 1st, help construct
|
||||
* our own internal model of the content-stack; and
|
||||
* 2nd, pass this message on to the sink.
|
||||
* @update gess4/6/98
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @param aNode -- next node to be added to model
|
||||
* @return TRUE if ok, FALSE if error
|
||||
*/ //----------------------------------------------------
|
||||
*/
|
||||
virtual PRInt32 GetDefaultParentTagFor(PRInt32 aTag) const=0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the parent down to the
|
||||
* child.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
virtual PRInt32 ForwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const=0;
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool ForwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const=0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
/**
|
||||
* This method tries to design a context map (without actually
|
||||
* changing our parser state) from the child up to the parent.
|
||||
*
|
||||
* @update gess4/6/98
|
||||
* @update gess4/6/98
|
||||
* @param aParent -- tag type of parent
|
||||
* @param aChild -- tag type of child
|
||||
* @return Non zero count of intermediate nodes;
|
||||
* 0 if unable to comply
|
||||
*/ //----------------------------------------------------
|
||||
virtual PRInt32 BackwardPropagate(PRInt32 aVector[],PRInt32 aParent,PRInt32 aChild) const=0;
|
||||
* @return True if closure was achieved -- other false
|
||||
*/
|
||||
virtual PRBool BackwardPropagate(nsString& aVector,PRInt32 aParentTag,PRInt32 aChildTag) const=0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@
|
||||
* are going to be handled. Stay tuned.
|
||||
*/
|
||||
|
||||
#ifndef NS_IHTMLCONTENTSINK
|
||||
#define NS_ITMLCONTENTSINK
|
||||
#ifndef NS_IHTMLCONTENTSINK
|
||||
#define NS_ITMLCONTENTSINK
|
||||
|
||||
#include "nsIParserNode.h"
|
||||
#include "nsIContentSink.h"
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
|
||||
class nsIHTMLContentSink : public nsIContentSink {
|
||||
public:
|
||||
public:
|
||||
|
||||
/**
|
||||
* This method gets called by the parser when it encounters
|
||||
@@ -219,3 +219,5 @@ class nsIHTMLContentSink : public nsIContentSink {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class nsIContentSink;
|
||||
*------------------------------------------------------*/
|
||||
class nsIParser : public nsISupports {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
virtual nsIContentSink* SetContentSink(nsIContentSink* aContentSink)=0;
|
||||
virtual PRBool Parse(nsIURL* aURL)=0;
|
||||
@@ -60,3 +60,5 @@ extern NS_HTMLPARS nsresult NS_NewHTMLParser(nsIParser** aInstancePtrResult);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
*------------------------------------------------------*/
|
||||
class nsIParserNode {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
virtual const nsString& GetName() const =0; //to get name of tag
|
||||
virtual const nsString& GetText() const =0; //get plain text if available
|
||||
@@ -71,3 +71,5 @@ class nsIParserNode {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,11 @@ class nsHTMLParser;
|
||||
|
||||
class CITokenHandler {
|
||||
public:
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ITOKENIZERDELEGATE
|
||||
#define ITOKENIZERDELEGATE
|
||||
#ifndef ITOKENIZERDELEGATE
|
||||
#define ITOKENIZERDELEGATE
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nsParserTypes.h"
|
||||
@@ -46,16 +46,16 @@ class CScanner;
|
||||
class CToken;
|
||||
|
||||
class ITokenizerDelegate {
|
||||
public:
|
||||
public:
|
||||
|
||||
virtual PRBool WillTokenize()=0;
|
||||
virtual PRBool DidTokenize()=0;
|
||||
virtual PRBool WillTokenize()=0;
|
||||
virtual PRBool DidTokenize()=0;
|
||||
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode)=0;
|
||||
virtual CToken* GetToken(CScanner& aScanner,PRInt32& anErrorCode)=0;
|
||||
virtual PRBool WillAddToken(CToken& aToken)=0;
|
||||
|
||||
virtual eParseMode GetParseMode() const=0;
|
||||
virtual nsIDTD* GetDTD(void) const=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -138,7 +138,7 @@ const nsString& nsCParserNode::GetSkippedContent() const {
|
||||
* @return int value that represents tag type
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 nsCParserNode::GetNodeType(void) const{
|
||||
return mToken->GetHTMLTag();
|
||||
return mToken->GetHTMLTag();
|
||||
}
|
||||
|
||||
|
||||
@@ -201,3 +201,5 @@ PRInt32 nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class nsHTMLParser;
|
||||
|
||||
class nsCParserNode : public nsIParserNode {
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
nsCParserNode(CHTMLToken* aToken);
|
||||
~nsCParserNode();
|
||||
@@ -77,3 +77,5 @@ class nsCParserNode : public nsIParserNode {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define PARSER_TYPES__
|
||||
|
||||
/* ===========================================================*
|
||||
Some useful constants...
|
||||
Some useful constants...
|
||||
* ===========================================================*/
|
||||
|
||||
#include "prtypes.h"
|
||||
@@ -40,35 +40,37 @@ enum eParseMode {
|
||||
eParseMode_other
|
||||
};
|
||||
|
||||
const PRInt32 kNotFound = -1;
|
||||
const PRInt32 kNoError = 0;
|
||||
const PRInt32 kNotFound = -1;
|
||||
const PRInt32 kNoError = 0;
|
||||
const PRInt32 kEOF = 1000;
|
||||
|
||||
const PRUint32 kNewLine = '\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 kGreaterThan = '>';
|
||||
const PRUint32 kAmpersand = '&';
|
||||
const PRUint32 kNullPRInt8 = '\0';
|
||||
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 kComma = ',';
|
||||
const PRUint32 kLeftParen = '(';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
const PRUint32 kNewLine = '\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 kGreaterThan = '>';
|
||||
const PRUint32 kAmpersand = '&';
|
||||
const PRUint32 kNullPRInt8 = '\0';
|
||||
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 kComma = ',';
|
||||
const PRUint32 kLeftParen = '(';
|
||||
const PRUint32 kRightParen = ')';
|
||||
const PRUint32 kLeftBrace = '{';
|
||||
const PRUint32 kRightBrace = '}';
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ CScanner::~CScanner() {
|
||||
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* @update gess4/3/98
|
||||
* @update gess4/3/98
|
||||
* @param
|
||||
* @return
|
||||
*------------------------------------------------------*/
|
||||
@@ -188,10 +188,10 @@ PRInt32 CScanner::SkipOver(nsString& aValidSet){
|
||||
result=GetChar(ch);
|
||||
if(!result) {
|
||||
PRInt32 pos=aValidSet.Find(ch);
|
||||
if(kNotFound==pos) {
|
||||
PutBack(ch);
|
||||
break;
|
||||
}
|
||||
if(kNotFound==pos) {
|
||||
PutBack(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else break;
|
||||
} //while
|
||||
@@ -249,18 +249,18 @@ PRInt32 CScanner::ReadWhile(nsString& aString,nsString& aValidSet,PRBool addTerm
|
||||
* @return error code
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addTerminal){
|
||||
PRUnichar ch=0;
|
||||
PRUnichar ch=0;
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
while(!Eof()) {
|
||||
result=GetChar(ch);
|
||||
while(!Eof()) {
|
||||
result=GetChar(ch);
|
||||
if(kNoError==result) {
|
||||
PRInt32 pos=aTerminalSet.Find(ch);
|
||||
if(kNotFound!=pos) {
|
||||
if(addTerminal)
|
||||
if(kNotFound!=pos) {
|
||||
if(addTerminal)
|
||||
aString+=ch;
|
||||
else PutBack(ch);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
else aString+=ch;
|
||||
}
|
||||
@@ -277,7 +277,7 @@ PRInt32 CScanner::ReadUntil(nsString& aString,nsString& aTerminalSet,PRBool addT
|
||||
* @return error code
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CScanner::ReadUntil(nsString& aString,PRUnichar aTerminalChar,PRBool addTerminal){
|
||||
PRUnichar ch=0;
|
||||
PRUnichar ch=0;
|
||||
PRInt32 result=kNoError;
|
||||
|
||||
while(kNoError==result) {
|
||||
@@ -308,3 +308,5 @@ void CScanner::SelfTest(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,21 +43,21 @@ class ifstream;
|
||||
|
||||
class CScanner {
|
||||
public:
|
||||
CScanner(nsIURL* aURL,eParseMode aMode=eParseMode_navigator);
|
||||
~CScanner();
|
||||
CScanner(nsIURL* aURL,eParseMode aMode=eParseMode_navigator);
|
||||
~CScanner();
|
||||
|
||||
PRInt32 GetChar(PRUnichar& ch);
|
||||
PRInt32 Peek(PRUnichar& ch);
|
||||
PRInt32 PutBack(PRUnichar ch);
|
||||
PRInt32 SkipOver(nsString& SkipChars);
|
||||
PRInt32 SkipPast(nsString& aSequence);
|
||||
PRInt32 SkipPast(PRUnichar aChar);
|
||||
PRInt32 SkipWhite(void);
|
||||
PRInt32 Peek(PRUnichar& ch);
|
||||
PRInt32 PutBack(PRUnichar ch);
|
||||
PRInt32 SkipOver(nsString& SkipChars);
|
||||
PRInt32 SkipPast(nsString& aSequence);
|
||||
PRInt32 SkipPast(PRUnichar aChar);
|
||||
PRInt32 SkipWhite(void);
|
||||
PRBool Eof(void);
|
||||
|
||||
PRInt32 ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);
|
||||
PRInt32 ReadUntil(nsString& aString,nsString& terminals,PRBool addTerminal);
|
||||
PRInt32 ReadWhile(nsString& aString,nsString& validChars,PRBool addTerminal);
|
||||
PRInt32 ReadUntil(nsString& aString,PRUnichar aTerminal,PRBool addTerminal);
|
||||
PRInt32 ReadUntil(nsString& aString,nsString& terminals,PRBool addTerminal);
|
||||
PRInt32 ReadWhile(nsString& aString,nsString& validChars,PRBool addTerminal);
|
||||
|
||||
static void SelfTest();
|
||||
|
||||
@@ -65,7 +65,7 @@ class CScanner {
|
||||
|
||||
PRInt32 FillBuffer(PRInt32& anError);
|
||||
|
||||
nsIInputStream* mStream;
|
||||
nsIInputStream* mStream;
|
||||
nsString mBuffer;
|
||||
PRInt32 mOffset;
|
||||
PRInt32 mTotalRead;
|
||||
@@ -73,3 +73,5 @@ class CScanner {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ CToken::~CToken() {
|
||||
* @return int error code
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::Consume(PRUnichar aChar,CScanner& aScanner) {
|
||||
PRInt32 result=kNoError;
|
||||
PRInt32 result=kNoError;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ PRInt32 CToken::Consume(PRUnichar aChar,CScanner& aScanner) {
|
||||
* @param aValue -- char* containing new value
|
||||
*------------------------------------------------------*/
|
||||
void CToken::SetStringValue(const char* aValue) {
|
||||
mTextValue=aValue;
|
||||
mTextValue=aValue;
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
@@ -70,7 +70,7 @@ void CToken::SetStringValue(const char* aValue) {
|
||||
* @param ostream -- output stream to accept output data
|
||||
*------------------------------------------------------*/
|
||||
void CToken::DebugDumpToken(ostream& anOutputStream) {
|
||||
anOutputStream << "[" << GetClassName() << "] ";
|
||||
anOutputStream << "[" << GetClassName() << "] ";
|
||||
for(int i=0;i<mTextValue.Length();i++){
|
||||
anOutputStream << char(mTextValue[i]);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void CToken::DebugDumpToken(ostream& anOutputStream) {
|
||||
*------------------------------------------------------*/
|
||||
void CToken::DebugDumpSource(ostream& anOutputStream) {
|
||||
char buf[256];
|
||||
anOutputStream << mTextValue.ToCString(buf, 256);
|
||||
anOutputStream << mTextValue.ToCString(buf,256);
|
||||
}
|
||||
|
||||
/**-------------------------------------------------------
|
||||
@@ -121,7 +121,7 @@ void CToken::SetOrdinal(PRInt32 value) {
|
||||
* @update gess 3/25/98
|
||||
* @return int containing ordinal value
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::GetOrdinal(void) {
|
||||
PRInt32 CToken::GetOrdinal(void) {
|
||||
return mOrdinalValue;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ PRInt32 CToken::GetOrdinal(void) {
|
||||
* @update gess 3/25/98
|
||||
* @return int value containing token type.
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CToken::GetTokenType(void) {
|
||||
PRInt32 CToken::GetTokenType(void) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ PRInt32 CToken::GetTokenType(void) {
|
||||
* @update gess 3/25/98
|
||||
* @return char* containing name of class
|
||||
*------------------------------------------------------*/
|
||||
const char* CToken::GetClassName(void) {
|
||||
const char* CToken::GetClassName(void) {
|
||||
return "token";
|
||||
}
|
||||
|
||||
@@ -154,3 +154,5 @@ void CToken::SelfTest(void) {
|
||||
#ifdef _DEBUG
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,25 +51,27 @@ class CScanner;
|
||||
* @update gess 3/25/98
|
||||
*------------------------------------------------------*/
|
||||
class CToken {
|
||||
public:
|
||||
CToken(const nsString& aName);
|
||||
virtual ~CToken();
|
||||
|
||||
virtual nsString& GetStringValue(void);
|
||||
virtual nsString& GetText(void);
|
||||
virtual void SetStringValue(const char* name);
|
||||
virtual void SetOrdinal(PRInt32 value);
|
||||
virtual PRInt32 GetOrdinal(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual void DebugDumpToken(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
static void SelfTest();
|
||||
public:
|
||||
CToken(const nsString& aName);
|
||||
~CToken();
|
||||
|
||||
virtual nsString& GetStringValue(void);
|
||||
virtual nsString& GetText(void);
|
||||
virtual void SetStringValue(const char* name);
|
||||
virtual void SetOrdinal(PRInt32 value);
|
||||
virtual PRInt32 GetOrdinal(void);
|
||||
virtual PRInt32 Consume(PRUnichar aChar,CScanner& aScanner);
|
||||
virtual void DebugDumpToken(ostream& out);
|
||||
virtual void DebugDumpSource(ostream& out);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual void SelfTest(void);
|
||||
|
||||
protected:
|
||||
PRInt32 mOrdinalValue;
|
||||
nsString mTextValue;
|
||||
PRInt32 mOrdinalValue;
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ CStartTokenHandler::CStartTokenHandler() : CTokenHandler(eToken_start) {
|
||||
*------------------------------------------------------*/
|
||||
CStartTokenHandler::~CStartTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -165,7 +165,7 @@ CEndTokenHandler::CEndTokenHandler(): CTokenHandler(eToken_end) {
|
||||
*------------------------------------------------------*/
|
||||
CEndTokenHandler::~CEndTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -215,7 +215,7 @@ CCommentTokenHandler::CCommentTokenHandler() : CTokenHandler(eToken_comment) {
|
||||
*------------------------------------------------------*/
|
||||
CCommentTokenHandler::~CCommentTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -264,7 +264,7 @@ CEntityTokenHandler::CEntityTokenHandler() : CTokenHandler(eToken_entity) {
|
||||
*------------------------------------------------------*/
|
||||
CEntityTokenHandler::~CEntityTokenHandler() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -313,7 +313,7 @@ CWhitespaceTokenHandler::CWhitespaceTokenHandler() : CTokenHandler(eToken_whites
|
||||
*------------------------------------------------------*/
|
||||
CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -325,7 +325,7 @@ CWhitespaceTokenHandler::~CWhitespaceTokenHandler(){
|
||||
PRBool CWhitespaceTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
|
||||
NS_ASSERTION(0!=aParser,kNullParserGiven);
|
||||
if(aParser){
|
||||
return aParser->HandleWhitespaceToken(aToken);
|
||||
return aParser->HandleSimpleContentToken(aToken);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ CNewlineTokenHandler::CNewlineTokenHandler() : CTokenHandler(eToken_newline) {
|
||||
*------------------------------------------------------*/
|
||||
CNewlineTokenHandler::~CNewlineTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -375,7 +375,7 @@ CNewlineTokenHandler::~CNewlineTokenHandler(){
|
||||
PRBool CNewlineTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
|
||||
NS_ASSERTION(0!=aParser,kNullParserGiven);
|
||||
if(aParser){
|
||||
return aParser->HandleNewlineToken(aToken);
|
||||
return aParser->HandleSimpleContentToken(aToken);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ CTextTokenHandler::CTextTokenHandler() : CTokenHandler(eToken_text) {
|
||||
*------------------------------------------------------*/
|
||||
CTextTokenHandler::~CTextTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -424,7 +424,7 @@ CTextTokenHandler::~CTextTokenHandler(){
|
||||
PRBool CTextTokenHandler::operator()(CToken* aToken,nsHTMLParser* aParser){
|
||||
NS_ASSERTION(0!=aParser,kNullParserGiven);
|
||||
if(aParser){
|
||||
return aParser->HandleTextToken(aToken);
|
||||
return aParser->HandleSimpleContentToken(aToken);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ CAttributeTokenHandler::CAttributeTokenHandler() : CTokenHandler(eToken_attribut
|
||||
*------------------------------------------------------*/
|
||||
CAttributeTokenHandler::~CAttributeTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -509,7 +509,7 @@ CScriptTokenHandler::CScriptTokenHandler() : CTokenHandler(eToken_script) {
|
||||
*------------------------------------------------------*/
|
||||
CScriptTokenHandler::~CScriptTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -558,7 +558,7 @@ CStyleTokenHandler::CStyleTokenHandler() : CTokenHandler(eToken_style) {
|
||||
*------------------------------------------------------*/
|
||||
CStyleTokenHandler::~CStyleTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -607,7 +607,7 @@ CSkippedContentTokenHandler::CSkippedContentTokenHandler() : CTokenHandler(eToke
|
||||
*------------------------------------------------------*/
|
||||
CSkippedContentTokenHandler::~CSkippedContentTokenHandler(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**-------------------------------------------------------
|
||||
*
|
||||
@@ -635,3 +635,5 @@ PRBool CSkippedContentTokenHandler::CanHandle(eHTMLTokenTypes aType){
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,23 +36,23 @@ class nsHTMLParser;
|
||||
|
||||
class CTokenHandler : public CITokenHandler {
|
||||
public:
|
||||
CTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
|
||||
CTokenHandler(eHTMLTokenTypes aType=eToken_unknown);
|
||||
virtual ~CTokenHandler();
|
||||
|
||||
|
||||
virtual eHTMLTokenTypes GetTokenType(void);
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
|
||||
protected:
|
||||
eHTMLTokenTypes mType;
|
||||
eHTMLTokenTypes mType;
|
||||
};
|
||||
|
||||
|
||||
class CStartTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CStartTokenHandler();
|
||||
CStartTokenHandler();
|
||||
virtual ~CStartTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -60,9 +60,9 @@ public:
|
||||
|
||||
class CEndTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CEndTokenHandler();
|
||||
CEndTokenHandler();
|
||||
virtual ~CEndTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -70,9 +70,9 @@ public:
|
||||
|
||||
class CCommentTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CCommentTokenHandler();
|
||||
CCommentTokenHandler();
|
||||
virtual ~CCommentTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
|
||||
class CEntityTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CEntityTokenHandler();
|
||||
CEntityTokenHandler();
|
||||
virtual ~CEntityTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -90,9 +90,9 @@ public:
|
||||
|
||||
class CWhitespaceTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CWhitespaceTokenHandler();
|
||||
CWhitespaceTokenHandler();
|
||||
virtual ~CWhitespaceTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -100,9 +100,9 @@ public:
|
||||
|
||||
class CNewlineTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CNewlineTokenHandler();
|
||||
CNewlineTokenHandler();
|
||||
virtual ~CNewlineTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
|
||||
class CTextTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CTextTokenHandler();
|
||||
CTextTokenHandler();
|
||||
virtual ~CTextTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -120,9 +120,9 @@ public:
|
||||
|
||||
class CAttributeTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CAttributeTokenHandler();
|
||||
CAttributeTokenHandler();
|
||||
virtual ~CAttributeTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -130,9 +130,9 @@ public:
|
||||
|
||||
class CScriptTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CScriptTokenHandler();
|
||||
CScriptTokenHandler();
|
||||
virtual ~CScriptTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -140,9 +140,9 @@ public:
|
||||
|
||||
class CStyleTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CStyleTokenHandler();
|
||||
CStyleTokenHandler();
|
||||
virtual ~CStyleTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
@@ -150,12 +150,14 @@ public:
|
||||
|
||||
class CSkippedContentTokenHandler : public CTokenHandler {
|
||||
public:
|
||||
CSkippedContentTokenHandler();
|
||||
CSkippedContentTokenHandler();
|
||||
virtual ~CSkippedContentTokenHandler();
|
||||
|
||||
|
||||
virtual PRBool operator()(CToken* aToken,nsHTMLParser* aParser);
|
||||
virtual PRBool CanHandle(eHTMLTokenTypes aType);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ CTokenizer::~CTokenizer() {
|
||||
/**
|
||||
* Retrieve a reference to the internal token deque.
|
||||
*
|
||||
* @update gess 4/20/98
|
||||
* @update gess 4/20/98
|
||||
* @return deque reference
|
||||
*/
|
||||
nsDeque& CTokenizer::GetDeque(void) {
|
||||
@@ -73,7 +73,7 @@ nsDeque& CTokenizer::GetDeque(void) {
|
||||
* @return new token or null
|
||||
*------------------------------------------------------*/
|
||||
CToken* CTokenizer::GetToken(PRInt32& anError) {
|
||||
CToken* nextToken=mDelegate->GetToken(*mScanner,anError);
|
||||
CToken* nextToken=mDelegate->GetToken(*mScanner,anError);
|
||||
return nextToken;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ CToken* CTokenizer::GetToken(PRInt32& anError) {
|
||||
* @return int containing element count
|
||||
*-----------------------------------------------------*/
|
||||
PRInt32 CTokenizer::GetSize(void) {
|
||||
return mTokenDeque.GetSize();
|
||||
return mTokenDeque.GetSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ PRBool CTokenizer::WillTokenize(){
|
||||
*------------------------------------------------------*/
|
||||
PRInt32 CTokenizer::Tokenize(void) {
|
||||
CToken* nextToken;
|
||||
PRInt32 result;
|
||||
PRInt32 result;
|
||||
|
||||
if(WillTokenize()) {
|
||||
do {
|
||||
@@ -125,7 +125,7 @@ PRInt32 CTokenizer::Tokenize(void) {
|
||||
nextToken->DebugDumpToken(cout);
|
||||
#endif
|
||||
if(mDelegate->WillAddToken(*nextToken)) {
|
||||
mTokenDeque.Push(nextToken);
|
||||
mTokenDeque.Push(nextToken);
|
||||
}
|
||||
}
|
||||
} while(nextToken!=0);
|
||||
@@ -145,7 +145,7 @@ PRInt32 CTokenizer::Tokenize(void) {
|
||||
* @return TRUE if all went well
|
||||
*------------------------------------------------------*/
|
||||
PRBool CTokenizer::DidTokenize() {
|
||||
PRBool result=mDelegate->DidTokenize();
|
||||
PRBool result=mDelegate->DidTokenize();
|
||||
|
||||
#ifdef VERBOSE_DEBUG
|
||||
DebugDumpTokens(cout);
|
||||
@@ -208,3 +208,5 @@ void CTokenizer::SelfTest(void) {
|
||||
#ifdef _DEBUG
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
/**
|
||||
* MODULE NOTES:
|
||||
* LAST MODS: gess 28Feb98
|
||||
* LAST MODS: gess 28Feb98
|
||||
*
|
||||
* This file declares the basic tokenizer class. The
|
||||
* central theme of this class is to control and
|
||||
@@ -37,8 +37,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TOKENIZER
|
||||
#define TOKENIZER
|
||||
#ifndef TOKENIZER
|
||||
#define TOKENIZER
|
||||
|
||||
#include "nsToken.h"
|
||||
#include "nsITokenizerDelegate.h"
|
||||
@@ -49,28 +49,30 @@ class CScanner;
|
||||
class nsIURL;
|
||||
|
||||
class CTokenizer {
|
||||
public:
|
||||
CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMode);
|
||||
~CTokenizer();
|
||||
public:
|
||||
CTokenizer(nsIURL* aURL,ITokenizerDelegate* aDelegate,eParseMode aMode);
|
||||
~CTokenizer();
|
||||
|
||||
PRInt32 Tokenize(void);
|
||||
CToken* GetToken(PRInt32& anErrorCode);
|
||||
PRInt32 Tokenize(void);
|
||||
CToken* GetToken(PRInt32& anErrorCode);
|
||||
PRInt32 GetSize(void);
|
||||
nsDeque& GetDeque(void);
|
||||
|
||||
void DebugDumpSource(ostream& out);
|
||||
void DebugDumpTokens(ostream& out);
|
||||
void DebugDumpSource(ostream& out);
|
||||
void DebugDumpTokens(ostream& out);
|
||||
static void SelfTest();
|
||||
|
||||
protected:
|
||||
|
||||
PRBool WillTokenize();
|
||||
PRBool DidTokenize();
|
||||
PRBool WillTokenize();
|
||||
PRBool DidTokenize();
|
||||
|
||||
ITokenizerDelegate* mDelegate;
|
||||
ITokenizerDelegate* mDelegate;
|
||||
CScanner* mScanner;
|
||||
nsDeque mTokenDeque;
|
||||
eParseMode mParseMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -33,3 +33,5 @@
|
||||
#endif
|
||||
|
||||
#endif /* nshtmlpars_h___ */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user