Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
CTransitionalDTD Class Reference

#include <COtherDTD.h>

Inheritance diagram for CTransitionalDTD:
Inheritance graph
[legend]
Collaboration diagram for CTransitionalDTD:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CTransitionalDTD ()
virtual ~CTransitionalDTD ()
nsresult HandleStartToken (CToken *aToken)
 The following set of methods are used to partially construct the content model (via the sink) according to the type of token.
nsresult HandleEndToken (CToken *aToken)
 This method gets called when an end token has been encountered in the parse process.
nsresult HandleEntityToken (CToken *aToken)
 This method gets called when an entity token has been encountered in the parse process.
 NS_IMETHOD_ (const nsIID &) GetMostDerivedIID(void) const =0
 NS_IMETHOD_ (eAutoDetectResult) CanParse(CParserContext &aParserContext)=0
 This method is called to determine if the given DTD can parse a document in a given source-type.
 NS_IMETHOD_ (PRBool) CanContain(PRInt32 aParent
 This method is called to determine whether or not a tag of one type can contain a tag of another type.
 NS_IMETHOD_ (PRBool) IsContainer(PRInt32 aTag) const =0
 This method gets called to determine whether a given tag is itself a container.
 NS_IMETHOD_ (void) Terminate()=0
 Use this id you want to stop the building content model --------------[ Sets DTD to STOP mode ]---------------- It's recommended to use this method in accordance with the parser's terminate() method.
 NS_IMETHOD_ (PRInt32) GetType()=0
NS_IMETHOD CreateNewInstance (nsIDTD **aInstancePtrResult)=0
 Call this method if you want the DTD to construct a clone of itself.
NS_IMETHOD WillBuildModel (const CParserContext &aParserContext, nsITokenizer *aTokenizer, nsIContentSink *aSink)=0
NS_IMETHOD DidBuildModel (nsresult anErrorCode, PRBool aNotifySink, nsIParser *aParser, nsIContentSink *aSink)=0
 Called by the parser after the parsing process has concluded gess5/18/98.
NS_IMETHOD BuildModel (nsIParser *aParser, nsITokenizer *aTokenizer, nsITokenObserver *anObserver, nsIContentSink *aSink)=0
 Called by the parser after the parsing process has concluded gess5/18/98.
NS_IMETHOD HandleToken (CToken *aToken, nsIParser *aParser)=0
 Called during model building phase of parse process.
NS_IMETHOD WillResumeParse (nsIContentSink *aSink)=0
 If the parse process gets interrupted midway, this method is called by the parser prior to resuming the process.
NS_IMETHOD WillInterruptParse (nsIContentSink *aSink)=0
 If the parse process gets interrupted, this method is called by the parser to notify the DTD that interruption will occur.
NS_IMETHOD CollectSkippedContent (PRInt32 aTag, nsAString &aContent, PRInt32 &aLineNo)=0

Public Attributes

PRInt32 aChild const = 0

Protected Member Functions

nsresult CollectAttributes (nsIParserNode &aNode, eHTMLTags aTag, PRInt32 aCount)
 Retrieve the attributes for this node, and add then into the node.
nsresult WillHandleStartTag (CToken *aToken, eHTMLTags aTag, nsIParserNode &aNode)
 This gets called before we've handled a given start tag.
nsresult DidHandleStartTag (nsIParserNode &aNode, eHTMLTags aChildTag)
 This gets called after we've handled a given start tag.
nsIParserNodeCreateNode (CToken *aToken=nsnull, PRInt32 aLineNumber=1, nsTokenAllocator *aTokenAllocator=0)

Protected Attributes

nsIHTMLContentSinkmSink
nsDTDContextmBodyContext
PRInt32 mHasOpenHead
PRPackedBool mHasOpenForm
PRPackedBool mHasOpenMap
PRPackedBool mHasOpenBody
PRPackedBool mHadFrameset
PRPackedBool mHadBody
PRPackedBool mHasOpenScript
PRPackedBool mEnableStrict
nsString mFilename
PRInt32 mLineNumber
nsParsermParser
nsITokenizermTokenizer
nsTokenAllocatormTokenAllocator
nsNodeAllocatormNodeAllocator
eHTMLTags mSkipTarget
nsresult mDTDState
nsDTDMode mDTDMode
eParserCommands mParserCommand
PRUint32 mComputedCRC32
PRUint32 mExpectedCRC32
nsString mScratch
eParserDocType mDocType

Detailed Description

Definition at line 213 of file COtherDTD.h.


Constructor & Destructor Documentation

Definition at line 863 of file COtherDTD.cpp.

{
  if (mBodyContext) mBodyContext->mFlags.mTransitional = PR_TRUE;
}

Definition at line 868 of file COtherDTD.cpp.

{}

Member Function Documentation

NS_IMETHOD nsIDTD::BuildModel ( nsIParser aParser,
nsITokenizer aTokenizer,
nsITokenObserver anObserver,
nsIContentSink aSink 
) [pure virtual, inherited]

Called by the parser after the parsing process has concluded gess5/18/98.

Parameters:
anErrorCode- contains error code resulting from parse process
Returns:

Here is the caller graph for this function:

nsresult COtherDTD::CollectAttributes ( nsIParserNode aNode,
eHTMLTags  aTag,
PRInt32  aCount 
) [protected, inherited]

Retrieve the attributes for this node, and add then into the node.

gess4/22/98

Parameters:
aNodeis the node you want to collect attributes for
aCountis the # of attributes you're expecting
Returns:
error code (should be 0)

Definition at line 724 of file COtherDTD.cpp.

                                                                                       {
  int attr=0;

  nsresult result=NS_OK;
  int theAvailTokenCount=mTokenizer->GetCount();
  if(aCount<=theAvailTokenCount) {
    //gElementTable->mElements[aTag]->GetSkipTarget();
    CToken* theToken=0; 
    for(attr=0;attr<aCount;++attr){  
      theToken=mTokenizer->PopToken(); 
      if(theToken)  {
        aNode.AddAttribute(theToken); 
      }
    }
  }
  else { 
    result=kEOF; 
  }
  return result; 
} 

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsIDTD::CollectSkippedContent ( PRInt32  aTag,
nsAString &  aContent,
PRInt32 aLineNo 
) [pure virtual, inherited]

Here is the caller graph for this function:

NS_IMETHOD nsIDTD::CreateNewInstance ( nsIDTD **  aInstancePtrResult) [pure virtual, inherited]

Call this method if you want the DTD to construct a clone of itself.

gess7/23/98

Parameters:
@return

Here is the caller graph for this function:

nsIParserNode* COtherDTD::CreateNode ( CToken aToken = nsnull,
PRInt32  aLineNumber = 1,
nsTokenAllocator aTokenAllocator = 0 
) [protected, inherited]
NS_IMETHOD nsIDTD::DidBuildModel ( nsresult  anErrorCode,
PRBool  aNotifySink,
nsIParser aParser,
nsIContentSink aSink 
) [pure virtual, inherited]

Called by the parser after the parsing process has concluded gess5/18/98.

Parameters:
anErrorCode- contains error code resulting from parse process
Returns:

Here is the caller graph for this function:

nsresult COtherDTD::DidHandleStartTag ( nsIParserNode aNode,
eHTMLTags  aChildTag 
) [protected, inherited]

This gets called after we've handled a given start tag.

It's a generic hook to let us to post processing.

Parameters:
aTokencontains the tag in question
aTagis the tag itself.
Returns:
status

Definition at line 530 of file COtherDTD.cpp.

                                                                             {
  nsresult result=NS_OK;

  switch(aChildTag){ 

    case eHTMLTag_script: 
      mHasOpenScript=PR_TRUE; 
      break;   

    case eHTMLTag_pre:
    case eHTMLTag_listing:
      {
        CToken* theNextToken=mTokenizer->PeekToken();
        if(theNextToken)  {
          eHTMLTokenTypes theType=eHTMLTokenTypes(theNextToken->GetTokenType());
          if(eToken_newline==theType){
            ++mLineNumber;
            mTokenizer->PopToken();  //skip 1st newline inside PRE and LISTING
          }//if
        }//if
      }
      break;

    default:
      break;
  }//switch 

  return result;
} 

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult COtherDTD::HandleEndToken ( CToken aToken) [inherited]

This method gets called when an end token has been encountered in the parse process.

If the end tag matches the start tag on the stack, then simply close it. Otherwise, we have a erroneous state condition. This can be because we have a close tag with no prior open tag (user error) or because we screwed something up in the parse process. I'm not sure yet how to tell the difference.

gess 3/25/98

Parameters:
aToken-- next (start) token to be handled
Returns:
PR_TRUE if all went well; PR_FALSE if error occured

Definition at line 682 of file COtherDTD.cpp.

                                                 { 
  nsresult    result=NS_OK;
  eHTMLTags   theChildTag=(eHTMLTags)aToken->GetTypeID();
 
  switch(theChildTag) {    
 
    case eHTMLTag_body: //we intentionally don't let the user close HTML or BODY
    case eHTMLTag_html:   
      break;    
        
    case eHTMLTag_script:       
      mHasOpenScript=PR_FALSE;         
      
    default: 
      PRInt32 theCount=mBodyContext->GetCount();
      eHTMLTags theParent=mBodyContext->TagAt(theCount-1);
      if(theChildTag==theParent) {
        theParent=mBodyContext->TagAt(theCount-2);
      }
      CElement* theElement=gElementTable->mElements[theParent];
      if(theElement) { 
        nsCParserNode* theNode=mNodeAllocator->CreateNode(aToken, mTokenAllocator);
        if(theNode) {
          result=theElement->HandleEndToken(theNode,theChildTag,mBodyContext,mSink);
          IF_FREE(theNode, mNodeAllocator);
        }
      }   
      break; 
  }     
   
  return result;            
}          

Here is the call graph for this function:

nsresult COtherDTD::HandleEntityToken ( CToken aToken) [inherited]

This method gets called when an entity token has been encountered in the parse process.

gess 3/25/98

Parameters:
aToken-- next (start) token to be handled
Returns:
PR_TRUE if all went well; PR_FALSE if error occured

Definition at line 753 of file COtherDTD.cpp.

                                                    {
  nsresult  result=NS_OK;

  nsAutoString theStr;
  aToken->GetSource(theStr);
  PRUnichar theChar=theStr.CharAt(0);
  CToken    *theToken=0;

  if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
    //if you're here we have a bogus entity.
    //convert it into a text token.
    nsAutoString entityName;
    entityName.AssignLiteral("&");
    entityName.Append(theStr); //should append the entity name; fix bug 51161.
    theToken=(CTextToken*)mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,entityName);
    result=HandleStartToken(theToken);
  }
  else {

    //add this code to fix bug 42629 (entities were getting dropped).
    eHTMLTags theParent=mBodyContext->Last();
    CElement* theElement=gElementTable->mElements[theParent];
    if(theElement) {
      nsCParserNode theNode(aToken, 0);
      result=theElement->HandleStartToken(&theNode,eHTMLTag_text,mBodyContext,mSink);  
    }
  }
  return result;
} 

Here is the call graph for this function:

nsresult COtherDTD::HandleStartToken ( CToken aToken) [inherited]

The following set of methods are used to partially construct the content model (via the sink) according to the type of token.

This method gets called when a start token has been encountered in the parse process.

gess5/11/98

Parameters:
aTokenis the token (of a given type) to be handled
Returns:
error code representing construction state; usually 0.

If the current container can contain this tag, then add it. Otherwise, you have two choices: 1) create an implicit container for this tag to be stored in 2) close the top container, and add this to whatever container ends up on top.

gess 1/04/99

Parameters:
aToken-- next (start) token to be handled
aNode-- CParserNode representing this start token
Returns:
PR_TRUE if all went well; PR_FALSE if error occured

Definition at line 615 of file COtherDTD.cpp.

                                                   {  

  //Begin by gathering up attributes...  
 
  nsresult  result=NS_OK;
  nsCParserNode* theNode=mNodeAllocator->CreateNode(aToken, mTokenAllocator);
  if(theNode) {
   
    eHTMLTags     theChildTag=(eHTMLTags)aToken->GetTypeID();
    PRInt16       attrCount=aToken->GetAttributeCount();
    eHTMLTags     theParent=mBodyContext->Last();
    
    result=(0==attrCount) ? NS_OK : CollectAttributes(*theNode,theChildTag,attrCount);
 
    if(NS_OK==result) {
      result=WillHandleStartTag(aToken,theChildTag,*theNode);
      if(NS_OK==result) {
 
        mLineNumber += aToken->GetNewlineCount();
 
        PRBool theTagWasHandled=PR_FALSE; 
 
        switch(theChildTag) {        
            
          case eHTMLTag_html:  
            if(!mBodyContext->HasOpenContainer(theChildTag)){
              mSink->OpenHTML(*theNode);
              mBodyContext->Push(theNode, 0, PR_FALSE);
            } 
            theTagWasHandled=PR_TRUE;   
            break;         
                 
          default:    
            CElement* theElement=gElementTable->mElements[theParent];
            if(theElement) {
              result=theElement->HandleStartToken(theNode,theChildTag,mBodyContext,mSink);  
              theTagWasHandled=PR_TRUE;  
            }    
            break;   
        }//switch              
         
        if(theTagWasHandled) {
          DidHandleStartTag(*theNode,theChildTag);  
        }
   
      } //if             
    }//if           
    IF_FREE(theNode, mNodeAllocator);
  }
  else result=NS_ERROR_OUT_OF_MEMORY;
          
  return result;        
}      

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsIDTD::HandleToken ( CToken aToken,
nsIParser aParser 
) [pure virtual, inherited]

Called during model building phase of parse process.

Each token created during the parse phase is stored in a deque (in the parser) and are passed to this method so that the DTD can process the token. Ultimately, the DTD will transform given token into calls onto a contentsink. gess 3/25/98

Parameters:
aToken-- token object to be put into content model
Returns:
error code (usually 0)

Here is the caller graph for this function:

nsIDTD::NS_IMETHOD_ ( const nsIID ) const [pure virtual, inherited]
nsIDTD::NS_IMETHOD_ ( eAutoDetectResult  ) [pure virtual, inherited]

This method is called to determine if the given DTD can parse a document in a given source-type.

NOTE: Parsing always assumes that the end result will involve storing the result in the main content model.

Parameters:
aParserContext-- the context for this document (knows the content type, document type, parser command, etc).
Returns:
eUnknownDetect if you don't know how to parse it, eValidDetect if you do, but someone may have a better idea, ePrimaryDetect if you think you know best
nsIDTD::NS_IMETHOD_ ( PRBool  ) [inherited]

This method is called to determine whether or not a tag of one type can contain a tag of another type.

gess 3/25/98

Parameters:
aParent-- int tag of parent container
aChild-- int tag of child container
Returns:
PR_TRUE if parent can contain child
nsIDTD::NS_IMETHOD_ ( PRBool  ) const [pure virtual, inherited]

This method gets called to determine whether a given tag is itself a container.

gess 3/25/98

Parameters:
aTag-- tag to test for containership
Returns:
PR_TRUE if given tag can contain other tags
nsIDTD::NS_IMETHOD_ ( void  ) [pure virtual, inherited]

Use this id you want to stop the building content model --------------[ Sets DTD to STOP mode ]---------------- It's recommended to use this method in accordance with the parser's terminate() method.

harishd 07/22/99

Parameters:
@return
nsIDTD::NS_IMETHOD_ ( PRInt32  ) [pure virtual, inherited]
NS_IMETHOD nsIDTD::WillBuildModel ( const CParserContext aParserContext,
nsITokenizer aTokenizer,
nsIContentSink aSink 
) [pure virtual, inherited]

Here is the caller graph for this function:

nsresult COtherDTD::WillHandleStartTag ( CToken aToken,
eHTMLTags  aTag,
nsIParserNode aNode 
) [protected, inherited]

This gets called before we've handled a given start tag.

It's a generic hook to let us do pre processing.

Parameters:
aTokencontains the tag in question
aChildTagis the tag itself.
aNodeis the node (tag) with associated attributes.
Returns:
TRUE if tag processing should continue; FALSE if the tag has been handled.

Definition at line 568 of file COtherDTD.cpp.

                                                                                        {
  nsresult result=NS_OK; 

    //first let's see if there's some skipped content to deal with... 
#if 0
  PRInt32 theAttrCount  = aNode.GetAttributeCount(); 
  if(*gElementTable->mElements[aTag].mSkipTarget) { 
    result=CollectSkippedContent(aNode,theAttrCount); 
  } 
#endif
  
  STOP_TIMER()
  MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: COtherDTD::WillHandleStartTag(), this=%p\n", this));

  if(mParser) {

    switch(aTag) {
      case eHTMLTag_newline:
        ++mLineNumber;
        break;
      default:
        break; 
    }
    mSink->NotifyTagObservers(&aNode);
  }

  MOZ_TIMER_DEBUGLOG(("Start: Parse Time: COtherDTD::WillHandleStartTag(), this=%p\n", this));
  START_TIMER()

  return result; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsIDTD::WillInterruptParse ( nsIContentSink aSink) [pure virtual, inherited]

If the parse process gets interrupted, this method is called by the parser to notify the DTD that interruption will occur.

gess5/18/98

Returns:
ignored

Here is the caller graph for this function:

NS_IMETHOD nsIDTD::WillResumeParse ( nsIContentSink aSink) [pure virtual, inherited]

If the parse process gets interrupted midway, this method is called by the parser prior to resuming the process.

gess5/18/98

Returns:
ignored

Here is the caller graph for this function:


Member Data Documentation

PRInt32 aChild nsIDTD::const = 0 [inherited]

Definition at line 178 of file nsIDTD.h.

nsDTDContext* COtherDTD::mBodyContext [protected, inherited]

Definition at line 183 of file COtherDTD.h.

PRUint32 COtherDTD::mComputedCRC32 [protected, inherited]

Definition at line 203 of file COtherDTD.h.

eParserDocType COtherDTD::mDocType [protected, inherited]

Definition at line 206 of file COtherDTD.h.

nsDTDMode COtherDTD::mDTDMode [protected, inherited]

Definition at line 200 of file COtherDTD.h.

nsresult COtherDTD::mDTDState [protected, inherited]

Definition at line 199 of file COtherDTD.h.

PRPackedBool COtherDTD::mEnableStrict [protected, inherited]

Definition at line 191 of file COtherDTD.h.

PRUint32 COtherDTD::mExpectedCRC32 [protected, inherited]

Definition at line 204 of file COtherDTD.h.

nsString COtherDTD::mFilename [protected, inherited]

Definition at line 192 of file COtherDTD.h.

PRPackedBool COtherDTD::mHadBody [protected, inherited]

Definition at line 189 of file COtherDTD.h.

PRPackedBool COtherDTD::mHadFrameset [protected, inherited]

Definition at line 188 of file COtherDTD.h.

PRPackedBool COtherDTD::mHasOpenBody [protected, inherited]

Definition at line 187 of file COtherDTD.h.

PRPackedBool COtherDTD::mHasOpenForm [protected, inherited]

Definition at line 185 of file COtherDTD.h.

PRInt32 COtherDTD::mHasOpenHead [protected, inherited]

Definition at line 184 of file COtherDTD.h.

PRPackedBool COtherDTD::mHasOpenMap [protected, inherited]

Definition at line 186 of file COtherDTD.h.

PRPackedBool COtherDTD::mHasOpenScript [protected, inherited]

Definition at line 190 of file COtherDTD.h.

PRInt32 COtherDTD::mLineNumber [protected, inherited]

Definition at line 193 of file COtherDTD.h.

nsNodeAllocator* COtherDTD::mNodeAllocator [protected, inherited]

Definition at line 197 of file COtherDTD.h.

nsParser* COtherDTD::mParser [protected, inherited]

Definition at line 194 of file COtherDTD.h.

Definition at line 201 of file COtherDTD.h.

nsString COtherDTD::mScratch [protected, inherited]

Definition at line 205 of file COtherDTD.h.

nsIHTMLContentSink* COtherDTD::mSink [protected, inherited]

Definition at line 181 of file COtherDTD.h.

eHTMLTags COtherDTD::mSkipTarget [protected, inherited]

Definition at line 198 of file COtherDTD.h.

Definition at line 196 of file COtherDTD.h.

nsITokenizer* COtherDTD::mTokenizer [protected, inherited]

Definition at line 195 of file COtherDTD.h.


The documentation for this class was generated from the following files: