зеркало из https://github.com/mozilla/pjs.git
Merging patch by jst (from mozilla/htmlparser).
Fixing bug 241328. Eliminating dead code, and making some classes use less memory on some 64-bit platforms. Also doing some general cleaning. r+sr=bzbarsky@mit.edu
This commit is contained in:
Родитель
2bb207ba40
Коммит
c284457122
|
@ -38,20 +38,20 @@
|
|||
/**
|
||||
* MODULE NOTES:
|
||||
* @update gess 4/1/98
|
||||
*
|
||||
* This file contains the declarations for all the HTML specific token types that
|
||||
*
|
||||
* This file contains the declarations for all the HTML specific token types that
|
||||
* our DTD's understand. In fact, the same set of token types are used for XML.
|
||||
* Currently we have tokens for text, comments, start and end tags, entities,
|
||||
* Currently we have tokens for text, comments, start and end tags, entities,
|
||||
* attributes, style, script and skipped content. Whitespace and newlines also
|
||||
* have their own token types, but don't count on them to stay forever.
|
||||
*
|
||||
*
|
||||
* If you're looking for the html tags, they're in a file called nsHTMLTag.h/cpp.
|
||||
*
|
||||
* Most of the token types have a similar API. They have methods to get the type
|
||||
* of token (GetTokenType); those that represent HTML tags also have a method to
|
||||
* get type tag type (GetTypeID). In addition, most have a method that causes the
|
||||
* token to help in the parsing process called (Consume). We've also thrown in a
|
||||
* few standard debugging methods as well.
|
||||
* token to help in the parsing process called (Consume). We've also thrown in a
|
||||
* few standard debugging methods as well.
|
||||
*/
|
||||
|
||||
#ifndef HTMLTOKENS_H
|
||||
|
@ -111,123 +111,112 @@ const PRUnichar* GetTagName(PRInt32 aTag);
|
|||
*/
|
||||
class CHTMLToken : public CToken {
|
||||
public:
|
||||
virtual ~CHTMLToken();
|
||||
virtual ~CHTMLToken();
|
||||
CHTMLToken(eHTMLTags aTag);
|
||||
|
||||
CHTMLToken(eHTMLTags aTag);
|
||||
|
||||
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
|
||||
virtual void SetContainerInfo(eContainerInfo aInfo) { }
|
||||
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
|
||||
virtual void SetContainerInfo(eContainerInfo aInfo) { }
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* This declares start tokens, which always take the form <xxxx>.
|
||||
* This class also knows how to consume related attributes.
|
||||
*
|
||||
* This declares start tokens, which always take the form <xxxx>.
|
||||
* This class also knows how to consume related attributes.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CStartToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(const nsAString& aString);
|
||||
CStartToken(const nsAString& aName,eHTMLTags aTag);
|
||||
public:
|
||||
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CStartToken(const nsAString& aString);
|
||||
CStartToken(const nsAString& aName,eHTMLTags aTag);
|
||||
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
|
||||
virtual PRBool IsEmpty(void);
|
||||
virtual void SetEmpty(PRBool aValue);
|
||||
virtual PRBool IsEmpty(void);
|
||||
virtual void SetEmpty(PRBool aValue);
|
||||
|
||||
virtual const nsAString& GetStringValue();
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
virtual const nsAString& GetStringValue();
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
//the following info is used to set well-formedness state on start tags...
|
||||
virtual eContainerInfo GetContainerInfo(void) const {return mContainerInfo;}
|
||||
virtual void SetContainerInfo(eContainerInfo aContainerInfo) {mContainerInfo=aContainerInfo;}
|
||||
virtual PRBool IsWellFormed(void) const {return PRBool(eWellFormed==mContainerInfo);}
|
||||
// the following info is used to set well-formedness state on start tags...
|
||||
virtual eContainerInfo GetContainerInfo(void) const {return mContainerInfo;}
|
||||
virtual void SetContainerInfo(eContainerInfo aContainerInfo) {
|
||||
mContainerInfo=aContainerInfo;
|
||||
}
|
||||
virtual PRBool IsWellFormed(void) const {
|
||||
return eWellFormed == mContainerInfo;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get and set the ID attribute atom for this element.
|
||||
* See http://www.w3.org/TR/1998/REC-xml-19980210#sec-attribute-types
|
||||
* for the definition of an ID attribute.
|
||||
*
|
||||
*/
|
||||
virtual nsresult GetIDAttributeAtom(nsIAtom** aResult);
|
||||
virtual nsresult SetIDAttributeAtom(nsIAtom* aID);
|
||||
|
||||
nsString mTextValue;
|
||||
nsString mTrailingContent;
|
||||
protected:
|
||||
eContainerInfo mContainerInfo;
|
||||
nsCOMPtr<nsIAtom> mIDAttributeAtom;
|
||||
PRPackedBool mEmpty;
|
||||
nsString mTextValue;
|
||||
nsString mTrailingContent;
|
||||
protected:
|
||||
eContainerInfo mContainerInfo;
|
||||
PRPackedBool mEmpty;
|
||||
#ifdef DEBUG
|
||||
PRPackedBool mAttributed;
|
||||
PRPackedBool mAttributed;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This declares end tokens, which always take the
|
||||
* This declares end tokens, which always take the
|
||||
* form </xxxx>. This class also knows how to consume
|
||||
* related attributes.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CEndToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CEndToken(eHTMLTags aTag);
|
||||
CEndToken(const nsAString& aString);
|
||||
CEndToken(const nsAString& aName,eHTMLTags aTag);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
public:
|
||||
CEndToken(eHTMLTags aTag);
|
||||
CEndToken(const nsAString& aString);
|
||||
CEndToken(const nsAString& aName,eHTMLTags aTag);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTypeID(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
|
||||
virtual const nsAString& GetStringValue();
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
virtual const nsAString& GetStringValue();
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This declares comment tokens. Comments are usually
|
||||
* thought of as tokens, but we treat them that way
|
||||
* This declares comment tokens. Comments are usually
|
||||
* thought of as tokens, but we treat them that way
|
||||
* here so that the parser can have a consistent view
|
||||
* of all tokens.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CCommentToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CCommentToken();
|
||||
CCommentToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
public:
|
||||
CCommentToken();
|
||||
CCommentToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
nsresult ConsumeStrictComment(nsScanner& aScanner);
|
||||
nsresult ConsumeQuirksComment(nsScanner& aScanner);
|
||||
nsresult ConsumeStrictComment(nsScanner& aScanner);
|
||||
nsresult ConsumeQuirksComment(nsScanner& aScanner);
|
||||
|
||||
protected:
|
||||
nsScannerSubstring mComment; // does not include MDO & MDC
|
||||
nsScannerSubstring mCommentDecl; // includes MDO & MDC
|
||||
protected:
|
||||
nsScannerSubstring mComment; // does not include MDO & MDC
|
||||
nsScannerSubstring mCommentDecl; // includes MDO & MDC
|
||||
};
|
||||
|
||||
|
||||
|
@ -235,102 +224,101 @@ class CCommentToken: public CHTMLToken {
|
|||
* This class declares entity tokens, which always take
|
||||
* the form &xxxx;. This class also offers a few utility
|
||||
* methods that allow you to easily reduce entities.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CEntityToken : public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CEntityToken();
|
||||
CEntityToken(const nsAString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
PRInt32 TranslateToUnicodeStr(nsString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
static nsresult ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
|
||||
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
|
||||
public:
|
||||
CEntityToken();
|
||||
CEntityToken(const nsAString& aString);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
PRInt32 TranslateToUnicodeStr(nsString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
static nsresult ConsumeEntity(PRUnichar aChar, nsString& aString,
|
||||
nsScanner& aScanner);
|
||||
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
|
||||
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Whitespace tokens are used where whitespace can be
|
||||
* detected as distinct from text. This allows us to
|
||||
* Whitespace tokens are used where whitespace can be
|
||||
* detected as distinct from text. This allows us to
|
||||
* easily skip leading/trailing whitespace when desired.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CWhitespaceToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CWhitespaceToken();
|
||||
CWhitespaceToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
public:
|
||||
CWhitespaceToken();
|
||||
CWhitespaceToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Text tokens contain the normalized form of html text.
|
||||
* These tokens are guaranteed not to contain entities,
|
||||
* start or end tags, or newlines.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CTextToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CTextToken();
|
||||
CTextToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
nsresult ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,
|
||||
nsString& aEndTagName,PRInt32 aFlag,PRBool& aFlushTokens);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 GetTextLength(void);
|
||||
virtual void CopyTo(nsAString& aStr);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void Bind(nsScanner* aScanner, nsScannerIterator& aStart, nsScannerIterator& aEnd);
|
||||
virtual void Bind(const nsAString& aStr);
|
||||
public:
|
||||
CTextToken();
|
||||
CTextToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
nsresult ConsumeUntil(PRUnichar aChar, PRBool aIgnoreComments,
|
||||
nsScanner& aScanner, nsString& aEndTagName,
|
||||
PRInt32 aFlag, PRBool& aFlushTokens);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual PRInt32 GetTextLength(void);
|
||||
virtual void CopyTo(nsAString& aStr);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void Bind(nsScanner* aScanner, nsScannerIterator& aStart,
|
||||
nsScannerIterator& aEnd);
|
||||
virtual void Bind(const nsAString& aStr);
|
||||
|
||||
protected:
|
||||
nsScannerSubstring mTextValue;
|
||||
protected:
|
||||
nsScannerSubstring mTextValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* CDATASection tokens contain raw unescaped text content delimited by
|
||||
* a ![CDATA[ and ]].
|
||||
* a ![CDATA[ and ]].
|
||||
* XXX Not really a HTML construct - maybe we need a separation
|
||||
*
|
||||
*
|
||||
* @update vidur 11/12/98
|
||||
*/
|
||||
class CCDATASectionToken : public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CCDATASectionToken(eHTMLTags aTag = eHTMLTag_unknown);
|
||||
CCDATASectionToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
CCDATASectionToken(eHTMLTags aTag = eHTMLTag_unknown);
|
||||
CCDATASectionToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
|
||||
|
@ -338,21 +326,20 @@ public:
|
|||
* Declaration tokens contain raw unescaped text content (not really, but
|
||||
* right now we use this only for view source).
|
||||
* XXX Not really a HTML construct - maybe we need a separation
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CMarkupDeclToken : public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CMarkupDeclToken();
|
||||
CMarkupDeclToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
CMarkupDeclToken();
|
||||
CMarkupDeclToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsScannerSubstring mTextValue;
|
||||
nsScannerSubstring mTextValue;
|
||||
};
|
||||
|
||||
|
||||
|
@ -361,57 +348,56 @@ protected:
|
|||
* pairs whereever they may occur. Typically, they should
|
||||
* occur only in start tokens. However, we may expand that
|
||||
* ability when XML tokens become commonplace.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CAttributeToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CAttributeToken();
|
||||
CAttributeToken(const nsAString& aString);
|
||||
CAttributeToken(const nsAString& aKey, const nsAString& aString);
|
||||
~CAttributeToken() {}
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetKey(void); // XXX {return mTextKey;}
|
||||
virtual void SetKey(const nsAString& aKey);
|
||||
virtual void BindKey(nsScanner* aScanner, nsScannerIterator& aStart, nsScannerIterator& aEnd);
|
||||
virtual const nsAString& GetValue(void) {return mTextValue;}
|
||||
virtual void SanitizeKey();
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
PRPackedBool mHasEqualWithoutValue;
|
||||
protected:
|
||||
public:
|
||||
CAttributeToken();
|
||||
CAttributeToken(const nsAString& aString);
|
||||
CAttributeToken(const nsAString& aKey, const nsAString& aString);
|
||||
~CAttributeToken() {}
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetKey(void); // XXX {return mTextKey;}
|
||||
virtual void SetKey(const nsAString& aKey);
|
||||
virtual void BindKey(nsScanner* aScanner, nsScannerIterator& aStart,
|
||||
nsScannerIterator& aEnd);
|
||||
virtual const nsAString& GetValue(void) {return mTextValue;}
|
||||
virtual void SanitizeKey();
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void GetSource(nsString& anOutputString);
|
||||
virtual void AppendSourceTo(nsAString& anOutputString);
|
||||
|
||||
PRPackedBool mHasEqualWithoutValue;
|
||||
protected:
|
||||
#ifdef DEBUG
|
||||
PRPackedBool mLastAttribute;
|
||||
PRPackedBool mLastAttribute;
|
||||
#endif
|
||||
nsAutoString mTextValue;
|
||||
nsScannerSubstring mTextKey;
|
||||
};
|
||||
nsAutoString mTextValue;
|
||||
nsScannerSubstring mTextKey;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Newline tokens contain, you guessed it, newlines.
|
||||
* Newline tokens contain, you guessed it, newlines.
|
||||
* They consume newline (CR/LF) either alone or in pairs.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
class CNewlineToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CNewlineToken();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
public:
|
||||
CNewlineToken();
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
static void AllocNewline();
|
||||
static void FreeNewline();
|
||||
static void AllocNewline();
|
||||
static void FreeNewline();
|
||||
};
|
||||
|
||||
|
||||
|
@ -419,69 +405,66 @@ class CNewlineToken: public CHTMLToken {
|
|||
* Script tokens contain sequences of javascript (or, gulp,
|
||||
* any other script you care to send). We don't tokenize
|
||||
* it here, nor validate it. We just wrap it up, and pass
|
||||
* it along to the html parser, who sends it (later on)
|
||||
* it along to the html parser, who sends it (later on)
|
||||
* to the scripting engine.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CScriptToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CScriptToken();
|
||||
CScriptToken(const nsAString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
public:
|
||||
CScriptToken();
|
||||
CScriptToken(const nsAString& aString);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Style tokens contain sequences of css style. We don't
|
||||
* tokenize it here, nor validate it. We just wrap it up,
|
||||
* and pass it along to the html parser, who sends it
|
||||
* Style tokens contain sequences of css style. We don't
|
||||
* tokenize it here, nor validate it. We just wrap it up,
|
||||
* and pass it along to the html parser, who sends it
|
||||
* (later on) to the style engine.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CStyleToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CStyleToken();
|
||||
CStyleToken(const nsAString& aString);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
public:
|
||||
CStyleToken();
|
||||
CStyleToken(const nsAString& aString);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Whitespace tokens are used where whitespace can be
|
||||
* detected as distinct from text. This allows us to
|
||||
* Whitespace tokens are used where whitespace can be
|
||||
* detected as distinct from text. This allows us to
|
||||
* easily skip leading/trailing whitespace when desired.
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
*/
|
||||
class CInstructionToken: public CHTMLToken {
|
||||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CInstructionToken();
|
||||
CInstructionToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
public:
|
||||
CInstructionToken();
|
||||
CInstructionToken(const nsAString& aString);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
class CErrorToken : public CHTMLToken {
|
||||
|
@ -490,23 +473,22 @@ class CErrorToken : public CHTMLToken {
|
|||
public:
|
||||
CErrorToken(nsParserError* aError=0);
|
||||
~CErrorToken();
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
|
||||
void SetError(nsParserError* aError); // CErrorToken takes ownership of aError
|
||||
|
||||
// The nsParserError object returned by GetError is still owned by CErrorToken.
|
||||
// DO NOT use the delete operator on it. Should we change this so that a copy
|
||||
// of nsParserError is returned which needs to be destroyed by the consumer?
|
||||
const nsParserError* GetError(void);
|
||||
const nsParserError* GetError(void);
|
||||
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
nsString mTextValue;
|
||||
nsParserError* mError;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* This token is generated by the HTML and Expat tokenizers
|
||||
* when they see the doctype declaration ("<!DOCTYPE ... >")
|
||||
*
|
||||
|
@ -516,16 +498,15 @@ class CDoctypeDeclToken: public CHTMLToken {
|
|||
CTOKEN_IMPL_SIZEOF
|
||||
|
||||
public:
|
||||
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CDoctypeDeclToken(const nsAString& aString,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual const char* GetClassName(void);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void SetStringValue(const nsAString& aStr);
|
||||
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
|
||||
CDoctypeDeclToken(const nsAString& aString,eHTMLTags aTag=eHTMLTag_unknown);
|
||||
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
virtual const nsAString& GetStringValue(void);
|
||||
virtual void SetStringValue(const nsAString& aStr);
|
||||
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
protected:
|
||||
nsString mTextValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -193,7 +193,9 @@ class CToken {
|
|||
* @update gess5/11/98
|
||||
* @param value is the new ord value for this token
|
||||
*/
|
||||
virtual void SetTypeID(PRInt32 aValue);
|
||||
void SetTypeID(PRInt32 aValue) {
|
||||
mTypeID = aValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter which retrieves the current ordinal value for this token
|
||||
|
@ -226,15 +228,6 @@ class CToken {
|
|||
*/
|
||||
virtual PRInt32 GetTokenType(void);
|
||||
|
||||
/**
|
||||
* Getter which retrieves the class name for this token
|
||||
* This method is only used for debug purposes.
|
||||
* @update gess5/11/98
|
||||
* @return const char* containing class name
|
||||
*/
|
||||
virtual const char* GetClassName(void);
|
||||
|
||||
|
||||
/**
|
||||
* For tokens who care, this can tell us whether the token is
|
||||
* well formed or not.
|
||||
|
|
|
@ -115,25 +115,6 @@ CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTa
|
|||
#endif
|
||||
}
|
||||
|
||||
nsresult CStartToken::GetIDAttributeAtom(nsIAtom** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mIDAttributeAtom;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult CStartToken::SetIDAttributeAtom(nsIAtom* aID)
|
||||
{
|
||||
NS_ENSURE_ARG(aID);
|
||||
mIDAttributeAtom = aID;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This method returns the typeid (the tag type) for this token.
|
||||
*
|
||||
|
@ -148,17 +129,6 @@ PRInt32 CStartToken::GetTypeID(){
|
|||
return mTypeID;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CStartToken::GetClassName(void) {
|
||||
return "start";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -365,17 +335,6 @@ PRInt32 CEndToken::GetTypeID(){
|
|||
return mTypeID;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CEndToken::GetClassName(void) {
|
||||
return "/end";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -447,17 +406,6 @@ CTextToken::CTextToken(const nsAString& aName) : CHTMLToken(eHTMLTag_text) {
|
|||
mTextValue.Rebind(aName);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CTextToken::GetClassName(void) {
|
||||
return "text";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -715,17 +663,6 @@ CCDATASectionToken::CCDATASectionToken(const nsAString& aName) : CHTMLToken(eHTM
|
|||
mTextValue.Assign(aName);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update vidur 11/12/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CCDATASectionToken::GetClassName(void) {
|
||||
return "cdatasection";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* @update vidur 11/12/98
|
||||
|
@ -843,15 +780,6 @@ CMarkupDeclToken::CMarkupDeclToken(const nsAString& aName) : CHTMLToken(eHTMLTag
|
|||
mTextValue.Rebind(aName);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CMarkupDeclToken::GetClassName(void) {
|
||||
return "markupdeclaration";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -1255,17 +1183,6 @@ const nsAString& CCommentToken::GetStringValue(void)
|
|||
return mComment.AsString();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CCommentToken::GetClassName(void){
|
||||
return "/**/";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -1287,18 +1204,6 @@ PRInt32 CCommentToken::GetTokenType(void) {
|
|||
CNewlineToken::CNewlineToken() : CHTMLToken(eHTMLTag_newline) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CNewlineToken::GetClassName(void) {
|
||||
return "crlf";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -1426,17 +1331,6 @@ CAttributeToken::CAttributeToken(const nsAString& aKey, const nsAString& aName)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CAttributeToken::GetClassName(void) {
|
||||
return "attr";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -1880,17 +1774,6 @@ CWhitespaceToken::CWhitespaceToken(const nsAString& aName) : CHTMLToken(eHTMLTag
|
|||
mTextValue.Assign(aName);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CWhitespaceToken::GetClassName(void) {
|
||||
return "ws";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -1965,18 +1848,6 @@ nsresult CEntityToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aFla
|
|||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CEntityToken::GetClassName(void) {
|
||||
return "&entity";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -2245,18 +2116,6 @@ CScriptToken::CScriptToken(const nsAString& aString) : CHTMLToken(eHTMLTag_scrip
|
|||
mTextValue.Assign(aString);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CScriptToken::GetClassName(void) {
|
||||
return "script";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -2287,17 +2146,6 @@ CStyleToken::CStyleToken(const nsAString& aString) : CHTMLToken(eHTMLTag_style)
|
|||
mTextValue.Assign(aString);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CStyleToken::GetClassName(void) {
|
||||
return "style";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
|
@ -2370,17 +2218,6 @@ nsresult CInstructionToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @update gess 9/23/98
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
const char* CInstructionToken::GetClassName(void){
|
||||
return "instruction";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -2412,10 +2249,6 @@ PRInt32 CErrorToken::GetTokenType(void){
|
|||
return eToken_error;
|
||||
}
|
||||
|
||||
const char* CErrorToken::GetClassName(void){
|
||||
return "error";
|
||||
}
|
||||
|
||||
void CErrorToken::SetError(nsParserError *aError) {
|
||||
mError = aError;
|
||||
}
|
||||
|
@ -2488,10 +2321,6 @@ nsresult CDoctypeDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32
|
|||
return result;
|
||||
}
|
||||
|
||||
const char* CDoctypeDeclToken::GetClassName(void) {
|
||||
return "doctype";
|
||||
}
|
||||
|
||||
PRInt32 CDoctypeDeclToken::GetTokenType(void) {
|
||||
return eToken_doctypeDecl;
|
||||
}
|
||||
|
|
|
@ -48,9 +48,7 @@
|
|||
* Default Constructor
|
||||
*/
|
||||
nsCParserNode::nsCParserNode()
|
||||
: mToken(nsnull),
|
||||
mUseCount(0),
|
||||
mGenericState(PR_FALSE),
|
||||
: mRefCnt(0), mGenericState(PR_FALSE), mUseCount(0), mToken(nsnull),
|
||||
mTokenAllocator(nsnull)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCParserNode);
|
||||
|
@ -68,25 +66,23 @@ nsCParserNode::nsCParserNode()
|
|||
*/
|
||||
nsCParserNode::nsCParserNode(CToken* aToken,
|
||||
nsTokenAllocator* aTokenAllocator,
|
||||
nsNodeAllocator* aNodeAllocator): nsIParserNode()
|
||||
nsNodeAllocator* aNodeAllocator)
|
||||
: mRefCnt(0), mGenericState(PR_FALSE), mUseCount(0), mToken(aToken),
|
||||
mTokenAllocator(aTokenAllocator)
|
||||
{
|
||||
mRefCnt = 0;
|
||||
MOZ_COUNT_CTOR(nsCParserNode);
|
||||
|
||||
static int theNodeCount = 0;
|
||||
++theNodeCount;
|
||||
mToken = aToken;
|
||||
IF_HOLD(mToken);
|
||||
mTokenAllocator = aTokenAllocator;
|
||||
mUseCount = 0;
|
||||
mGenericState = PR_FALSE;
|
||||
|
||||
#ifdef HEAP_ALLOCATED_NODES
|
||||
mNodeAllocator = aNodeAllocator;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
* destructor
|
||||
* NOTE: We intentionally DONT recycle mToken here.
|
||||
* It may get cached for use elsewhere
|
||||
* @update gess 3/25/98
|
||||
|
|
|
@ -258,9 +258,9 @@ class nsCParserNode : public nsIParserNode {
|
|||
*/
|
||||
virtual nsresult ReleaseAll();
|
||||
|
||||
CToken* mToken;
|
||||
PRInt32 mUseCount;
|
||||
PRPackedBool mGenericState;
|
||||
PRInt32 mUseCount;
|
||||
CToken* mToken;
|
||||
|
||||
nsTokenAllocator* mTokenAllocator;
|
||||
#ifdef HEAP_ALLOCATED_NODES
|
||||
|
|
|
@ -46,7 +46,9 @@ MOZ_DECL_CTOR_COUNTER(CToken)
|
|||
static int TokenCount=0;
|
||||
static int DelTokenCount=0;
|
||||
|
||||
int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
|
||||
int CToken::GetTokenCount() {
|
||||
return TokenCount-DelTokenCount;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************
|
||||
|
@ -116,7 +118,7 @@ nsresult CToken::Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode) {
|
|||
* @update gess5/11/98
|
||||
* @return reference to string containing string value
|
||||
*/
|
||||
void CToken::GetSource(nsString& anOutputString){
|
||||
void CToken::GetSource(nsString& anOutputString) {
|
||||
anOutputString.Assign(GetStringValue());
|
||||
}
|
||||
|
||||
|
@ -124,21 +126,10 @@ void CToken::GetSource(nsString& anOutputString){
|
|||
* @update harishd 3/23/00
|
||||
* @return reference to string containing string value
|
||||
*/
|
||||
void CToken::AppendSourceTo(nsAString& anOutputString){
|
||||
void CToken::AppendSourceTo(nsAString& anOutputString) {
|
||||
anOutputString.Append(GetStringValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the internal ordinal value for this token.
|
||||
* This method is deprecated, and will soon be going away.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param value -- new ordinal value for this token
|
||||
*/
|
||||
void CToken::SetTypeID(PRInt32 aTypeID) {
|
||||
mTypeID=aTypeID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves copy of internal ordinal value.
|
||||
* This method is deprecated, and will soon be going away.
|
||||
|
@ -156,7 +147,7 @@ PRInt32 CToken::GetTypeID(void) {
|
|||
* @update gess 3/25/98
|
||||
* @return int containing attribute count
|
||||
*/
|
||||
PRInt16 CToken::GetAttributeCount(void) {
|
||||
PRInt16 CToken::GetAttributeCount(void) {
|
||||
return mAttrCount;
|
||||
}
|
||||
|
||||
|
@ -168,20 +159,10 @@ PRInt16 CToken::GetAttributeCount(void) {
|
|||
* @update gess 3/25/98
|
||||
* @return int value containing token type.
|
||||
*/
|
||||
PRInt32 CToken::GetTokenType(void) {
|
||||
PRInt32 CToken::GetTokenType(void) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve this tokens classname.
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @return char* containing name of class
|
||||
*/
|
||||
const char* CToken::GetClassName(void) {
|
||||
return "token";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -201,10 +201,6 @@ class CSharedVSContext {
|
|||
public:
|
||||
|
||||
CSharedVSContext() :
|
||||
mEndNode(),
|
||||
mStartNode(),
|
||||
mTokenNode(),
|
||||
mITextToken(),
|
||||
mErrorToken(NS_LITERAL_STRING("error")) {
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче