PRInt32 thePeerIndex=theCloseTags->GetTopmostIndexOf(aTagStack); if(kNotFound!=thePeerIndex){ PRInt32   theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack); if(theRootIndex<thePeerIndex) return aTagStack.mTags[thePeerIndex]; }
while(aChildIndex<--theTopIndex) { eHTMLTags theNextTag=aTagStack.mTags[theTopIndex]; if(PR_FALSE==theCloseTags->Contains(theNextTag)) { if(PR_FALSE==theRootTags->Contains(theNextTag)) { break; }  }  } return aCurrentTag;
eHTMLTags FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag,nsTagStack& aTagStack,PRInt32 aChildIndex) {  int theTopIndex=aTagStack.mCount;  eHTMLTags aPrevTag=aTagStack.mTags[theTopIndex-1];   if(nsHTMLElement::IsContainer(aCurrentTag)){    if(aPrevTag==aCurrentTag){      return aCurrentTag;    }        if(nsHTMLElement::IsBlockCloser(aCurrentTag)) {      CTagList* theCloseTags=gHTMLElements[aCurrentTag].GetAutoCloseEndTags();      CTagList* theRootTags=gHTMLElements[aCurrentTag].GetRootTags();      if(theCloseTags){          PRInt32 thePeerIndex=theCloseTags->GetTopmostIndexOf(aTagStack);        if(kNotFound!=thePeerIndex){          PRInt32   theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack);          if(theRootIndex<thePeerIndex)            return aTagStack.mTags[thePeerIndex];        } //if      }//if      else if(theRootTags) {        //since we didn't find any close tags, see if there is an instance of aCurrentTag        //above the stack from the roottag.        PRInt32 theRootIndex=theRootTags->GetTopmostIndexOf(aTagStack);                  return (theRootIndex<aChildIndex) ? aCurrentTag : eHTMLTag_unknown;      }    } //if  } //if  return eHTMLTag_unknown;}