Bug 461031 - Bring a little more sanity to parser notifications of the content sink. This should help increase responsiveness, especially on pages with lots of inline scripts. r+sr=jst

This commit is contained in:
Blake Kaplan 2008-10-30 14:31:00 -07:00
Родитель 32918e20a6
Коммит 5ac270730d
20 изменённых файлов: 45 добавлений и 60 удалений

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

@ -344,7 +344,7 @@ public:
NS_DECL_ISUPPORTS
// nsIContentSink (superclass of nsIHTMLContentSink)
NS_IMETHOD WillTokenize() { return NS_OK; }
NS_IMETHOD WillParse() { return NS_OK; }
NS_IMETHOD WillBuildModel() { return NS_OK; }
NS_IMETHOD DidBuildModel() { return NS_OK; }
NS_IMETHOD WillInterrupt() { return NS_OK; }
@ -360,7 +360,6 @@ public:
NS_IMETHOD EndContext(PRInt32 aPosition) { return NS_OK; }
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn)
{ *aReturn = PR_TRUE; return NS_OK; }
NS_IMETHOD WillProcessTokens() { return NS_OK; }
NS_IMETHOD DidProcessTokens() { return NS_OK; }
NS_IMETHOD WillProcessAToken() { return NS_OK; }
NS_IMETHOD DidProcessAToken() { return NS_OK; }

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

@ -99,7 +99,7 @@ public:
nsAString& aStr);
// nsIContentSink
NS_IMETHOD WillTokenize(void) { return NS_OK; }
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
NS_IMETHOD DidBuildModel(void) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
@ -123,7 +123,6 @@ public:
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD BeginContext(PRInt32 aPosition) { return NS_OK; }
NS_IMETHOD EndContext(PRInt32 aPosition) { return NS_OK; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }

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

@ -1714,7 +1714,7 @@ nsContentSink::DropParserAndPerfHint(void)
}
nsresult
nsContentSink::WillProcessTokensImpl(void)
nsContentSink::WillParseImpl(void)
{
if (mCanInterruptParser) {
mDelayTimerStart = PR_IntervalToMicroseconds(PR_IntervalNow());

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

@ -131,13 +131,13 @@ class nsContentSink : public nsICSSLoaderObserver,
virtual nsresult ProcessMETATag(nsIContent* aContent);
// nsIContentSink implementation helpers
NS_HIDDEN_(nsresult) WillParseImpl(void);
NS_HIDDEN_(nsresult) WillInterruptImpl(void);
NS_HIDDEN_(nsresult) WillResumeImpl(void);
NS_HIDDEN_(nsresult) DidProcessATokenImpl(void);
NS_HIDDEN_(void) WillBuildModelImpl(void);
NS_HIDDEN_(void) DidBuildModelImpl(void);
NS_HIDDEN_(void) DropParserAndPerfHint(void);
NS_HIDDEN_(nsresult) WillProcessTokensImpl(void);
void NotifyAppend(nsIContent* aContent, PRUint32 aStartIndex);

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

@ -96,7 +96,7 @@ public:
nsAString& aStr);
// nsIContentSink
NS_IMETHOD WillTokenize(void) { return NS_OK; }
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
NS_IMETHOD DidBuildModel(void) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }

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

@ -181,7 +181,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsIContentSink
NS_IMETHOD WillTokenize(void);
NS_IMETHOD WillParse(void);
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
NS_IMETHOD WillInterrupt(void);
@ -199,7 +199,6 @@ public:
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
NS_IMETHOD WillProcessTokens(void);
NS_IMETHOD DidProcessTokens(void);
NS_IMETHOD WillProcessAToken(void);
NS_IMETHOD DidProcessAToken(void);
@ -1744,6 +1743,12 @@ HTMLContentSink::Init(nsIDocument* aDoc,
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::WillParse(void)
{
return WillParseImpl();
}
NS_IMETHODIMP
HTMLContentSink::WillBuildModel(void)
{
@ -2696,18 +2701,6 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
return rv;
}
NS_IMETHODIMP
HTMLContentSink::WillTokenize(void)
{
return NS_OK;
}
NS_IMETHODIMP
HTMLContentSink::WillProcessTokens(void)
{
return WillProcessTokensImpl();
}
NS_IMETHODIMP
HTMLContentSink::DidProcessTokens(void)
{
@ -2729,7 +2722,7 @@ HTMLContentSink::DidProcessAToken(void)
NS_IMETHODIMP
HTMLContentSink::WillInterrupt()
{
return WillInterruptImpl();
return WillInterruptImpl();
}
NS_IMETHODIMP

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

@ -87,7 +87,7 @@ public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
// nsIContentSink
NS_IMETHOD WillTokenize(void) { return NS_OK; }
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
NS_IMETHOD WillInterrupt(void);
@ -106,7 +106,6 @@ public:
return NS_OK;
}
NS_IMETHOD_(PRBool) IsFormOnStack() { return PR_FALSE; }
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }

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

@ -205,9 +205,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// nsIContentSink
NS_IMETHODIMP
nsXMLContentSink::WillTokenize(void)
nsXMLContentSink::WillParse(void)
{
return WillProcessTokensImpl();
return WillParseImpl();
}
NS_IMETHODIMP

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

@ -90,7 +90,7 @@ public:
NS_DECL_NSIEXPATSINK
// nsIContentSink
NS_IMETHOD WillTokenize(void);
NS_IMETHOD WillParse(void);
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
NS_IMETHOD WillInterrupt(void);

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

@ -108,7 +108,7 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR
// nsIContentSink
NS_IMETHOD WillTokenize(void) { return NS_OK; }
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(void) { return NS_OK; }
NS_IMETHOD DidBuildModel();
NS_IMETHOD WillInterrupt(void) { return NS_OK; }

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

@ -69,7 +69,7 @@ public:
NS_DECL_NSIEXPATSINK
// nsIContentSink
NS_IMETHOD WillTokenize(void) { return NS_OK; }
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
NS_IMETHOD WillInterrupt(void);

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

@ -65,22 +65,19 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_SINK_IID)
/**
* This method gets called before the nsParser calls tokenize.
* This is needed because the XML side actually builds
* the content model as part of the tokenization and
* not on BuildModel(). The XML side can use this call
* to do stuff that the HTML side does in WillProcessTokens().
*
* @update 2006-10-17 hsivonen
* This method is called by the parser when it is entered from
* the event loop. The content sink wants to know how long the
* parser has been active since we last processed events on the
* main event loop and this call calibrates that measurement.
*/
NS_IMETHOD WillTokenize(void)=0;
NS_IMETHOD WillParse(void)=0;
/**
* This method gets called when the parser begins the process
* of building the content model via the content sink.
*
* @update 5/7/98 gess
*/
*/
NS_IMETHOD WillBuildModel(void)=0;
/**
@ -88,7 +85,7 @@ public:
* of building the content model via the content sink.
*
* @update 5/7/98 gess
*/
*/
NS_IMETHOD DidBuildModel()=0;
/**
@ -97,7 +94,7 @@ public:
* more data is available.
*
* @update 5/7/98 gess
*/
*/
NS_IMETHOD WillInterrupt(void)=0;
/**
@ -105,7 +102,7 @@ public:
* and we're about to start dumping content again to the sink.
*
* @update 5/7/98 gess
*/
*/
NS_IMETHOD WillResume(void)=0;
/**

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

@ -82,9 +82,10 @@
#include "nsIContentSink.h"
#include "nsHTMLTags.h"
// d19e6730-5e2f-4131-89db-8a918515097d
#define NS_IHTML_CONTENT_SINK_IID \
{ 0x73b5a072, 0x0f87, 0x4d07, \
{ 0xa8, 0x16, 0xe6, 0xac, 0x73, 0xa7, 0x04, 0x3c } }
{ 0xd19e6730, 0x5e2f, 0x4131, \
{ 0x89, 0xdb, 0x8a, 0x91, 0x85, 0x15, 0x09, 0x7d } }
#if defined(XP_MAC)
@ -130,12 +131,6 @@ public:
*/
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn) = 0;
/**
* This method is called when parser is about to begin
* synchronously processing a chunk of tokens.
*/
NS_IMETHOD WillProcessTokens(void) = 0;
/**
* This method is called when parser has
* completed processing a chunk of tokens. The processing of the

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

@ -323,8 +323,6 @@ CNavDTD::BuildModel(nsIParser* aParser,
}
}
mSink->WillProcessTokens();
while (NS_SUCCEEDED(result)) {
if (!(mFlags & NS_DTD_FLAG_STOP_PARSING)) {
CToken* theToken = mTokenizer->PopToken();

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

@ -94,7 +94,7 @@ void WriteTabs(PRFileDesc * out,int aTabCount) {
}
NS_IMETHODIMP
nsLoggingSink::WillTokenize() {
nsLoggingSink::WillParse() {
return NS_OK;
}

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

@ -60,7 +60,7 @@ public:
NS_DECL_ISUPPORTS
// nsIContentSink
NS_IMETHOD WillTokenize();
NS_IMETHOD WillParse();
NS_IMETHOD WillBuildModel();
NS_IMETHOD DidBuildModel();
NS_IMETHOD WillInterrupt();
@ -86,7 +86,6 @@ public:
NS_IMETHOD BeginContext(PRInt32 aPosition);
NS_IMETHOD EndContext(PRInt32 aPosition);
NS_IMETHOD WillProcessTokens(void) { return NS_OK; }
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }

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

@ -1724,6 +1724,9 @@ nsParser::ContinueInterruptedParsing()
PRBool isFinalChunk = mParserContext &&
mParserContext->mStreamListenerState == eOnStop;
if (mSink) {
mSink->WillParse();
}
result = ResumeParse(PR_TRUE, isFinalChunk); // Ref. bug 57999
if (result != NS_OK) {
@ -2867,6 +2870,9 @@ nsParser::OnDataAvailable(nsIRequest *request, nsISupports* aContext,
// Don't bother to start parsing until we've seen some
// non-whitespace data
if (theContext->mScanner->FirstNonWhitespacePosition() >= 0) {
if (mSink) {
mSink->WillParse();
}
rv = ResumeParse();
}
} else {
@ -2915,6 +2921,9 @@ nsParser::OnStopRequest(nsIRequest *request, nsISupports* aContext,
mParserFilter->Finish();
if (NS_SUCCEEDED(rv)) {
if (mSink) {
mSink->WillParse();
}
rv = ResumeParse(PR_TRUE, PR_TRUE);
}
@ -2964,7 +2973,6 @@ nsParser::WillTokenize(PRBool aIsFinalChunk)
NS_IPARSER_FLAG_HTML;
nsresult result = mParserContext->GetTokenizer(type, mSink, theTokenizer);
NS_ENSURE_SUCCESS(result, PR_FALSE);
mSink->WillTokenize();
return NS_SUCCEEDED(theTokenizer->WillTokenize(aIsFinalChunk,
&mTokenAllocator));
}

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

@ -451,8 +451,6 @@ NS_IMETHODIMP CViewSourceHTML::BuildModel(nsIParser* aParser,nsITokenizer* aToke
}
}
mSink->WillProcessTokens();
while(NS_SUCCEEDED(result)){
CToken* theToken=mTokenizer->PopToken();
if(theToken) {

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

@ -72,7 +72,7 @@ public:
nsSAXXMLReader();
//nsIContentSink
NS_IMETHOD WillTokenize()
NS_IMETHOD WillParse()
{
return NS_OK;
}

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

@ -159,7 +159,7 @@ public:
NS_DECL_NSIEXPATSINK
// nsIContentSink
NS_IMETHOD WillTokenize(void);
NS_IMETHOD WillParse(void);
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
NS_IMETHOD WillInterrupt(void);
@ -607,7 +607,7 @@ RDFContentSinkImpl::ReportError(const PRUnichar* aErrorText,
// nsIContentSink interface
NS_IMETHODIMP
RDFContentSinkImpl::WillTokenize(void)
RDFContentSinkImpl::WillParse(void)
{
return NS_OK;
}