From c36fbdecd5a173c8b6aafbd46ddde8768a373ba5 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Fri, 19 Oct 2007 03:51:16 +0000 Subject: [PATCH] Don't run XBL constructors during frame construction, ever. Bug 398006, r=sicking, sr=roc git-svn-id: svn://10.0.0.236/trunk@237879 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/src/base/nsDOMClassInfo.cpp | 7 ++++++- mozilla/layout/base/nsPresShell.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 9dff7007856..451ab19e194 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -7009,7 +7009,12 @@ nsElementSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } if (binding) { - binding->ExecuteAttachedHandler(); + // Make sure the presshell is in a state where it's safe to execute script + PRBool safeToRunScript = PR_FALSE; + pctx->PresShell()->IsSafeToFlush(safeToRunScript); + if (safeToRunScript) { + binding->ExecuteAttachedHandler(); + } } return NS_OK; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index f7c50cdca19..e4e5c672367 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -3332,7 +3332,11 @@ PresShell::RecreateFramesFor(nsIContent* aContent) nsStyleChangeList changeList; changeList.AppendChange(nsnull, aContent, nsChangeHint_ReconstructFrame); + // Mark ourselves as not safe to flush while we're doing frame construction. + ++mChangeNestCount; nsresult rv = mFrameConstructor->ProcessRestyledFrames(changeList); + --mChangeNestCount; + mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC); #ifdef ACCESSIBILITY InvalidateAccessibleSubtree(aContent); @@ -6031,6 +6035,10 @@ PresShell::DidCauseReflow() if (--mChangeNestCount == 0) { // We may have had more reflow commands appended to the queue during // our reflow. Make sure these get processed at some point. + + // XXXbz why is this really needed? ProcessReflowCommands handles posting + // reflow events if there are reflow roots remaining, and FrameNeedsReflow + // posts events as needed as well. I think we should remove this. PostReflowEvent(); } @@ -6375,7 +6383,11 @@ PresShell::Observe(nsISupports* aSubject, nsStyleChangeList changeList; WalkFramesThroughPlaceholders(mPresContext, rootFrame, ReframeImageBoxes, &changeList); + // Mark ourselves as not safe to flush while we're doing frame + // construction. + ++mChangeNestCount; mFrameConstructor->ProcessRestyledFrames(changeList); + --mChangeNestCount; mViewManager->EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC); #ifdef ACCESSIBILITY