diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index 6fbb3e015a6..3c5474218f0 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -397,7 +397,10 @@ nsresult CNavDTD::WillBuildModel( const CParserContext& aParserContext,nsIConte
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::WillBuildModel(), this=%p\n", this));
+#ifdef DEBUG
mBodyContext->ResetCounters();
+#endif
+
mDocType=aParserContext.mDocType;
if(aSink && (!mSink)) {
@@ -982,6 +985,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
break;
+#ifdef DEBUG
case eHTMLTag_counter:
{
PRInt32 theCount=mBodyContext->GetCount();
@@ -1026,6 +1030,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
}
break;
+#endif
default:
break;
@@ -2126,21 +2131,24 @@ nsresult CNavDTD::HandleEntityToken(CToken* aToken) {
nsAutoString theStr(aToken->GetStringValue());
PRUnichar theChar=theStr.CharAt(0);
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
-
+ CToken *theToken=0;
+#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...
CNamedEntity *theEntity=mBodyContext->GetEntity(theStr);
- CToken *theToken=0;
if(theEntity) {
- theToken=NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue));
+ theToken = NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue));
}
else {
+#endif
//if you're here we have a bogus entity.
//convert it into a text token.
nsAutoString entityName;
entityName.Assign(NS_LITERAL_STRING("&"));
entityName.Append(theStr); //should append the entity name; fix bug 51161.
theToken = mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,entityName);
+#ifdef DEBUG
}
+#endif
return HandleToken(theToken,mParser); //theToken should get recycled automagically...
}
@@ -3225,20 +3233,22 @@ nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
- if((mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM) && (mOpenFormCount == 1)) {
- mFlags &= ~NS_PARSER_FLAG_HAS_OPEN_FORM;
+ if(mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM) {
+ if (mOpenFormCount == 1) {
+ mFlags &= ~NS_PARSER_FLAG_HAS_OPEN_FORM;
- STOP_TIMER();
- MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
+ STOP_TIMER();
+ MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
- result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
+ result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
- MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
- START_TIMER();
+ MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
+ START_TIMER();
- mFlags &= ~NS_PARSER_FLAG_IS_FORM_CONTAINER;
+ mFlags &= ~NS_PARSER_FLAG_IS_FORM_CONTAINER;
+ }
+ --mOpenFormCount;
}
- --mOpenFormCount;
return result;
}
diff --git a/mozilla/htmlparser/src/COtherDTD.cpp b/mozilla/htmlparser/src/COtherDTD.cpp
index 6ddc4c87df3..169aab02185 100644
--- a/mozilla/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/htmlparser/src/COtherDTD.cpp
@@ -355,7 +355,9 @@ nsresult COtherDTD::WillBuildModel( const CParserContext& aParserContext,nsICon
if(result==NS_OK) {
result = aSink->WillBuildModel();
+#ifdef DEBUG
mBodyContext->ResetCounters();
+#endif
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: COtherDTD::WillBuildModel(), this=%p\n", this));
START_TIMER();
@@ -574,6 +576,7 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
break;
+#ifdef DEBUG
case eHTMLTag_meta:
{
//we should only enable user-defined entities in debug builds...
@@ -602,6 +605,7 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
}
break;
+#endif
default:
break;
@@ -840,19 +844,23 @@ nsresult COtherDTD::HandleEntityToken(CToken* aToken) {
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
+#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...
CNamedEntity *theEntity=mBodyContext->GetEntity(theStr);
if(theEntity) {
theToken=(CTextToken*)mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue);
}
else {
+#endif
//if you're here we have a bogus entity.
//convert it into a text token.
nsAutoString entityName;
entityName.Assign(NS_LITERAL_STRING("&"));
entityName.Append(theStr); //should append the entity name; fix bug 51161.
theToken=(CTextToken*)mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,entityName);
+#ifdef DEBUG
}
+#endif
result=HandleStartToken(theToken);
}
else {
diff --git a/mozilla/htmlparser/src/COtherElements.h b/mozilla/htmlparser/src/COtherElements.h
index 17699c49b11..53f5478bf30 100644
--- a/mozilla/htmlparser/src/COtherElements.h
+++ b/mozilla/htmlparser/src/COtherElements.h
@@ -1016,14 +1016,18 @@ public:
PRInt32 theCount=aContext->GetCount();
eHTMLTags theGrandParentTag=aContext->TagAt(theCount-2);
- nsCParserNode *theNode=(nsCParserNode*)aNode;
+ nsCParserNode *theNode = (nsCParserNode*)aNode;
+
+#ifdef DEBUG
nsAutoString theNumber;
aContext->IncrementCounter(theGrandParentTag,*theNode,theNumber);
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNewNode(&theToken,theLineNumber,0 /*stack token*/);
- result=aSink->AddLeaf(theNewNode);
+ *theNode = theNewNode;
+#endif
+ result=aSink->AddLeaf(*theNode);
return result;
}
diff --git a/mozilla/htmlparser/src/nsDTDUtils.cpp b/mozilla/htmlparser/src/nsDTDUtils.cpp
index e7cdb3e1d57..fa59b793200 100644
--- a/mozilla/htmlparser/src/nsDTDUtils.cpp
+++ b/mozilla/htmlparser/src/nsDTDUtils.cpp
@@ -404,27 +404,26 @@ nsDTDContext::nsDTDContext() : mStack(), mEntities(0){
mResidualStyleCount=0;
mContextTopIndex=-1;
mTableStates=0;
- mCounters=0;
mTokenAllocator=0;
mNodeAllocator=0;
mAllBits=0;
-#ifdef NS_DEBUG
+#ifdef DEBUG
memset(mXTags,0,sizeof(mXTags));
+ mCounters = 0;
#endif
}
-
-
-class CEntityDeallocator: public nsDequeFunctor{
-public:
- virtual void* operator()(void* anObject) {
- CNamedEntity *theEntity=(CNamedEntity*)anObject;
- delete theEntity;
- return 0;
- }
-};
-
+#ifdef DEBUG
+ class CEntityDeallocator: public nsDequeFunctor{
+ public:
+ virtual void* operator()(void* anObject) {
+ CNamedEntity *theEntity=(CNamedEntity*)anObject;
+ delete theEntity;
+ return 0;
+ }
+ };
+#endif
/**
*
@@ -440,14 +439,18 @@ nsDTDContext::~nsDTDContext() {
delete theState;
}
+#ifdef DEBUG
CEntityDeallocator theDeallocator;
mEntities.ForEach(theDeallocator);
if(mCounters) {
delete [] mCounters;
mCounters = 0;
}
+#endif
+
}
+#ifdef DEBUG
CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
PRInt32 theCount=mEntities.GetSize();
@@ -489,7 +492,6 @@ CNamedEntity* nsDTDContext::RegisterEntity(const nsString& aName,const nsString
return theEntity;
}
-
/****************************************************************
The abacus class is useful today for debug purposes, but it
will eventually serve as the implementation for css counters.
@@ -902,6 +904,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
return result;
}
+#endif
/**
*
diff --git a/mozilla/htmlparser/src/nsDTDUtils.h b/mozilla/htmlparser/src/nsDTDUtils.h
index 3f0dea10bc1..bf431db093d 100644
--- a/mozilla/htmlparser/src/nsDTDUtils.h
+++ b/mozilla/htmlparser/src/nsDTDUtils.h
@@ -230,7 +230,7 @@ public:
CTableState *mPrevious;
};
-
+#ifdef DEBUG
//used for named entities and counters (XXX debug only)
class CNamedEntity {
public:
@@ -257,7 +257,7 @@ public:
nsString mValue;
PRInt32 mOrdinal;
};
-
+#endif
/************************************************************************
nsTokenAllocator class implementation.
This class is used to recycle tokens.
@@ -354,13 +354,6 @@ public:
static void ReleaseGlobalObjects(void);
- CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
- CNamedEntity* GetEntity(const nsString& aName)const;
-
- void ResetCounters(void);
- void AllocateCounters(void);
- PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
-
void SetTokenAllocator(nsTokenAllocator* aTokenAllocator) { mTokenAllocator=aTokenAllocator; }
void SetNodeAllocator(nsNodeAllocator* aNodeAllocator) { mNodeAllocator=aNodeAllocator; }
@@ -385,12 +378,19 @@ public:
nsTokenAllocator *mTokenAllocator;
nsNodeAllocator *mNodeAllocator;
CTableState *mTableStates;
- PRInt32 *mCounters;
nsDeque mEntities;
#ifdef NS_DEBUG
enum { eMaxTags = 100 };
eHTMLTags mXTags[eMaxTags];
+ PRInt32 *mCounters;
+
+ void ResetCounters(void);
+ void AllocateCounters(void);
+ PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
+
+ CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
+ CNamedEntity* GetEntity(const nsString& aName)const;
#endif
};
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index 6fbb3e015a6..3c5474218f0 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -397,7 +397,10 @@ nsresult CNavDTD::WillBuildModel( const CParserContext& aParserContext,nsIConte
STOP_TIMER();
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::WillBuildModel(), this=%p\n", this));
+#ifdef DEBUG
mBodyContext->ResetCounters();
+#endif
+
mDocType=aParserContext.mDocType;
if(aSink && (!mSink)) {
@@ -982,6 +985,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
break;
+#ifdef DEBUG
case eHTMLTag_counter:
{
PRInt32 theCount=mBodyContext->GetCount();
@@ -1026,6 +1030,7 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
}
break;
+#endif
default:
break;
@@ -2126,21 +2131,24 @@ nsresult CNavDTD::HandleEntityToken(CToken* aToken) {
nsAutoString theStr(aToken->GetStringValue());
PRUnichar theChar=theStr.CharAt(0);
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
-
+ CToken *theToken=0;
+#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...
CNamedEntity *theEntity=mBodyContext->GetEntity(theStr);
- CToken *theToken=0;
if(theEntity) {
- theToken=NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue));
+ theToken = NS_STATIC_CAST(CTextToken*,mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue));
}
else {
+#endif
//if you're here we have a bogus entity.
//convert it into a text token.
nsAutoString entityName;
entityName.Assign(NS_LITERAL_STRING("&"));
entityName.Append(theStr); //should append the entity name; fix bug 51161.
theToken = mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,entityName);
+#ifdef DEBUG
}
+#endif
return HandleToken(theToken,mParser); //theToken should get recycled automagically...
}
@@ -3225,20 +3233,22 @@ nsresult CNavDTD::OpenForm(const nsIParserNode *aNode){
nsresult CNavDTD::CloseForm(const nsIParserNode *aNode){
// NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
nsresult result=NS_OK;
- if((mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM) && (mOpenFormCount == 1)) {
- mFlags &= ~NS_PARSER_FLAG_HAS_OPEN_FORM;
+ if(mFlags & NS_PARSER_FLAG_HAS_OPEN_FORM) {
+ if (mOpenFormCount == 1) {
+ mFlags &= ~NS_PARSER_FLAG_HAS_OPEN_FORM;
- STOP_TIMER();
- MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
+ STOP_TIMER();
+ MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
- result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
+ result=(mSink) ? mSink->CloseForm(*aNode) : NS_OK;
- MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
- START_TIMER();
+ MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::CloseForm(), this=%p\n", this));
+ START_TIMER();
- mFlags &= ~NS_PARSER_FLAG_IS_FORM_CONTAINER;
+ mFlags &= ~NS_PARSER_FLAG_IS_FORM_CONTAINER;
+ }
+ --mOpenFormCount;
}
- --mOpenFormCount;
return result;
}
diff --git a/mozilla/parser/htmlparser/src/COtherDTD.cpp b/mozilla/parser/htmlparser/src/COtherDTD.cpp
index 6ddc4c87df3..169aab02185 100644
--- a/mozilla/parser/htmlparser/src/COtherDTD.cpp
+++ b/mozilla/parser/htmlparser/src/COtherDTD.cpp
@@ -355,7 +355,9 @@ nsresult COtherDTD::WillBuildModel( const CParserContext& aParserContext,nsICon
if(result==NS_OK) {
result = aSink->WillBuildModel();
+#ifdef DEBUG
mBodyContext->ResetCounters();
+#endif
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: COtherDTD::WillBuildModel(), this=%p\n", this));
START_TIMER();
@@ -574,6 +576,7 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
break;
+#ifdef DEBUG
case eHTMLTag_meta:
{
//we should only enable user-defined entities in debug builds...
@@ -602,6 +605,7 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
}
}
break;
+#endif
default:
break;
@@ -840,19 +844,23 @@ nsresult COtherDTD::HandleEntityToken(CToken* aToken) {
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
+#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...
CNamedEntity *theEntity=mBodyContext->GetEntity(theStr);
if(theEntity) {
theToken=(CTextToken*)mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,theEntity->mValue);
}
else {
+#endif
//if you're here we have a bogus entity.
//convert it into a text token.
nsAutoString entityName;
entityName.Assign(NS_LITERAL_STRING("&"));
entityName.Append(theStr); //should append the entity name; fix bug 51161.
theToken=(CTextToken*)mTokenAllocator->CreateTokenOfType(eToken_text,eHTMLTag_text,entityName);
+#ifdef DEBUG
}
+#endif
result=HandleStartToken(theToken);
}
else {
diff --git a/mozilla/parser/htmlparser/src/COtherElements.h b/mozilla/parser/htmlparser/src/COtherElements.h
index 17699c49b11..53f5478bf30 100644
--- a/mozilla/parser/htmlparser/src/COtherElements.h
+++ b/mozilla/parser/htmlparser/src/COtherElements.h
@@ -1016,14 +1016,18 @@ public:
PRInt32 theCount=aContext->GetCount();
eHTMLTags theGrandParentTag=aContext->TagAt(theCount-2);
- nsCParserNode *theNode=(nsCParserNode*)aNode;
+ nsCParserNode *theNode = (nsCParserNode*)aNode;
+
+#ifdef DEBUG
nsAutoString theNumber;
aContext->IncrementCounter(theGrandParentTag,*theNode,theNumber);
CTextToken theToken(theNumber);
PRInt32 theLineNumber=0;
nsCParserNode theNewNode(&theToken,theLineNumber,0 /*stack token*/);
- result=aSink->AddLeaf(theNewNode);
+ *theNode = theNewNode;
+#endif
+ result=aSink->AddLeaf(*theNode);
return result;
}
diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp
index e7cdb3e1d57..fa59b793200 100644
--- a/mozilla/parser/htmlparser/src/nsDTDUtils.cpp
+++ b/mozilla/parser/htmlparser/src/nsDTDUtils.cpp
@@ -404,27 +404,26 @@ nsDTDContext::nsDTDContext() : mStack(), mEntities(0){
mResidualStyleCount=0;
mContextTopIndex=-1;
mTableStates=0;
- mCounters=0;
mTokenAllocator=0;
mNodeAllocator=0;
mAllBits=0;
-#ifdef NS_DEBUG
+#ifdef DEBUG
memset(mXTags,0,sizeof(mXTags));
+ mCounters = 0;
#endif
}
-
-
-class CEntityDeallocator: public nsDequeFunctor{
-public:
- virtual void* operator()(void* anObject) {
- CNamedEntity *theEntity=(CNamedEntity*)anObject;
- delete theEntity;
- return 0;
- }
-};
-
+#ifdef DEBUG
+ class CEntityDeallocator: public nsDequeFunctor{
+ public:
+ virtual void* operator()(void* anObject) {
+ CNamedEntity *theEntity=(CNamedEntity*)anObject;
+ delete theEntity;
+ return 0;
+ }
+ };
+#endif
/**
*
@@ -440,14 +439,18 @@ nsDTDContext::~nsDTDContext() {
delete theState;
}
+#ifdef DEBUG
CEntityDeallocator theDeallocator;
mEntities.ForEach(theDeallocator);
if(mCounters) {
delete [] mCounters;
mCounters = 0;
}
+#endif
+
}
+#ifdef DEBUG
CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
PRInt32 theCount=mEntities.GetSize();
@@ -489,7 +492,6 @@ CNamedEntity* nsDTDContext::RegisterEntity(const nsString& aName,const nsString
return theEntity;
}
-
/****************************************************************
The abacus class is useful today for debug purposes, but it
will eventually serve as the implementation for css counters.
@@ -902,6 +904,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
return result;
}
+#endif
/**
*
diff --git a/mozilla/parser/htmlparser/src/nsDTDUtils.h b/mozilla/parser/htmlparser/src/nsDTDUtils.h
index 3f0dea10bc1..bf431db093d 100644
--- a/mozilla/parser/htmlparser/src/nsDTDUtils.h
+++ b/mozilla/parser/htmlparser/src/nsDTDUtils.h
@@ -230,7 +230,7 @@ public:
CTableState *mPrevious;
};
-
+#ifdef DEBUG
//used for named entities and counters (XXX debug only)
class CNamedEntity {
public:
@@ -257,7 +257,7 @@ public:
nsString mValue;
PRInt32 mOrdinal;
};
-
+#endif
/************************************************************************
nsTokenAllocator class implementation.
This class is used to recycle tokens.
@@ -354,13 +354,6 @@ public:
static void ReleaseGlobalObjects(void);
- CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
- CNamedEntity* GetEntity(const nsString& aName)const;
-
- void ResetCounters(void);
- void AllocateCounters(void);
- PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
-
void SetTokenAllocator(nsTokenAllocator* aTokenAllocator) { mTokenAllocator=aTokenAllocator; }
void SetNodeAllocator(nsNodeAllocator* aNodeAllocator) { mNodeAllocator=aNodeAllocator; }
@@ -385,12 +378,19 @@ public:
nsTokenAllocator *mTokenAllocator;
nsNodeAllocator *mNodeAllocator;
CTableState *mTableStates;
- PRInt32 *mCounters;
nsDeque mEntities;
#ifdef NS_DEBUG
enum { eMaxTags = 100 };
eHTMLTags mXTags[eMaxTags];
+ PRInt32 *mCounters;
+
+ void ResetCounters(void);
+ void AllocateCounters(void);
+ PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
+
+ CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
+ CNamedEntity* GetEntity(const nsString& aName)const;
#endif
};