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.
This commit is contained in:
FranklinDM 2023-03-11 00:02:28 +08:00 committed by roytam1
commit 18e693464d

View file

@ -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();
}
}