Backing out my changes to see if it fixes the orangeness

This commit is contained in:
harishd%netscape.com 2002-12-13 00:28:47 +00:00
Родитель 88da4209b7
Коммит 6b2eccc420
10 изменённых файлов: 514 добавлений и 502 удалений

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

@ -97,10 +97,14 @@ const PRUnichar* GetTagName(PRInt32 aTag);
*/
class CHTMLToken : public CToken {
public:
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual const PRUint16 GetContainerInfo() { return NS_HTMLTOKENS_UNKNOWNFORM; }
virtual void SetContainerInfo(PRUint16 aInfo) { }
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
virtual void SetContainerInfo(eContainerInfo aInfo) { }
protected:
};
/**
@ -113,36 +117,47 @@ class CStartToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
CStartToken(const nsAString& aString);
CStartToken(const nsAString& aName,eHTMLTags aTag);
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 const nsAString& GetStringValue();
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
virtual void SetAttributeCount(PRInt16 aCount) { mAttrCount = aCount; }
virtual PRInt16 GetAttributeCount(void) { return mAttrCount; }
virtual void SetEmpty(PRBool aValue);
virtual PRBool IsEmpty(void) { return mFlags & NS_HTMLTOKENS_EMPTYTOKEN; }
//the following info is used to set well-formedness state on start tags...
virtual void SetContainerInfo(PRUint16 aInfo);
virtual const PRUint16 GetContainerInfo() { return mFlags; }
virtual PRBool IsWellFormed(void) const { return mFlags & NS_HTMLTOKENS_WELLFORMED; }
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);
virtual void SetEmpty(PRBool aValue);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
nsString mTextValue;
nsString mTrailingContent;
//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);
nsString mTextValue;
nsString mTrailingContent;
protected:
PRInt16 mAttrCount;
eContainerInfo mContainerInfo;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
PRPackedBool mEmpty;
#ifdef DEBUG
PRPackedBool mAttributed;
PRPackedBool mAttributed;
#endif
};
@ -158,22 +173,22 @@ 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);
virtual const nsAString& GetStringValue();
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
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);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -189,19 +204,18 @@ 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);
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);
virtual void AppendSourceTo(nsAString& anOutputString);
nsresult ConsumeStrictComment(nsScanner& aScanner);
nsresult ConsumeQuirksComment(nsScanner& aScanner);
protected:
nsresult ConsumeStrictComment(nsScanner& aScanner);
nsresult ConsumeQuirksComment(nsScanner& aScanner);
nsSlidingSubstring mComment; // does not include MDO & MDC
nsSlidingSubstring mCommentDecl; // includes MDO & MDC
};
@ -220,22 +234,21 @@ class CEntityToken : public CHTMLToken {
public:
CEntityToken();
CEntityToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
PRInt32 TranslateToUnicodeStr(nsString& aString);
static nsresult ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
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);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -250,16 +263,15 @@ 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);
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);
protected:
nsString mTextValue;
nsString mTextValue;
};
/**
@ -273,23 +285,21 @@ class CTextToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CTextToken();
CTextToken(const nsAString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
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 aMode,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);
nsresult ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,
nsString& aEndTagName,PRInt32 aMode,PRBool& aFlushTokens);
PRInt32 GetTextLength(void);
void CopyTo(nsAString& aStr);
void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
void Bind(const nsAString& aStr);
virtual void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual void Bind(const nsAString& aStr);
protected:
nsSlidingSubstring mTextValue;
nsSlidingSubstring mTextValue;
};
@ -312,7 +322,7 @@ public:
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -328,13 +338,13 @@ class CMarkupDeclToken : public CHTMLToken {
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 nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
protected:
nsSlidingSubstring mTextValue;
nsSlidingSubstring mTextValue;
};
@ -350,32 +360,32 @@ 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& GetStringValue(void);
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
const nsAString& GetKey(void) {return mTextKey;}
void SetKey(const nsAString& aKey);
void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
const nsAString& GetValue(void) {return mTextValue;}
void SanitizeKey();
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) {return mTextKey;}
virtual void SetKey(const nsAString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsAString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
#ifdef DEBUG
virtual void DebugDumpToken(nsOutputStream& out);
void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpToken(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
#endif
PRPackedBool mHasEqualWithoutValue;
PRPackedBool mHasEqualWithoutValue;
protected:
#ifdef DEBUG
PRPackedBool mLastAttribute;
PRPackedBool mLastAttribute;
#endif
nsAutoString mTextValue;
nsSlidingSubstring mTextKey;
@ -392,15 +402,14 @@ class CNewlineToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CNewlineToken();
CNewlineToken();
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
static void AllocNewline();
static void FreeNewline();
static void AllocNewline();
static void FreeNewline();
};
@ -421,10 +430,10 @@ class CScriptToken: public CHTMLToken {
CScriptToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -444,10 +453,10 @@ class CStyleToken: public CHTMLToken {
CStyleToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -505,16 +514,16 @@ class CDoctypeDeclToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
CDoctypeDeclToken(const nsAString& aString,eHTMLTags aTag=eHTMLTag_unknown);
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);
nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
const char* GetClassName(void);
PRInt32 GetTokenType(void);
void SetStringValue(const nsAString& aStr);
const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
#endif

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

@ -75,17 +75,18 @@
#include "nsFileSpec.h"
#include "nsFixedSizeAllocator.h"
#define NS_HTMLTOKENS_UNKNOWNFORM 0x00000001
#define NS_HTMLTOKENS_WELLFORMED 0x00000002
#define NS_HTMLTOKENS_MALFORMED 0x00000004
#define NS_HTMLTOKENS_EMPTYTOKEN 0x00000008
#define NS_HTMLTOKENS_NOT_AN_ENTITY \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_HTMLPARSER,2000)
class nsScanner;
class nsTokenAllocator;
enum eContainerInfo {
eWellFormed,
eMalformed,
eFormUnknown
};
/**
* Implement the SizeOf() method; leaf classes derived from CToken
* must declare this.
@ -182,7 +183,7 @@ class CToken {
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual void GetSource(nsAString& anOutputString);
virtual void GetSource(nsString& anOutputString);
/** @update harishd 03/23/00
* @return reference to string containing string value
@ -210,8 +211,6 @@ class CToken {
*/
virtual PRInt16 GetAttributeCount(void);
virtual void SetAttributeCount(PRInt16 aValue) { }
/**
* Causes token to consume data from given scanner.
* Note that behavior varies wildly between CToken subclasses.
@ -236,14 +235,6 @@ class CToken {
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpSource(nsOutputStream& out);
/**
* 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);
#endif
/**
@ -253,6 +244,15 @@ 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.
@ -289,6 +289,8 @@ class CToken {
mLineNumber = mLineNumber == 0 ? aLineNumber : mLineNumber;
}
void SetAttributeCount(PRInt16 aValue) { mAttrCount = aValue; }
/**
* perform self test.
* @update gess5/11/98
@ -305,11 +307,11 @@ protected:
*/
virtual size_t SizeOf() const = 0;
PRInt32 mTypeID;
PRInt32 mUseCount;
PRInt32 mNewlineCount;
PRInt32 mLineNumber;
PRUint16 mFlags;
PRInt32 mTypeID;
PRInt32 mUseCount;
PRInt32 mNewlineCount;
PRInt32 mLineNumber;
PRInt16 mAttrCount;
};

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

@ -354,15 +354,15 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
//*** start by finding the first start tag that hasn't been reviewed.
while (mTokenScanPos > 0) {
while(mTokenScanPos>0) {
theRootToken=(CHTMLToken*)mTokenDeque.ObjectAt(mTokenScanPos);
if ( theRootToken) {
if(theRootToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theRootToken->GetTokenType());
if (eToken_start == theType) {
if (theRootToken->GetContainerInfo() & NS_HTMLTOKENS_UNKNOWNFORM) {
if(eToken_start==theType) {
if(eFormUnknown==theRootToken->GetContainerInfo()) {
break;
}
}
}
}
mTokenScanPos--;
}
@ -414,16 +414,16 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
if(theTag==theLastToken->GetTypeID()) {
theStack.Pop(); //yank it for real
theStackDepth--;
theLastToken->SetContainerInfo(NS_HTMLTOKENS_WELLFORMED);
theLastToken->SetContainerInfo(eWellFormed);
//in addition, let's look above this container to see if we can find
//any tags that are already marked malformed. If so, pop them too!
theLastToken= NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
while (theLastToken) {
if (theRootToken->GetContainerInfo() & NS_HTMLTOKENS_MALFORMED) {
while(theLastToken) {
if(eMalformed==theRootToken->GetContainerInfo()) {
theStack.Pop(); //yank the malformed token for real.
theLastToken = NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
theLastToken= NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
continue;
}
break;
@ -434,11 +434,11 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
//be malformed. If the tag is a block, we don't really care (but we'll
//mark it anyway). If it's an inline we DO care, especially if the
//inline tried to contain a block (that's when RS handling kicks in).
if (theTagIsInline) {
PRInt32 theIndex = FindLastIndexOfTag(theTag,theStack);
if (kNotFound != theIndex) {
theToken = (CHTMLToken*)theStack.ObjectAt(theIndex);
theToken->SetContainerInfo(NS_HTMLTOKENS_MALFORMED);
if(theTagIsInline) {
PRInt32 theIndex=FindLastIndexOfTag(theTag,theStack);
if(kNotFound!=theIndex) {
theToken=(CHTMLToken*)theStack.ObjectAt(theIndex);
theToken->SetContainerInfo(eMalformed);
}
//otherwise we ignore an out-of-place end tag.
}

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

@ -90,29 +90,51 @@ CHTMLToken::~CHTMLToken() {
* @param
* @return
*/
CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag)
{
CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
#ifdef DEBUG
mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken(const nsAString& aName) : CHTMLToken(eHTMLTag_unknown)
{
CStartToken::CStartToken(const nsAString& aName) : CHTMLToken(eHTMLTag_unknown) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
mTextValue.Assign(aName);
#ifdef DEBUG
mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTag)
{
CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTag) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
mTextValue.Assign(aName);
#ifdef DEBUG
mAttributed = PR_FALSE;
#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.
*
@ -120,9 +142,7 @@ CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTa
* @param
* @return
*/
PRInt32
CStartToken::GetTypeID()
{
PRInt32 CStartToken::GetTypeID(){
if(eHTMLTag_unknown==mTypeID) {
mTypeID = nsHTMLTags::LookupTag(mTextValue);
}
@ -136,9 +156,7 @@ CStartToken::GetTypeID()
* @param
* @return
*/
const char*
CStartToken::GetClassName(void)
{
const char* CStartToken::GetClassName(void) {
return "start";
}
@ -149,29 +167,10 @@ CStartToken::GetClassName(void)
* @param
* @return
*/
PRInt32 CStartToken::GetTokenType(void)
{
PRInt32 CStartToken::GetTokenType(void) {
return eToken_start;
}
void CStartToken::SetContainerInfo(PRUint16 aInfo)
{
if (aInfo & NS_HTMLTOKENS_UNKNOWNFORM) {
mFlags &= ~(NS_HTMLTOKENS_MALFORMED | NS_HTMLTOKENS_WELLFORMED);
mFlags |= NS_HTMLTOKENS_UNKNOWNFORM;
}
else if (aInfo & NS_HTMLTOKENS_WELLFORMED) {
mFlags &= ~(NS_HTMLTOKENS_UNKNOWNFORM | NS_HTMLTOKENS_MALFORMED);
mFlags |= NS_HTMLTOKENS_WELLFORMED;
}
else if (aInfo & NS_HTMLTOKENS_MALFORMED) {
mFlags &= ~(NS_HTMLTOKENS_UNKNOWNFORM | NS_HTMLTOKENS_WELLFORMED);
mFlags |= NS_HTMLTOKENS_MALFORMED;
}
else {
NS_WARNING("invalid container info!");
}
}
/*
*
*
@ -179,16 +178,22 @@ void CStartToken::SetContainerInfo(PRUint16 aInfo)
* @param
* @return
*/
void CStartToken::SetEmpty(PRBool aValue)
{
if (aValue) {
mFlags |= NS_HTMLTOKENS_EMPTYTOKEN;
}
else {
mFlags &= ~NS_HTMLTOKENS_EMPTYTOKEN;
}
void CStartToken::SetEmpty(PRBool aValue) {
mEmpty=aValue;
}
/*
*
*
* @update gess 3/25/98
* @param
* @return
*/
PRBool CStartToken::IsEmpty(void) {
return mEmpty;
}
/*
* Consume the identifier portion of the start tag
*
@ -263,7 +268,7 @@ const nsAString& CStartToken::GetStringValue()
* @param anOutputString will recieve the result
* @return nada
*/
void CStartToken::GetSource(nsAString& anOutputString){
void CStartToken::GetSource(nsString& anOutputString){
anOutputString.Append(PRUnichar('<'));
/*
* Watch out for Bug 15204
@ -367,9 +372,7 @@ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aFlag)
* @param
* @return eHTMLTag id of this endtag
*/
PRInt32
CEndToken::GetTypeID()
{
PRInt32 CEndToken::GetTypeID(){
if(eHTMLTag_unknown==mTypeID) {
mTypeID = nsHTMLTags::LookupTag(mTextValue);
switch(mTypeID) {
@ -436,7 +439,7 @@ const nsAString& CEndToken::GetStringValue()
* @param anOutputString will recieve the result
* @return nada
*/
void CEndToken::GetSource(nsAString& anOutputString){
void CEndToken::GetSource(nsString& anOutputString){
anOutputString.Append(NS_LITERAL_STRING("</"));
if(mTextValue.Length()>0)
anOutputString.Append(mTextValue);
@ -1521,7 +1524,7 @@ const nsAString& CAttributeToken::GetStringValue(void)
* @param anOutputString will recieve the result
* @return nada
*/
void CAttributeToken::GetSource(nsAString& anOutputString){
void CAttributeToken::GetSource(nsString& anOutputString){
anOutputString.Truncate();
AppendSourceTo(anOutputString);
}
@ -2223,7 +2226,7 @@ const nsAString& CEntityToken::GetStringValue(void)
* @param anOutputString will recieve the result
* @return nada
*/
void CEntityToken::GetSource(nsAString& anOutputString){
void CEntityToken::GetSource(nsString& anOutputString){
anOutputString.Append(NS_LITERAL_STRING("&"));
anOutputString+=mTextValue;
//anOutputString+=";";

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

@ -59,23 +59,22 @@ int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
*
* @update gess 7/21/98
*/
CToken::CToken(PRInt32 aTag)
: mNewlineCount(0),
mLineNumber(0),
mTypeID(aTag),
mUseCount(1),
mFlags(NS_HTMLTOKENS_UNKNOWNFORM)
// Note that the use count starts with 1 instead of 0. This
// is because of the assumption that any token created is in
// use and therefore does not require an explicit addref, or
// rather IF_HOLD. This will make sure that tokens created
// on the stack do not accidently hit the arena recycler.
{
CToken::CToken(PRInt32 aTag) {
// Tokens are allocated through the arena ( not heap allocated..yay ).
// We, therefore, don't need this macro anymore..
#ifdef MATCH_CTOR_DTOR
MOZ_COUNT_CTOR(CToken);
#endif
mAttrCount=0;
mNewlineCount=0;
mLineNumber = 0;
mTypeID=aTag;
// Note that the use count starts with 1 instead of 0. This
// is because of the assumption that any token created is in
// use and therefore does not require an explicit addref, or
// rather IF_HOLD. This, also, will make sure that tokens created
// on the stack do not accidently hit the arena recycler.
mUseCount=1;
#ifdef NS_DEBUG
++TokenCount;
@ -128,7 +127,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) {
for(i=0;i<theLen;++i){
anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get();
}
anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << 0 << nsEndl;
anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << mAttrCount << nsEndl;
}
/**
@ -141,19 +140,6 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) {
void CToken::DebugDumpSource(nsOutputStream& anOutputStream) {
anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get();
}
/**
* retrieve this tokens classname.
*
* @update gess 3/25/98
* @return char* containing name of class
*/
const char*
CToken::GetClassName(void)
{
return "token";
}
#endif
@ -163,7 +149,7 @@ CToken::GetClassName(void)
* @update gess5/11/98
* @return reference to string containing string value
*/
void CToken::GetSource(nsAString& anOutputString){
void CToken::GetSource(nsString& anOutputString){
anOutputString.Assign(GetStringValue());
}
@ -193,9 +179,7 @@ void CToken::SetTypeID(PRInt32 aTypeID) {
* @update gess 3/25/98
* @return int containing ordinal value
*/
PRInt32
CToken::GetTypeID(void)
{
PRInt32 CToken::GetTypeID(void) {
return mTypeID;
}
@ -205,10 +189,8 @@ CToken::GetTypeID(void)
* @update gess 3/25/98
* @return int containing attribute count
*/
PRInt16
CToken::GetAttributeCount(void)
{
return 0;
PRInt16 CToken::GetAttributeCount(void) {
return mAttrCount;
}
@ -219,18 +201,28 @@ 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";
}
/**
*
* @update gess 3/25/98
*/
void CToken::SelfTest(void)
{
void CToken::SelfTest(void) {
#ifdef _DEBUG
#endif
}

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

@ -97,10 +97,14 @@ const PRUnichar* GetTagName(PRInt32 aTag);
*/
class CHTMLToken : public CToken {
public:
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual const PRUint16 GetContainerInfo() { return NS_HTMLTOKENS_UNKNOWNFORM; }
virtual void SetContainerInfo(PRUint16 aInfo) { }
virtual ~CHTMLToken();
CHTMLToken(eHTMLTags aTag);
virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
virtual void SetContainerInfo(eContainerInfo aInfo) { }
protected:
};
/**
@ -113,36 +117,47 @@ class CStartToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
CStartToken(const nsAString& aString);
CStartToken(const nsAString& aName,eHTMLTags aTag);
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 const nsAString& GetStringValue();
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
virtual void SetAttributeCount(PRInt16 aCount) { mAttrCount = aCount; }
virtual PRInt16 GetAttributeCount(void) { return mAttrCount; }
virtual void SetEmpty(PRBool aValue);
virtual PRBool IsEmpty(void) { return mFlags & NS_HTMLTOKENS_EMPTYTOKEN; }
//the following info is used to set well-formedness state on start tags...
virtual void SetContainerInfo(PRUint16 aInfo);
virtual const PRUint16 GetContainerInfo() { return mFlags; }
virtual PRBool IsWellFormed(void) const { return mFlags & NS_HTMLTOKENS_WELLFORMED; }
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);
virtual void SetEmpty(PRBool aValue);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
nsString mTextValue;
nsString mTrailingContent;
//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);
nsString mTextValue;
nsString mTrailingContent;
protected:
PRInt16 mAttrCount;
eContainerInfo mContainerInfo;
nsCOMPtr<nsIAtom> mIDAttributeAtom;
PRPackedBool mEmpty;
#ifdef DEBUG
PRPackedBool mAttributed;
PRPackedBool mAttributed;
#endif
};
@ -158,22 +173,22 @@ 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);
virtual const nsAString& GetStringValue();
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
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);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue();
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -189,19 +204,18 @@ 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);
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);
virtual void AppendSourceTo(nsAString& anOutputString);
nsresult ConsumeStrictComment(nsScanner& aScanner);
nsresult ConsumeQuirksComment(nsScanner& aScanner);
protected:
nsresult ConsumeStrictComment(nsScanner& aScanner);
nsresult ConsumeQuirksComment(nsScanner& aScanner);
nsSlidingSubstring mComment; // does not include MDO & MDC
nsSlidingSubstring mCommentDecl; // includes MDO & MDC
};
@ -220,22 +234,21 @@ class CEntityToken : public CHTMLToken {
public:
CEntityToken();
CEntityToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
PRInt32 TranslateToUnicodeStr(nsString& aString);
static nsresult ConsumeEntity(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
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);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpSource(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -250,16 +263,15 @@ 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);
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);
protected:
nsString mTextValue;
nsString mTextValue;
};
/**
@ -273,23 +285,21 @@ class CTextToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CTextToken();
CTextToken(const nsAString& aString);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
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 aMode,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);
nsresult ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,
nsString& aEndTagName,PRInt32 aMode,PRBool& aFlushTokens);
PRInt32 GetTextLength(void);
void CopyTo(nsAString& aStr);
void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
void Bind(const nsAString& aStr);
virtual void Bind(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual void Bind(const nsAString& aStr);
protected:
nsSlidingSubstring mTextValue;
nsSlidingSubstring mTextValue;
};
@ -312,7 +322,7 @@ public:
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -328,13 +338,13 @@ class CMarkupDeclToken : public CHTMLToken {
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 nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
protected:
nsSlidingSubstring mTextValue;
nsSlidingSubstring mTextValue;
};
@ -350,32 +360,32 @@ 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& GetStringValue(void);
virtual void GetSource(nsAString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
const nsAString& GetKey(void) {return mTextKey;}
void SetKey(const nsAString& aKey);
void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
const nsAString& GetValue(void) {return mTextValue;}
void SanitizeKey();
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) {return mTextKey;}
virtual void SetKey(const nsAString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsAString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
#ifdef DEBUG
virtual void DebugDumpToken(nsOutputStream& out);
void DebugDumpSource(nsOutputStream& out);
virtual void DebugDumpToken(nsOutputStream& out);
#endif
virtual const nsAString& GetStringValue(void);
virtual void GetSource(nsString& anOutputString);
virtual void AppendSourceTo(nsAString& anOutputString);
#ifdef DEBUG
virtual void DebugDumpSource(nsOutputStream& out);
#endif
PRPackedBool mHasEqualWithoutValue;
PRPackedBool mHasEqualWithoutValue;
protected:
#ifdef DEBUG
PRPackedBool mLastAttribute;
PRPackedBool mLastAttribute;
#endif
nsAutoString mTextValue;
nsSlidingSubstring mTextKey;
@ -392,15 +402,14 @@ class CNewlineToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CNewlineToken();
CNewlineToken();
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
static void AllocNewline();
static void FreeNewline();
static void AllocNewline();
static void FreeNewline();
};
@ -421,10 +430,10 @@ class CScriptToken: public CHTMLToken {
CScriptToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -444,10 +453,10 @@ class CStyleToken: public CHTMLToken {
CStyleToken(const nsAString& aString);
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual const nsAString& GetStringValue(void);
virtual const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
@ -505,16 +514,16 @@ class CDoctypeDeclToken: public CHTMLToken {
CTOKEN_IMPL_SIZEOF
public:
CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
CDoctypeDeclToken(const nsAString& aString,eHTMLTags aTag=eHTMLTag_unknown);
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);
nsresult Consume(PRUnichar aChar,nsScanner& aScanner,PRInt32 aMode);
const char* GetClassName(void);
PRInt32 GetTokenType(void);
void SetStringValue(const nsAString& aStr);
const nsAString& GetStringValue(void);
protected:
nsString mTextValue;
nsString mTextValue;
};
#endif

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

@ -75,17 +75,18 @@
#include "nsFileSpec.h"
#include "nsFixedSizeAllocator.h"
#define NS_HTMLTOKENS_UNKNOWNFORM 0x00000001
#define NS_HTMLTOKENS_WELLFORMED 0x00000002
#define NS_HTMLTOKENS_MALFORMED 0x00000004
#define NS_HTMLTOKENS_EMPTYTOKEN 0x00000008
#define NS_HTMLTOKENS_NOT_AN_ENTITY \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_HTMLPARSER,2000)
class nsScanner;
class nsTokenAllocator;
enum eContainerInfo {
eWellFormed,
eMalformed,
eFormUnknown
};
/**
* Implement the SizeOf() method; leaf classes derived from CToken
* must declare this.
@ -182,7 +183,7 @@ class CToken {
* @update gess5/11/98
* @return reference to string containing string value
*/
virtual void GetSource(nsAString& anOutputString);
virtual void GetSource(nsString& anOutputString);
/** @update harishd 03/23/00
* @return reference to string containing string value
@ -210,8 +211,6 @@ class CToken {
*/
virtual PRInt16 GetAttributeCount(void);
virtual void SetAttributeCount(PRInt16 aValue) { }
/**
* Causes token to consume data from given scanner.
* Note that behavior varies wildly between CToken subclasses.
@ -236,14 +235,6 @@ class CToken {
* @param out is the output stream where token should write itself
*/
virtual void DebugDumpSource(nsOutputStream& out);
/**
* 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);
#endif
/**
@ -253,6 +244,15 @@ 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.
@ -289,6 +289,8 @@ class CToken {
mLineNumber = mLineNumber == 0 ? aLineNumber : mLineNumber;
}
void SetAttributeCount(PRInt16 aValue) { mAttrCount = aValue; }
/**
* perform self test.
* @update gess5/11/98
@ -305,11 +307,11 @@ protected:
*/
virtual size_t SizeOf() const = 0;
PRInt32 mTypeID;
PRInt32 mUseCount;
PRInt32 mNewlineCount;
PRInt32 mLineNumber;
PRUint16 mFlags;
PRInt32 mTypeID;
PRInt32 mUseCount;
PRInt32 mNewlineCount;
PRInt32 mLineNumber;
PRInt16 mAttrCount;
};

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

@ -354,15 +354,15 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
//*** start by finding the first start tag that hasn't been reviewed.
while (mTokenScanPos > 0) {
while(mTokenScanPos>0) {
theRootToken=(CHTMLToken*)mTokenDeque.ObjectAt(mTokenScanPos);
if ( theRootToken) {
if(theRootToken) {
eHTMLTokenTypes theType=eHTMLTokenTypes(theRootToken->GetTokenType());
if (eToken_start == theType) {
if (theRootToken->GetContainerInfo() & NS_HTMLTOKENS_UNKNOWNFORM) {
if(eToken_start==theType) {
if(eFormUnknown==theRootToken->GetContainerInfo()) {
break;
}
}
}
}
mTokenScanPos--;
}
@ -414,16 +414,16 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
if(theTag==theLastToken->GetTypeID()) {
theStack.Pop(); //yank it for real
theStackDepth--;
theLastToken->SetContainerInfo(NS_HTMLTOKENS_WELLFORMED);
theLastToken->SetContainerInfo(eWellFormed);
//in addition, let's look above this container to see if we can find
//any tags that are already marked malformed. If so, pop them too!
theLastToken= NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
while (theLastToken) {
if (theRootToken->GetContainerInfo() & NS_HTMLTOKENS_MALFORMED) {
while(theLastToken) {
if(eMalformed==theRootToken->GetContainerInfo()) {
theStack.Pop(); //yank the malformed token for real.
theLastToken = NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
theLastToken= NS_STATIC_CAST(CHTMLToken*, theStack.Peek());
continue;
}
break;
@ -434,11 +434,11 @@ nsresult nsHTMLTokenizer::ScanDocStructure(PRBool aFinalChunk) {
//be malformed. If the tag is a block, we don't really care (but we'll
//mark it anyway). If it's an inline we DO care, especially if the
//inline tried to contain a block (that's when RS handling kicks in).
if (theTagIsInline) {
PRInt32 theIndex = FindLastIndexOfTag(theTag,theStack);
if (kNotFound != theIndex) {
theToken = (CHTMLToken*)theStack.ObjectAt(theIndex);
theToken->SetContainerInfo(NS_HTMLTOKENS_MALFORMED);
if(theTagIsInline) {
PRInt32 theIndex=FindLastIndexOfTag(theTag,theStack);
if(kNotFound!=theIndex) {
theToken=(CHTMLToken*)theStack.ObjectAt(theIndex);
theToken->SetContainerInfo(eMalformed);
}
//otherwise we ignore an out-of-place end tag.
}

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

@ -90,29 +90,51 @@ CHTMLToken::~CHTMLToken() {
* @param
* @return
*/
CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag)
{
CStartToken::CStartToken(eHTMLTags aTag) : CHTMLToken(aTag) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
#ifdef DEBUG
mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken(const nsAString& aName) : CHTMLToken(eHTMLTag_unknown)
{
CStartToken::CStartToken(const nsAString& aName) : CHTMLToken(eHTMLTag_unknown) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
mTextValue.Assign(aName);
#ifdef DEBUG
mAttributed = PR_FALSE;
#endif
}
CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTag)
{
CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTag) {
mEmpty=PR_FALSE;
mContainerInfo=eFormUnknown;
mTextValue.Assign(aName);
#ifdef DEBUG
mAttributed = PR_FALSE;
#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.
*
@ -120,9 +142,7 @@ CStartToken::CStartToken(const nsAString& aName,eHTMLTags aTag) : CHTMLToken(aTa
* @param
* @return
*/
PRInt32
CStartToken::GetTypeID()
{
PRInt32 CStartToken::GetTypeID(){
if(eHTMLTag_unknown==mTypeID) {
mTypeID = nsHTMLTags::LookupTag(mTextValue);
}
@ -136,9 +156,7 @@ CStartToken::GetTypeID()
* @param
* @return
*/
const char*
CStartToken::GetClassName(void)
{
const char* CStartToken::GetClassName(void) {
return "start";
}
@ -149,29 +167,10 @@ CStartToken::GetClassName(void)
* @param
* @return
*/
PRInt32 CStartToken::GetTokenType(void)
{
PRInt32 CStartToken::GetTokenType(void) {
return eToken_start;
}
void CStartToken::SetContainerInfo(PRUint16 aInfo)
{
if (aInfo & NS_HTMLTOKENS_UNKNOWNFORM) {
mFlags &= ~(NS_HTMLTOKENS_MALFORMED | NS_HTMLTOKENS_WELLFORMED);
mFlags |= NS_HTMLTOKENS_UNKNOWNFORM;
}
else if (aInfo & NS_HTMLTOKENS_WELLFORMED) {
mFlags &= ~(NS_HTMLTOKENS_UNKNOWNFORM | NS_HTMLTOKENS_MALFORMED);
mFlags |= NS_HTMLTOKENS_WELLFORMED;
}
else if (aInfo & NS_HTMLTOKENS_MALFORMED) {
mFlags &= ~(NS_HTMLTOKENS_UNKNOWNFORM | NS_HTMLTOKENS_WELLFORMED);
mFlags |= NS_HTMLTOKENS_MALFORMED;
}
else {
NS_WARNING("invalid container info!");
}
}
/*
*
*
@ -179,16 +178,22 @@ void CStartToken::SetContainerInfo(PRUint16 aInfo)
* @param
* @return
*/
void CStartToken::SetEmpty(PRBool aValue)
{
if (aValue) {
mFlags |= NS_HTMLTOKENS_EMPTYTOKEN;
}
else {
mFlags &= ~NS_HTMLTOKENS_EMPTYTOKEN;
}
void CStartToken::SetEmpty(PRBool aValue) {
mEmpty=aValue;
}
/*
*
*
* @update gess 3/25/98
* @param
* @return
*/
PRBool CStartToken::IsEmpty(void) {
return mEmpty;
}
/*
* Consume the identifier portion of the start tag
*
@ -263,7 +268,7 @@ const nsAString& CStartToken::GetStringValue()
* @param anOutputString will recieve the result
* @return nada
*/
void CStartToken::GetSource(nsAString& anOutputString){
void CStartToken::GetSource(nsString& anOutputString){
anOutputString.Append(PRUnichar('<'));
/*
* Watch out for Bug 15204
@ -367,9 +372,7 @@ nsresult CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aFlag)
* @param
* @return eHTMLTag id of this endtag
*/
PRInt32
CEndToken::GetTypeID()
{
PRInt32 CEndToken::GetTypeID(){
if(eHTMLTag_unknown==mTypeID) {
mTypeID = nsHTMLTags::LookupTag(mTextValue);
switch(mTypeID) {
@ -436,7 +439,7 @@ const nsAString& CEndToken::GetStringValue()
* @param anOutputString will recieve the result
* @return nada
*/
void CEndToken::GetSource(nsAString& anOutputString){
void CEndToken::GetSource(nsString& anOutputString){
anOutputString.Append(NS_LITERAL_STRING("</"));
if(mTextValue.Length()>0)
anOutputString.Append(mTextValue);
@ -1521,7 +1524,7 @@ const nsAString& CAttributeToken::GetStringValue(void)
* @param anOutputString will recieve the result
* @return nada
*/
void CAttributeToken::GetSource(nsAString& anOutputString){
void CAttributeToken::GetSource(nsString& anOutputString){
anOutputString.Truncate();
AppendSourceTo(anOutputString);
}
@ -2223,7 +2226,7 @@ const nsAString& CEntityToken::GetStringValue(void)
* @param anOutputString will recieve the result
* @return nada
*/
void CEntityToken::GetSource(nsAString& anOutputString){
void CEntityToken::GetSource(nsString& anOutputString){
anOutputString.Append(NS_LITERAL_STRING("&"));
anOutputString+=mTextValue;
//anOutputString+=";";

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

@ -59,23 +59,22 @@ int CToken::GetTokenCount(){return TokenCount-DelTokenCount;}
*
* @update gess 7/21/98
*/
CToken::CToken(PRInt32 aTag)
: mNewlineCount(0),
mLineNumber(0),
mTypeID(aTag),
mUseCount(1),
mFlags(NS_HTMLTOKENS_UNKNOWNFORM)
// Note that the use count starts with 1 instead of 0. This
// is because of the assumption that any token created is in
// use and therefore does not require an explicit addref, or
// rather IF_HOLD. This will make sure that tokens created
// on the stack do not accidently hit the arena recycler.
{
CToken::CToken(PRInt32 aTag) {
// Tokens are allocated through the arena ( not heap allocated..yay ).
// We, therefore, don't need this macro anymore..
#ifdef MATCH_CTOR_DTOR
MOZ_COUNT_CTOR(CToken);
#endif
mAttrCount=0;
mNewlineCount=0;
mLineNumber = 0;
mTypeID=aTag;
// Note that the use count starts with 1 instead of 0. This
// is because of the assumption that any token created is in
// use and therefore does not require an explicit addref, or
// rather IF_HOLD. This, also, will make sure that tokens created
// on the stack do not accidently hit the arena recycler.
mUseCount=1;
#ifdef NS_DEBUG
++TokenCount;
@ -128,7 +127,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) {
for(i=0;i<theLen;++i){
anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get();
}
anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << 0 << nsEndl;
anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << mAttrCount << nsEndl;
}
/**
@ -141,19 +140,6 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) {
void CToken::DebugDumpSource(nsOutputStream& anOutputStream) {
anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get();
}
/**
* retrieve this tokens classname.
*
* @update gess 3/25/98
* @return char* containing name of class
*/
const char*
CToken::GetClassName(void)
{
return "token";
}
#endif
@ -163,7 +149,7 @@ CToken::GetClassName(void)
* @update gess5/11/98
* @return reference to string containing string value
*/
void CToken::GetSource(nsAString& anOutputString){
void CToken::GetSource(nsString& anOutputString){
anOutputString.Assign(GetStringValue());
}
@ -193,9 +179,7 @@ void CToken::SetTypeID(PRInt32 aTypeID) {
* @update gess 3/25/98
* @return int containing ordinal value
*/
PRInt32
CToken::GetTypeID(void)
{
PRInt32 CToken::GetTypeID(void) {
return mTypeID;
}
@ -205,10 +189,8 @@ CToken::GetTypeID(void)
* @update gess 3/25/98
* @return int containing attribute count
*/
PRInt16
CToken::GetAttributeCount(void)
{
return 0;
PRInt16 CToken::GetAttributeCount(void) {
return mAttrCount;
}
@ -219,18 +201,28 @@ 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";
}
/**
*
* @update gess 3/25/98
*/
void CToken::SelfTest(void)
{
void CToken::SelfTest(void) {
#ifdef _DEBUG
#endif
}