diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index f8cf00fe03b1..48a1dff47163 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -250,6 +250,24 @@ ShadowRoot::RemoveDestInsertionPoint(nsIContent* aInsertionPoint, } } +void +ShadowRoot::DistributionChanged() +{ + // FIXME(emilio): We could be more granular in a bunch of cases. + auto* host = GetHost(); + if (!host) { + return; + } + + auto* shell = OwnerDoc()->GetShell(); + if (!shell) { + return; + } + + // FIXME(emilio): Rename this to DestroyFramesForAndRestyle? + shell->DestroyFramesFor(host); +} + void ShadowRoot::DistributeSingleNode(nsIContent* aContent) { @@ -311,6 +329,8 @@ ShadowRoot::DistributeSingleNode(nsIContent* aContent) if (auto* parentShadow = foundInsertionPoint->GetParent()->GetShadowRoot()) { parentShadow->DistributeSingleNode(aContent); } + + DistributionChanged(); } void @@ -340,6 +360,8 @@ ShadowRoot::RemoveDistributedNode(nsIContent* aContent) if (auto* parentShadow = insertionPoint->GetParent()->GetShadowRoot()) { parentShadow->RemoveDistributedNode(aContent); } + + DistributionChanged(); return; } } @@ -386,6 +408,8 @@ ShadowRoot::DistributeAllNodes() for (ShadowRoot* shadow : shadowsToUpdate) { shadow->DistributeAllNodes(); } + + DistributionChanged(); } void diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 7ea505422c16..64838b5ad4e5 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -72,6 +72,12 @@ private: */ void RemoveDistributedNode(nsIContent* aContent); + /** + * Called when we redistribute content in such a way that new insertion points + * come into existence, or elements are moved between insertion points. + */ + void DistributionChanged(); + static bool IsPooledNode(nsIContent* aChild, nsIContent* aContainer, nsIContent* aHost);