Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsHTMLTokenizer.cpp File Reference

This is an implementation of the nsITokenizer interface. More...

#include "nsIAtom.h"
#include "nsHTMLTokenizer.h"
#include "nsScanner.h"
#include "nsElementTable.h"
#include "CParserContext.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"

Go to the source code of this file.

Functions

static NS_DEFINE_IID (kISupportsIID, NS_ISUPPORTS_IID)
static NS_DEFINE_IID (kITokenizerIID, NS_ITOKENIZER_IID)
static NS_DEFINE_IID (kClassIID, NS_HTMLTOKENIZER_IID)
nsresult NS_NewHTMLTokenizer (nsITokenizer **aInstancePtrResult, PRInt32 aFlag, eParserDocType aDocType, eParserCommands aCommand, PRInt32 aFlags)
 This method is defined in nsHTMLTokenizer.h.
static PRInt32 FindLastIndexOfTag (eHTMLTags aTag, nsDeque &aTagStack)
 This is a utilty method for ScanDocStructure, which finds a given tag in the stack.

Detailed Description

This is an implementation of the nsITokenizer interface.

This file contains the implementation of a tokenizer to tokenize an HTML document. It attempts to do so, making tradeoffs between compatibility with older parsers and the SGML specification. Note that most of the real "tokenization" takes place in nsHTMLTokens.cpp.

Definition in file nsHTMLTokenizer.cpp.


Function Documentation

static PRInt32 FindLastIndexOfTag ( eHTMLTags  aTag,
nsDeque &  aTagStack 
) [static]

This is a utilty method for ScanDocStructure, which finds a given tag in the stack.

The return value is meant to be used with nsDeque::ObjectAt() on aTagStack.

Parameters:
aTag-- the ID of the tag we're seeking
aTagStack-- the stack to be searched
Returns:
index position of tag in stack if found, otherwise kNotFound

Definition at line 372 of file nsHTMLTokenizer.cpp.

{
  PRInt32 theCount=aTagStack.GetSize();
  
  while(0<theCount) {
    CHTMLToken *theToken=(CHTMLToken*)aTagStack.ObjectAt(--theCount);  
    if(theToken) {
      eHTMLTags  theTag=(eHTMLTags)theToken->GetTypeID();
      if(theTag==aTag) {
        return theCount;
      }
    }
  }

  return kNotFound;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_IID ( kISupportsIID  ,
NS_ISUPPORTS_IID   
) [static]
static NS_DEFINE_IID ( kITokenizerIID  ,
NS_ITOKENIZER_IID   
) [static]
static NS_DEFINE_IID ( kClassIID  ,
NS_HTMLTOKENIZER_IID   
) [static]
nsresult NS_NewHTMLTokenizer ( nsITokenizer **  aInstancePtrResult,
PRInt32  aFlag,
eParserDocType  aDocType,
eParserCommands  aCommand,
PRInt32  aFlags 
)

This method is defined in nsHTMLTokenizer.h.

It is used to cause the COM-like construction of an HTMLTokenizer.

Parameters:
aInstancePtrResult**ptr to newly instantiated parser
aFlagParser flags the tokenizer should be aware of
aDocTypeThe doctype of the current document.
aCommandThe current command (view-source, fragment, etc).
Returns:
NS_xxx error result

Definition at line 109 of file nsHTMLTokenizer.cpp.

{
  NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
  if (nsnull == aInstancePtrResult) {
    return NS_ERROR_NULL_POINTER;
  }
  nsHTMLTokenizer* it = new nsHTMLTokenizer(aFlag,aDocType,aCommand,aFlags);
  if (nsnull == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return it->QueryInterface(kClassIID, (void **) aInstancePtrResult);
}

Here is the caller graph for this function: