Putting back the change that I just backed outsince it doesn't affect xul window performance. a=sheriff

This commit is contained in:
harishd%netscape.com 2002-01-15 00:35:11 +00:00
Родитель 2946992700
Коммит 1806e7df51
4 изменённых файлов: 22 добавлений и 212 удалений

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

@ -164,7 +164,7 @@ Driver_HandleEndDoctypeDecl(void *aUserData)
}
}
#ifdef MALLOC_Driver_HandleExternalEntityRef
PR_STATIC_CALLBACK(int)
Driver_HandleExternalEntityRef(XML_Parser parser,
const XML_Char *openEntityNames,
@ -175,13 +175,11 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
int result = PR_TRUE;
#ifdef XML_DTD
// Load the external entity into a buffer
nsCOMPtr<nsIInputStream> in;
nsAutoString absURL;
nsresult rv = NS_OK;
PRUnichar *uniBuf = nsnull;
PRUint32 retLen = 0;
#ifdef MOZ_SVG
// yuck. I don't know of any other way to do this, though, since we don't
// read external dtd's, and we need the #FIXED xmlns attribute, so we
@ -201,102 +199,18 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
sizeof(svgPublicIdPrefix)-1)) {
uniBuf = ToNewUnicode(svgDtd);
retLen = svgDtd.Length();
} else {
}
else {
#endif
rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_SUCCEEDED(rv) && in)
rv = nsExpatDriver::LoadStream(in, uniBuf, retLen);
nsresult rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_FAILED(rv)) {
return result;
}
#ifdef MOZ_SVG
}
#endif
// Pass the buffer to expat for parsing
if (NS_SUCCEEDED(rv) && uniBuf) {
// Create a parser for parsing the external entity
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, 0,
(const XML_Char*) NS_LITERAL_STRING("UTF-16").get());
if (entParser) {
XML_SetBase(entParser, (const XML_Char*) absURL.get());
result = XML_Parse(entParser, (char *)uniBuf, retLen * sizeof(PRUnichar), 1);
XML_ParserFree(entParser);
}
}
PR_FREEIF(uniBuf);
#else /* ! XML_DTD */
NS_NOTYETIMPLEMENTED("Error: Driver_HandleExternalEntityRef() not yet implemented.");
#endif /* XML_DTD */
return result;
}
nsresult
nsExpatDriver::LoadStream(nsIInputStream* in,
PRUnichar*& uniBuf,
PRUint32& retLen)
{
// read it
PRUint32 aCount = 1024,
bufsize = aCount*sizeof(PRUnichar);
nsCOMPtr<nsIUnicharInputStream> uniIn;
nsresult res = NS_NewUTF8ConverterStream(getter_AddRefs(uniIn),
in, aCount);
if (NS_FAILED(res)) return res;
PRUint32 aReadCount = 0;
PRUnichar *aBuf = (PRUnichar *) PR_Malloc(bufsize);
while (NS_OK == (res=uniIn->Read(aBuf, retLen, aCount, &aReadCount))
&& aReadCount != 0) {
retLen += aReadCount;
#if 1
bufsize += aCount * sizeof(PRUnichar);
aBuf = (PRUnichar *) PR_Realloc(aBuf, bufsize);
#else
if (((aReadCount+32) >= aCount) &&
((retLen+aCount) * sizeof(PRUnichar) >= bufsize)) {
bufsize += aCount * sizeof(PRUnichar);
uniBuf = (PRUnichar *) PR_Realloc(uniBuf, bufsize*sizeof(PRUnichar));
}
#endif
}/* while */
uniBuf = (PRUnichar *) PR_Malloc(retLen*sizeof(PRUnichar));
nsCRT::memcpy(uniBuf, aBuf, sizeof(PRUnichar) * retLen);
PR_FREEIF(aBuf);
return res;
}
#else
static int
=======
PR_STATIC_CALLBACK(int)
Driver_HandleExternalEntityRef(XML_Parser parser,
const XML_Char *openEntityNames,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
int result = PR_TRUE;
#ifdef XML_DTD
// Load the external entity into a buffer
nsCOMPtr<nsIInputStream> in;
nsAutoString absURL;
nsresult rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_FAILED(rv)) {
return result;
}
nsCOMPtr<nsIUnicharInputStream> uniIn;
NS_NewUTF8ConverterStream(getter_AddRefs(uniIn), in, 1024);
@ -328,12 +242,11 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
}
#else // ! XML_DTD
NS_NOTYETIMPLEMENTED("Error: Tokenizer_HandleExternalEntityRef() not yet implemented.");
NS_NOTYETIMPLEMENTED("Error: Driver_HandleExternalEntityRef() not yet implemented.");
#endif // XML_DTD
return result;
}
#endif
/***************************** END CALL BACKS *********************************/

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

@ -45,9 +45,6 @@
#include "nsITokenizer.h"
#include "nsFileSpec.h"
// Testing xul window performance
#define MALLOC_Driver_HandleExternalEntityRef 1
class nsIExpatSink;
class nsExpatDriver : public nsIDTD,
@ -66,11 +63,6 @@ public:
const XML_Char* aBaseURL,
nsIInputStream** in,
nsAString& aAbsURL);
#ifdef MALLOC_Driver_HandleExternalEntityRef
static nsresult LoadStream(nsIInputStream* in,
PRUnichar* &uniBuf,
PRUint32 &retLen);
#endif
nsresult HandleStartElement(const PRUnichar *aName, const PRUnichar **aAtts);
nsresult HandleEndElement(const PRUnichar *aName);

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

@ -164,7 +164,7 @@ Driver_HandleEndDoctypeDecl(void *aUserData)
}
}
#ifdef MALLOC_Driver_HandleExternalEntityRef
PR_STATIC_CALLBACK(int)
Driver_HandleExternalEntityRef(XML_Parser parser,
const XML_Char *openEntityNames,
@ -175,13 +175,11 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
int result = PR_TRUE;
#ifdef XML_DTD
// Load the external entity into a buffer
nsCOMPtr<nsIInputStream> in;
nsAutoString absURL;
nsresult rv = NS_OK;
PRUnichar *uniBuf = nsnull;
PRUint32 retLen = 0;
#ifdef MOZ_SVG
// yuck. I don't know of any other way to do this, though, since we don't
// read external dtd's, and we need the #FIXED xmlns attribute, so we
@ -201,102 +199,18 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
sizeof(svgPublicIdPrefix)-1)) {
uniBuf = ToNewUnicode(svgDtd);
retLen = svgDtd.Length();
} else {
}
else {
#endif
rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_SUCCEEDED(rv) && in)
rv = nsExpatDriver::LoadStream(in, uniBuf, retLen);
nsresult rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_FAILED(rv)) {
return result;
}
#ifdef MOZ_SVG
}
#endif
// Pass the buffer to expat for parsing
if (NS_SUCCEEDED(rv) && uniBuf) {
// Create a parser for parsing the external entity
XML_Parser entParser = XML_ExternalEntityParserCreate(parser, 0,
(const XML_Char*) NS_LITERAL_STRING("UTF-16").get());
if (entParser) {
XML_SetBase(entParser, (const XML_Char*) absURL.get());
result = XML_Parse(entParser, (char *)uniBuf, retLen * sizeof(PRUnichar), 1);
XML_ParserFree(entParser);
}
}
PR_FREEIF(uniBuf);
#else /* ! XML_DTD */
NS_NOTYETIMPLEMENTED("Error: Driver_HandleExternalEntityRef() not yet implemented.");
#endif /* XML_DTD */
return result;
}
nsresult
nsExpatDriver::LoadStream(nsIInputStream* in,
PRUnichar*& uniBuf,
PRUint32& retLen)
{
// read it
PRUint32 aCount = 1024,
bufsize = aCount*sizeof(PRUnichar);
nsCOMPtr<nsIUnicharInputStream> uniIn;
nsresult res = NS_NewUTF8ConverterStream(getter_AddRefs(uniIn),
in, aCount);
if (NS_FAILED(res)) return res;
PRUint32 aReadCount = 0;
PRUnichar *aBuf = (PRUnichar *) PR_Malloc(bufsize);
while (NS_OK == (res=uniIn->Read(aBuf, retLen, aCount, &aReadCount))
&& aReadCount != 0) {
retLen += aReadCount;
#if 1
bufsize += aCount * sizeof(PRUnichar);
aBuf = (PRUnichar *) PR_Realloc(aBuf, bufsize);
#else
if (((aReadCount+32) >= aCount) &&
((retLen+aCount) * sizeof(PRUnichar) >= bufsize)) {
bufsize += aCount * sizeof(PRUnichar);
uniBuf = (PRUnichar *) PR_Realloc(uniBuf, bufsize*sizeof(PRUnichar));
}
#endif
}/* while */
uniBuf = (PRUnichar *) PR_Malloc(retLen*sizeof(PRUnichar));
nsCRT::memcpy(uniBuf, aBuf, sizeof(PRUnichar) * retLen);
PR_FREEIF(aBuf);
return res;
}
#else
static int
=======
PR_STATIC_CALLBACK(int)
Driver_HandleExternalEntityRef(XML_Parser parser,
const XML_Char *openEntityNames,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId)
{
int result = PR_TRUE;
#ifdef XML_DTD
// Load the external entity into a buffer
nsCOMPtr<nsIInputStream> in;
nsAutoString absURL;
nsresult rv = nsExpatDriver::OpenInputStream(systemId, base, getter_AddRefs(in), absURL);
if (NS_FAILED(rv)) {
return result;
}
nsCOMPtr<nsIUnicharInputStream> uniIn;
NS_NewUTF8ConverterStream(getter_AddRefs(uniIn), in, 1024);
@ -328,12 +242,11 @@ Driver_HandleExternalEntityRef(XML_Parser parser,
}
#else // ! XML_DTD
NS_NOTYETIMPLEMENTED("Error: Tokenizer_HandleExternalEntityRef() not yet implemented.");
NS_NOTYETIMPLEMENTED("Error: Driver_HandleExternalEntityRef() not yet implemented.");
#endif // XML_DTD
return result;
}
#endif
/***************************** END CALL BACKS *********************************/

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

@ -45,9 +45,6 @@
#include "nsITokenizer.h"
#include "nsFileSpec.h"
// Testing xul window performance
#define MALLOC_Driver_HandleExternalEntityRef 1
class nsIExpatSink;
class nsExpatDriver : public nsIDTD,
@ -66,11 +63,6 @@ public:
const XML_Char* aBaseURL,
nsIInputStream** in,
nsAString& aAbsURL);
#ifdef MALLOC_Driver_HandleExternalEntityRef
static nsresult LoadStream(nsIInputStream* in,
PRUnichar* &uniBuf,
PRUint32 &retLen);
#endif
nsresult HandleStartElement(const PRUnichar *aName, const PRUnichar **aAtts);
nsresult HandleEndElement(const PRUnichar *aName);