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;