From 29386ec285e8aa908ff63ba3d091cfa484af3fcf Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Wed, 19 Apr 2000 08:08:28 +0000 Subject: [PATCH] removed warnings; retry landing Strict DTD. r=harishd --- htmlparser/src/COtherDTD.cpp | 18 +- htmlparser/src/COtherElements.h | 200 +++++++++++++++------ htmlparser/src/CParserContext.cpp | 76 +++++--- htmlparser/src/CParserContext.h | 6 +- htmlparser/src/nsExpatTokenizer.cpp | 2 +- htmlparser/src/nsHTMLTokens.cpp | 4 +- htmlparser/src/nsHTMLTokens.h | 2 +- htmlparser/src/nsParser.cpp | 2 +- htmlparser/src/nsToken.cpp | 5 +- htmlparser/src/nsToken.h | 2 +- parser/htmlparser/src/COtherDTD.cpp | 18 +- parser/htmlparser/src/COtherElements.h | 200 +++++++++++++++------ parser/htmlparser/src/CParserContext.cpp | 76 +++++--- parser/htmlparser/src/CParserContext.h | 6 +- parser/htmlparser/src/nsExpatTokenizer.cpp | 2 +- parser/htmlparser/src/nsHTMLTokens.cpp | 4 +- parser/htmlparser/src/nsHTMLTokens.h | 2 +- parser/htmlparser/src/nsParser.cpp | 2 +- parser/htmlparser/src/nsToken.cpp | 5 +- parser/htmlparser/src/nsToken.h | 2 +- 20 files changed, 438 insertions(+), 196 deletions(-) diff --git a/htmlparser/src/COtherDTD.cpp b/htmlparser/src/COtherDTD.cpp index 597f4fdc75c2..cfc87bf67bd8 100644 --- a/htmlparser/src/COtherDTD.cpp +++ b/htmlparser/src/COtherDTD.cpp @@ -1,4 +1,4 @@ -#if 0 + /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * The contents of this file are subject to the Netscape Public @@ -20,9 +20,9 @@ * * Contributor(s): */ - + //#define ENABLE_CRC -//#define RICKG_DEBUG +//#define RICKG_DEBUG #ifdef RICKG_DEBUG @@ -70,9 +70,9 @@ static char* kVerificationDir = "c:/temp"; static char gShowCRC; #endif - + -#ifdef MOZ_PERF_METRICS +#ifdef MOZ_PERF_METRICS # define START_TIMER() \ if(mParser) MOZ_TIMER_START(mParser->mParseTime); \ if(mParser) MOZ_TIMER_START(mParser->mDTDTime); @@ -190,14 +190,14 @@ nsCParserNode* COtherDTD::CreateNode(void) { } else{ result=new nsCParserNode(); -#ifdef NS_DEBUG +#ifdef NS_DEBUG #if 1 - gNodeCount++; + gNodeCount++; #endif #endif } return result; -} +} /** @@ -2032,5 +2032,3 @@ nsresult COtherDTD::WillInterruptParse(void){ return result; } - -#endif diff --git a/htmlparser/src/COtherElements.h b/htmlparser/src/COtherElements.h index 1194c278cb8d..79a71cb10d51 100644 --- a/htmlparser/src/COtherElements.h +++ b/htmlparser/src/COtherElements.h @@ -231,7 +231,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=0; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=0; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -250,21 +257,12 @@ public: class CDeprecatedElement: public CElement { public: - static CGroupMembers& GetGroup(void) { - static CGroupMembers theGroup={0}; - return theGroup; - } - static CGroupMembers& GetContainedGroups(void) { - static CGroupMembers theContainedGroups={0}; - return theContainedGroups; - } - - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=0; anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + anElement.mGroup.mAllBits=0; + anElement.mContainsGroups.mAllBits=0; } CDeprecatedElement(eHTMLTags aTag) : CElement(aTag) { @@ -305,7 +303,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -336,7 +341,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aContainsGroup){ anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; @@ -370,7 +382,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -400,7 +419,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -433,7 +459,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -463,15 +496,15 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ - anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; } CFontStyleElement(eHTMLTags aTag) : CElement(aTag) { - Initialize(*this,aTag,GetGroup(),GetContainedGroups()); + Initialize(*this,aTag); } }; @@ -494,7 +527,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aContainsGroup){ anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; @@ -527,7 +567,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -559,7 +606,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -589,7 +643,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -620,7 +681,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -639,27 +707,18 @@ public: class CFrameElement: public CElement { public: - static CGroupMembers& GetGroup(void) { - static CGroupMembers theGroup={0}; - theGroup.mBits.mFrame=1; - return theGroup; - } - static CGroupMembers& GetContainedGroups(void) { - static CGroupMembers theGroup={0}; - theGroup.mBits.mFrame=1; - return theGroup; - } - - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + anElement.mGroup.mAllBits=0; + anElement.mGroup.mBits.mFrame=1; + anElement.mContainsGroups.mAllBits=0; + anElement.mContainsGroups.mBits.mFrame=1; } CFrameElement(eHTMLTags aTag) : CElement(aTag) { - Initialize(*this,aTag,GetGroup(),GetContainedGroups()); + Initialize(*this,aTag); } }; @@ -716,7 +775,14 @@ public: return theGroupsContainedByHead; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -806,7 +872,14 @@ public: return theContainedGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -866,11 +939,12 @@ public: class CTitleElement : public CTextContainer { public: - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ - anElement.mProperties.mIsContainer=1; - anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ + CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } CTitleElement() : CTextContainer(eHTMLTag_title), mText("") { @@ -923,6 +997,10 @@ public: class CStyleElement: public CTextContainer { public: + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=CTextContainer::GetGroup(), CGroupMembers& aGroupContains=CTextContainer::GetContainedGroups()){ CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } @@ -940,6 +1018,10 @@ public: class CScriptElement: public CTextContainer { public: + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=CTextContainer::GetGroup(), CGroupMembers& aGroupContains=CTextContainer::GetContainedGroups()){ CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } @@ -970,7 +1052,15 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -1337,7 +1427,7 @@ void CElementTable::InitializeElements() { mDfltElements[eHTMLTag_form].mIncludeKids=kFormKids; mDfltElements[eHTMLTag_form].mExcludeKids=kFormExcludeKids; - CLeafElement::Initialize( mDfltElements[eHTMLTag_frame], eHTMLTag_frame, CFrameElement::GetGroup(), CLeafElement::GetContainedGroups()); + CFrameElement::Initialize( mDfltElements[eHTMLTag_frame], eHTMLTag_frame); CFrameElement::Initialize( mDfltElements[eHTMLTag_frameset], eHTMLTag_frameset); mDfltElements[eHTMLTag_frameset].mIncludeKids=kFramesetKids; @@ -1358,9 +1448,9 @@ void CElementTable::InitializeElements() { CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_ilayer], eHTMLTag_ilayer); CLeafElement::Initialize( mDfltElements[eHTMLTag_img], eHTMLTag_img, CSpecialElement::GetGroup(), CLeafElement::GetContainedGroups()); CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_image], eHTMLTag_image); - CLeafElement::Initialize( mDfltElements[eHTMLTag_input], eHTMLTag_input, CFormControlElement::GetGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_input], eHTMLTag_input, CFormControlElement::GetGroup(),CLeafElement::GetContainedGroups()); CPhraseElement::Initialize( mDfltElements[eHTMLTag_ins], eHTMLTag_ins, CPhraseElement::GetGroup(), CFlowElement::GetContainedGroups()); - CLeafElement::Initialize( mDfltElements[eHTMLTag_isindex], eHTMLTag_isindex, CHeadElement::GetMiscGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_isindex], eHTMLTag_isindex, CHeadElement::GetMiscGroup(), CLeafElement::GetContainedGroups()); CPhraseElement::Initialize( mDfltElements[eHTMLTag_kbd], eHTMLTag_kbd); CPhraseElement::Initialize( mDfltElements[eHTMLTag_keygen], eHTMLTag_keygen); @@ -1413,7 +1503,7 @@ void CElementTable::InitializeElements() { mDfltElements[eHTMLTag_optgroup].mContainsGroups.mBits.mLeaf=1; CBlockElement::Initialize( mDfltElements[eHTMLTag_p], eHTMLTag_p, CBlockElement::GetGroup(), CInlineElement::GetContainedGroups()); - CLeafElement::Initialize( mDfltElements[eHTMLTag_param], eHTMLTag_param, CSpecialElement::GetGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_param], eHTMLTag_param, CSpecialElement::GetGroup(), CLeafElement::GetContainedGroups()); CBlockElement::Initialize( mDfltElements[eHTMLTag_parsererror],eHTMLTag_parsererror); CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_plaintext], eHTMLTag_plaintext); CBlockElement::Initialize( mDfltElements[eHTMLTag_pre], eHTMLTag_pre); diff --git a/htmlparser/src/CParserContext.cpp b/htmlparser/src/CParserContext.cpp index cbdf1fd91543..86ce69923ff5 100644 --- a/htmlparser/src/CParserContext.cpp +++ b/htmlparser/src/CParserContext.cpp @@ -141,6 +141,41 @@ void CParserContext::SetMimeType(const nsString& aMimeType){ else if(mMimeType.EqualsWithConversion(kXIFTextContentType)) mDocType=eXMLText; } + +/************************************************************************************************* + First, let's define our modalities: + + 1. compatibility-mode: behave as much like nav4 as possible (unless it's too broken to bother) + 2. standard-mode: do html as well as you can per spec, and throw out navigator quirks + 3. strict-mode: adhere to the strict DTD specificiation to the highest degree possible + + Assume the doctype is in the following form: + + [HTML] [PUBLIC|...] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..." + + + Here are the new rules for DTD handling; comments welcome: + + - strict dtd's enable strict-mode (and naturally our strict DTD): + - example: + - example: + + - XHTML and XML documents are always strict: + - example: + + - transitional, frameset, etc. without URI enables compatibility-mode: + - example: + + - unless the URI points to the strict.dtd, then we use strict: + - example: + + - doctypes with systemID's or internal subset are handled in strict: + - example: + - example: + + - all other doctypes are handled in compatibility-mode + +*****************************************************************************************************/ /** * This is called when it's time to find out @@ -155,20 +190,16 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { mParseMode = eParseMode_unknown; - PRInt32 theIndex=theBuffer.Find("' PRInt32 theGTPos=theBuffer.FindChar(kGreaterThan,theIndex+1); PRInt32 theEnd=(kNotFound==theGTPos) ? 512 : MinInt(512,theGTPos); - PRInt32 theSubIndex=theBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); + PRInt32 theSubIndex=theBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); //skip to the type and desc-text... PRInt32 theErr=0; PRInt32 theMajorVersion=3; - //note that if we don't find '>', then we just scan the first 512 bytes. if(0<=theSubIndex) { @@ -199,7 +230,7 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { theMajorVersion=3; } else { - theSubIndex=theBuffer.Find("HYPERTEXT MARKUP LANGUAGE",PR_TRUE,theStartPos,theCount); + theSubIndex=theBuffer.Find("HYPERTEXT MARKUP",PR_TRUE,theStartPos,theCount); if(0<=theSubIndex) { mDocType=eHTML3Text; mParseMode=eParseMode_quirks; @@ -214,15 +245,16 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { theCount=theEnd-theStartPos; nsAutoString theNum; + //get the next substring from the buffer, which should be a number. + //now see what the version number is... + theStartPos=theBuffer.FindCharInSet("123456789",theStartPos); if(0<=theStartPos) { theBuffer.Mid(theNum,theStartPos-1,3); theMajorVersion=theNum.ToInteger(&theErr); } - - //get the next substring from the buffer, which should be a number. - //now see what the version number is... + //now see what the theStartPos+=3; theCount=theEnd-theStartPos; if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theStartPos,theCount)>kNotFound)|| @@ -231,7 +263,17 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { (theBuffer.Find("LATIN1", PR_TRUE,theStartPos,theCount) >kNotFound) || (theBuffer.Find("SYMBOLS",PR_TRUE,theStartPos,theCount) >kNotFound) || (theBuffer.Find("SPECIAL",PR_TRUE,theStartPos,theCount) >kNotFound)) { - mParseMode=eParseMode_noquirks; + mParseMode=eParseMode_quirks; + } + + //one last thing: look for a URI that specifies the strict.dtd + theStartPos+=6; + theCount=theEnd-theStartPos; + theSubIndex=theBuffer.Find("STRICT.DTD",PR_TRUE,theStartPos,theCount); + if(0tokenRecycler->CreateTokenOfType(eToken_attribute, eHTMLTag_unknown); nsString& key = attrToken->GetKey(); key.AssignWithConversion("xmlns"); - attrToken->SetStringValue(kHTMLNameSpaceURI); + attrToken->SetCStringValue(kHTMLNameSpaceURI); newToken->SetAttributeCount(1); newToken = (CToken*) attrToken; AddToken(newToken, NS_OK, mState->tokenDeque, mState->tokenRecycler); diff --git a/htmlparser/src/nsHTMLTokens.cpp b/htmlparser/src/nsHTMLTokens.cpp index f83054afef12..157d9d25df1d 100644 --- a/htmlparser/src/nsHTMLTokens.cpp +++ b/htmlparser/src/nsHTMLTokens.cpp @@ -70,7 +70,7 @@ CHTMLToken::CHTMLToken(eHTMLTags aTag) : CToken(aTag) { * @update gess5/11/98 * @param name is a char* value containing new string value */ -void CHTMLToken::SetStringValue(const char* name){ +void CHTMLToken::SetCStringValue(const char* name){ if(name) { mTextValue.AssignWithConversion(name); mTypeID = nsHTMLTags::LookupTag(mTextValue); @@ -324,7 +324,7 @@ void CStartToken::AppendSource(nsString& anOutputString){ * @return */ CEndToken::CEndToken(eHTMLTags aTag) : CHTMLToken(aTag) { - SetStringValue(GetTagName(aTag)); + SetCStringValue(GetTagName(aTag)); } diff --git a/htmlparser/src/nsHTMLTokens.h b/htmlparser/src/nsHTMLTokens.h index c6b460f5333a..88e36767795e 100644 --- a/htmlparser/src/nsHTMLTokens.h +++ b/htmlparser/src/nsHTMLTokens.h @@ -100,7 +100,7 @@ public: CHTMLToken(eHTMLTags aTag); CHTMLToken(const nsString& aString,eHTMLTags aTag=eHTMLTag_unknown); - virtual void SetStringValue(const char* name); + virtual void SetCStringValue(const char* name); virtual nsString& GetStringValueXXX(void); protected: diff --git a/htmlparser/src/nsParser.cpp b/htmlparser/src/nsParser.cpp index 5fd3a62aa52e..fd4c6e3fcac8 100644 --- a/htmlparser/src/nsParser.cpp +++ b/htmlparser/src/nsParser.cpp @@ -97,7 +97,7 @@ public: nsIDTD* theDTD; NS_NewNavHTMLDTD(&theDTD); //do this as a default HTML DTD... mDTDDeque.Push(theDTD); -#if 0 +#if 1 NS_NewOtherHTMLDTD(&theDTD); //do this as the default DTD for strict documents... mDTDDeque.Push(theDTD); #endif diff --git a/htmlparser/src/nsToken.cpp b/htmlparser/src/nsToken.cpp index 884a277cafd3..50ca09a48d5a 100644 --- a/htmlparser/src/nsToken.cpp +++ b/htmlparser/src/nsToken.cpp @@ -164,15 +164,14 @@ void CToken::DebugDumpSource(nsOutputStream& anOutputStream) { * @update gess5/11/98 * @param name is a char* value containing new string value */ -void CToken::SetStringValue(const char* name){ +void CToken::SetCStringValue(const char* name){ mTextValue.AssignWithConversion(name); } /** * Setter method for the string value of this token */ -void CToken::SetStringValue(nsString& aStr) -{ +void CToken::SetStringValue(nsString& aStr) { mTextValue = aStr; } diff --git a/htmlparser/src/nsToken.h b/htmlparser/src/nsToken.h index 91290561873b..d5c76a8dc0ed 100644 --- a/htmlparser/src/nsToken.h +++ b/htmlparser/src/nsToken.h @@ -124,7 +124,7 @@ class CToken { * @update gess5/11/98 * @param name is a char* value containing new string value */ - virtual void SetStringValue(const char* name); + virtual void SetCStringValue(const char* name); /** * Setter method for the string value of this token diff --git a/parser/htmlparser/src/COtherDTD.cpp b/parser/htmlparser/src/COtherDTD.cpp index 597f4fdc75c2..cfc87bf67bd8 100644 --- a/parser/htmlparser/src/COtherDTD.cpp +++ b/parser/htmlparser/src/COtherDTD.cpp @@ -1,4 +1,4 @@ -#if 0 + /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * The contents of this file are subject to the Netscape Public @@ -20,9 +20,9 @@ * * Contributor(s): */ - + //#define ENABLE_CRC -//#define RICKG_DEBUG +//#define RICKG_DEBUG #ifdef RICKG_DEBUG @@ -70,9 +70,9 @@ static char* kVerificationDir = "c:/temp"; static char gShowCRC; #endif - + -#ifdef MOZ_PERF_METRICS +#ifdef MOZ_PERF_METRICS # define START_TIMER() \ if(mParser) MOZ_TIMER_START(mParser->mParseTime); \ if(mParser) MOZ_TIMER_START(mParser->mDTDTime); @@ -190,14 +190,14 @@ nsCParserNode* COtherDTD::CreateNode(void) { } else{ result=new nsCParserNode(); -#ifdef NS_DEBUG +#ifdef NS_DEBUG #if 1 - gNodeCount++; + gNodeCount++; #endif #endif } return result; -} +} /** @@ -2032,5 +2032,3 @@ nsresult COtherDTD::WillInterruptParse(void){ return result; } - -#endif diff --git a/parser/htmlparser/src/COtherElements.h b/parser/htmlparser/src/COtherElements.h index 1194c278cb8d..79a71cb10d51 100644 --- a/parser/htmlparser/src/COtherElements.h +++ b/parser/htmlparser/src/COtherElements.h @@ -231,7 +231,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=0; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=0; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -250,21 +257,12 @@ public: class CDeprecatedElement: public CElement { public: - static CGroupMembers& GetGroup(void) { - static CGroupMembers theGroup={0}; - return theGroup; - } - static CGroupMembers& GetContainedGroups(void) { - static CGroupMembers theContainedGroups={0}; - return theContainedGroups; - } - - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=0; anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + anElement.mGroup.mAllBits=0; + anElement.mContainsGroups.mAllBits=0; } CDeprecatedElement(eHTMLTags aTag) : CElement(aTag) { @@ -305,7 +303,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -336,7 +341,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aContainsGroup){ anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; @@ -370,7 +382,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -400,7 +419,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -433,7 +459,14 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -463,15 +496,15 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ - anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; } CFontStyleElement(eHTMLTags aTag) : CElement(aTag) { - Initialize(*this,aTag,GetGroup(),GetContainedGroups()); + Initialize(*this,aTag); } }; @@ -494,7 +527,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aContainsGroup=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aContainsGroup){ anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; anElement.mContainsGroups.mAllBits=aContainsGroup.mAllBits; @@ -527,7 +567,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -559,7 +606,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -589,7 +643,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -620,7 +681,14 @@ public: return theGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -639,27 +707,18 @@ public: class CFrameElement: public CElement { public: - static CGroupMembers& GetGroup(void) { - static CGroupMembers theGroup={0}; - theGroup.mBits.mFrame=1; - return theGroup; - } - static CGroupMembers& GetContainedGroups(void) { - static CGroupMembers theGroup={0}; - theGroup.mBits.mFrame=1; - return theGroup; - } - - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + anElement.mGroup.mAllBits=0; + anElement.mGroup.mBits.mFrame=1; + anElement.mContainsGroups.mAllBits=0; + anElement.mContainsGroups.mBits.mFrame=1; } CFrameElement(eHTMLTags aTag) : CElement(aTag) { - Initialize(*this,aTag,GetGroup(),GetContainedGroups()); + Initialize(*this,aTag); } }; @@ -716,7 +775,14 @@ public: return theGroupsContainedByHead; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -806,7 +872,14 @@ public: return theContainedGroups; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -866,11 +939,12 @@ public: class CTitleElement : public CTextContainer { public: - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ - anElement.mProperties.mIsContainer=1; - anElement.mTag=aTag; - anElement.mGroup.mAllBits=aGroup.mAllBits; - anElement.mContainsGroups.mAllBits=aGroupContains.mAllBits; + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ + CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } CTitleElement() : CTextContainer(eHTMLTag_title), mText("") { @@ -923,6 +997,10 @@ public: class CStyleElement: public CTextContainer { public: + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=CTextContainer::GetGroup(), CGroupMembers& aGroupContains=CTextContainer::GetContainedGroups()){ CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } @@ -940,6 +1018,10 @@ public: class CScriptElement: public CTextContainer { public: + static void Initialize(CElement& anElement,eHTMLTags aTag){ + CTextContainer::Initialize(anElement,aTag); + } + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=CTextContainer::GetGroup(), CGroupMembers& aGroupContains=CTextContainer::GetContainedGroups()){ CTextContainer::Initialize(anElement,aTag,aGroup,aGroupContains); } @@ -970,7 +1052,15 @@ public: return theGroup; } - static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup=GetGroup(), CGroupMembers& aGroupContains=GetContainedGroups()){ + + static void Initialize(CElement& anElement,eHTMLTags aTag){ + anElement.mProperties.mIsContainer=1; + anElement.mTag=aTag; + anElement.mGroup.mAllBits=GetGroup().mAllBits; + anElement.mContainsGroups.mAllBits=GetContainedGroups().mAllBits; + } + + static void Initialize(CElement& anElement,eHTMLTags aTag,CGroupMembers& aGroup, CGroupMembers& aGroupContains){ anElement.mProperties.mIsContainer=1; anElement.mTag=aTag; anElement.mGroup.mAllBits=aGroup.mAllBits; @@ -1337,7 +1427,7 @@ void CElementTable::InitializeElements() { mDfltElements[eHTMLTag_form].mIncludeKids=kFormKids; mDfltElements[eHTMLTag_form].mExcludeKids=kFormExcludeKids; - CLeafElement::Initialize( mDfltElements[eHTMLTag_frame], eHTMLTag_frame, CFrameElement::GetGroup(), CLeafElement::GetContainedGroups()); + CFrameElement::Initialize( mDfltElements[eHTMLTag_frame], eHTMLTag_frame); CFrameElement::Initialize( mDfltElements[eHTMLTag_frameset], eHTMLTag_frameset); mDfltElements[eHTMLTag_frameset].mIncludeKids=kFramesetKids; @@ -1358,9 +1448,9 @@ void CElementTable::InitializeElements() { CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_ilayer], eHTMLTag_ilayer); CLeafElement::Initialize( mDfltElements[eHTMLTag_img], eHTMLTag_img, CSpecialElement::GetGroup(), CLeafElement::GetContainedGroups()); CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_image], eHTMLTag_image); - CLeafElement::Initialize( mDfltElements[eHTMLTag_input], eHTMLTag_input, CFormControlElement::GetGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_input], eHTMLTag_input, CFormControlElement::GetGroup(),CLeafElement::GetContainedGroups()); CPhraseElement::Initialize( mDfltElements[eHTMLTag_ins], eHTMLTag_ins, CPhraseElement::GetGroup(), CFlowElement::GetContainedGroups()); - CLeafElement::Initialize( mDfltElements[eHTMLTag_isindex], eHTMLTag_isindex, CHeadElement::GetMiscGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_isindex], eHTMLTag_isindex, CHeadElement::GetMiscGroup(), CLeafElement::GetContainedGroups()); CPhraseElement::Initialize( mDfltElements[eHTMLTag_kbd], eHTMLTag_kbd); CPhraseElement::Initialize( mDfltElements[eHTMLTag_keygen], eHTMLTag_keygen); @@ -1413,7 +1503,7 @@ void CElementTable::InitializeElements() { mDfltElements[eHTMLTag_optgroup].mContainsGroups.mBits.mLeaf=1; CBlockElement::Initialize( mDfltElements[eHTMLTag_p], eHTMLTag_p, CBlockElement::GetGroup(), CInlineElement::GetContainedGroups()); - CLeafElement::Initialize( mDfltElements[eHTMLTag_param], eHTMLTag_param, CSpecialElement::GetGroup()); + CLeafElement::Initialize( mDfltElements[eHTMLTag_param], eHTMLTag_param, CSpecialElement::GetGroup(), CLeafElement::GetContainedGroups()); CBlockElement::Initialize( mDfltElements[eHTMLTag_parsererror],eHTMLTag_parsererror); CDeprecatedElement::Initialize( mDfltElements[eHTMLTag_plaintext], eHTMLTag_plaintext); CBlockElement::Initialize( mDfltElements[eHTMLTag_pre], eHTMLTag_pre); diff --git a/parser/htmlparser/src/CParserContext.cpp b/parser/htmlparser/src/CParserContext.cpp index cbdf1fd91543..86ce69923ff5 100644 --- a/parser/htmlparser/src/CParserContext.cpp +++ b/parser/htmlparser/src/CParserContext.cpp @@ -141,6 +141,41 @@ void CParserContext::SetMimeType(const nsString& aMimeType){ else if(mMimeType.EqualsWithConversion(kXIFTextContentType)) mDocType=eXMLText; } + +/************************************************************************************************* + First, let's define our modalities: + + 1. compatibility-mode: behave as much like nav4 as possible (unless it's too broken to bother) + 2. standard-mode: do html as well as you can per spec, and throw out navigator quirks + 3. strict-mode: adhere to the strict DTD specificiation to the highest degree possible + + Assume the doctype is in the following form: + + [HTML] [PUBLIC|...] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..." + + + Here are the new rules for DTD handling; comments welcome: + + - strict dtd's enable strict-mode (and naturally our strict DTD): + - example: + - example: + + - XHTML and XML documents are always strict: + - example: + + - transitional, frameset, etc. without URI enables compatibility-mode: + - example: + + - unless the URI points to the strict.dtd, then we use strict: + - example: + + - doctypes with systemID's or internal subset are handled in strict: + - example: + - example: + + - all other doctypes are handled in compatibility-mode + +*****************************************************************************************************/ /** * This is called when it's time to find out @@ -155,20 +190,16 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { mParseMode = eParseMode_unknown; - PRInt32 theIndex=theBuffer.Find("' PRInt32 theGTPos=theBuffer.FindChar(kGreaterThan,theIndex+1); PRInt32 theEnd=(kNotFound==theGTPos) ? 512 : MinInt(512,theGTPos); - PRInt32 theSubIndex=theBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); + PRInt32 theSubIndex=theBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); //skip to the type and desc-text... PRInt32 theErr=0; PRInt32 theMajorVersion=3; - //note that if we don't find '>', then we just scan the first 512 bytes. if(0<=theSubIndex) { @@ -199,7 +230,7 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { theMajorVersion=3; } else { - theSubIndex=theBuffer.Find("HYPERTEXT MARKUP LANGUAGE",PR_TRUE,theStartPos,theCount); + theSubIndex=theBuffer.Find("HYPERTEXT MARKUP",PR_TRUE,theStartPos,theCount); if(0<=theSubIndex) { mDocType=eHTML3Text; mParseMode=eParseMode_quirks; @@ -214,15 +245,16 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { theCount=theEnd-theStartPos; nsAutoString theNum; + //get the next substring from the buffer, which should be a number. + //now see what the version number is... + theStartPos=theBuffer.FindCharInSet("123456789",theStartPos); if(0<=theStartPos) { theBuffer.Mid(theNum,theStartPos-1,3); theMajorVersion=theNum.ToInteger(&theErr); } - - //get the next substring from the buffer, which should be a number. - //now see what the version number is... + //now see what the theStartPos+=3; theCount=theEnd-theStartPos; if((theBuffer.Find("TRANSITIONAL",PR_TRUE,theStartPos,theCount)>kNotFound)|| @@ -231,7 +263,17 @@ eParseMode CParserContext::DetermineParseMode(const nsString& theBuffer) { (theBuffer.Find("LATIN1", PR_TRUE,theStartPos,theCount) >kNotFound) || (theBuffer.Find("SYMBOLS",PR_TRUE,theStartPos,theCount) >kNotFound) || (theBuffer.Find("SPECIAL",PR_TRUE,theStartPos,theCount) >kNotFound)) { - mParseMode=eParseMode_noquirks; + mParseMode=eParseMode_quirks; + } + + //one last thing: look for a URI that specifies the strict.dtd + theStartPos+=6; + theCount=theEnd-theStartPos; + theSubIndex=theBuffer.Find("STRICT.DTD",PR_TRUE,theStartPos,theCount); + if(0tokenRecycler->CreateTokenOfType(eToken_attribute, eHTMLTag_unknown); nsString& key = attrToken->GetKey(); key.AssignWithConversion("xmlns"); - attrToken->SetStringValue(kHTMLNameSpaceURI); + attrToken->SetCStringValue(kHTMLNameSpaceURI); newToken->SetAttributeCount(1); newToken = (CToken*) attrToken; AddToken(newToken, NS_OK, mState->tokenDeque, mState->tokenRecycler); diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp index f83054afef12..157d9d25df1d 100644 --- a/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/parser/htmlparser/src/nsHTMLTokens.cpp @@ -70,7 +70,7 @@ CHTMLToken::CHTMLToken(eHTMLTags aTag) : CToken(aTag) { * @update gess5/11/98 * @param name is a char* value containing new string value */ -void CHTMLToken::SetStringValue(const char* name){ +void CHTMLToken::SetCStringValue(const char* name){ if(name) { mTextValue.AssignWithConversion(name); mTypeID = nsHTMLTags::LookupTag(mTextValue); @@ -324,7 +324,7 @@ void CStartToken::AppendSource(nsString& anOutputString){ * @return */ CEndToken::CEndToken(eHTMLTags aTag) : CHTMLToken(aTag) { - SetStringValue(GetTagName(aTag)); + SetCStringValue(GetTagName(aTag)); } diff --git a/parser/htmlparser/src/nsHTMLTokens.h b/parser/htmlparser/src/nsHTMLTokens.h index c6b460f5333a..88e36767795e 100644 --- a/parser/htmlparser/src/nsHTMLTokens.h +++ b/parser/htmlparser/src/nsHTMLTokens.h @@ -100,7 +100,7 @@ public: CHTMLToken(eHTMLTags aTag); CHTMLToken(const nsString& aString,eHTMLTags aTag=eHTMLTag_unknown); - virtual void SetStringValue(const char* name); + virtual void SetCStringValue(const char* name); virtual nsString& GetStringValueXXX(void); protected: diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/src/nsParser.cpp index 5fd3a62aa52e..fd4c6e3fcac8 100644 --- a/parser/htmlparser/src/nsParser.cpp +++ b/parser/htmlparser/src/nsParser.cpp @@ -97,7 +97,7 @@ public: nsIDTD* theDTD; NS_NewNavHTMLDTD(&theDTD); //do this as a default HTML DTD... mDTDDeque.Push(theDTD); -#if 0 +#if 1 NS_NewOtherHTMLDTD(&theDTD); //do this as the default DTD for strict documents... mDTDDeque.Push(theDTD); #endif diff --git a/parser/htmlparser/src/nsToken.cpp b/parser/htmlparser/src/nsToken.cpp index 884a277cafd3..50ca09a48d5a 100644 --- a/parser/htmlparser/src/nsToken.cpp +++ b/parser/htmlparser/src/nsToken.cpp @@ -164,15 +164,14 @@ void CToken::DebugDumpSource(nsOutputStream& anOutputStream) { * @update gess5/11/98 * @param name is a char* value containing new string value */ -void CToken::SetStringValue(const char* name){ +void CToken::SetCStringValue(const char* name){ mTextValue.AssignWithConversion(name); } /** * Setter method for the string value of this token */ -void CToken::SetStringValue(nsString& aStr) -{ +void CToken::SetStringValue(nsString& aStr) { mTextValue = aStr; } diff --git a/parser/htmlparser/src/nsToken.h b/parser/htmlparser/src/nsToken.h index 91290561873b..d5c76a8dc0ed 100644 --- a/parser/htmlparser/src/nsToken.h +++ b/parser/htmlparser/src/nsToken.h @@ -124,7 +124,7 @@ class CToken { * @update gess5/11/98 * @param name is a char* value containing new string value */ - virtual void SetStringValue(const char* name); + virtual void SetCStringValue(const char* name); /** * Setter method for the string value of this token