Removed mDoctypeText from nsExpatDriver. This |could| improve Ts/Txul time slightly. b=102345, r=heikki, sr=jst
This commit is contained in:
Родитель
cfb87cef22
Коммит
a1ce884f46
|
@ -1425,7 +1425,9 @@ nsXMLContentSink::HandleComment(const PRUnichar *aName)
|
|||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXMLContentSink::HandleCDataSection(const PRUnichar *aData, PRUint32 aLength)
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleCDataSection(const PRUnichar *aData,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
FlushText();
|
||||
|
||||
|
@ -1456,7 +1458,8 @@ NS_IMETHODIMP nsXMLContentSink::HandleCDataSection(const PRUnichar *aData, PRUin
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSink::HandleDoctypeDecl(const PRUnichar *aDoctype)
|
||||
nsXMLContentSink::HandleDoctypeDecl(const PRUnichar *aDoctype,
|
||||
PRUint32 aLength)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -1464,12 +1467,8 @@ nsXMLContentSink::HandleDoctypeDecl(const PRUnichar *aDoctype)
|
|||
if (!doc)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString docTypeStr(aDoctype);
|
||||
nsAutoString str, name, publicId, systemId;
|
||||
|
||||
if (Substring(docTypeStr, 0, 9).Equals(NS_LITERAL_STRING("<!DOCTYPE"))) {
|
||||
docTypeStr.Right(str, docTypeStr.Length()-9);
|
||||
}
|
||||
nsAutoString str(aDoctype, aLength);
|
||||
nsAutoString name, publicId, systemId;
|
||||
|
||||
GetDocTypeToken(str, name, PR_FALSE);
|
||||
|
||||
|
@ -1484,8 +1483,7 @@ nsXMLContentSink::HandleDoctypeDecl(const PRUnichar *aDoctype)
|
|||
GetDocTypeToken(str, systemId, PR_TRUE);
|
||||
}
|
||||
|
||||
// The rest is the internal subset (minus whitespace and the trailing >)
|
||||
str.Truncate(str.Length()-1); // Delete the trailing >
|
||||
// The rest is the internal subset (minus whitespace)
|
||||
str.Trim(kWhitespace);
|
||||
|
||||
nsCOMPtr<nsIDOMDocumentType> oldDocType;
|
||||
|
|
|
@ -1025,7 +1025,7 @@ XULContentSinkImpl::HandleCDataSection(const PRUnichar *aData, PRUint32 aLength)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULContentSinkImpl::HandleDoctypeDecl(const PRUnichar *aDoctype)
|
||||
XULContentSinkImpl::HandleDoctypeDecl(const PRUnichar *aDoctype, PRUint32 aLength)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ interface nsIExpatSink : nsISupports
|
|||
void HandleCDataSection(in wstring aData,
|
||||
in unsigned long aLength);
|
||||
|
||||
void HandleDoctypeDecl(in wstring aDoctype);
|
||||
void HandleDoctypeDecl(in wstring aDoctype,
|
||||
in unsigned long aLength);
|
||||
|
||||
void HandleCharacterData(in wstring aData,
|
||||
in unsigned long aLength);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "prmem.h"
|
||||
#include "nsTextFormatter.h"
|
||||
|
||||
static const PRUint32 kNotInDoctype = PRUint32(-1);
|
||||
static const char* kDTDDirectory = "dtd/";
|
||||
|
||||
/***************************** EXPAT CALL BACKS *******************************/
|
||||
|
@ -235,11 +236,12 @@ NS_NewExpatDriver(nsIDTD** aResult) {
|
|||
nsExpatDriver::nsExpatDriver()
|
||||
:mExpatParser(0),
|
||||
mSink(0),
|
||||
mInDoctype(0),
|
||||
mBuffer(0),
|
||||
mInCData(0),
|
||||
mBytesParsed(0),
|
||||
mBytePosition(0),
|
||||
mInternalState(NS_OK)
|
||||
mInternalState(NS_OK),
|
||||
mDoctypePos(-1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -305,13 +307,7 @@ nsExpatDriver::HandleComment(const PRUnichar *aValue)
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
if (mInDoctype) {
|
||||
// We do not want comments popping out of the doctype...
|
||||
mDoctypeText.Append(NS_LITERAL_STRING("<!--"));
|
||||
mDoctypeText.Append(aValue);
|
||||
mDoctypeText.Append(NS_LITERAL_STRING("-->"));
|
||||
}
|
||||
else if (mSink){
|
||||
if (mSink && mDoctypePos == kNotInDoctype){
|
||||
mInternalState = mSink->HandleComment(aValue);
|
||||
}
|
||||
|
||||
|
@ -341,10 +337,7 @@ nsExpatDriver::HandleDefault(const PRUnichar *aValue,
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
if (mInDoctype) {
|
||||
mDoctypeText.Append(aValue, aLength);
|
||||
}
|
||||
else if (mSink) {
|
||||
if (mSink && mDoctypePos == kNotInDoctype) {
|
||||
static const PRUnichar newline[] = {'\n','\0'};
|
||||
for (PRUint32 i = 0; i < aLength && NS_SUCCEEDED(mInternalState); i++) {
|
||||
if (aValue[i] == '\n' || aValue[i] == '\r') {
|
||||
|
@ -380,8 +373,7 @@ nsExpatDriver::HandleEndCdataSection()
|
|||
nsresult
|
||||
nsExpatDriver::HandleStartDoctypeDecl()
|
||||
{
|
||||
mInDoctype = PR_TRUE;
|
||||
mDoctypeText.Assign(NS_LITERAL_STRING("<!DOCTYPE "));
|
||||
mDoctypePos = XML_GetCurrentByteIndex(mExpatParser);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -390,14 +382,15 @@ nsExpatDriver::HandleEndDoctypeDecl()
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
mInDoctype = PR_FALSE;
|
||||
mDoctypeText.Append(PRUnichar('>'));
|
||||
|
||||
const PRUnichar* doctypeStart = mBuffer + ( mDoctypePos - mBytesParsed ) / 2;
|
||||
const PRUnichar* doctypeEnd = mBuffer + ( XML_GetCurrentByteIndex(mExpatParser) - mBytesParsed ) / 2;
|
||||
|
||||
if(mSink) {
|
||||
mInternalState = mSink->HandleDoctypeDecl(mDoctypeText.get());
|
||||
mInternalState = mSink->HandleDoctypeDecl(doctypeStart, doctypeEnd - doctypeStart);
|
||||
}
|
||||
|
||||
mDoctypeText.Truncate();
|
||||
mDoctypePos = kNotInDoctype;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -730,9 +723,9 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner,
|
|||
|
||||
while (start != end) {
|
||||
PRUint32 fragLength = PRUint32(start.size_forward());
|
||||
const PRUnichar* expatBuffer = start.get();
|
||||
mBuffer = start.get();
|
||||
|
||||
mInternalState = ParseBuffer((const char *)expatBuffer,
|
||||
mInternalState = ParseBuffer((const char *)mBuffer,
|
||||
fragLength * sizeof(PRUnichar),
|
||||
aFlushTokens);
|
||||
|
||||
|
|
|
@ -82,16 +82,19 @@ protected:
|
|||
nsresult HandleError(const char *aBuffer, PRUint32 aLength, PRBool aIsFinal);
|
||||
void GetLine(const char* aSourceBuffer, PRUint32 aLength, PRUint32 aOffset, nsString& aLine);
|
||||
|
||||
XML_Parser mExpatParser;
|
||||
nsIExpatSink* mSink;
|
||||
nsString mLastLine;
|
||||
nsString mDoctypeText;
|
||||
nsString mCDataText;
|
||||
PRPackedBool mInDoctype;
|
||||
PRPackedBool mInCData;
|
||||
PRUint32 mBytesParsed;
|
||||
PRInt32 mBytePosition;
|
||||
nsresult mInternalState;
|
||||
XML_Parser mExpatParser;
|
||||
nsIExpatSink* mSink;
|
||||
const PRUnichar* mBuffer; // weak
|
||||
|
||||
nsString mLastLine;
|
||||
nsString mCDataText;
|
||||
PRPackedBool mInCData;
|
||||
PRInt32 mBytePosition;
|
||||
nsresult mInternalState;
|
||||
PRUint32 mBytesParsed;
|
||||
PRUint32 mDoctypePos;
|
||||
|
||||
|
||||
};
|
||||
nsresult NS_NewExpatDriver(nsIDTD** aDriver);
|
||||
|
||||
|
|
|
@ -1877,7 +1877,7 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk, PRBo
|
|||
DidBuildModel(mStreamStatus);
|
||||
mInternalState = result;
|
||||
}
|
||||
break;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
else if(((NS_OK==result) && (theTokenizerResult==kEOF)) || (result==NS_ERROR_HTMLPARSER_INTERRUPTED)){
|
||||
|
|
|
@ -54,7 +54,8 @@ interface nsIExpatSink : nsISupports
|
|||
void HandleCDataSection(in wstring aData,
|
||||
in unsigned long aLength);
|
||||
|
||||
void HandleDoctypeDecl(in wstring aDoctype);
|
||||
void HandleDoctypeDecl(in wstring aDoctype,
|
||||
in unsigned long aLength);
|
||||
|
||||
void HandleCharacterData(in wstring aData,
|
||||
in unsigned long aLength);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "prmem.h"
|
||||
#include "nsTextFormatter.h"
|
||||
|
||||
static const PRUint32 kNotInDoctype = PRUint32(-1);
|
||||
static const char* kDTDDirectory = "dtd/";
|
||||
|
||||
/***************************** EXPAT CALL BACKS *******************************/
|
||||
|
@ -235,11 +236,12 @@ NS_NewExpatDriver(nsIDTD** aResult) {
|
|||
nsExpatDriver::nsExpatDriver()
|
||||
:mExpatParser(0),
|
||||
mSink(0),
|
||||
mInDoctype(0),
|
||||
mBuffer(0),
|
||||
mInCData(0),
|
||||
mBytesParsed(0),
|
||||
mBytePosition(0),
|
||||
mInternalState(NS_OK)
|
||||
mInternalState(NS_OK),
|
||||
mDoctypePos(-1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
@ -305,13 +307,7 @@ nsExpatDriver::HandleComment(const PRUnichar *aValue)
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
if (mInDoctype) {
|
||||
// We do not want comments popping out of the doctype...
|
||||
mDoctypeText.Append(NS_LITERAL_STRING("<!--"));
|
||||
mDoctypeText.Append(aValue);
|
||||
mDoctypeText.Append(NS_LITERAL_STRING("-->"));
|
||||
}
|
||||
else if (mSink){
|
||||
if (mSink && mDoctypePos == kNotInDoctype){
|
||||
mInternalState = mSink->HandleComment(aValue);
|
||||
}
|
||||
|
||||
|
@ -341,10 +337,7 @@ nsExpatDriver::HandleDefault(const PRUnichar *aValue,
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
if (mInDoctype) {
|
||||
mDoctypeText.Append(aValue, aLength);
|
||||
}
|
||||
else if (mSink) {
|
||||
if (mSink && mDoctypePos == kNotInDoctype) {
|
||||
static const PRUnichar newline[] = {'\n','\0'};
|
||||
for (PRUint32 i = 0; i < aLength && NS_SUCCEEDED(mInternalState); i++) {
|
||||
if (aValue[i] == '\n' || aValue[i] == '\r') {
|
||||
|
@ -380,8 +373,7 @@ nsExpatDriver::HandleEndCdataSection()
|
|||
nsresult
|
||||
nsExpatDriver::HandleStartDoctypeDecl()
|
||||
{
|
||||
mInDoctype = PR_TRUE;
|
||||
mDoctypeText.Assign(NS_LITERAL_STRING("<!DOCTYPE "));
|
||||
mDoctypePos = XML_GetCurrentByteIndex(mExpatParser);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -390,14 +382,15 @@ nsExpatDriver::HandleEndDoctypeDecl()
|
|||
{
|
||||
NS_ASSERTION(mSink, "content sink not found!");
|
||||
|
||||
mInDoctype = PR_FALSE;
|
||||
mDoctypeText.Append(PRUnichar('>'));
|
||||
|
||||
const PRUnichar* doctypeStart = mBuffer + ( mDoctypePos - mBytesParsed ) / 2;
|
||||
const PRUnichar* doctypeEnd = mBuffer + ( XML_GetCurrentByteIndex(mExpatParser) - mBytesParsed ) / 2;
|
||||
|
||||
if(mSink) {
|
||||
mInternalState = mSink->HandleDoctypeDecl(mDoctypeText.get());
|
||||
mInternalState = mSink->HandleDoctypeDecl(doctypeStart, doctypeEnd - doctypeStart);
|
||||
}
|
||||
|
||||
mDoctypeText.Truncate();
|
||||
mDoctypePos = kNotInDoctype;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -730,9 +723,9 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner,
|
|||
|
||||
while (start != end) {
|
||||
PRUint32 fragLength = PRUint32(start.size_forward());
|
||||
const PRUnichar* expatBuffer = start.get();
|
||||
mBuffer = start.get();
|
||||
|
||||
mInternalState = ParseBuffer((const char *)expatBuffer,
|
||||
mInternalState = ParseBuffer((const char *)mBuffer,
|
||||
fragLength * sizeof(PRUnichar),
|
||||
aFlushTokens);
|
||||
|
||||
|
|
|
@ -82,16 +82,19 @@ protected:
|
|||
nsresult HandleError(const char *aBuffer, PRUint32 aLength, PRBool aIsFinal);
|
||||
void GetLine(const char* aSourceBuffer, PRUint32 aLength, PRUint32 aOffset, nsString& aLine);
|
||||
|
||||
XML_Parser mExpatParser;
|
||||
nsIExpatSink* mSink;
|
||||
nsString mLastLine;
|
||||
nsString mDoctypeText;
|
||||
nsString mCDataText;
|
||||
PRPackedBool mInDoctype;
|
||||
PRPackedBool mInCData;
|
||||
PRUint32 mBytesParsed;
|
||||
PRInt32 mBytePosition;
|
||||
nsresult mInternalState;
|
||||
XML_Parser mExpatParser;
|
||||
nsIExpatSink* mSink;
|
||||
const PRUnichar* mBuffer; // weak
|
||||
|
||||
nsString mLastLine;
|
||||
nsString mCDataText;
|
||||
PRPackedBool mInCData;
|
||||
PRInt32 mBytePosition;
|
||||
nsresult mInternalState;
|
||||
PRUint32 mBytesParsed;
|
||||
PRUint32 mDoctypePos;
|
||||
|
||||
|
||||
};
|
||||
nsresult NS_NewExpatDriver(nsIDTD** aDriver);
|
||||
|
||||
|
|
|
@ -1877,7 +1877,7 @@ nsresult nsParser::ResumeParse(PRBool allowIteration, PRBool aIsFinalChunk, PRBo
|
|||
DidBuildModel(mStreamStatus);
|
||||
mInternalState = result;
|
||||
}
|
||||
break;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
else if(((NS_OK==result) && (theTokenizerResult==kEOF)) || (result==NS_ERROR_HTMLPARSER_INTERRUPTED)){
|
||||
|
|
|
@ -603,7 +603,7 @@ RDFContentSinkImpl::HandleCDataSection(const PRUnichar *aData,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFContentSinkImpl::HandleDoctypeDecl(const PRUnichar *aDoctype)
|
||||
RDFContentSinkImpl::HandleDoctypeDecl(const PRUnichar *aDoctype, PRUint32 aLength)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче