By the time we're processing reflow callbacks, reflow is done. Bug 334518,

r+sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2006-04-18 21:48:12 +00:00
parent 1812f04b05
commit 4e074a03a2

View File

@ -6523,54 +6523,57 @@ PresShell::ProcessReflowCommands(PRBool aInterruptible)
mDocument->BeginUpdate(UPDATE_ALL);
mDocument->EndUpdate(UPDATE_ALL);
AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
mIsReflowing = PR_TRUE;
// Scope for the reflow entry point
{
AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow);
mIsReflowing = PR_TRUE;
do {
// Coalesce the reflow commands into a tree.
IncrementalReflow reflow;
for (PRInt32 i = mReflowCommands.Count() - 1; i >= 0; --i) {
nsHTMLReflowCommand *command =
NS_STATIC_CAST(nsHTMLReflowCommand *, mReflowCommands[i]);
do {
// Coalesce the reflow commands into a tree.
IncrementalReflow reflow;
for (PRInt32 i = mReflowCommands.Count() - 1; i >= 0; --i) {
nsHTMLReflowCommand *command =
NS_STATIC_CAST(nsHTMLReflowCommand *, mReflowCommands[i]);
IncrementalReflow::AddCommandResult res =
reflow.AddCommand(mPresContext, command);
if (res == IncrementalReflow::eEnqueued ||
res == IncrementalReflow::eCancel) {
// Remove the command from the queue.
mReflowCommands.RemoveElementAt(i);
ReflowCommandRemoved(command);
if (res == IncrementalReflow::eCancel)
delete command;
}
else {
// The reflow command couldn't be added to the tree; leave
// it in the queue, and we'll handle it next time.
IncrementalReflow::AddCommandResult res =
reflow.AddCommand(mPresContext, command);
if (res == IncrementalReflow::eEnqueued ||
res == IncrementalReflow::eCancel) {
// Remove the command from the queue.
mReflowCommands.RemoveElementAt(i);
ReflowCommandRemoved(command);
if (res == IncrementalReflow::eCancel)
delete command;
}
else {
// The reflow command couldn't be added to the tree; leave
// it in the queue, and we'll handle it next time.
#ifdef DEBUG
printf("WARNING: Couldn't add reflow command, so splitting.\n");
printf("WARNING: Couldn't add reflow command, so splitting.\n");
#endif
}
}
}
#ifdef DEBUG
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
printf("Incremental reflow tree:\n");
reflow.Dump(mPresContext);
}
if (VERIFY_REFLOW_NOISY_RC & gVerifyReflowFlags) {
printf("Incremental reflow tree:\n");
reflow.Dump(mPresContext);
}
#endif
// Dispatch an incremental reflow.
reflow.Dispatch(mPresContext, desiredSize, maxSize, *rcx);
// Dispatch an incremental reflow.
reflow.Dispatch(mPresContext, desiredSize, maxSize, *rcx);
// Keep going until we're out of reflow commands, or we've run
// past our deadline.
} while (mReflowCommands.Count() &&
(!aInterruptible || PR_IntervalNow() < deadline));
// Keep going until we're out of reflow commands, or we've run
// past our deadline.
} while (mReflowCommands.Count() &&
(!aInterruptible || PR_IntervalNow() < deadline));
// XXXwaterson for interruptible reflow, examine the tree and
// re-enqueue any unflowed reflow targets.
// XXXwaterson for interruptible reflow, examine the tree and
// re-enqueue any unflowed reflow targets.
mIsReflowing = PR_FALSE;
mIsReflowing = PR_FALSE;
}
NS_IF_RELEASE(rcx);