Bug 1400936 - Only tear down the servo data in SetXBLInsertionParent if the parent actually changed. r=bholley, a=sledru
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 23 Sep 2017 00:02:59 +0200
changeset 434251 6b96a0fab002660434dc96f3ff8cf086cac1f4ac
parent 434250 2d4c045f3066e9b6292bb8bf5571517be0161502
child 434252 ca0193447310df73222a91c485f6e41a8debe6f2
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, sledru
bugs1400936
milestone57.0
Bug 1400936 - Only tear down the servo data in SetXBLInsertionParent if the parent actually changed. r=bholley, a=sledru This is the reason similar assertion failures can't be reproduced with elements and stuff like fieldset and form validity changes. nsBindingManager::ContentRemoved calls SetXBLInsertionParent, which clears all the Servo data from the subtree eagerly, which is a waste when the actual binding parent is the same (null). MozReview-Commit-ID: A5wLKfD4OTL Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
dom/base/FragmentOrElement.cpp
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -1326,30 +1326,33 @@ FragmentOrElement::GetExistingDestInsert
     return &slots->mDestInsertionPoints;
   }
   return nullptr;
 }
 
 void
 FragmentOrElement::SetXBLInsertionParent(nsIContent* aContent)
 {
+  nsCOMPtr<nsIContent> oldInsertionParent = nullptr;
   if (aContent) {
     nsExtendedDOMSlots* slots = ExtendedDOMSlots();
     SetFlags(NODE_MAY_BE_IN_BINDING_MNGR);
+    oldInsertionParent = slots->mXBLInsertionParent.forget();
     slots->mXBLInsertionParent = aContent;
   } else {
-    nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
-    if (slots) {
+    if (nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots()) {
+      oldInsertionParent = slots->mXBLInsertionParent.forget();
       slots->mXBLInsertionParent = 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 (IsStyledByServo() && IsElement() && AsElement()->HasServoData()) {
+  if (oldInsertionParent != aContent &&
+      IsStyledByServo() && IsElement() && AsElement()->HasServoData()) {
     ServoRestyleManager::ClearServoDataFromSubtree(AsElement());
   }
 }
 
 nsresult
 FragmentOrElement::InsertChildAt(nsIContent* aKid,
                                 uint32_t aIndex,
                                 bool aNotify)