From 9a071f3b7af7461168e0b80cdea8f4ff7f64780b Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sun, 19 Mar 2023 23:43:34 +0800 Subject: [PATCH] Issue #1592 - Part 9: Post a restyle event after changing the slot of a slottable --- dom/base/ShadowRoot.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index d432c96e41..8482da5e99 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -9,6 +9,7 @@ #include "mozilla/dom/DocumentFragment.h" #include "ChildIterator.h" #include "nsContentUtils.h" +#include "nsLayoutUtils.h" #include "nsDOMClassInfoID.h" #include "nsIDOMHTMLElement.h" #include "nsIStyleSheetLinkingElement.h" @@ -162,6 +163,16 @@ ShadowRoot::AddSlot(HTMLSlotElement* aSlot) oldSlot->RemoveAssignedNode(assignedNode); currentSlot->AppendAssignedNode(assignedNode); + Element* restyleElement; + if (assignedNode->IsElement()) { + restyleElement = assignedNode->AsElement(); + } else { + // This is likely a text node. Use the host instead. + restyleElement = GetHost(); + } + nsLayoutUtils::PostRestyleEvent( + restyleElement, eRestyle_Subtree, nsChangeHint(0)); + doEnqueueSlotChange = true; }