зеркало из https://github.com/mozilla/gecko-dev.git
bug 275288: remove obsolete CRC calculations. r+sr=roc
This commit is contained in:
Родитель
0e05c4d8d4
Коммит
f22c99b2f1
|
@ -35,7 +35,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
//#define ENABLE_CRC
|
||||
//#define ALLOW_TR_AS_CHILD_OF_TABLE //by setting this to true, TR is allowable directly in TABLE.
|
||||
|
||||
#define ENABLE_RESIDUALSTYLE
|
||||
|
@ -83,13 +82,8 @@ static const char kNullToken[] = "Error: Null token given";
|
|||
static const char kInvalidTagStackPos[] = "Error: invalid tag stack position";
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
static char gShowCRC;
|
||||
#endif
|
||||
|
||||
#include "nsElementTable.h"
|
||||
|
||||
|
||||
#ifdef MOZ_PERF_METRICS
|
||||
# define START_TIMER() \
|
||||
if(mParser) MOZ_TIMER_START(mParser->mParseTime); \
|
||||
|
@ -179,10 +173,6 @@ CNavDTD::CNavDTD() : nsIDTD(),
|
|||
mLineNumber(1),
|
||||
mOpenMapCount(0),
|
||||
mFlags(NS_DTD_FLAG_NONE)
|
||||
#ifdef ENABLE_CRC
|
||||
,mComputedCRC32(0),
|
||||
mExpectedCRC32(0)
|
||||
#endif
|
||||
{
|
||||
mBodyContext=new nsDTDContext();
|
||||
}
|
||||
|
@ -393,11 +383,6 @@ nsresult CNavDTD::WillBuildModel(const CParserContext& aParserContext,
|
|||
mFlags |= NS_IPARSER_FLAG_SCRIPT_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
mComputedCRC32=0;
|
||||
mExpectedCRC32=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -591,43 +576,8 @@ nsresult CNavDTD::DidBuildModel(nsresult anErrorCode,
|
|||
}
|
||||
}
|
||||
|
||||
STOP_TIMER();
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: Parse Time: CNavDTD::DidBuildModel(), this=%p\n", this));
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
|
||||
//let's only grab this state once!
|
||||
if (!gShowCRC) {
|
||||
gShowCRC=1; //this only indicates we'll not initialize again.
|
||||
char* theEnvString = PR_GetEnv("RICKG_CRC");
|
||||
if (theEnvString){
|
||||
if (('1'== theEnvString[0]) || ('Y'== theEnvString[0]) || ('y'== theEnvString[0])){
|
||||
gShowCRC=2; //this indicates that the CRC flag was found in the environment.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (2 == gShowCRC) {
|
||||
if (mComputedCRC32 != mExpectedCRC32) {
|
||||
if (mExpectedCRC32 != 0) {
|
||||
printf("CRC Computed: %u Expected CRC: %u\n,",mComputedCRC32,mExpectedCRC32);
|
||||
result = aSink->DidBuildModel();
|
||||
}
|
||||
else {
|
||||
printf("Computed CRC: %u.\n",mComputedCRC32);
|
||||
result = aSink->DidBuildModel();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
MOZ_TIMER_DEBUGLOG(("Start: Parse Time: CNavDTD::DidBuildModel(), this=%p\n", this));
|
||||
START_TIMER();
|
||||
|
||||
//Now make sure the misplaced content list is empty,
|
||||
//by forcefully recycling any tokens we might find there.
|
||||
|
||||
//Now make sure the misplaced content list is empty,
|
||||
//by forcefully recycling any tokens we might find there.
|
||||
CToken* theToken = 0;
|
||||
while ((theToken = (CToken*)mMisplacedContent.Pop())) {
|
||||
IF_FREE(theToken, mTokenAllocator);
|
||||
|
@ -1428,35 +1378,6 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
|
|||
START_TIMER()
|
||||
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
|
||||
STOP_TIMER()
|
||||
|
||||
if(eHTMLTag_meta==aTag) {
|
||||
PRInt32 theCount=aNode.GetAttributeCount();
|
||||
if(1<theCount){
|
||||
|
||||
const nsAString& theKey = aNode.GetKeyAt(0);
|
||||
if(theKey.Equals("NAME",IGNORE_CASE)) {
|
||||
const nsString& theValue1=aNode.GetValueAt(0);
|
||||
if(theValue1.Equals("\"CRC\"",IGNORE_CASE)) {
|
||||
const nsAString& theKey2 = aNode.GetKeyAt(1);
|
||||
if(theKey2.Equals("CONTENT",IGNORE_CASE)) {
|
||||
const nsString& theValue2=aNode.GetValueAt(1);
|
||||
PRInt32 err=0;
|
||||
mExpectedCRC32=theValue2.ToInteger(&err);
|
||||
} //if
|
||||
} //if
|
||||
} //else
|
||||
|
||||
} //if
|
||||
}//if
|
||||
|
||||
START_TIMER()
|
||||
|
||||
#endif
|
||||
|
||||
if(NS_OK==result) {
|
||||
result=gHTMLElements[aTag].HasSpecialProperty(kDiscardTag) ? 1 : NS_OK;
|
||||
}
|
||||
|
@ -3275,12 +3196,6 @@ CNavDTD::OpenContainer(const nsCParserNode *aNode,
|
|||
OpenTransientStyles(aTag);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
#define K_OPENOP 100
|
||||
CRCStruct theStruct(aTag,K_OPENOP);
|
||||
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
|
||||
#endif
|
||||
|
||||
switch (aTag) {
|
||||
case eHTMLTag_html:
|
||||
result=OpenHTML(aNode); break;
|
||||
|
@ -3384,11 +3299,6 @@ nsresult
|
|||
CNavDTD::CloseContainer(const eHTMLTags aTag, eHTMLTags aTarget,PRBool aClosedByStartTag)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
#ifdef ENABLE_CRC
|
||||
#define K_CLOSEOP 200
|
||||
CRCStruct theStruct(nodeType,K_CLOSEOP);
|
||||
mComputedCRC32=AccumulateCRC(mComputedCRC32,(char*)&theStruct,sizeof(theStruct));
|
||||
#endif
|
||||
|
||||
switch (aTag) {
|
||||
|
||||
|
|
|
@ -395,11 +395,6 @@ protected:
|
|||
PRInt32 mOpenMapCount;
|
||||
|
||||
PRUint16 mFlags;
|
||||
|
||||
#ifdef ENABLE_CRC
|
||||
PRUint32 mComputedCRC32;
|
||||
PRUint32 mExpectedCRC32;
|
||||
#endif
|
||||
};
|
||||
|
||||
inline nsresult NS_NewNavHTMLDTD(nsIDTD** aInstancePtrResult)
|
||||
|
|
|
@ -1485,48 +1485,6 @@ void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char*
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* The table lookup technique was adapted from the algorithm described *
|
||||
* by Avram Perez, Byte-wise CRC Calculations, IEEE Micro 3, 40 (1983). *
|
||||
*************************************************************************/
|
||||
|
||||
#define POLYNOMIAL 0x04c11db7L
|
||||
|
||||
static PRBool crc_table_initialized;
|
||||
static PRUint32 crc_table[256];
|
||||
|
||||
static void gen_crc_table() {
|
||||
/* generate the table of CRC remainders for all possible bytes */
|
||||
int i, j;
|
||||
PRUint32 crc_accum;
|
||||
for ( i = 0; i < 256; i++ ) {
|
||||
crc_accum = ( (unsigned long) i << 24 );
|
||||
for ( j = 0; j < 8; j++ ) {
|
||||
if ( crc_accum & 0x80000000L )
|
||||
crc_accum = ( crc_accum << 1 ) ^ POLYNOMIAL;
|
||||
else crc_accum = ( crc_accum << 1 );
|
||||
}
|
||||
crc_table[i] = crc_accum;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PRUint32 AccumulateCRC(PRUint32 crc_accum, char *data_blk_ptr, int data_blk_size) {
|
||||
if (!crc_table_initialized) {
|
||||
gen_crc_table();
|
||||
crc_table_initialized = PR_TRUE;
|
||||
}
|
||||
|
||||
/* update the CRC on the data block one byte at a time */
|
||||
int i, j;
|
||||
for ( j = 0; j < data_blk_size; j++ ) {
|
||||
i = ( (int) ( crc_accum >> 24) ^ *data_blk_ptr++ ) & 0xff;
|
||||
crc_accum = ( crc_accum << 8 ) ^ crc_table[i];
|
||||
}
|
||||
return crc_accum;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
This defines the topic object used by the observer service.
|
||||
The observerService uses a list of these, 1 per topic when
|
||||
|
|
|
@ -96,9 +96,6 @@ class nsNodeAllocator;
|
|||
void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
|
||||
void DebugDumpContainmentRules2(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
|
||||
#endif
|
||||
PRUint32 AccumulateCRC(PRUint32 crc_accum, char *data_blk_ptr, int data_blk_size);
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
First, define the tagstack class
|
||||
|
@ -471,16 +468,6 @@ inline PRBool FindTagInSet(PRInt32 aTag,const eHTMLTags *aTagSet,PRInt32 aCount)
|
|||
return PRBool(-1<IndexOfTagInSet(aTag,aTagSet,aCount));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
This little structure is used to compute CRC32 values for our debug validator
|
||||
******************************************************************************/
|
||||
|
||||
struct CRCStruct {
|
||||
CRCStruct(eHTMLTags aTag,PRInt32 anOp) {mTag=aTag; mOperation=anOp;}
|
||||
eHTMLTags mTag;
|
||||
PRInt32 mOperation; //usually open or close
|
||||
};
|
||||
|
||||
/**************************************************************
|
||||
This defines the topic object used by the observer service.
|
||||
The observerService uses a list of these, 1 per topic when
|
||||
|
|
Загрузка…
Ссылка в новой задаче