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