Bug 900738 - Remove HasSameOwnerDoc, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 02 Aug 2013 13:24:41 +0300
changeset 141130 7130c6699b743bcbe6b13975d2f792f84aabb78c
parent 141129 e3b5e807075205083351cc02d1d7d742e265bfaf
child 141131 58aed54902a539f23033a205382c05e582311661
push id31989
push useropettay@mozilla.com
push dateFri, 02 Aug 2013 14:38:52 +0000
treeherdermozilla-inbound@7130c6699b74 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs900738
milestone25.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 900738 - Remove HasSameOwnerDoc, r=bz
content/base/public/nsINode.h
content/base/src/Element.cpp
content/base/src/nsDOMAttributeMap.cpp
content/base/src/nsGenericDOMDataNode.cpp
content/base/src/nsINode.cpp
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -857,33 +857,16 @@ public:
    * may be different. When cloning an element, all attributes of the element
    * will be cloned. The children of the node will not be cloned.
    *
    * @param aNodeInfo the nodeinfo to use for the clone
    * @param aResult the clone
    */
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const = 0;
 
-  /**
-   * Checks if a node has the same ownerDocument as this one. Note that this
-   * actually compares nodeinfo managers because nodes always have one, even
-   * when they don't have an ownerDocument. If this function returns true
-   * it doesn't mean that the nodes actually have an ownerDocument.
-   *
-   * @param aOther Other node to check
-   * @return Whether the owner documents of this node and of aOther are the
-   *         same.
-   */
-  bool HasSameOwnerDoc(nsINode *aOther)
-  {
-    // We compare nodeinfo managers because nodes always have one, even when
-    // they don't have an ownerDocument.
-    return mNodeInfo->NodeInfoManager() == aOther->mNodeInfo->NodeInfoManager();
-  }
-
   // This class can be extended by subclasses that wish to store more
   // information in the slots.
   class nsSlots
   {
   public:
     nsSlots()
       : mChildNodes(nullptr),
         mWeakReference(nullptr)
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -895,17 +895,17 @@ Element::GetElementsByClassName(const ns
 }
 
 nsresult
 Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                     nsIContent* aBindingParent,
                     bool aCompileEventHandlers)
 {
   NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
-  NS_PRECONDITION(HasSameOwnerDoc(NODE_FROM(aParent, aDocument)),
+  NS_PRECONDITION((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
                   "Must have the same owner document");
   NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
                   "aDocument must be current doc of aParent");
   NS_PRECONDITION(!GetCurrentDoc(), "Already have a document.  Unbind first!");
   // Note that as we recurse into the kids, they'll have a non-null parent.  So
   // only assert if our parent is _changing_ while we have a parent.
   NS_PRECONDITION(!GetParent() || aParent == GetParent(),
                   "Already have a parent.  Unbind first!");
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -278,17 +278,17 @@ nsDOMAttributeMap::SetNamedItemInternal(
 
     // setting a preexisting attribute is a no-op, just return the same
     // node.
     nsRefPtr<Attr> attribute = &aAttr;
     return attribute.forget();
   }
 
   nsresult rv;
-  if (!mContent->HasSameOwnerDoc(&aAttr)) {
+  if (mContent->OwnerDoc() != aAttr.OwnerDoc()) {
     nsCOMPtr<nsINode> adoptedNode =
       mContent->OwnerDoc()->AdoptNode(aAttr, aError);
     if (aError.Failed()) {
       return nullptr;
     }
 
     NS_ASSERTION(adoptedNode == &aAttr, "Uh, adopt node changed nodes?");
   }
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -435,17 +435,17 @@ nsGenericDOMDataNode::ToCString(nsAStrin
 
 
 nsresult
 nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                                  nsIContent* aBindingParent,
                                  bool aCompileEventHandlers)
 {
   NS_PRECONDITION(aParent || aDocument, "Must have document if no parent!");
-  NS_PRECONDITION(HasSameOwnerDoc(NODE_FROM(aParent, aDocument)),
+  NS_PRECONDITION(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
                   "Must have the same owner document");
   NS_PRECONDITION(!aParent || aDocument == aParent->GetCurrentDoc(),
                   "aDocument must be current doc of aParent");
   NS_PRECONDITION(!GetCurrentDoc() && !IsInDoc(),
                   "Already have a document.  Unbind first!");
   // Note that as we recurse into the kids, they'll have a non-null parent.  So
   // only assert if our parent is _changing_ while we have a parent.
   NS_PRECONDITION(!GetParent() || aParent == GetParent(),
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -1313,17 +1313,17 @@ AdoptNodeIntoOwnerDoc(nsINode *aParent, 
 
   nsCOMPtr<nsIDOMNode> adoptedNode;
   rv = domDoc->AdoptNode(node, getter_AddRefs(adoptedNode));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(aParent->OwnerDoc() == doc,
                "ownerDoc chainged while adopting");
   NS_ASSERTION(adoptedNode == node, "Uh, adopt node changed nodes?");
-  NS_ASSERTION(aParent->HasSameOwnerDoc(aNode),
+  NS_ASSERTION(aParent->OwnerDoc() == aNode->OwnerDoc(),
                "ownerDocument changed again after adopting!");
 
   return NS_OK;
 }
 
 nsresult
 nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex,
                          bool aNotify, nsAttrAndChildArray& aChildArray)
@@ -1335,17 +1335,17 @@ nsINode::doInsertChildAt(nsIContent* aKi
   // The id-handling code, and in the future possibly other code, need to
   // react to unexpected attribute changes.
   nsMutationGuard::DidMutate();
 
   // Do this before checking the child-count since this could cause mutations
   nsIDocument* doc = GetCurrentDoc();
   mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
 
-  if (!HasSameOwnerDoc(aKid)) {
+  if (OwnerDoc() != aKid->OwnerDoc()) {
     rv = AdoptNodeIntoOwnerDoc(this, aKid);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   uint32_t childCount = aChildArray.ChildCount();
   NS_ENSURE_TRUE(aIndex <= childCount, NS_ERROR_ILLEGAL_VALUE);
   bool isAppend = (aIndex == childCount);
 
@@ -1948,17 +1948,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
     --insPos;
   }
 
   // Move new child over to our document if needed. Do this after removing
   // it from its parent so that AdoptNode doesn't fire DOMNodeRemoved
   // DocumentType nodes are the only nodes that can have a null
   // ownerDocument according to the DOM spec, and we need to allow
   // inserting them w/o calling AdoptNode().
-  if (!HasSameOwnerDoc(newContent)) {
+  if (OwnerDoc() != newContent->OwnerDoc()) {
     aError = AdoptNodeIntoOwnerDoc(this, aNewChild);
     if (aError.Failed()) {
       return nullptr;
     }
   }
 
   /*
    * Check if we're inserting a document fragment. If we are, we need