allow button anywhere in content, other small improvements
git-svn-id: svn://10.0.0.236/trunk@13549 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(mCount<eStackSize,"TagStack Overflow: DEBUG VERSION!");
|
||||
#endif
|
||||
}
|
||||
|
||||
mTags[mCount++]=aTag;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ class nsIURL;
|
||||
enum eParseMode {
|
||||
|
||||
eParseMode_unknown=0,
|
||||
eParseMode_navigator,
|
||||
eParseMode_noquirks,
|
||||
eParseMode_raptor, //5.0 version of nav. and greater
|
||||
eParseMode_navigator, //pre 5.0 versions
|
||||
eParseMode_noquirks, //pre 5.0 without quirks (as best as we can...)
|
||||
eParseMode_other,
|
||||
eParseMode_autodetect
|
||||
};
|
||||
|
||||
@@ -269,24 +269,6 @@ eParseMode nsParser::GetParseMode(void){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 5/13/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eParseMode DetermineParseMode() {
|
||||
const char* theModeStr= PR_GetEnv("PARSE_MODE");
|
||||
const char* other="other";
|
||||
|
||||
eParseMode result=eParseMode_navigator;
|
||||
|
||||
if(theModeStr)
|
||||
if(0==nsCRT::strcasecmp(other,theModeStr))
|
||||
result=eParseMode_other;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -357,6 +339,42 @@ eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer,nsString& aT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is called (by willBuildModel) when it's time to find out
|
||||
* what mode the parser/DTD should run for this document.
|
||||
* (Each parsercontext can have it's own mode).
|
||||
*
|
||||
* @update gess 5/13/98
|
||||
* @return parsermode (define in nsIParser.h)
|
||||
*/
|
||||
eParseMode DetermineParseMode(nsParser& aParser) {
|
||||
const char* theModeStr= PR_GetEnv("PARSE_MODE");
|
||||
const char* other="other";
|
||||
|
||||
CScanner* theScanner=aParser.GetScanner();
|
||||
if(theScanner){
|
||||
nsString& theBuffer=theScanner->GetBuffer();
|
||||
PRInt32 theIndex=theBuffer.Find("HTML 4.0");
|
||||
if(kNotFound==theIndex)
|
||||
theIndex=theBuffer.Find("html 4.0");
|
||||
if(kNotFound<theIndex)
|
||||
return eParseMode_raptor;
|
||||
else {
|
||||
PRInt32 theIndex=theBuffer.Find("noquirks");
|
||||
if(kNotFound==theIndex)
|
||||
theIndex=theBuffer.Find("NOQUIRKS");
|
||||
if(kNotFound<theIndex)
|
||||
return eParseMode_noquirks;
|
||||
}
|
||||
}
|
||||
|
||||
if(theModeStr)
|
||||
if(0==nsCRT::strcasecmp(other,theModeStr))
|
||||
return eParseMode_other;
|
||||
return eParseMode_navigator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This gets called just prior to the model actually
|
||||
* being constructed. It's important to make this the
|
||||
@@ -370,17 +388,19 @@ eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer,nsString& aT
|
||||
*/
|
||||
PRInt32 nsParser::WillBuildModel(nsString& aFilename){
|
||||
|
||||
mMajorIteration=-1;
|
||||
mMinorIteration=-1;
|
||||
|
||||
mParserContext->mParseMode=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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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(mCount<eStackSize,"TagStack Overflow: DEBUG VERSION!");
|
||||
#endif
|
||||
}
|
||||
|
||||
mTags[mCount++]=aTag;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,9 @@ class nsIURL;
|
||||
enum eParseMode {
|
||||
|
||||
eParseMode_unknown=0,
|
||||
eParseMode_navigator,
|
||||
eParseMode_noquirks,
|
||||
eParseMode_raptor, //5.0 version of nav. and greater
|
||||
eParseMode_navigator, //pre 5.0 versions
|
||||
eParseMode_noquirks, //pre 5.0 without quirks (as best as we can...)
|
||||
eParseMode_other,
|
||||
eParseMode_autodetect
|
||||
};
|
||||
|
||||
@@ -269,24 +269,6 @@ eParseMode nsParser::GetParseMode(void){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 5/13/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
eParseMode DetermineParseMode() {
|
||||
const char* theModeStr= PR_GetEnv("PARSE_MODE");
|
||||
const char* other="other";
|
||||
|
||||
eParseMode result=eParseMode_navigator;
|
||||
|
||||
if(theModeStr)
|
||||
if(0==nsCRT::strcasecmp(other,theModeStr))
|
||||
result=eParseMode_other;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -357,6 +339,42 @@ eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer,nsString& aT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is called (by willBuildModel) when it's time to find out
|
||||
* what mode the parser/DTD should run for this document.
|
||||
* (Each parsercontext can have it's own mode).
|
||||
*
|
||||
* @update gess 5/13/98
|
||||
* @return parsermode (define in nsIParser.h)
|
||||
*/
|
||||
eParseMode DetermineParseMode(nsParser& aParser) {
|
||||
const char* theModeStr= PR_GetEnv("PARSE_MODE");
|
||||
const char* other="other";
|
||||
|
||||
CScanner* theScanner=aParser.GetScanner();
|
||||
if(theScanner){
|
||||
nsString& theBuffer=theScanner->GetBuffer();
|
||||
PRInt32 theIndex=theBuffer.Find("HTML 4.0");
|
||||
if(kNotFound==theIndex)
|
||||
theIndex=theBuffer.Find("html 4.0");
|
||||
if(kNotFound<theIndex)
|
||||
return eParseMode_raptor;
|
||||
else {
|
||||
PRInt32 theIndex=theBuffer.Find("noquirks");
|
||||
if(kNotFound==theIndex)
|
||||
theIndex=theBuffer.Find("NOQUIRKS");
|
||||
if(kNotFound<theIndex)
|
||||
return eParseMode_noquirks;
|
||||
}
|
||||
}
|
||||
|
||||
if(theModeStr)
|
||||
if(0==nsCRT::strcasecmp(other,theModeStr))
|
||||
return eParseMode_other;
|
||||
return eParseMode_navigator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This gets called just prior to the model actually
|
||||
* being constructed. It's important to make this the
|
||||
@@ -370,17 +388,19 @@ eAutoDetectResult nsParser::AutoDetectContentType(nsString& aBuffer,nsString& aT
|
||||
*/
|
||||
PRInt32 nsParser::WillBuildModel(nsString& aFilename){
|
||||
|
||||
mMajorIteration=-1;
|
||||
mMinorIteration=-1;
|
||||
|
||||
mParserContext->mParseMode=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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user