Bug 1439016: Clear servo data on slot changes too. r?bholley
Pretty much the same way as what we do on XBL insertion point changes, since the
data would be stale.
I think both of those are kind of a hack, btw, and that we could fix it doing
ClearServoDataFromSubtree properly before we start unbinding. That'd prevent all
these issues, and all the complexity that entails receiving restyle requests
mid-unbind (we'd guarantee the tree is always in a stable state).
That's a matter of a different bug though.
MozReview-Commit-ID: Ev6RvGuPGiv
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -1224,17 +1224,25 @@ nsIContent::GetContainingShadowHost() co
return shadow->GetHost();
}
return nullptr;
}
void
nsIContent::SetAssignedSlot(HTMLSlotElement* aSlot)
{
- ExtendedContentSlots()->mAssignedSlot = aSlot;
+ MOZ_ASSERT(aSlot || GetExistingExtendedContentSlots());
+ nsExtendedContentSlots* slots = ExtendedContentSlots();
+
+ RefPtr<HTMLSlotElement> oldSlot = slots->mAssignedSlot.forget();
+ slots->mAssignedSlot = aSlot;
+
+ if (oldSlot != aSlot && IsElement() && AsElement()->HasServoData()) {
+ ServoRestyleManager::ClearServoDataFromSubtree(AsElement());
+ }
}
void
nsIContent::SetXBLInsertionPoint(nsIContent* aContent)
{
nsCOMPtr<nsIContent> oldInsertionPoint = nullptr;
if (aContent) {
nsExtendedContentSlots* slots = ExtendedContentSlots();
@@ -1245,18 +1253,18 @@ nsIContent::SetXBLInsertionPoint(nsICont
if (nsExtendedContentSlots* slots = GetExistingExtendedContentSlots()) {
oldInsertionPoint = slots->mXBLInsertionPoint.forget();
slots->mXBLInsertionPoint = nullptr;
}
}
// We just changed the flattened tree, so any Servo style data is now invalid.
// We rely on nsXBLService::LoadBindings to re-traverse the subtree afterwards.
- if (oldInsertionPoint != aContent &&
- IsStyledByServo() && IsElement() && AsElement()->HasServoData()) {
+ if (oldInsertionPoint != aContent && IsElement() &&
+ AsElement()->HasServoData()) {
ServoRestyleManager::ClearServoDataFromSubtree(AsElement());
}
}
nsresult
FragmentOrElement::InsertChildBefore(nsIContent* aKid,
nsIContent* aBeforeThis,
bool aNotify)