This commit is contained in:
Olli Pettay 2009-01-02 17:41:43 +02:00
Родитель 7d736ef6b9
Коммит 91d0df883d
6 изменённых файлов: 62 добавлений и 28 удалений

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

@ -5115,6 +5115,18 @@ nsDocument::FlushSkinBindings()
BindingManager()->FlushSkinBindings();
}
class nsFrameLoaderRunner : public nsRunnable
{
public:
nsFrameLoaderRunner(nsDocument* aDoc) : mDoc(aDoc) {}
NS_IMETHOD Run() {
mDoc->InitializeFinalizeFrameLoaders();
return NS_OK;
}
private:
nsRefPtr<nsDocument> mDoc;
};
nsresult
nsDocument::InitializeFrameLoader(nsFrameLoader* aLoader)
{
@ -5125,11 +5137,12 @@ nsDocument::InitializeFrameLoader(nsFrameLoader* aLoader)
"document is being deleted");
return NS_ERROR_FAILURE;
}
if (mUpdateNestLevel == 0 && !mDelayFrameLoaderInitialization) {
nsRefPtr<nsFrameLoader> loader = aLoader;
return loader->ReallyStartLoading();
} else {
mInitializableFrameLoaders.AppendElement(aLoader);
mInitializableFrameLoaders.AppendElement(aLoader);
if (!mFrameLoaderRunner) {
mFrameLoaderRunner = new nsFrameLoaderRunner(this);
NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
}
return NS_OK;
}
@ -5141,11 +5154,12 @@ nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader)
if (mInDestructor) {
return NS_ERROR_FAILURE;
}
if (mUpdateNestLevel == 0) {
nsRefPtr<nsFrameLoader> loader = aLoader;
loader->Finalize();
} else {
mFinalizableFrameLoaders.AppendElement(aLoader);
mFinalizableFrameLoaders.AppendElement(aLoader);
if (!mFrameLoaderRunner) {
mFrameLoaderRunner = new nsFrameLoaderRunner(this);
NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
}
return NS_OK;
}
@ -5153,8 +5167,11 @@ nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader)
void
nsDocument::InitializeFinalizeFrameLoaders()
{
NS_ASSERTION(mUpdateNestLevel == 0 && !mDelayFrameLoaderInitialization,
"Wrong time to call InitializeFinalizeFrameLoaders!");
mFrameLoaderRunner = nsnull;
if (mDelayFrameLoaderInitialization || mUpdateNestLevel != 0) {
return;
}
// Don't use a temporary array for mInitializableFrameLoaders, because
// loading a frame may cause some other frameloader to be removed from the
// array. But be careful to keep the loader alive when starting the load!

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

@ -997,6 +997,7 @@ public:
nsresult CloneDocHelper(nsDocument* clone) const;
void InitializeFinalizeFrameLoaders();
protected:
void RegisterNamedItems(nsIContent *aContent);
@ -1016,8 +1017,6 @@ protected:
void DispatchContentLoadedEvents();
void InitializeFinalizeFrameLoaders();
void RetrieveRelevantHeaders(nsIChannel *aChannel);
static PRBool TryChannelCharset(nsIChannel *aChannel,
@ -1262,6 +1261,7 @@ private:
nsTArray<nsRefPtr<nsFrameLoader> > mInitializableFrameLoaders;
nsTArray<nsRefPtr<nsFrameLoader> > mFinalizableFrameLoaders;
nsCOMPtr<nsIRunnable> mFrameLoaderRunner;
nsRevocableEventPtr<nsRunnableMethod<nsDocument> > mPendingTitleChangeEvent;

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

@ -2865,6 +2865,8 @@ nsGenericHTMLFrameElement::BindToTree(nsIDocument* aDocument,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
// We're in a document now. Kick off the frame load.
LoadSrc();
}

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

@ -849,6 +849,8 @@ nsXULElement::BindToTree(nsIDocument* aDocument,
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
// We're in a document now. Kick off the frame load.
LoadSrc();
}

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

@ -13453,6 +13453,8 @@ void
nsCSSFrameConstructor::ProcessPendingRestyles()
{
NS_PRECONDITION(mDocument, "No document? Pshaw!\n");
NS_PRECONDITION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
PRUint32 count = mPendingRestyles.Count();
@ -13596,21 +13598,24 @@ nsCSSFrameConstructor::LazyGenerateChildrenEvent::Run()
menuPopupFrame->SetGeneratedChildren();
#endif
nsCSSFrameConstructor* fc = mPresShell->FrameConstructor();
fc->BeginUpdate();
{
nsAutoScriptBlocker scriptBlocker;
nsCSSFrameConstructor* fc = mPresShell->FrameConstructor();
fc->BeginUpdate();
nsFrameItems childItems;
nsFrameConstructorState state(mPresShell, nsnull, nsnull, nsnull);
nsresult rv = fc->ProcessChildren(state, mContent, frame, PR_FALSE,
childItems, PR_FALSE);
if (NS_FAILED(rv))
return rv;
nsFrameItems childItems;
nsFrameConstructorState state(mPresShell, nsnull, nsnull, nsnull);
nsresult rv = fc->ProcessChildren(state, mContent, frame, PR_FALSE,
childItems, PR_FALSE);
if (NS_FAILED(rv))
return rv;
fc->CreateAnonymousFrames(mContent->Tag(), state, mContent, frame,
PR_FALSE, childItems);
frame->SetInitialChildList(nsnull, childItems.childList);
fc->CreateAnonymousFrames(mContent->Tag(), state, mContent, frame,
PR_FALSE, childItems);
frame->SetInitialChildList(nsnull, childItems.childList);
fc->EndUpdate();
fc->EndUpdate();
}
if (mCallback)
mCallback(mContent, frame, mArg);

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

@ -2396,7 +2396,10 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
// Now flush out pending restyles before we actually reflow, in
// case XBL constructors changed styles somewhere.
mFrameConstructor->ProcessPendingRestyles();
{
nsAutoScriptBlocker scriptBlocker;
mFrameConstructor->ProcessPendingRestyles();
}
// And that might have run _more_ XBL constructors
NS_ENSURE_STATE(!mHaveShutDown);
@ -2499,7 +2502,10 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
// Make sure style is up to date
mFrameConstructor->ProcessPendingRestyles();
{
nsAutoScriptBlocker scriptBlocker;
mFrameConstructor->ProcessPendingRestyles();
}
if (!mIsDestroying) {
// XXX Do a full invalidate at the beginning so that invalidates along
@ -4496,6 +4502,7 @@ PresShell::DoFlushPendingNotifications(mozFlushType aType,
// reflow).
mPresContext->FlushUserFontSet();
nsAutoScriptBlocker scriptBlocker;
mFrameConstructor->ProcessPendingRestyles();
}
@ -4513,6 +4520,7 @@ PresShell::DoFlushPendingNotifications(mozFlushType aType,
// up the new rules and we'll end up with frames whose style doesn't match
// the frame type.
if (!mIsDestroying) {
nsAutoScriptBlocker scriptBlocker;
mFrameConstructor->ProcessPendingRestyles();
}