From f404081f953d93a60f59a7ed622a81b3bab90307 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 27 Oct 1998 05:13:16 +0000 Subject: [PATCH] allow button anywhere in content, other small improvements git-svn-id: svn://10.0.0.236/trunk@13549 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/CNavDTD.cpp | 12 ++- mozilla/htmlparser/src/nsDTDUtils.cpp | 7 +- mozilla/htmlparser/src/nsIParser.h | 5 +- mozilla/htmlparser/src/nsParser.cpp | 76 ++++++++++++------- mozilla/htmlparser/src/nsParserTypes.h | 1 + mozilla/parser/htmlparser/src/CNavDTD.cpp | 12 ++- mozilla/parser/htmlparser/src/nsDTDUtils.cpp | 7 +- mozilla/parser/htmlparser/src/nsIParser.h | 5 +- mozilla/parser/htmlparser/src/nsParser.cpp | 76 ++++++++++++------- mozilla/parser/htmlparser/src/nsParserTypes.h | 1 + 10 files changed, 132 insertions(+), 70 deletions(-) diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp index e0750f9a8b6..e43eaaeadfc 100644 --- a/mozilla/htmlparser/src/CNavDTD.cpp +++ b/mozilla/htmlparser/src/CNavDTD.cpp @@ -9,7 +9,7 @@ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. - * + * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights @@ -361,7 +361,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) { nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); mHasOpenForm=PR_FALSE; mHasOpenMap=PR_FALSE; - InitializeDefaultTokenHandlers(); + InitializeDefaultTokenHandlers(); mHeadContext=new nsDTDContext(); mBodyContext=new nsDTDContext(); mFormContext=0; @@ -1905,7 +1905,13 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { result=HasOpenContainer(aChild); //don't bother if they're already open... break; - case eHTMLTag_button: case eHTMLTag_fieldset: + //The following line was commented out to fix bug 1166. + //Effectively, this allows a button to exist anywhere in the document, + //and not just inside a form. + + //case eHTMLTag_button: + + case eHTMLTag_fieldset: case eHTMLTag_input: case eHTMLTag_isindex: case eHTMLTag_label: case eHTMLTag_legend: case eHTMLTag_select: case eHTMLTag_textarea: diff --git a/mozilla/htmlparser/src/nsDTDUtils.cpp b/mozilla/htmlparser/src/nsDTDUtils.cpp index a3a9df7fb8e..86ac19275a3 100644 --- a/mozilla/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/htmlparser/src/nsDTDUtils.cpp @@ -19,7 +19,7 @@ #include "nsDTDUtils.h" - + /*************************************************************** First, define the tagstack class ***************************************************************/ @@ -72,8 +72,8 @@ void nsTagStack::Empty(void) { void nsTagStack::Push(eHTMLTags aTag) { if(mCount>=mSize) { - #ifdef _dynstack + //regrow the dynamic stack... eHTMLTags* tmp=new eHTMLTags[2*mSize]; nsCRT::zero(tmp,2*mSize*sizeof(eHTMLTag_html)); nsCRT::memcpy(tmp,mTags,mSize*sizeof(eHTMLTag_html)); @@ -86,8 +86,11 @@ void nsTagStack::Push(eHTMLTags aTag) { delete mBits; mBits=tmp2; mSize*=2; +#else + NS_PRECONDITION(mCountGetBuffer(); + PRInt32 theIndex=theBuffer.Find("HTML 4.0"); + if(kNotFound==theIndex) + theIndex=theBuffer.Find("html 4.0"); + if(kNotFoundmParseMode=DetermineParseMode(); - if(PR_TRUE==FindSuitableDTD(*mParserContext)) { - mParserContext->mDTD->SetParser(this); - mParserContext->mDTD->SetContentSink(mSink); - mParserContext->mDTD->WillBuildModel(aFilename,PRBool(0==mParserContext->mPrevContext)); + mMajorIteration=-1; + mMinorIteration=-1; + PRInt32 result=kNoError; + if(mParserContext){ + mParserContext->mParseMode=DetermineParseMode(*this); + if(PR_TRUE==FindSuitableDTD(*mParserContext)) { + mParserContext->mDTD->SetParser(this); + mParserContext->mDTD->SetContentSink(mSink); + mParserContext->mDTD->WillBuildModel(aFilename,PRBool(0==mParserContext->mPrevContext)); + } } - - return kNoError; + else result=kInvalidParserContext; + return result; } /** diff --git a/mozilla/htmlparser/src/nsParserTypes.h b/mozilla/htmlparser/src/nsParserTypes.h index 2722672c50a..bbfe9c941a2 100644 --- a/mozilla/htmlparser/src/nsParserTypes.h +++ b/mozilla/htmlparser/src/nsParserTypes.h @@ -43,6 +43,7 @@ const PRInt32 kBadFilename = 10004; const PRInt32 kBadURL = 10005; const PRInt32 kInterrupted = 10006; const PRInt32 kProcessComplete = 10007; +const PRInt32 kInvalidParserContext = 10008; const PRInt32 kNotFound = -1; const PRInt32 kNoError = NS_OK; diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp index e0750f9a8b6..e43eaaeadfc 100644 --- a/mozilla/parser/htmlparser/src/CNavDTD.cpp +++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp @@ -9,7 +9,7 @@ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL * for the specific language governing rights and limitations under the * NPL. - * + * * The Initial Developer of this code under the NPL is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights @@ -361,7 +361,7 @@ CNavDTD::CNavDTD() : nsIDTD(), mTokenDeque(gTokenKiller) { nsCRT::zero(mTokenHandlers,sizeof(mTokenHandlers)); mHasOpenForm=PR_FALSE; mHasOpenMap=PR_FALSE; - InitializeDefaultTokenHandlers(); + InitializeDefaultTokenHandlers(); mHeadContext=new nsDTDContext(); mBodyContext=new nsDTDContext(); mFormContext=0; @@ -1905,7 +1905,13 @@ PRBool CNavDTD::CanOmit(eHTMLTags aParent,eHTMLTags aChild) const { result=HasOpenContainer(aChild); //don't bother if they're already open... break; - case eHTMLTag_button: case eHTMLTag_fieldset: + //The following line was commented out to fix bug 1166. + //Effectively, this allows a button to exist anywhere in the document, + //and not just inside a form. + + //case eHTMLTag_button: + + case eHTMLTag_fieldset: case eHTMLTag_input: case eHTMLTag_isindex: case eHTMLTag_label: case eHTMLTag_legend: case eHTMLTag_select: case eHTMLTag_textarea: diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp index a3a9df7fb8e..86ac19275a3 100644 --- a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp +++ b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp @@ -19,7 +19,7 @@ #include "nsDTDUtils.h" - + /*************************************************************** First, define the tagstack class ***************************************************************/ @@ -72,8 +72,8 @@ void nsTagStack::Empty(void) { void nsTagStack::Push(eHTMLTags aTag) { if(mCount>=mSize) { - #ifdef _dynstack + //regrow the dynamic stack... eHTMLTags* tmp=new eHTMLTags[2*mSize]; nsCRT::zero(tmp,2*mSize*sizeof(eHTMLTag_html)); nsCRT::memcpy(tmp,mTags,mSize*sizeof(eHTMLTag_html)); @@ -86,8 +86,11 @@ void nsTagStack::Push(eHTMLTags aTag) { delete mBits; mBits=tmp2; mSize*=2; +#else + NS_PRECONDITION(mCountGetBuffer(); + PRInt32 theIndex=theBuffer.Find("HTML 4.0"); + if(kNotFound==theIndex) + theIndex=theBuffer.Find("html 4.0"); + if(kNotFoundmParseMode=DetermineParseMode(); - if(PR_TRUE==FindSuitableDTD(*mParserContext)) { - mParserContext->mDTD->SetParser(this); - mParserContext->mDTD->SetContentSink(mSink); - mParserContext->mDTD->WillBuildModel(aFilename,PRBool(0==mParserContext->mPrevContext)); + mMajorIteration=-1; + mMinorIteration=-1; + PRInt32 result=kNoError; + if(mParserContext){ + mParserContext->mParseMode=DetermineParseMode(*this); + if(PR_TRUE==FindSuitableDTD(*mParserContext)) { + mParserContext->mDTD->SetParser(this); + mParserContext->mDTD->SetContentSink(mSink); + mParserContext->mDTD->WillBuildModel(aFilename,PRBool(0==mParserContext->mPrevContext)); + } } - - return kNoError; + else result=kInvalidParserContext; + return result; } /** diff --git a/mozilla/parser/htmlparser/src/nsParserTypes.h b/mozilla/parser/htmlparser/src/nsParserTypes.h index 2722672c50a..bbfe9c941a2 100644 --- a/mozilla/parser/htmlparser/src/nsParserTypes.h +++ b/mozilla/parser/htmlparser/src/nsParserTypes.h @@ -43,6 +43,7 @@ const PRInt32 kBadFilename = 10004; const PRInt32 kBadURL = 10005; const PRInt32 kInterrupted = 10006; const PRInt32 kProcessComplete = 10007; +const PRInt32 kInvalidParserContext = 10008; const PRInt32 kNotFound = -1; const PRInt32 kNoError = NS_OK;