# HG changeset patch # User Emilio Cobos Alvarez # Date 1519048452 -3600 # Node ID 577a507f9ee1b970382008c46d5402970eb82632 # Parent dfd28d17636adfb0668fdb29b2e9ca73fdb965e3 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 diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -1128,17 +1128,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 oldSlot = slots->mAssignedSlot.forget(); + slots->mAssignedSlot = aSlot; + + if (oldSlot != aSlot && IsElement() && AsElement()->HasServoData()) { + ServoRestyleManager::ClearServoDataFromSubtree(AsElement()); + } } void nsIContent::SetXBLInsertionPoint(nsIContent* aContent) { nsCOMPtr oldInsertionPoint = nullptr; if (aContent) { nsExtendedContentSlots* slots = ExtendedContentSlots(); @@ -1149,18 +1157,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::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify)