Bug 1596768 - Remove GetBindingParent usage in editor. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Nov 2019 17:44:11 +0000
changeset 502250 afb9438378f091aa9f31192c235191625c3d538a
parent 502249 db1a18b908bfaf15485d1dd5430f67c46b5d65a8
child 502251 9e78205ab7d0eac06ad757db1fc605b3e2c7a75c
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1596768
milestone72.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 1596768 - Remove GetBindingParent usage in editor. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D53199
editor/libeditor/HTMLEditor.cpp
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3374,25 +3374,31 @@ void HTMLEditor::ContentInserted(nsICont
   DoContentInserted(aChild, eInserted);
 }
 
 bool HTMLEditor::IsInObservedSubtree(nsIContent* aChild) {
   if (!aChild) {
     return false;
   }
 
-  Element* root = GetRoot();
-  // To be super safe here, check both ChromeOnlyAccess and GetBindingParent.
-  // That catches (also unbound) native anonymous content, XBL and ShadowDOM.
-  if (root && (root->ChromeOnlyAccess() != aChild->ChromeOnlyAccess() ||
-               root->GetBindingParent() != aChild->GetBindingParent())) {
-    return false;
-  }
-
-  return !aChild->ChromeOnlyAccess() && !aChild->GetBindingParent();
+  // FIXME(emilio, bug 1596856): This should probably work if the root is in the
+  // same shadow tree as the child, probably? I don't know what the
+  // contenteditable-in-shadow-dom situation is.
+  if (Element* root = GetRoot()) {
+    // To be super safe here, check both ChromeOnlyAccess and NAC / Shadow DOM.
+    // That catches (also unbound) native anonymous content and ShadowDOM.
+    if (root->ChromeOnlyAccess() != aChild->ChromeOnlyAccess() ||
+        root->IsInNativeAnonymousSubtree() != aChild->IsInNativeAnonymousSubtree() ||
+        root->IsInShadowTree() != aChild->IsInShadowTree()) {
+      return false;
+    }
+  }
+
+  return !aChild->ChromeOnlyAccess() && !aChild->IsInShadowTree() &&
+         !aChild->IsInNativeAnonymousSubtree();
 }
 
 void HTMLEditor::DoContentInserted(nsIContent* aChild,
                                    InsertedOrAppended aInsertedOrAppended) {
   MOZ_ASSERT(aChild);
   nsINode* container = aChild->GetParentNode();
   MOZ_ASSERT(container);