Bug 1389743 - Only reconstruct frames synchronously from ContentRemoved when called from frame construction

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 06:14:10 -04:00 committed by Roy Tam
commit f63cd76698
9 changed files with 201 additions and 285 deletions

View file

@ -2828,10 +2828,9 @@ PresShell::CancelAllPendingReflows()
}
void
PresShell::DestroyFramesFor(nsIContent* aContent,
nsIContent** aDestroyedFramesFor)
PresShell::DestroyFramesFor(Element* aElement)
{
MOZ_ASSERT(aContent);
MOZ_ASSERT(aElement);
NS_ENSURE_TRUE_VOID(mPresContext);
if (!mDidInitialize) {
return;
@ -2843,43 +2842,18 @@ PresShell::DestroyFramesFor(nsIContent* aContent,
++mChangeNestCount;
nsCSSFrameConstructor* fc = FrameConstructor();
bool didReconstruct;
fc->BeginUpdate();
fc->DestroyFramesFor(aContent, aDestroyedFramesFor);
fc->DestroyFramesFor(aElement, &didReconstruct);
fc->EndUpdate();
--mChangeNestCount;
}
void
PresShell::CreateFramesFor(nsIContent* aContent)
{
NS_ENSURE_TRUE_VOID(mPresContext);
if (!mDidInitialize) {
// Nothing to do here. In fact, if we proceed and aContent is the
// root we will crash.
return;
// XXXmats doesn't frame state need to be restored in this case?
if (!didReconstruct) {
PostRecreateFramesFor(aElement);
}
// Don't call RecreateFramesForContent since that is not exported and we want
// to keep the number of entrypoints down.
NS_ASSERTION(mViewManager, "Should have view manager");
MOZ_ASSERT(aContent);
// Have to make sure that the content notifications are flushed before we
// start messing with the frame model; otherwise we can get content doubling.
mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
nsAutoScriptBlocker scriptBlocker;
// Mark ourselves as not safe to flush while we're doing frame construction.
++mChangeNestCount;
nsCSSFrameConstructor* fc = FrameConstructor();
nsILayoutHistoryState* layoutState = fc->GetLastCapturedLayoutHistoryState();
fc->BeginUpdate();
fc->ContentInserted(aContent->GetParent(), aContent, layoutState, false);
fc->EndUpdate();
mPresContext->RestyleManager()->PostRestyleEvent(
aElement, eRestyle_Subtree, nsChangeHint(0));
--mChangeNestCount;
}