diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index f043b4aa37d..370e34061be 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -129,6 +129,12 @@ static char formElementTags[]= {
eHTMLTag_isindex, eHTMLTag_label, eHTMLTag_legend,
eHTMLTag_select, eHTMLTag_textarea,0};
+static char gHeadingTags[]={
+ eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
+ eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6,
+ 0};
+
+
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@@ -143,6 +149,7 @@ PRBool CNavDTD::CanContainFormElement(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
+
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@@ -341,10 +348,7 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
case eHTMLTag_h3: case eHTMLTag_h4:
case eHTMLTag_h5: case eHTMLTag_h6:
{
- static char badTags[]={
- eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
- eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6, 0};
- if(0!=strchr(badTags,aChild))
+ if(0!=strchr(gHeadingTags,aChild))
result=PR_FALSE;
else result=PRBool(0!=strchr(gTagSet1,aChild));
}
@@ -635,6 +639,68 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
+/**
+ * This method gets called to determine whether a given
+ * ENDtag can be omitted. Admittedly,this is a gross simplification.
+ *
+ * @update gess 3/25/98
+ * @param aTag -- tag to test for containership
+ * @return PR_TRUE if given tag can contain other tags
+ */
+PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
+ PRBool result=PR_FALSE;
+
+ //begin with some simple (and obvious) cases...
+ switch((eHTMLTags)aChild) {
+
+ case eHTMLTag_userdefined:
+ case eHTMLTag_comment:
+ result=PR_TRUE;
+ break;
+
+ case eHTMLTag_h1: case eHTMLTag_h2:
+ case eHTMLTag_h3: case eHTMLTag_h4:
+ case eHTMLTag_h5: case eHTMLTag_h6:
+ {
+ if(0!=strchr(gHeadingTags,aParent))
+ result=PR_FALSE;
+ //Actually, we probably need to walk the stack here...
+ else result=PR_TRUE;
+ }
+ break;
+
+ case eHTMLTag_button: case eHTMLTag_fieldset:
+ case eHTMLTag_input: case eHTMLTag_isindex:
+ case eHTMLTag_label: case eHTMLTag_legend:
+ case eHTMLTag_select: case eHTMLTag_textarea:
+ if(PR_FALSE==mParser->HasOpenForm())
+ result=PR_TRUE;
+ break;
+
+ case eHTMLTag_newline:
+ case eHTMLTag_whitespace:
+
+ switch((eHTMLTags)aParent) {
+ case eHTMLTag_html: case eHTMLTag_head:
+ case eHTMLTag_title: case eHTMLTag_map:
+ case eHTMLTag_tr: case eHTMLTag_table:
+ case eHTMLTag_thead: case eHTMLTag_tfoot:
+ case eHTMLTag_tbody: case eHTMLTag_col:
+ case eHTMLTag_colgroup: case eHTMLTag_unknown:
+ result=PR_TRUE;
+ default:
+ break;
+ } //switch
+ break;
+
+ default:
+ if(aChild!=aParent)
+ result=PR_TRUE;
+ break;
+ } //switch
+ return result;
+}
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/htmlparser/src/CNavDTD.h b/mozilla/htmlparser/src/CNavDTD.h
index 8fbe7cc51fe..acc33831e16 100644
--- a/mozilla/htmlparser/src/CNavDTD.h
+++ b/mozilla/htmlparser/src/CNavDTD.h
@@ -104,6 +104,17 @@ class CNavDTD : public nsIDTD {
*/
virtual PRBool CanOmit(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 aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(PRInt32 aParent,PRInt32 aChild)const;
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/htmlparser/src/COtherDTD.cpp b/mozilla/htmlparser/src/COtherDTD.cpp
index 1eaf16312d4..7965b8c7d44 100644
--- a/mozilla/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/htmlparser/src/COtherDTD.cpp
@@ -556,6 +556,19 @@ PRBool COtherDTD::CanOmit(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::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
+ PRBool result=PR_FALSE;
+ return result;
+}
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/htmlparser/src/COtherDTD.h b/mozilla/htmlparser/src/COtherDTD.h
index d0e5c3665dc..0e9adc6d13e 100644
--- a/mozilla/htmlparser/src/COtherDTD.h
+++ b/mozilla/htmlparser/src/COtherDTD.h
@@ -106,6 +106,17 @@ class COtherDTD : public nsIDTD {
*/
virtual PRBool CanOmit(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 aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(PRInt32 aParent,PRInt32 aChild)const;
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/htmlparser/src/nsHTMLParser.cpp b/mozilla/htmlparser/src/nsHTMLParser.cpp
index ce0345a74d2..05242870a75 100644
--- a/mozilla/htmlparser/src/nsHTMLParser.cpp
+++ b/mozilla/htmlparser/src/nsHTMLParser.cpp
@@ -760,11 +760,11 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
NS_PRECONDITION(0!=aToken,kNullToken);
PRBool result=PR_FALSE;
- CEndToken* st = (CEndToken*)(aToken);
- eHTMLTags tokenTagType=st->GetHTMLTag();
+ CEndToken* et = (CEndToken*)(aToken);
+ eHTMLTags tokenTagType=et->GetHTMLTag();
//now check to see if this token should be omitted...
- if(PR_TRUE==mDTD->CanOmit(GetTopNode(),tokenTagType)) {
+ if(PR_TRUE==mDTD->CanOmitEndTag(GetTopNode(),tokenTagType)) {
return PR_TRUE;
}
diff --git a/mozilla/htmlparser/src/nsIDTD.h b/mozilla/htmlparser/src/nsIDTD.h
index cf8017112b8..402ed56f92b 100644
--- a/mozilla/htmlparser/src/nsIDTD.h
+++ b/mozilla/htmlparser/src/nsIDTD.h
@@ -95,6 +95,17 @@ class nsIDTD : public nsISupports {
*/
virtual PRBool CanOmit(PRInt32 aParent,PRInt32 aChild)const=0;
+ /**
+ * This method gets called to determine whether a given
+ * tag can contain newlines. Most do not.
+ *
+ * @update gess 3/25/98
+ * @param aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(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
diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp
index 47cd6561588..f8ba4ed729d 100644
--- a/mozilla/htmlparser/src/nsScanner.cpp
+++ b/mozilla/htmlparser/src/nsScanner.cpp
@@ -53,8 +53,11 @@ CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
* @return
*/
CScanner::~CScanner() {
- mStream->Close();
- mStream->Release();
+ if(mStream) {
+ mStream->Close();
+ mStream->Release();
+ mStream=0;
+ }
}
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index f043b4aa37d..370e34061be 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -129,6 +129,12 @@ static char formElementTags[]= {
eHTMLTag_isindex, eHTMLTag_label, eHTMLTag_legend,
eHTMLTag_select, eHTMLTag_textarea,0};
+static char gHeadingTags[]={
+ eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
+ eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6,
+ 0};
+
+
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@@ -143,6 +149,7 @@ PRBool CNavDTD::CanContainFormElement(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
+
/**
* This method is called to determine whether or not a tag
* of one type can contain a tag of another type.
@@ -341,10 +348,7 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
case eHTMLTag_h3: case eHTMLTag_h4:
case eHTMLTag_h5: case eHTMLTag_h6:
{
- static char badTags[]={
- eHTMLTag_h1, eHTMLTag_h2, eHTMLTag_h3,
- eHTMLTag_h4, eHTMLTag_h5, eHTMLTag_h6, 0};
- if(0!=strchr(badTags,aChild))
+ if(0!=strchr(gHeadingTags,aChild))
result=PR_FALSE;
else result=PRBool(0!=strchr(gTagSet1,aChild));
}
@@ -635,6 +639,68 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
return result;
}
+/**
+ * This method gets called to determine whether a given
+ * ENDtag can be omitted. Admittedly,this is a gross simplification.
+ *
+ * @update gess 3/25/98
+ * @param aTag -- tag to test for containership
+ * @return PR_TRUE if given tag can contain other tags
+ */
+PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
+ PRBool result=PR_FALSE;
+
+ //begin with some simple (and obvious) cases...
+ switch((eHTMLTags)aChild) {
+
+ case eHTMLTag_userdefined:
+ case eHTMLTag_comment:
+ result=PR_TRUE;
+ break;
+
+ case eHTMLTag_h1: case eHTMLTag_h2:
+ case eHTMLTag_h3: case eHTMLTag_h4:
+ case eHTMLTag_h5: case eHTMLTag_h6:
+ {
+ if(0!=strchr(gHeadingTags,aParent))
+ result=PR_FALSE;
+ //Actually, we probably need to walk the stack here...
+ else result=PR_TRUE;
+ }
+ break;
+
+ case eHTMLTag_button: case eHTMLTag_fieldset:
+ case eHTMLTag_input: case eHTMLTag_isindex:
+ case eHTMLTag_label: case eHTMLTag_legend:
+ case eHTMLTag_select: case eHTMLTag_textarea:
+ if(PR_FALSE==mParser->HasOpenForm())
+ result=PR_TRUE;
+ break;
+
+ case eHTMLTag_newline:
+ case eHTMLTag_whitespace:
+
+ switch((eHTMLTags)aParent) {
+ case eHTMLTag_html: case eHTMLTag_head:
+ case eHTMLTag_title: case eHTMLTag_map:
+ case eHTMLTag_tr: case eHTMLTag_table:
+ case eHTMLTag_thead: case eHTMLTag_tfoot:
+ case eHTMLTag_tbody: case eHTMLTag_col:
+ case eHTMLTag_colgroup: case eHTMLTag_unknown:
+ result=PR_TRUE;
+ default:
+ break;
+ } //switch
+ break;
+
+ default:
+ if(aChild!=aParent)
+ result=PR_TRUE;
+ break;
+ } //switch
+ return result;
+}
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.h b/mozilla/parser/htmlparser/src/CNavDTD.h
index 8fbe7cc51fe..acc33831e16 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.h
+++ b/mozilla/parser/htmlparser/src/CNavDTD.h
@@ -104,6 +104,17 @@ class CNavDTD : public nsIDTD {
*/
virtual PRBool CanOmit(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 aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(PRInt32 aParent,PRInt32 aChild)const;
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/parser/htmlparser/src/COtherDTD.cpp b/mozilla/parser/htmlparser/src/COtherDTD.cpp
index 1eaf16312d4..7965b8c7d44 100644
--- a/mozilla/parser/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/parser/htmlparser/src/COtherDTD.cpp
@@ -556,6 +556,19 @@ PRBool COtherDTD::CanOmit(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::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
+ PRBool result=PR_FALSE;
+ return result;
+}
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/parser/htmlparser/src/COtherDTD.h b/mozilla/parser/htmlparser/src/COtherDTD.h
index d0e5c3665dc..0e9adc6d13e 100644
--- a/mozilla/parser/htmlparser/src/COtherDTD.h
+++ b/mozilla/parser/htmlparser/src/COtherDTD.h
@@ -106,6 +106,17 @@ class COtherDTD : public nsIDTD {
*/
virtual PRBool CanOmit(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 aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(PRInt32 aParent,PRInt32 aChild)const;
+
/**
* This method gets called to determine whether a given
* tag is itself a container
diff --git a/mozilla/parser/htmlparser/src/nsHTMLParser.cpp b/mozilla/parser/htmlparser/src/nsHTMLParser.cpp
index ce0345a74d2..05242870a75 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLParser.cpp
@@ -760,11 +760,11 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
NS_PRECONDITION(0!=aToken,kNullToken);
PRBool result=PR_FALSE;
- CEndToken* st = (CEndToken*)(aToken);
- eHTMLTags tokenTagType=st->GetHTMLTag();
+ CEndToken* et = (CEndToken*)(aToken);
+ eHTMLTags tokenTagType=et->GetHTMLTag();
//now check to see if this token should be omitted...
- if(PR_TRUE==mDTD->CanOmit(GetTopNode(),tokenTagType)) {
+ if(PR_TRUE==mDTD->CanOmitEndTag(GetTopNode(),tokenTagType)) {
return PR_TRUE;
}
diff --git a/mozilla/parser/htmlparser/src/nsIDTD.h b/mozilla/parser/htmlparser/src/nsIDTD.h
index cf8017112b8..402ed56f92b 100644
--- a/mozilla/parser/htmlparser/src/nsIDTD.h
+++ b/mozilla/parser/htmlparser/src/nsIDTD.h
@@ -95,6 +95,17 @@ class nsIDTD : public nsISupports {
*/
virtual PRBool CanOmit(PRInt32 aParent,PRInt32 aChild)const=0;
+ /**
+ * This method gets called to determine whether a given
+ * tag can contain newlines. Most do not.
+ *
+ * @update gess 3/25/98
+ * @param aParent -- tag type of parent
+ * @param aChild -- tag type of child
+ * @return PR_TRUE if given tag can contain other tags
+ */
+ virtual PRBool CanOmitEndTag(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
diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp
index 47cd6561588..f8ba4ed729d 100644
--- a/mozilla/parser/htmlparser/src/nsScanner.cpp
+++ b/mozilla/parser/htmlparser/src/nsScanner.cpp
@@ -53,8 +53,11 @@ CScanner::CScanner(nsIURL* aURL,eParseMode aMode) : mBuffer("") {
* @return
*/
CScanner::~CScanner() {
- mStream->Close();
- mStream->Release();
+ if(mStream) {
+ mStream->Close();
+ mStream->Release();
+ mStream=0;
+ }
}