Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
CCDATASectionToken Class Reference

CDATASection tokens contain raw unescaped text content delimited by a ![CDATA[ and ]]. More...

#include <nsHTMLTokens.h>

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

List of all members.

Public Types

enum  eTokenOrigin { eSource, eResidualStyle }

Public Member Functions

 CCDATASectionToken (eHTMLTags aTag=eHTMLTag_unknown)
 CCDATASectionToken (const nsAString &aString)
virtual nsresult Consume (PRUnichar aChar, nsScanner &aScanner, PRInt32 aMode)
 Causes token to consume data from given scanner.
virtual PRInt32 GetTokenType (void)
 Getter which retrieves type of token gess5/11/98.
virtual const nsSubstringGetStringValue (void)
 Retrieve string value of the token gess5/11/98.
virtual eContainerInfo GetContainerInfo (void) const
virtual void SetContainerInfo (eContainerInfo aInfo)
void AddRef ()
 Make a note on number of times you have been referenced harishd 08/02/00.
void Release (nsFixedSizeAllocator &aArenaPool)
 Free yourself if no one is holding you.
virtual void GetSource (nsString &anOutputString)
 Get string of full contents, suitable for debug dump.
virtual void AppendSourceTo (nsAString &anOutputString)
 harishd 03/23/00
void SetTypeID (PRInt32 aValue)
 Sets the ordinal value of this token (not currently used) gess5/11/98.
virtual PRInt32 GetTypeID (void)
 Getter which retrieves the current ordinal value for this token gess5/11/98.
virtual PRInt16 GetAttributeCount (void)
 Getter which retrieves the current attribute count for this token gess5/11/98.
virtual PRBool IsWellFormed (void) const
 For tokens who care, this can tell us whether the token is well formed or not.
virtual PRBool IsEmpty (void)
virtual void SetEmpty (PRBool aValue)
 If aValue is TRUE then the token represents a short-hand tag.
PRInt32 GetNewlineCount ()
void SetNewlineCount (PRInt32 aCount)
PRInt32 GetLineNumber ()
void SetLineNumber (PRInt32 aLineNumber)
void SetInError (PRBool aInError)
PRBool IsInError ()
void SetAttributeCount (PRInt16 aValue)
virtual void SelfTest (void)
 perform self test.

Static Public Member Functions

static void Destroy (CToken *aToken, nsFixedSizeAllocator &aArenaPool)
 Destroy a token.
static int GetTokenCount ()

Protected Member Functions

virtual size_t SizeOf () const =0
 Returns the size of the token object.

Static Protected Member Functions

static voidoperator new (size_t aSize, nsFixedSizeAllocator &anArena) CPP_THROW_NEW
 harishd 08/01/00
static void operator delete (void *, size_t)
 Hide operator delete; clients should use Destroy() instead.

Protected Attributes

nsString mTextValue
PRInt32 mTypeID
PRInt32 mUseCount
PRInt32 mNewlineCount
PRUint32 mLineNumber: 31
PRUint32 mInError: 1
PRInt16 mAttrCount

Friends

class nsTokenAllocator

Detailed Description

CDATASection tokens contain raw unescaped text content delimited by a ![CDATA[ and ]].

XXX Not really a HTML construct - maybe we need a separation

vidur 11/12/98

Definition at line 320 of file nsHTMLTokens.h.


Member Enumeration Documentation

enum CToken::eTokenOrigin [inherited]
Enumerator:
eSource 
eResidualStyle 

Definition at line 109 of file nsToken.h.


Constructor & Destructor Documentation

Definition at line 1017 of file nsHTMLTokens.cpp.

                                                     : CHTMLToken(aTag) {
}

Definition at line 1028 of file nsHTMLTokens.cpp.


Member Function Documentation

void CToken::AddRef ( void  ) [inline, inherited]

Make a note on number of times you have been referenced harishd 08/02/00.

Definition at line 154 of file nsToken.h.

{ ++mUseCount; }
void CToken::AppendSourceTo ( nsAString &  anOutputString) [virtual, inherited]

harishd 03/23/00

harishd 3/23/00

Returns:
reference to string containing string value

Reimplemented in CAttributeToken, CEntityToken, CCommentToken, CEndToken, and CStartToken.

Definition at line 130 of file nsToken.cpp.

                                                     {
  anOutputString.Append(GetStringValue());
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult CCDATASectionToken::Consume ( PRUnichar  aChar,
nsScanner aScanner,
PRInt32  aMode 
) [virtual]

Causes token to consume data from given scanner.

Virtual method used to tell this toke to consume his valid chars.

Note that behavior varies wildly between CToken subclasses. gess5/11/98

Parameters:
aChar-- most recent char consumed
aScanner-- input source where token should get data
Returns:
error code (0 means ok)

gess 3/25/98

Parameters:
aChar-- first char in sequence
aScanner-- object to retrieve data from
Returns:
int error code

Reimplemented from CToken.

Definition at line 1050 of file nsHTMLTokens.cpp.

                                                                                       {
  static const PRUnichar theTerminalsChars[] = 
  { PRUnichar('\r'), PRUnichar('\n'), PRUnichar(']'), PRUnichar(0) };
  static const nsReadEndCondition theEndCondition(theTerminalsChars);
  nsresult  result=NS_OK;
  PRBool    done=PR_FALSE;

  while((NS_OK==result) && (!done)) {
    result=aScanner.ReadUntil(mTextValue,theEndCondition,PR_FALSE);
    if(NS_OK==result) {
      result=aScanner.Peek(aChar);
      if((kCR==aChar) && (NS_OK==result)) {
        result=aScanner.GetChar(aChar); //strip off the \r
        result=aScanner.Peek(aChar);    //then see what's next.
        if(NS_OK==result) {
          switch(aChar) {
            case kCR:
              result=aScanner.GetChar(aChar); //strip off the \r
              mTextValue.AppendLiteral("\n\n");
              mNewlineCount += 2;
              break;
            case kNewLine:
               //which means we saw \r\n, which becomes \n
              result=aScanner.GetChar(aChar); //strip off the \n
                  //now fall through on purpose...
            default:
              mTextValue.AppendLiteral("\n");
              mNewlineCount++;
              break;
          } //switch
        } //if
      }
      else if (kNewLine == aChar) {
        result=aScanner.GetChar(aChar);
        mTextValue.Append(aChar);
        ++mNewlineCount;
      }
      else if (kRightSquareBracket == aChar) {
        PRBool canClose = PR_FALSE;
        result=aScanner.GetChar(aChar); //strip off the ]
        mTextValue.Append(aChar);
        result=aScanner.Peek(aChar);    //then see what's next.
        if((NS_OK==result) && (kRightSquareBracket==aChar)) {
          result=aScanner.GetChar(aChar); //strip off the second ]
          mTextValue.Append(aChar);
          canClose = PR_TRUE;
        }
        // The goal here is to not lose data from the page when encountering
        // markup like: <![endif]-->.  This means that in normal parsing, we
        // allow ']' to end the marked section and just drop everything between
        // it an the '>'.  In view-source mode, we cannot drop things on the
        // floor like that.  In fact, to make view-source of XML with script in
        // CDATA sections at all bearable, we need to somewhat enforce the ']]>'
        // terminator for marked sections.  So make the tokenization somewhat
        // different when in view-source _and_ dealing with a CDATA section.
        PRBool inCDATA = (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) &&
          StringBeginsWith(mTextValue, NS_LITERAL_STRING("[CDATA["));
        if (inCDATA) {
          result = aScanner.Peek(aChar);
        } else {
          nsAutoString dummy; // skip any bad data
          result=aScanner.ReadUntil(dummy,kGreaterThan,PR_FALSE);
        }
        if (NS_OK==result &&
            (!inCDATA || (canClose && kGreaterThan == aChar))) {
          result=aScanner.GetChar(aChar); //strip off the >
          done=PR_TRUE;
        }
      }
      else done=PR_TRUE;
    }
  }

  if (kEOF == result && !aScanner.IsIncremental()) {
    // We ran out of space looking for the end of this CDATA section.
    // In order to not completely lose the entire section, treat everything
    // until the end of the document as part of the CDATA section and let
    // the DTD handle it.
    mInError = PR_TRUE;
    result = NS_OK;
  }

  return result;
}

Here is the call graph for this function:

static void CToken::Destroy ( CToken aToken,
nsFixedSizeAllocator &  aArenaPool 
) [inline, static, inherited]

Destroy a token.

Definition at line 143 of file nsToken.h.

    {
      size_t sz = aToken->SizeOf();
      aToken->~CToken();
      aArenaPool.Free(aToken, sz);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt16 CToken::GetAttributeCount ( void  ) [virtual, inherited]

Getter which retrieves the current attribute count for this token gess5/11/98.

Retrieves copy of attr count for this token.

Returns:
current attribute count

gess 3/25/98

Returns:
int containing attribute count

Definition at line 151 of file nsToken.cpp.

                                      {
  return mAttrCount;
}

Here is the caller graph for this function:

virtual eContainerInfo CHTMLToken::GetContainerInfo ( void  ) const [inline, virtual, inherited]

Reimplemented in CStartToken.

Definition at line 115 of file nsHTMLTokens.h.

{return eFormUnknown;}

Here is the caller graph for this function:

PRInt32 CToken::GetLineNumber ( void  ) [inline, inherited]

Definition at line 257 of file nsToken.h.

    { 
      return mLineNumber;
    }

Here is the caller graph for this function:

PRInt32 CToken::GetNewlineCount ( ) [inline, inherited]

Definition at line 247 of file nsToken.h.

    { 
      return mNewlineCount; 
    }

Here is the caller graph for this function:

void CToken::GetSource ( nsString anOutputString) [virtual, inherited]

Get string of full contents, suitable for debug dump.

It should look exactly like the input source. gess5/11/98

Returns:
reference to string containing string value

Reimplemented in CAttributeToken, CEntityToken, CEndToken, and CStartToken.

Definition at line 122 of file nsToken.cpp.

                                               {
  anOutputString.Assign(GetStringValue());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve string value of the token gess5/11/98.

Returns:
reference to string containing string value

Implements CToken.

Definition at line 1135 of file nsHTMLTokens.cpp.

{
  return mTextValue;
}
int CToken::GetTokenCount ( ) [static, inherited]

Definition at line 49 of file nsToken.cpp.

Getter which retrieves type of token gess5/11/98.

Retrieve type of token.

Returns:
int containing token type

This class returns -1, but subclasses return something more meaningful.

gess 3/25/98

Returns:
int value containing token type.

Reimplemented from CToken.

Definition at line 1038 of file nsHTMLTokens.cpp.

                                             {
  return eToken_cdatasection;
}
PRInt32 CToken::GetTypeID ( void  ) [virtual, inherited]

Getter which retrieves the current ordinal value for this token gess5/11/98.

Retrieves copy of internal ordinal value.

Returns:
current ordinal value

This method is deprecated, and will soon be going away.

gess 3/25/98

Returns:
int containing ordinal value

Reimplemented in CEndToken, and CStartToken.

Definition at line 141 of file nsToken.cpp.

                              {
  return mTypeID;
}

Here is the caller graph for this function:

virtual PRBool CToken::IsEmpty ( void  ) [inline, virtual, inherited]

Reimplemented in CStartToken.

Definition at line 240 of file nsToken.h.

{ return PR_FALSE; }
PRBool CToken::IsInError ( ) [inline, inherited]

Definition at line 272 of file nsToken.h.

    {
      return mInError;
    }

Here is the caller graph for this function:

virtual PRBool CToken::IsWellFormed ( void  ) const [inline, virtual, inherited]

For tokens who care, this can tell us whether the token is well formed or not.

gess 8/30/00

Returns:
PR_FALSE; subclasses MUST override if they care.

Reimplemented in CStartToken.

Definition at line 238 of file nsToken.h.

{return PR_FALSE;}

Here is the caller graph for this function:

static void CToken::operator delete ( void ,
size_t   
) [inline, static, protected, inherited]

Hide operator delete; clients should use Destroy() instead.

Definition at line 131 of file nsToken.h.

{}
static void* CToken::operator new ( size_t  aSize,
nsFixedSizeAllocator &  anArena 
) [inline, static, protected, inherited]

harishd 08/01/00

Parameters:
aSize-
aArena- Allocate memory from this pool.

Definition at line 123 of file nsToken.h.

    {
      return anArena.Alloc(aSize);
    }
void CToken::Release ( nsFixedSizeAllocator &  aArenaPool) [inline, inherited]

Free yourself if no one is holding you.

harishd 08/02/00

Definition at line 160 of file nsToken.h.

                                                   {
      if(--mUseCount==0)
        Destroy(this, aArenaPool);
    }

Here is the call graph for this function:

void CToken::SelfTest ( void  ) [virtual, inherited]

perform self test.

gess 3/25/98

gess5/11/98

Definition at line 172 of file nsToken.cpp.

                          {
#ifdef _DEBUG
#endif
}
void CToken::SetAttributeCount ( PRInt16  aValue) [inline, inherited]

Definition at line 277 of file nsToken.h.

Here is the caller graph for this function:

virtual void CHTMLToken::SetContainerInfo ( eContainerInfo  aInfo) [inline, virtual, inherited]

Reimplemented in CStartToken.

Definition at line 116 of file nsHTMLTokens.h.

{ }

Here is the caller graph for this function:

virtual void CToken::SetEmpty ( PRBool  aValue) [inline, virtual, inherited]

If aValue is TRUE then the token represents a short-hand tag.

Reimplemented in CStartToken.

Definition at line 245 of file nsToken.h.

{ return ; }

Here is the call graph for this function:

Here is the caller graph for this function:

void CToken::SetInError ( PRBool  aInError) [inline, inherited]

Definition at line 267 of file nsToken.h.

    {
      mInError = aInError;
    }

Here is the caller graph for this function:

void CToken::SetLineNumber ( PRInt32  aLineNumber) [inline, inherited]

Definition at line 262 of file nsToken.h.

    { 
      mLineNumber = mLineNumber == 0 ? aLineNumber : mLineNumber;
    }
void CToken::SetNewlineCount ( PRInt32  aCount) [inline, inherited]

Definition at line 252 of file nsToken.h.

Here is the caller graph for this function:

void CToken::SetTypeID ( PRInt32  aValue) [inline, inherited]

Sets the ordinal value of this token (not currently used) gess5/11/98.

Parameters:
valueis the new ord value for this token

Definition at line 196 of file nsToken.h.

                                   {
      mTypeID = aValue;
    }

Here is the caller graph for this function:

virtual size_t CToken::SizeOf ( ) const [protected, pure virtual, inherited]

Returns the size of the token object.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsTokenAllocator [friend, inherited]

Definition at line 115 of file nsToken.h.


Member Data Documentation

PRInt16 CToken::mAttrCount [protected, inherited]

Definition at line 300 of file nsToken.h.

PRUint32 CToken::mInError [protected, inherited]

Definition at line 299 of file nsToken.h.

PRUint32 CToken::mLineNumber [protected, inherited]

Definition at line 298 of file nsToken.h.

PRInt32 CToken::mNewlineCount [protected, inherited]

Definition at line 297 of file nsToken.h.

Definition at line 331 of file nsHTMLTokens.h.

PRInt32 CToken::mTypeID [protected, inherited]

Definition at line 295 of file nsToken.h.

PRInt32 CToken::mUseCount [protected, inherited]

Definition at line 296 of file nsToken.h.


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