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:
peterv%propagandism.org 2004-04-23 13:29:02 +00:00
Родитель 2bb207ba40
Коммит c284457122
8 изменённых файлов: 224 добавлений и 448 удалений

Просмотреть файл

@ -112,7 +112,6 @@ const PRUnichar* GetTagName(PRInt32 aTag);
class CHTMLToken : public CToken {
public:
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
@ -137,7 +136,6 @@ class CStartToken: public CHTMLToken {
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual PRInt32 GetTypeID(void);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual PRBool IsEmpty(void);
@ -149,24 +147,17 @@ class CStartToken: public CHTMLToken {
// 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);}
/*
* 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);
virtual void SetContainerInfo(eContainerInfo aContainerInfo) {
mContainerInfo=aContainerInfo;
}
virtual PRBool IsWellFormed(void) const {
return eWellFormed == mContainerInfo;
}
nsString mTextValue;
nsString mTrailingContent;
protected:
eContainerInfo mContainerInfo;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
PRPackedBool mEmpty;
#ifdef DEBUG
PRPackedBool mAttributed;
@ -190,7 +181,6 @@ class CEndToken: public CHTMLToken {
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);
virtual const nsAString& GetStringValue();
@ -217,7 +207,6 @@ class CCommentToken: public CHTMLToken {
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);
@ -244,11 +233,11 @@ class CEntityToken : public CHTMLToken {
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 nsresult ConsumeEntity(PRUnichar aChar, nsString& aString,
nsScanner& aScanner);
static PRInt32 TranslateToUnicodeStr(PRInt32 aValue,nsString& aString);
virtual const nsAString& GetStringValue(void);
@ -274,7 +263,6 @@ class CWhitespaceToken: public CHTMLToken {
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);
@ -296,14 +284,15 @@ class CTextToken: public CHTMLToken {
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);
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(nsScanner* aScanner, nsScannerIterator& aStart,
nsScannerIterator& aEnd);
virtual void Bind(const nsAString& aStr);
protected:
@ -325,7 +314,6 @@ 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);
@ -347,7 +335,6 @@ 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);
@ -373,11 +360,11 @@ class CAttributeToken: public CHTMLToken {
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 void BindKey(nsScanner* aScanner, nsScannerIterator& aStart,
nsScannerIterator& aEnd);
virtual const nsAString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
virtual const nsAString& GetStringValue(void);
@ -406,7 +393,6 @@ class CNewlineToken: public CHTMLToken {
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);
@ -430,7 +416,6 @@ class CScriptToken: public CHTMLToken {
public:
CScriptToken();
CScriptToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
@ -453,7 +438,6 @@ class CStyleToken: public CHTMLToken {
public:
CStyleToken();
CStyleToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
@ -476,7 +460,6 @@ class CInstructionToken: public CHTMLToken {
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);
@ -490,7 +473,6 @@ class CErrorToken : public CHTMLToken {
public:
CErrorToken(nsParserError* aError=0);
~CErrorToken();
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
void SetError(nsParserError* aError); // CErrorToken takes ownership of aError
@ -519,7 +501,6 @@ 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);

Просмотреть файл

@ -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;
}
/**************************************************************
@ -128,17 +130,6 @@ 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.
@ -172,16 +163,6 @@ 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")) {
}

Просмотреть файл