Bug 201271 Fix interface inconsistencies in parser

patch by choess@stwing.upenn.edu r=harishd sr=jst
This commit is contained in:
timeless%mozdev.org 2003-04-09 22:44:25 +00:00
parent d083a54a9d
commit ccd42d2e17
12 changed files with 114 additions and 114 deletions

View File

@ -1391,7 +1391,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
* This gets called before we've handled a given start tag. * This gets called before we've handled a given start tag.
* It's a generic hook to let us do pre processing. * It's a generic hook to let us do pre processing.
* @param aToken contains the tag in question * @param aToken contains the tag in question
* @param aChildTag is the tag itself. * @param aTag is the tag itself.
* @param aNode is the node (tag) with associated attributes. * @param aNode is the node (tag) with associated attributes.
* @return TRUE if tag processing should continue; FALSE if the tag has been handled. * @return TRUE if tag processing should continue; FALSE if the tag has been handled.
*/ */
@ -2569,34 +2569,34 @@ PRBool CNavDTD::IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const {
* @param aChild -- tag enum of child container * @param aChild -- tag enum of child container
* @return PR_TRUE if propagation should occur * @return PR_TRUE if propagation should occur
*/ */
PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag,PRBool aParentContains) { PRBool CNavDTD::CanPropagate(eHTMLTags aParent,eHTMLTags aChild,PRBool aParentContains) {
PRBool result=PR_FALSE; PRBool result=PR_FALSE;
PRBool theParentContains=(-1==aParentContains) ? CanContain(aParentTag,aChildTag) : aParentContains; PRBool theParentContains=(-1==aParentContains) ? CanContain(aParent,aChild) : aParentContains;
if(aParentTag==aChildTag) { if(aParent==aChild) {
return result; return result;
} }
if(nsHTMLElement::IsContainer(aChildTag)){ if(nsHTMLElement::IsContainer(aChild)){
mScratch.Truncate(); mScratch.Truncate();
if(!gHTMLElements[aChildTag].HasSpecialProperty(kNoPropagate)){ if(!gHTMLElements[aChild].HasSpecialProperty(kNoPropagate)){
if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { if(nsHTMLElement::IsBlockParent(aParent) || (gHTMLElements[aParent].GetSpecialChildren())) {
result=ForwardPropagate(mScratch,aParentTag,aChildTag); result=ForwardPropagate(mScratch,aParent,aChild);
if(PR_FALSE==result){ if(PR_FALSE==result){
if(eHTMLTag_unknown!=aParentTag) { if(eHTMLTag_unknown!=aParent) {
if(aParentTag!=aChildTag) //dont even bother if we're already inside a similar element... if(aParent!=aChild) //dont even bother if we're already inside a similar element...
result=BackwardPropagate(mScratch,aParentTag,aChildTag); result=BackwardPropagate(mScratch,aParent,aChild);
} //if } //if
else result=BackwardPropagate(mScratch,eHTMLTag_html,aChildTag); else result=BackwardPropagate(mScratch,eHTMLTag_html,aChild);
} //elseif } //elseif
}//if }//if
}//if }//if
if(mScratch.Length()-1>gHTMLElements[aParentTag].mPropagateRange) if(mScratch.Length()-1>gHTMLElements[aParent].mPropagateRange)
result=PR_FALSE; result=PR_FALSE;
}//if }//if
else result=theParentContains; else result=theParentContains;
@ -2709,24 +2709,24 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
* @param aChild -- tag type of child * @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise * @return TRUE if propagation closes; false otherwise
*/ */
PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) { PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParent,eHTMLTags aChild) {
PRBool result=PR_FALSE; PRBool result=PR_FALSE;
switch(aParentTag) { switch(aParent) {
case eHTMLTag_table: case eHTMLTag_table:
{ {
if((eHTMLTag_tr==aChildTag) || (eHTMLTag_td==aChildTag)) { if((eHTMLTag_tr==aChild) || (eHTMLTag_td==aChild)) {
return BackwardPropagate(aSequence,aParentTag,aChildTag); return BackwardPropagate(aSequence,aParent,aChild);
} }
} }
//otherwise, intentionally fall through... //otherwise, intentionally fall through...
case eHTMLTag_tr: case eHTMLTag_tr:
{ {
PRBool theCanContainResult=CanContain(eHTMLTag_td,aChildTag); PRBool theCanContainResult=CanContain(eHTMLTag_td,aChild);
if(PR_TRUE==theCanContainResult) { if(PR_TRUE==theCanContainResult) {
aSequence.Append((PRUnichar)eHTMLTag_td); aSequence.Append((PRUnichar)eHTMLTag_td);
result=BackwardPropagate(aSequence,aParentTag,eHTMLTag_td); result=BackwardPropagate(aSequence,aParent,eHTMLTag_td);
} }
} }
break; break;
@ -2752,25 +2752,25 @@ PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLT
* @param aChild -- tag type of child * @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise * @return TRUE if propagation closes; false otherwise
*/ */
PRBool CNavDTD::BackwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) const { PRBool CNavDTD::BackwardPropagate(nsString& aSequence,eHTMLTags aParent,eHTMLTags aChild) const {
eHTMLTags theParentTag=aParentTag; //just init to get past first condition... eHTMLTags theParent=aParent; //just init to get past first condition...
do { do {
const TagList* theRootTags=gHTMLElements[aChildTag].GetRootTags(); const TagList* theRootTags=gHTMLElements[aChild].GetRootTags();
if(theRootTags) { if(theRootTags) {
theParentTag=theRootTags->mTags[0]; theParent=theRootTags->mTags[0];
if(CanContain(theParentTag,aChildTag)) { if(CanContain(theParent,aChild)) {
//we've found a complete sequence, so push the parent... //we've found a complete sequence, so push the parent...
aChildTag=theParentTag; aChild=theParent;
aSequence.Append((PRUnichar)theParentTag); aSequence.Append((PRUnichar)theParent);
} }
} }
else break; else break;
} }
while((theParentTag!=eHTMLTag_unknown) && (theParentTag!=aParentTag)); while((theParent!=eHTMLTag_unknown) && (theParent!=aParent));
return PRBool(aParentTag==theParentTag); return PRBool(aParent==theParent);
} }
@ -3635,21 +3635,21 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
* @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container.
* @return TRUE if ok, FALSE if error * @return TRUE if ok, FALSE if error
*/ */
nsresult CNavDTD::CloseContainersTo(eHTMLTags aTarget,PRBool aClosedByStartTag){ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag){
NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
PRInt32 pos=mBodyContext->LastOf(aTarget); PRInt32 pos=mBodyContext->LastOf(aTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the tag is indeed open, so close it. //the tag is indeed open, so close it.
return CloseContainersTo(pos,aTarget,aClosedByStartTag); return CloseContainersTo(pos,aTag,aClosedByStartTag);
} }
eHTMLTags theTopTag=mBodyContext->Last(); eHTMLTags theTopTag=mBodyContext->Last();
PRBool theTagIsSynonymous=((nsHTMLElement::IsResidualStyleTag(aTarget)) && (nsHTMLElement::IsResidualStyleTag(theTopTag))); PRBool theTagIsSynonymous=((nsHTMLElement::IsResidualStyleTag(aTag)) && (nsHTMLElement::IsResidualStyleTag(theTopTag)));
if(!theTagIsSynonymous){ if(!theTagIsSynonymous){
theTagIsSynonymous=(gHTMLElements[aTarget].IsMemberOf(kHeading) && theTagIsSynonymous=(gHTMLElements[aTag].IsMemberOf(kHeading) &&
gHTMLElements[theTopTag].IsMemberOf(kHeading)); gHTMLElements[theTopTag].IsMemberOf(kHeading));
} }
@ -3657,21 +3657,21 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTarget,PRBool aClosedByStartTag){
//if you're here, it's because we're trying to close one tag, //if you're here, it's because we're trying to close one tag,
//but a different (synonymous) one is actually open. Because this is NAV4x //but a different (synonymous) one is actually open. Because this is NAV4x
//compatibililty mode, we must close the one that's really open. //compatibililty mode, we must close the one that's really open.
aTarget=theTopTag; aTag=theTopTag;
pos=mBodyContext->LastOf(aTarget); pos=mBodyContext->LastOf(aTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the tag is indeed open, so close it. //the tag is indeed open, so close it.
return CloseContainersTo(pos,aTarget,aClosedByStartTag); return CloseContainersTo(pos,aTag,aClosedByStartTag);
} }
} }
nsresult result=NS_OK; nsresult result=NS_OK;
const TagList* theRootTags=gHTMLElements[aTarget].GetRootTags(); const TagList* theRootTags=gHTMLElements[aTag].GetRootTags();
eHTMLTags theParentTag=(theRootTags) ? theRootTags->mTags[0] : eHTMLTag_unknown; eHTMLTags theParentTag=(theRootTags) ? theRootTags->mTags[0] : eHTMLTag_unknown;
pos=mBodyContext->LastOf(theParentTag); pos=mBodyContext->LastOf(theParentTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the parent container is open, so close it instead //the parent container is open, so close it instead
result=CloseContainersTo(pos+1,aTarget,aClosedByStartTag); result=CloseContainersTo(pos+1,aTag,aClosedByStartTag);
} }
return result; return result;
} }
@ -3762,25 +3762,25 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
* stack until the child can be properly placed. * stack until the child can be properly placed.
* *
* @update gess 4/8/98 * @update gess 4/8/98
* @param aChildTag is the child for whom we need to * @param aChild is the child for whom we need to
* create a new context vector * create a new context vector
* @return true if we succeeded, otherwise false * @return true if we succeeded, otherwise false
*/ */
nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChild){
mScratch.Truncate(); mScratch.Truncate();
nsresult result=(nsresult)kContextMismatch; nsresult result=(nsresult)kContextMismatch;
eHTMLTags theTop=mBodyContext->Last(); eHTMLTags theTop=mBodyContext->Last();
PRBool bResult=ForwardPropagate(mScratch,theTop,aChildTag); PRBool bResult=ForwardPropagate(mScratch,theTop,aChild);
if(PR_FALSE==bResult){ if(PR_FALSE==bResult){
if(eHTMLTag_unknown!=theTop) { if(eHTMLTag_unknown!=theTop) {
if(theTop!=aChildTag) //dont even bother if we're already inside a similar element... if(theTop!=aChild) //dont even bother if we're already inside a similar element...
bResult=BackwardPropagate(mScratch,theTop,aChildTag); bResult=BackwardPropagate(mScratch,theTop,aChild);
} //if } //if
else bResult=BackwardPropagate(mScratch,eHTMLTag_html,aChildTag); else bResult=BackwardPropagate(mScratch,eHTMLTag_html,aChild);
} //elseif } //elseif
PRInt32 theLen=mScratch.Length(); PRInt32 theLen=mScratch.Length();

View File

@ -176,8 +176,8 @@ public:
* @return True if closure was achieved -- other false * @return True if closure was achieved -- other false
*/ */
virtual PRBool ForwardPropagate(nsString& aSequence, virtual PRBool ForwardPropagate(nsString& aSequence,
eHTMLTags aParentTag, eHTMLTags aParent,
eHTMLTags aChildTag); eHTMLTags aChild);
/** /**
* This method tries to design a context map (without actually * This method tries to design a context map (without actually
@ -189,17 +189,17 @@ public:
* @return True if closure was achieved -- other false * @return True if closure was achieved -- other false
*/ */
virtual PRBool BackwardPropagate(nsString& aSequence, virtual PRBool BackwardPropagate(nsString& aSequence,
eHTMLTags aParentTag, eHTMLTags aParent,
eHTMLTags aChildTag) const; eHTMLTags aChild) const;
/** /**
* Attempt forward and/or backward propagation for the given * Attempt forward and/or backward propagation for the given
* child within the current context vector stack. * child within the current context vector stack.
* @update gess5/11/98 * @update gess5/11/98
* @param type of child to be propagated. * @param aChild -- type of child to be propagated.
* @return TRUE if succeeds, otherwise FALSE * @return TRUE if succeeds, otherwise FALSE
*/ */
nsresult CreateContextStackFor(eHTMLTags aChildTag); nsresult CreateContextStackFor(eHTMLTags aChild);
/** /**
* Ask parser if a given container is open ANYWHERE on stack * Ask parser if a given container is open ANYWHERE on stack

View File

@ -554,7 +554,7 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
* This gets called after we've handled a given start tag. * This gets called after we've handled a given start tag.
* It's a generic hook to let us to post processing. * It's a generic hook to let us to post processing.
* @param aToken contains the tag in question * @param aToken contains the tag in question
* @param aChildTag is the tag itself. * @param aTag is the tag itself.
* @return status * @return status
*/ */
nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){

View File

@ -159,7 +159,7 @@ class COtherDTD : public nsIDTD
protected: protected:
nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount); nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode); nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode& aNode);
nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag); nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
nsIParserNode* CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0); nsIParserNode* CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0);

View File

@ -379,7 +379,7 @@ eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const
* @update harishd 04/04/99 * @update harishd 04/04/99
* @update gess 04/21/99 * @update gess 04/21/99
*/ */
eHTMLTags nsEntryStack::Last() const eHTMLTags nsEntryStack::Last(void) const
{ {
eHTMLTags result=eHTMLTag_unknown; eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) { if(0<mCount) {
@ -1243,7 +1243,7 @@ void nsDTDContext::RemoveStyle(eHTMLTags aTag){
* *
* @return nada * @return nada
*/ */
void nsDTDContext::ReleaseGlobalObjects(){ void nsDTDContext::ReleaseGlobalObjects(void){
} }

View File

@ -127,7 +127,7 @@ public:
void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0); void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE); void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE); void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void Append(nsEntryStack *theStack); void Append(nsEntryStack *aStack);
nsCParserNode* Pop(void); nsCParserNode* Pop(void);
nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag); nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag);
nsCParserNode* NodeAt(PRInt32 anIndex) const; nsCParserNode* NodeAt(PRInt32 anIndex) const;
@ -355,7 +355,7 @@ public:
PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;} PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;}
nsEntryStack* GetStylesAt(PRInt32 anIndex) const; nsEntryStack* GetStylesAt(PRInt32 anIndex) const;
void PushStyle(nsCParserNode* aNode); void PushStyle(nsCParserNode* aNode);
void PushStyles(nsEntryStack *theStyles); void PushStyles(nsEntryStack *aStyles);
nsCParserNode* PopStyle(void); nsCParserNode* PopStyle(void);
nsCParserNode* PopStyle(eHTMLTags aTag); nsCParserNode* PopStyle(eHTMLTags aTag);
void RemoveStyle(eHTMLTags aTag); void RemoveStyle(eHTMLTags aTag);
@ -574,7 +574,7 @@ struct CRCStruct {
class nsObserverEntry : public nsIObserverEntry { class nsObserverEntry : public nsIObserverEntry {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
nsObserverEntry(const nsAString& aTopic); nsObserverEntry(const nsAString& aString);
virtual ~nsObserverEntry(); virtual ~nsObserverEntry();
NS_IMETHOD Notify(nsIParserNode* aNode, NS_IMETHOD Notify(nsIParserNode* aNode,

View File

@ -1391,7 +1391,7 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsC
* This gets called before we've handled a given start tag. * This gets called before we've handled a given start tag.
* It's a generic hook to let us do pre processing. * It's a generic hook to let us do pre processing.
* @param aToken contains the tag in question * @param aToken contains the tag in question
* @param aChildTag is the tag itself. * @param aTag is the tag itself.
* @param aNode is the node (tag) with associated attributes. * @param aNode is the node (tag) with associated attributes.
* @return TRUE if tag processing should continue; FALSE if the tag has been handled. * @return TRUE if tag processing should continue; FALSE if the tag has been handled.
*/ */
@ -2569,34 +2569,34 @@ PRBool CNavDTD::IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const {
* @param aChild -- tag enum of child container * @param aChild -- tag enum of child container
* @return PR_TRUE if propagation should occur * @return PR_TRUE if propagation should occur
*/ */
PRBool CNavDTD::CanPropagate(eHTMLTags aParentTag,eHTMLTags aChildTag,PRBool aParentContains) { PRBool CNavDTD::CanPropagate(eHTMLTags aParent,eHTMLTags aChild,PRBool aParentContains) {
PRBool result=PR_FALSE; PRBool result=PR_FALSE;
PRBool theParentContains=(-1==aParentContains) ? CanContain(aParentTag,aChildTag) : aParentContains; PRBool theParentContains=(-1==aParentContains) ? CanContain(aParent,aChild) : aParentContains;
if(aParentTag==aChildTag) { if(aParent==aChild) {
return result; return result;
} }
if(nsHTMLElement::IsContainer(aChildTag)){ if(nsHTMLElement::IsContainer(aChild)){
mScratch.Truncate(); mScratch.Truncate();
if(!gHTMLElements[aChildTag].HasSpecialProperty(kNoPropagate)){ if(!gHTMLElements[aChild].HasSpecialProperty(kNoPropagate)){
if(nsHTMLElement::IsBlockParent(aParentTag) || (gHTMLElements[aParentTag].GetSpecialChildren())) { if(nsHTMLElement::IsBlockParent(aParent) || (gHTMLElements[aParent].GetSpecialChildren())) {
result=ForwardPropagate(mScratch,aParentTag,aChildTag); result=ForwardPropagate(mScratch,aParent,aChild);
if(PR_FALSE==result){ if(PR_FALSE==result){
if(eHTMLTag_unknown!=aParentTag) { if(eHTMLTag_unknown!=aParent) {
if(aParentTag!=aChildTag) //dont even bother if we're already inside a similar element... if(aParent!=aChild) //dont even bother if we're already inside a similar element...
result=BackwardPropagate(mScratch,aParentTag,aChildTag); result=BackwardPropagate(mScratch,aParent,aChild);
} //if } //if
else result=BackwardPropagate(mScratch,eHTMLTag_html,aChildTag); else result=BackwardPropagate(mScratch,eHTMLTag_html,aChild);
} //elseif } //elseif
}//if }//if
}//if }//if
if(mScratch.Length()-1>gHTMLElements[aParentTag].mPropagateRange) if(mScratch.Length()-1>gHTMLElements[aParent].mPropagateRange)
result=PR_FALSE; result=PR_FALSE;
}//if }//if
else result=theParentContains; else result=theParentContains;
@ -2709,24 +2709,24 @@ PRBool CNavDTD::IsContainer(PRInt32 aTag) const {
* @param aChild -- tag type of child * @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise * @return TRUE if propagation closes; false otherwise
*/ */
PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) { PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParent,eHTMLTags aChild) {
PRBool result=PR_FALSE; PRBool result=PR_FALSE;
switch(aParentTag) { switch(aParent) {
case eHTMLTag_table: case eHTMLTag_table:
{ {
if((eHTMLTag_tr==aChildTag) || (eHTMLTag_td==aChildTag)) { if((eHTMLTag_tr==aChild) || (eHTMLTag_td==aChild)) {
return BackwardPropagate(aSequence,aParentTag,aChildTag); return BackwardPropagate(aSequence,aParent,aChild);
} }
} }
//otherwise, intentionally fall through... //otherwise, intentionally fall through...
case eHTMLTag_tr: case eHTMLTag_tr:
{ {
PRBool theCanContainResult=CanContain(eHTMLTag_td,aChildTag); PRBool theCanContainResult=CanContain(eHTMLTag_td,aChild);
if(PR_TRUE==theCanContainResult) { if(PR_TRUE==theCanContainResult) {
aSequence.Append((PRUnichar)eHTMLTag_td); aSequence.Append((PRUnichar)eHTMLTag_td);
result=BackwardPropagate(aSequence,aParentTag,eHTMLTag_td); result=BackwardPropagate(aSequence,aParent,eHTMLTag_td);
} }
} }
break; break;
@ -2752,25 +2752,25 @@ PRBool CNavDTD::ForwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLT
* @param aChild -- tag type of child * @param aChild -- tag type of child
* @return TRUE if propagation closes; false otherwise * @return TRUE if propagation closes; false otherwise
*/ */
PRBool CNavDTD::BackwardPropagate(nsString& aSequence,eHTMLTags aParentTag,eHTMLTags aChildTag) const { PRBool CNavDTD::BackwardPropagate(nsString& aSequence,eHTMLTags aParent,eHTMLTags aChild) const {
eHTMLTags theParentTag=aParentTag; //just init to get past first condition... eHTMLTags theParent=aParent; //just init to get past first condition...
do { do {
const TagList* theRootTags=gHTMLElements[aChildTag].GetRootTags(); const TagList* theRootTags=gHTMLElements[aChild].GetRootTags();
if(theRootTags) { if(theRootTags) {
theParentTag=theRootTags->mTags[0]; theParent=theRootTags->mTags[0];
if(CanContain(theParentTag,aChildTag)) { if(CanContain(theParent,aChild)) {
//we've found a complete sequence, so push the parent... //we've found a complete sequence, so push the parent...
aChildTag=theParentTag; aChild=theParent;
aSequence.Append((PRUnichar)theParentTag); aSequence.Append((PRUnichar)theParent);
} }
} }
else break; else break;
} }
while((theParentTag!=eHTMLTag_unknown) && (theParentTag!=aParentTag)); while((theParent!=eHTMLTag_unknown) && (theParent!=aParent));
return PRBool(aParentTag==theParentTag); return PRBool(aParent==theParent);
} }
@ -3635,21 +3635,21 @@ nsresult CNavDTD::CloseContainersTo(PRInt32 anIndex,eHTMLTags aTarget, PRBool aC
* @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container. * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container.
* @return TRUE if ok, FALSE if error * @return TRUE if ok, FALSE if error
*/ */
nsresult CNavDTD::CloseContainersTo(eHTMLTags aTarget,PRBool aClosedByStartTag){ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTag,PRBool aClosedByStartTag){
NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos); NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
PRInt32 pos=mBodyContext->LastOf(aTarget); PRInt32 pos=mBodyContext->LastOf(aTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the tag is indeed open, so close it. //the tag is indeed open, so close it.
return CloseContainersTo(pos,aTarget,aClosedByStartTag); return CloseContainersTo(pos,aTag,aClosedByStartTag);
} }
eHTMLTags theTopTag=mBodyContext->Last(); eHTMLTags theTopTag=mBodyContext->Last();
PRBool theTagIsSynonymous=((nsHTMLElement::IsResidualStyleTag(aTarget)) && (nsHTMLElement::IsResidualStyleTag(theTopTag))); PRBool theTagIsSynonymous=((nsHTMLElement::IsResidualStyleTag(aTag)) && (nsHTMLElement::IsResidualStyleTag(theTopTag)));
if(!theTagIsSynonymous){ if(!theTagIsSynonymous){
theTagIsSynonymous=(gHTMLElements[aTarget].IsMemberOf(kHeading) && theTagIsSynonymous=(gHTMLElements[aTag].IsMemberOf(kHeading) &&
gHTMLElements[theTopTag].IsMemberOf(kHeading)); gHTMLElements[theTopTag].IsMemberOf(kHeading));
} }
@ -3657,21 +3657,21 @@ nsresult CNavDTD::CloseContainersTo(eHTMLTags aTarget,PRBool aClosedByStartTag){
//if you're here, it's because we're trying to close one tag, //if you're here, it's because we're trying to close one tag,
//but a different (synonymous) one is actually open. Because this is NAV4x //but a different (synonymous) one is actually open. Because this is NAV4x
//compatibililty mode, we must close the one that's really open. //compatibililty mode, we must close the one that's really open.
aTarget=theTopTag; aTag=theTopTag;
pos=mBodyContext->LastOf(aTarget); pos=mBodyContext->LastOf(aTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the tag is indeed open, so close it. //the tag is indeed open, so close it.
return CloseContainersTo(pos,aTarget,aClosedByStartTag); return CloseContainersTo(pos,aTag,aClosedByStartTag);
} }
} }
nsresult result=NS_OK; nsresult result=NS_OK;
const TagList* theRootTags=gHTMLElements[aTarget].GetRootTags(); const TagList* theRootTags=gHTMLElements[aTag].GetRootTags();
eHTMLTags theParentTag=(theRootTags) ? theRootTags->mTags[0] : eHTMLTag_unknown; eHTMLTags theParentTag=(theRootTags) ? theRootTags->mTags[0] : eHTMLTag_unknown;
pos=mBodyContext->LastOf(theParentTag); pos=mBodyContext->LastOf(theParentTag);
if(kNotFound!=pos) { if(kNotFound!=pos) {
//the parent container is open, so close it instead //the parent container is open, so close it instead
result=CloseContainersTo(pos+1,aTarget,aClosedByStartTag); result=CloseContainersTo(pos+1,aTag,aClosedByStartTag);
} }
return result; return result;
} }
@ -3762,25 +3762,25 @@ nsresult CNavDTD::AddHeadLeaf(nsIParserNode *aNode){
* stack until the child can be properly placed. * stack until the child can be properly placed.
* *
* @update gess 4/8/98 * @update gess 4/8/98
* @param aChildTag is the child for whom we need to * @param aChild is the child for whom we need to
* create a new context vector * create a new context vector
* @return true if we succeeded, otherwise false * @return true if we succeeded, otherwise false
*/ */
nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChildTag){ nsresult CNavDTD::CreateContextStackFor(eHTMLTags aChild){
mScratch.Truncate(); mScratch.Truncate();
nsresult result=(nsresult)kContextMismatch; nsresult result=(nsresult)kContextMismatch;
eHTMLTags theTop=mBodyContext->Last(); eHTMLTags theTop=mBodyContext->Last();
PRBool bResult=ForwardPropagate(mScratch,theTop,aChildTag); PRBool bResult=ForwardPropagate(mScratch,theTop,aChild);
if(PR_FALSE==bResult){ if(PR_FALSE==bResult){
if(eHTMLTag_unknown!=theTop) { if(eHTMLTag_unknown!=theTop) {
if(theTop!=aChildTag) //dont even bother if we're already inside a similar element... if(theTop!=aChild) //dont even bother if we're already inside a similar element...
bResult=BackwardPropagate(mScratch,theTop,aChildTag); bResult=BackwardPropagate(mScratch,theTop,aChild);
} //if } //if
else bResult=BackwardPropagate(mScratch,eHTMLTag_html,aChildTag); else bResult=BackwardPropagate(mScratch,eHTMLTag_html,aChild);
} //elseif } //elseif
PRInt32 theLen=mScratch.Length(); PRInt32 theLen=mScratch.Length();

View File

@ -176,8 +176,8 @@ public:
* @return True if closure was achieved -- other false * @return True if closure was achieved -- other false
*/ */
virtual PRBool ForwardPropagate(nsString& aSequence, virtual PRBool ForwardPropagate(nsString& aSequence,
eHTMLTags aParentTag, eHTMLTags aParent,
eHTMLTags aChildTag); eHTMLTags aChild);
/** /**
* This method tries to design a context map (without actually * This method tries to design a context map (without actually
@ -189,17 +189,17 @@ public:
* @return True if closure was achieved -- other false * @return True if closure was achieved -- other false
*/ */
virtual PRBool BackwardPropagate(nsString& aSequence, virtual PRBool BackwardPropagate(nsString& aSequence,
eHTMLTags aParentTag, eHTMLTags aParent,
eHTMLTags aChildTag) const; eHTMLTags aChild) const;
/** /**
* Attempt forward and/or backward propagation for the given * Attempt forward and/or backward propagation for the given
* child within the current context vector stack. * child within the current context vector stack.
* @update gess5/11/98 * @update gess5/11/98
* @param type of child to be propagated. * @param aChild -- type of child to be propagated.
* @return TRUE if succeeds, otherwise FALSE * @return TRUE if succeeds, otherwise FALSE
*/ */
nsresult CreateContextStackFor(eHTMLTags aChildTag); nsresult CreateContextStackFor(eHTMLTags aChild);
/** /**
* Ask parser if a given container is open ANYWHERE on stack * Ask parser if a given container is open ANYWHERE on stack

View File

@ -554,7 +554,7 @@ nsresult COtherDTD::HandleToken(CToken* aToken,nsIParser* aParser){
* This gets called after we've handled a given start tag. * This gets called after we've handled a given start tag.
* It's a generic hook to let us to post processing. * It's a generic hook to let us to post processing.
* @param aToken contains the tag in question * @param aToken contains the tag in question
* @param aChildTag is the tag itself. * @param aTag is the tag itself.
* @return status * @return status
*/ */
nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){

View File

@ -159,7 +159,7 @@ class COtherDTD : public nsIDTD
protected: protected:
nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount); nsresult CollectAttributes(nsIParserNode& aNode,eHTMLTags aTag,PRInt32 aCount);
nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode); nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode& aNode);
nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag); nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
nsIParserNode* CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0); nsIParserNode* CreateNode(CToken* aToken=nsnull,PRInt32 aLineNumber=1,nsTokenAllocator* aTokenAllocator=0);

View File

@ -379,7 +379,7 @@ eHTMLTags nsEntryStack::operator[](PRInt32 anIndex) const
* @update harishd 04/04/99 * @update harishd 04/04/99
* @update gess 04/21/99 * @update gess 04/21/99
*/ */
eHTMLTags nsEntryStack::Last() const eHTMLTags nsEntryStack::Last(void) const
{ {
eHTMLTags result=eHTMLTag_unknown; eHTMLTags result=eHTMLTag_unknown;
if(0<mCount) { if(0<mCount) {
@ -1243,7 +1243,7 @@ void nsDTDContext::RemoveStyle(eHTMLTags aTag){
* *
* @return nada * @return nada
*/ */
void nsDTDContext::ReleaseGlobalObjects(){ void nsDTDContext::ReleaseGlobalObjects(void){
} }

View File

@ -127,7 +127,7 @@ public:
void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0); void EnsureCapacityFor(PRInt32 aNewMax, PRInt32 aShiftOffset=0);
void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE); void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE); void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, PRBool aRefCntNode = PR_TRUE);
void Append(nsEntryStack *theStack); void Append(nsEntryStack *aStack);
nsCParserNode* Pop(void); nsCParserNode* Pop(void);
nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag); nsCParserNode* Remove(PRInt32 anIndex,eHTMLTags aTag);
nsCParserNode* NodeAt(PRInt32 anIndex) const; nsCParserNode* NodeAt(PRInt32 anIndex) const;
@ -355,7 +355,7 @@ public:
PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;} PRInt32 GetResidualStyleCount(void) {return mResidualStyleCount;}
nsEntryStack* GetStylesAt(PRInt32 anIndex) const; nsEntryStack* GetStylesAt(PRInt32 anIndex) const;
void PushStyle(nsCParserNode* aNode); void PushStyle(nsCParserNode* aNode);
void PushStyles(nsEntryStack *theStyles); void PushStyles(nsEntryStack *aStyles);
nsCParserNode* PopStyle(void); nsCParserNode* PopStyle(void);
nsCParserNode* PopStyle(eHTMLTags aTag); nsCParserNode* PopStyle(eHTMLTags aTag);
void RemoveStyle(eHTMLTags aTag); void RemoveStyle(eHTMLTags aTag);
@ -574,7 +574,7 @@ struct CRCStruct {
class nsObserverEntry : public nsIObserverEntry { class nsObserverEntry : public nsIObserverEntry {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
nsObserverEntry(const nsAString& aTopic); nsObserverEntry(const nsAString& aString);
virtual ~nsObserverEntry(); virtual ~nsObserverEntry();
NS_IMETHOD Notify(nsIParserNode* aNode, NS_IMETHOD Notify(nsIParserNode* aNode,