Bug 1596455 - Simplify nsIContent::IsInAnonymousSubtree. r=bzbarsky
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 14 Nov 2019 23:09:03 +0000
changeset 502130 fd63a50a812ec869d3e17e86f9a89ed47c8f1671
parent 502129 4817e5961588294d16d7e194ed843b402bd48768
child 502131 fc12d7dbaaf54ce5af741b400589ba2ad7454425
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)
reviewersbzbarsky
bugs1596455
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 1596455 - Simplify nsIContent::IsInAnonymousSubtree. r=bzbarsky Now that XBL is gone, the only anonymous subtrees are NAC. I'd prefer to defer the removal of IsInAnonymousSubtree if possible, as there's a bunch of patches coming on top of this one :) Differential Revision: https://phabricator.services.mozilla.com/D53033
dom/base/nsIContent.h
dom/base/nsIContentInlines.h
dom/base/nsINode.cpp
dom/base/nsINode.h
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -195,23 +195,16 @@ class nsIContent : public nsINode {
   bool IsRootOfAnonymousSubtree() const {
 #ifdef DEBUG
     AssertAnonymousSubtreeRelatedInvariants();
 #endif
     return HasFlag(NODE_IS_ANONYMOUS_ROOT);
   }
 
   /**
-   * Returns true if there is NOT a path through child lists
-   * from the top of this node's parent chain back to this node or
-   * if the node is in native anonymous subtree without a parent.
-   */
-  inline bool IsInAnonymousSubtree() const;
-
-  /**
    * Return true iff this node is in an HTML document (in the HTML5 sense of
    * the term, i.e. not in an XHTML/XML document).
    */
   inline bool IsInHTMLDocument() const;
 
   /**
    * Returns true if in a chrome document
    */
--- a/dom/base/nsIContentInlines.h
+++ b/dom/base/nsIContentInlines.h
@@ -159,40 +159,16 @@ inline bool nsINode::IsEditable() const 
     return false;
   }
 
   // Check if the node is in a document and the document is in designMode.
   Document* doc = GetUncomposedDoc();
   return doc && doc->HasFlag(NODE_IS_EDITABLE);
 }
 
-inline bool nsIContent::IsInAnonymousSubtree() const {
-  NS_ASSERTION(
-      !IsInNativeAnonymousSubtree() || GetBindingParent() ||
-          (!IsInUncomposedDoc() && static_cast<nsIContent*>(SubtreeRoot())
-                                       ->IsInNativeAnonymousSubtree()),
-      "Must have binding parent when in native anonymous subtree which is in "
-      "document.\n"
-      "Native anonymous subtree which is not in document must have native "
-      "anonymous root.");
-
-  if (IsInNativeAnonymousSubtree()) {
-    return true;
-  }
-
-  nsIContent* bindingParent = GetBindingParent();
-  if (!bindingParent) {
-    return false;
-  }
-
-  // We reuse the binding parent machinery for Shadow DOM too, so prevent that
-  // from getting us confused in this case.
-  return !bindingParent->GetShadowRoot();
-}
-
 inline void nsIContent::HandleInsertionToOrRemovalFromSlot() {
   using mozilla::dom::HTMLSlotElement;
 
   MOZ_ASSERT(GetParentElement());
   if (!IsInShadowTree() || IsRootOfAnonymousSubtree()) {
     return;
   }
   HTMLSlotElement* slot = HTMLSlotElement::FromNode(mParent);
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -547,24 +547,16 @@ void nsINode::CheckNotNativeAnonymous() 
       NS_ERROR("Element not marked to be in native anonymous subtree!");
       break;
     }
     content = content->GetBindingParent();
   }
 }
 #endif
 
-bool nsINode::IsInAnonymousSubtree() const {
-  if (!IsContent()) {
-    return false;
-  }
-
-  return AsContent()->IsInAnonymousSubtree();
-}
-
 std::ostream& operator<<(std::ostream& aStream, const nsINode& aNode) {
   nsAutoString elemDesc;
   const nsINode* curr = &aNode;
   while (curr) {
     const nsString& localName = curr->LocalName();
     nsString id;
     if (curr->IsElement()) {
       curr->AsElement()->GetId(id);
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -1239,17 +1239,27 @@ class nsINode : public mozilla::dom::Eve
     }
     CheckNotNativeAnonymous();
     return false;
 #else
     return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
 #endif
   }
 
-  bool IsInAnonymousSubtree() const;
+  /**
+   * Returns true if there is NOT a path through child lists
+   * from the top of this node's parent chain back to this node or
+   * if the node is in native anonymous subtree without a parent.
+   *
+   * TODO(emilio):: Remove this function, and use just
+   * IsInNativeAnonymousSubtree, or something?
+   */
+  bool IsInAnonymousSubtree() const {
+    return IsInNativeAnonymousSubtree();
+  }
 
   bool IsInSVGUseShadowTree() const {
     return !!GetContainingSVGUseShadowHost();
   }
 
   mozilla::dom::SVGUseElement* GetContainingSVGUseShadowHost() const {
     if (!IsInShadowTree()) {
       return nullptr;