Bug 1411754: Rename PresShell::DestroyFramesFor to DestroyFramesForAndRestyle. r=mats

I'm drive-by removing the comment about the frame tree state because I looked
into it, and the answer is: we properly restore it.

The gotcha is that we retain it too much, indeed, we retain it enough that it
can leak. See bug 1397239.

MozReview-Commit-ID: LP6bXkduEZ4

--HG--
extra : rebase_source : f7e18fc35e48b75c07fcc84b939614d379926828
This commit is contained in:
Emilio Cobos Álvarez 2017-10-25 23:12:25 +02:00
Родитель d454491418
Коммит 4deb3bee3b
6 изменённых файлов: 14 добавлений и 21 удалений

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

@ -1169,7 +1169,7 @@ Element::CreateShadowRoot(ErrorResult& aError)
if (nsIDocument* doc = GetComposedDoc()) { if (nsIDocument* doc = GetComposedDoc()) {
if (nsIPresShell* shell = doc->GetShell()) { if (nsIPresShell* shell = doc->GetShell()) {
shell->DestroyFramesFor(this); shell->DestroyFramesForAndRestyle(this);
MOZ_ASSERT(!shell->FrameManager()->GetDisplayContentsStyleFor(this)); MOZ_ASSERT(!shell->FrameManager()->GetDisplayContentsStyleFor(this));
} }
} }

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

@ -267,8 +267,7 @@ ShadowRoot::DistributionChanged()
return; return;
} }
// FIXME(emilio): Rename this to DestroyFramesForAndRestyle? shell->DestroyFramesForAndRestyle(host);
shell->DestroyFramesFor(host);
} }
const HTMLContentElement* const HTMLContentElement*
@ -513,7 +512,7 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument,
return; return;
} }
shell->DestroyFramesFor(aElement); shell->DestroyFramesForAndRestyle(aElement);
} }
bool bool

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

@ -126,7 +126,7 @@ public:
// since if the binding fetch fails then we don't want to destroy the // since if the binding fetch fails then we don't want to destroy the
// frames. // frames.
if (nsIPresShell* shell = doc->GetShell()) { if (nsIPresShell* shell = doc->GetShell()) {
shell->DestroyFramesFor(mBoundElement->AsElement()); shell->DestroyFramesForAndRestyle(mBoundElement->AsElement());
} }
MOZ_ASSERT(!mBoundElement->GetPrimaryFrame()); MOZ_ASSERT(!mBoundElement->GetPrimaryFrame());
} }

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

@ -2922,7 +2922,7 @@ PresShell::CancelAllPendingReflows()
} }
void void
PresShell::DestroyFramesFor(Element* aElement) PresShell::DestroyFramesForAndRestyle(Element* aElement)
{ {
MOZ_ASSERT(aElement); MOZ_ASSERT(aElement);
NS_ENSURE_TRUE_VOID(mPresContext); NS_ENSURE_TRUE_VOID(mPresContext);
@ -2940,21 +2940,15 @@ PresShell::DestroyFramesFor(Element* aElement)
bool didReconstruct = fc->DestroyFramesFor(aElement); bool didReconstruct = fc->DestroyFramesFor(aElement);
fc->EndUpdate(); fc->EndUpdate();
// XXXmats doesn't frame state need to be restored in this case? auto changeHint = didReconstruct
if (!didReconstruct) { ? nsChangeHint(0)
PostRecreateFramesFor(aElement); : nsChangeHint_ReconstructFrame;
}
// NOTE(emilio): This is needed to force also a full subtree restyle for the // NOTE(emilio): eRestyle_Subtree is needed to force also a full subtree
// content (in Stylo, where the existence of frames != the existence of // restyle for the content (in Stylo, where the existence of frames != the
// styles). // existence of styles).
//
// It's a bit out of place in a function called DestroyFramesFor,
// however the two only callers of this code really need this (given they
// shuffle the flattened tree around), and this avoids exposing additional
// APIs on the pres shell.
mPresContext->RestyleManager()->PostRestyleEvent( mPresContext->RestyleManager()->PostRestyleEvent(
aElement, eRestyle_Subtree, nsChangeHint(0)); aElement, eRestyle_Subtree, changeHint);
--mChangeNestCount; --mChangeNestCount;
} }

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

@ -131,7 +131,7 @@ public:
virtual bool IsSafeToFlush() const override; virtual bool IsSafeToFlush() const override;
virtual void DoFlushPendingNotifications(mozilla::FlushType aType) override; virtual void DoFlushPendingNotifications(mozilla::FlushType aType) override;
virtual void DoFlushPendingNotifications(mozilla::ChangesToFlush aType) override; virtual void DoFlushPendingNotifications(mozilla::ChangesToFlush aType) override;
virtual void DestroyFramesFor(mozilla::dom::Element* aElement) override; virtual void DestroyFramesForAndRestyle(mozilla::dom::Element* aElement) override;
/** /**
* Post a callback that should be handled after reflow has finished. * Post a callback that should be handled after reflow has finished.

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

@ -528,7 +528,7 @@ public:
* *
* Note that this may destroy frames for an ancestor instead. * Note that this may destroy frames for an ancestor instead.
*/ */
virtual void DestroyFramesFor(mozilla::dom::Element* aElement) = 0; virtual void DestroyFramesForAndRestyle(mozilla::dom::Element* aElement) = 0;
void PostRecreateFramesFor(mozilla::dom::Element* aElement); void PostRecreateFramesFor(mozilla::dom::Element* aElement);
void RestyleForAnimation(mozilla::dom::Element* aElement, void RestyleForAnimation(mozilla::dom::Element* aElement,