зеркало из https://github.com/mozilla/pjs.git
Bug 654106 - Avoid registering a script observer in the fragment parsing case. r=bzbarsky.
This commit is contained in:
Родитель
222e1200db
Коммит
179c0852d6
|
@ -287,6 +287,9 @@ nsContentSink::Init(nsIDocument* aDoc,
|
|||
|
||||
mDocumentURI = aURI;
|
||||
mDocShell = do_QueryInterface(aContainer);
|
||||
mScriptLoader = mDocument->ScriptLoader();
|
||||
|
||||
if (!mFragmentMode) {
|
||||
if (mDocShell) {
|
||||
PRUint32 loadType = 0;
|
||||
mDocShell->GetLoadType(&loadType);
|
||||
|
@ -299,12 +302,12 @@ nsContentSink::Init(nsIDocument* aDoc,
|
|||
new nsScriptLoaderObserverProxy(this);
|
||||
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
mScriptLoader = mDocument->ScriptLoader();
|
||||
mScriptLoader->AddObserver(proxy);
|
||||
|
||||
mCSSLoader = aDoc->CSSLoader();
|
||||
|
||||
ProcessHTTPHeaders(aChannel);
|
||||
}
|
||||
|
||||
mCSSLoader = aDoc->CSSLoader();
|
||||
|
||||
mNodeInfoManager = aDoc->NodeInfoManager();
|
||||
|
||||
|
@ -315,10 +318,11 @@ nsContentSink::Init(nsIDocument* aDoc,
|
|||
FavorPerformanceHint(!mDynamicLowerValue, 0);
|
||||
}
|
||||
|
||||
mCanInterruptParser = sCanInterruptParser;
|
||||
// prevent DropParserAndPerfHint from unblocking onload in the fragment
|
||||
// case
|
||||
mCanInterruptParser = !mFragmentMode && sCanInterruptParser;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -343,6 +343,8 @@ protected:
|
|||
// shouldn't be performing any more content model notifications,
|
||||
// since we're not longer updating our child counts.
|
||||
PRUint8 mIsDocumentObserver : 1;
|
||||
// True if this is a fragment parser
|
||||
PRUint8 mFragmentMode : 1;
|
||||
|
||||
//
|
||||
// -- Can interrupt parsing members --
|
||||
|
|
|
@ -497,6 +497,8 @@ nsHtml5Parser::ParseHtml5Fragment(const nsAString& aSourceBuffer,
|
|||
nsIURI* uri = doc->GetDocumentURI();
|
||||
NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
mExecutor->EnableFragmentMode(aPreventScriptExecution);
|
||||
|
||||
Initialize(doc, uri, nsnull, nsnull);
|
||||
|
||||
mExecutor->SetParser(this);
|
||||
|
@ -516,8 +518,6 @@ nsHtml5Parser::ParseHtml5Fragment(const nsAString& aSourceBuffer,
|
|||
}
|
||||
#endif
|
||||
|
||||
mExecutor->EnableFragmentMode(aPreventScriptExecution);
|
||||
|
||||
NS_PRECONDITION(!mExecutor->HasStarted(),
|
||||
"Tried to start parse without initializing the parser.");
|
||||
mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled());
|
||||
|
|
|
@ -124,8 +124,6 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
|
|||
|
||||
PRBool mCallContinueInterruptedParsingIfEnabled;
|
||||
|
||||
PRBool mFragmentMode;
|
||||
|
||||
PRBool mPreventScriptExecution;
|
||||
|
||||
public:
|
||||
|
@ -241,8 +239,6 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
|
|||
*/
|
||||
void EnableFragmentMode(PRBool aPreventScriptExecution) {
|
||||
mFragmentMode = PR_TRUE;
|
||||
mCanInterruptParser = PR_FALSE; // prevent DropParserAndPerfHint
|
||||
// from unblocking onload
|
||||
mPreventScriptExecution = aPreventScriptExecution;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче