зеркало из https://github.com/mozilla/gecko-dev.git
MUCH better support for auto-closing tags.
This commit is contained in:
Родитель
b241581840
Коммит
c13d70ca8f
|
@ -145,7 +145,7 @@ static char gHeadingTags[]={
|
|||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
PRBool CNavDTD::CanContainFormElement(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=(mParser) ? mParser->HasOpenForm() : PR_FALSE;
|
||||
PRBool result=(mParser) ? mParser->HasOpenContainer(eHTMLTag_form) : PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
|||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_select: case eHTMLTag_textarea:
|
||||
if(PR_FALSE==mParser->HasOpenForm())
|
||||
if(PR_FALSE==mParser->HasOpenContainer(eHTMLTag_form))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -631,7 +631,6 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
|||
default:
|
||||
if(eHTMLTag_unknown==aParent)
|
||||
result=PR_FALSE;
|
||||
// result=PRBool(eHTMLTag_html!=aChild);
|
||||
break;
|
||||
} //switch
|
||||
return result;
|
||||
|
@ -672,7 +671,7 @@ PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
|
|||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_textarea:
|
||||
if(PR_FALSE==mParser->HasOpenForm())
|
||||
if(PR_FALSE==mParser->HasOpenContainer(aChild))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -693,8 +692,7 @@ PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
|
|||
break;
|
||||
|
||||
default:
|
||||
if(aChild!=aParent)
|
||||
result=PR_TRUE;
|
||||
result=(!mParser->HasOpenContainer(aChild));
|
||||
break;
|
||||
} //switch
|
||||
return result;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// 1) If you see </>, simply treat it as a bad tag.
|
||||
// 2) If you see </ ...>, treat it like a comment.
|
||||
// 3) If you see <> or <_ (< space) simply treat it as text.
|
||||
// 4) If you see <~ (< followed by non-alpha), treat it as text.
|
||||
// 4) If you see <[!a..z] (< followed by non-alpha), treat it as text.
|
||||
|
||||
static char gIdentChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
|
||||
|
|
|
@ -191,8 +191,17 @@ eHTMLTags nsHTMLParser::NodeAt(PRInt32 aPos) const {
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLParser::HasOpenForm() const {
|
||||
return mHasOpenForm;
|
||||
PRBool nsHTMLParser::HasOpenContainer(PRInt32 aContainer) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
switch((eHTMLTags)aContainer) {
|
||||
case eHTMLTag_form:
|
||||
result=mHasOpenForm; break;
|
||||
|
||||
default:
|
||||
result=(kNotFound!=GetTopmostIndex((eHTMLTags)aContainer)); break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -789,8 +798,6 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
switch(tokenTagType) {
|
||||
case eHTMLTag_html:
|
||||
result=CloseContainersTo(tokenTagType); break;
|
||||
|
||||
case eHTMLTag_style:
|
||||
case eHTMLTag_link:
|
||||
|
@ -798,6 +805,7 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
case eHTMLTag_textarea:
|
||||
case eHTMLTag_title:
|
||||
case eHTMLTag_head:
|
||||
case eHTMLTag_script:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -806,9 +814,6 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
result=CloseHead(theNode);
|
||||
break;
|
||||
|
||||
case eHTMLTag_body:
|
||||
result=CloseContainersTo(eHTMLTag_body); break;
|
||||
|
||||
case eHTMLTag_form:
|
||||
{
|
||||
nsCParserNode aNode((CHTMLToken*)aToken);
|
||||
|
@ -816,12 +821,9 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
result=PR_TRUE; break;
|
||||
|
||||
default:
|
||||
if(mDTD->IsContainer(tokenTagType)){
|
||||
result=CloseContainer(theNode);
|
||||
result=CloseContainersTo(tokenTagType);
|
||||
}
|
||||
result=PR_TRUE;
|
||||
//
|
||||
|
|
|
@ -88,7 +88,7 @@ friend class CTokenHandler;
|
|||
virtual PRBool Parse(nsIURL* aURL,eParseMode aMode);
|
||||
virtual PRBool ResumeParse();
|
||||
virtual PRInt32 GetStack(PRInt32* aStackPtr);
|
||||
virtual PRBool HasOpenForm() const;
|
||||
virtual PRBool HasOpenContainer(PRInt32 aContainer) const;
|
||||
|
||||
|
||||
PRBool HandleStartToken(CToken* aToken);
|
||||
|
|
|
@ -55,7 +55,7 @@ class nsIParser : public nsISupports {
|
|||
virtual PRBool Parse(nsIURL* aURL)=0;
|
||||
virtual PRBool ResumeParse()=0;
|
||||
virtual PRInt32 GetStack(PRInt32* aStackPtr)=0;
|
||||
virtual PRBool HasOpenForm() const=0;
|
||||
virtual PRBool HasOpenContainer(PRInt32 aContainer) const=0;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewHTMLParser(nsIParser** aInstancePtrResult);
|
||||
|
|
|
@ -145,7 +145,7 @@ static char gHeadingTags[]={
|
|||
* @return PR_TRUE if parent can contain child
|
||||
*/
|
||||
PRBool CNavDTD::CanContainFormElement(PRInt32 aParent,PRInt32 aChild) const {
|
||||
PRBool result=(mParser) ? mParser->HasOpenForm() : PR_FALSE;
|
||||
PRBool result=(mParser) ? mParser->HasOpenContainer(eHTMLTag_form) : PR_FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
|||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_select: case eHTMLTag_textarea:
|
||||
if(PR_FALSE==mParser->HasOpenForm())
|
||||
if(PR_FALSE==mParser->HasOpenContainer(eHTMLTag_form))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -631,7 +631,6 @@ PRBool CNavDTD::CanOmit(PRInt32 aParent,PRInt32 aChild) const {
|
|||
default:
|
||||
if(eHTMLTag_unknown==aParent)
|
||||
result=PR_FALSE;
|
||||
// result=PRBool(eHTMLTag_html!=aChild);
|
||||
break;
|
||||
} //switch
|
||||
return result;
|
||||
|
@ -672,7 +671,7 @@ PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
|
|||
case eHTMLTag_input: case eHTMLTag_isindex:
|
||||
case eHTMLTag_label: case eHTMLTag_legend:
|
||||
case eHTMLTag_textarea:
|
||||
if(PR_FALSE==mParser->HasOpenForm())
|
||||
if(PR_FALSE==mParser->HasOpenContainer(aChild))
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -693,8 +692,7 @@ PRBool CNavDTD::CanOmitEndTag(PRInt32 aParent,PRInt32 aChild) const {
|
|||
break;
|
||||
|
||||
default:
|
||||
if(aChild!=aParent)
|
||||
result=PR_TRUE;
|
||||
result=(!mParser->HasOpenContainer(aChild));
|
||||
break;
|
||||
} //switch
|
||||
return result;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// 1) If you see </>, simply treat it as a bad tag.
|
||||
// 2) If you see </ ...>, treat it like a comment.
|
||||
// 3) If you see <> or <_ (< space) simply treat it as text.
|
||||
// 4) If you see <~ (< followed by non-alpha), treat it as text.
|
||||
// 4) If you see <[!a..z] (< followed by non-alpha), treat it as text.
|
||||
|
||||
static char gIdentChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
|
||||
|
||||
|
|
|
@ -191,8 +191,17 @@ eHTMLTags nsHTMLParser::NodeAt(PRInt32 aPos) const {
|
|||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRBool nsHTMLParser::HasOpenForm() const {
|
||||
return mHasOpenForm;
|
||||
PRBool nsHTMLParser::HasOpenContainer(PRInt32 aContainer) const {
|
||||
PRBool result=PR_FALSE;
|
||||
|
||||
switch((eHTMLTags)aContainer) {
|
||||
case eHTMLTag_form:
|
||||
result=mHasOpenForm; break;
|
||||
|
||||
default:
|
||||
result=(kNotFound!=GetTopmostIndex((eHTMLTags)aContainer)); break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -789,8 +798,6 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
|
||||
nsCParserNode theNode((CHTMLToken*)aToken);
|
||||
switch(tokenTagType) {
|
||||
case eHTMLTag_html:
|
||||
result=CloseContainersTo(tokenTagType); break;
|
||||
|
||||
case eHTMLTag_style:
|
||||
case eHTMLTag_link:
|
||||
|
@ -798,6 +805,7 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
case eHTMLTag_textarea:
|
||||
case eHTMLTag_title:
|
||||
case eHTMLTag_head:
|
||||
case eHTMLTag_script:
|
||||
result=PR_TRUE;
|
||||
break;
|
||||
|
||||
|
@ -806,9 +814,6 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
result=CloseHead(theNode);
|
||||
break;
|
||||
|
||||
case eHTMLTag_body:
|
||||
result=CloseContainersTo(eHTMLTag_body); break;
|
||||
|
||||
case eHTMLTag_form:
|
||||
{
|
||||
nsCParserNode aNode((CHTMLToken*)aToken);
|
||||
|
@ -816,12 +821,9 @@ PRBool nsHTMLParser::HandleEndToken(CToken* aToken) {
|
|||
}
|
||||
break;
|
||||
|
||||
case eHTMLTag_script:
|
||||
result=PR_TRUE; break;
|
||||
|
||||
default:
|
||||
if(mDTD->IsContainer(tokenTagType)){
|
||||
result=CloseContainer(theNode);
|
||||
result=CloseContainersTo(tokenTagType);
|
||||
}
|
||||
result=PR_TRUE;
|
||||
//
|
||||
|
|
|
@ -88,7 +88,7 @@ friend class CTokenHandler;
|
|||
virtual PRBool Parse(nsIURL* aURL,eParseMode aMode);
|
||||
virtual PRBool ResumeParse();
|
||||
virtual PRInt32 GetStack(PRInt32* aStackPtr);
|
||||
virtual PRBool HasOpenForm() const;
|
||||
virtual PRBool HasOpenContainer(PRInt32 aContainer) const;
|
||||
|
||||
|
||||
PRBool HandleStartToken(CToken* aToken);
|
||||
|
|
|
@ -55,7 +55,7 @@ class nsIParser : public nsISupports {
|
|||
virtual PRBool Parse(nsIURL* aURL)=0;
|
||||
virtual PRBool ResumeParse()=0;
|
||||
virtual PRInt32 GetStack(PRInt32* aStackPtr)=0;
|
||||
virtual PRBool HasOpenForm() const=0;
|
||||
virtual PRBool HasOpenContainer(PRInt32 aContainer) const=0;
|
||||
};
|
||||
|
||||
extern NS_HTMLPARS nsresult NS_NewHTMLParser(nsIParser** aInstancePtrResult);
|
||||
|
|
Загрузка…
Ссылка в новой задаче