From 18e693464db4ad123afc59c06aa0b8f5eaad94d8 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sat, 11 Mar 2023 00:02:28 +0800 Subject: [PATCH] Issue #2135 - Destroy the host frame and restyle when there are content changes This is likely inefficient, but I haven't found a way other than this to ensure that the host frame is updated if the inserted/removed content isn't slotted. I'm assuming that Firefox is handling this somewhere else (and may have been even moved to Stylo), but was mentioned in an m-c bug we haven't seen yet. In fact, this is actually similar to how we handled elements passed to ContentInserted before landing e31ed5b07466d4a579fe4b025f97c971003fbc3f. --- dom/base/ShadowRoot.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index e31b97262c..92d5a2f2a9 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -578,6 +578,13 @@ ShadowRoot::ContentInserted(nsIDocument* aDocument, if (slot && slot->GetContainingShadow() == this && slot->AssignedNodes().IsEmpty()) { slot->EnqueueSlotChangeEvent(); + return; + } + + // XXX: The following makes the host destroy its frames and force a + // restyle for cases where the content isn't slotted. + if (aContainer == this) { + DistributionChanged(); } } @@ -614,6 +621,13 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument, if (slot && slot->GetContainingShadow() == this && slot->AssignedNodes().IsEmpty()) { slot->EnqueueSlotChangeEvent(); + return; + } + + // XXX: The following makes the host destroy its frames and force a + // restyle for cases where the content isn't slotted. + if (aContainer == this) { + DistributionChanged(); } }