Bug 1419334: Fix GetFlattenedTreeParentNodeInternal test for unassigned XBL children nodes. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 21 Nov 2017 10:32:47 +0100
changeset 392955 c46274ce509e0676871287506fa3480ecd911677
parent 392954 ac76ac88fc5e7b00c43fc6dd2e183528e6bafd6c
child 392956 328ee69ec1bcee488c43abdbc102b98fa15fea29
push id32947
push useraciure@mozilla.com
push dateWed, 22 Nov 2017 09:57:59 +0000
treeherdermozilla-central@5378dcb45044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1419334
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1419334: Fix GetFlattenedTreeParentNodeInternal test for unassigned XBL children nodes. r=smaug We check for them when the node doesn't have the MAY_BE_IN_BINDING_MNGR flag, but the flag is not precise, so in presence of dynamic changes that somehow make the node assigned, then unassigned, like changing the binding, it may not be correct. MozReview-Commit-ID: 9jyqCnR0yFn
dom/base/FragmentOrElement.cpp
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -246,24 +246,31 @@ nsIContent::GetFlattenedTreeParentNodeIn
     // but the child does not match any insertion points, thus
     // the flattened tree parent is nullptr.
     nsTArray<nsIContent*>* destInsertionPoints = GetExistingDestInsertionPoints();
     if (!destInsertionPoints || destInsertionPoints->IsEmpty()) {
       return nullptr;
     }
     parent = destInsertionPoints->LastElement()->GetParent();
     MOZ_ASSERT(parent);
-  } else if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
+  } else if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR) ||
+             parent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
+    // We need to check `parent` to properly handle the unassigned child case
+    // below, since if we were never assigned we would never have the flag set.
+    //
+    // Note that unassigned child nodes _could_ have the flag set, if they were
+    // ever assigned, or if they have a binding themselves.
     if (nsIContent* insertionPoint = GetXBLInsertionPoint()) {
       parent = insertionPoint->GetParent();
       MOZ_ASSERT(parent);
+    } else if (parent->OwnerDoc()->BindingManager()->GetBindingWithContent(parent)) {
+      // This is an unassigned node child of the bound element, so it isn't part
+      // of the flat tree.
+      return nullptr;
     }
-  } else if (parent->OwnerDoc()->BindingManager()->GetBindingWithContent(parent)) {
-    // This is fallback content not assigned to any insertion point.
-    return nullptr;
   }
 
   // Shadow roots never shows up in the flattened tree. Return the host
   // instead.
   if (parent->IsInShadowTree()) {
     if (ShadowRoot* parentShadowRoot = ShadowRoot::FromNode(parent)) {
       return parentShadowRoot->GetHost();
     }