Bug 562688 part 6. Eliminate eELEMENT users in content/base. r=jst
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 30 Apr 2010 09:12:05 -0400
changeset 41636 f5ab6f6df21940f5037f897efd4e37b30926aeff
parent 41635 4872aec50aed6763f522ff120be9535d08075921
child 41637 95d587ae3c405bef88532658138e8fc616ee55e9
push id13073
push userbzbarsky@mozilla.com
push dateFri, 30 Apr 2010 13:15:13 +0000
treeherdermozilla-central@37cd6605aea2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs562688
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 562688 part 6. Eliminate eELEMENT users in content/base. r=jst
content/base/src/nsContentUtils.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocumentEncoder.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsNodeUtils.cpp
content/base/src/nsRange.cpp
content/base/src/nsTraversal.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3756,19 +3756,19 @@ nsContentUtils::CreateContextualFragment
         return NS_ERROR_OUT_OF_MEMORY;
       }
     }
     nsCOMPtr<nsIDOMDocumentFragment> frag;
     rv = NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
     NS_ENSURE_SUCCESS(rv, rv);
     
     nsCOMPtr<nsIContent> contextAsContent = do_QueryInterface(aContextNode);
-    if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
+    if (contextAsContent && !contextAsContent->IsElement()) {
       contextAsContent = contextAsContent->GetParent();
-      if (contextAsContent && !contextAsContent->IsNodeOfType(nsINode::eELEMENT)) {
+      if (contextAsContent && !contextAsContent->IsElement()) {
         // can this even happen?
         contextAsContent = nsnull;
       }
     }
     
     if (contextAsContent) {
       parser->ParseFragment(aFragment, 
                             frag, 
@@ -3787,20 +3787,20 @@ nsContentUtils::CreateContextualFragment
     document->SetFragmentParser(parser);
     return NS_OK;
   }
 
   nsAutoTArray<nsString, 32> tagStack;
   nsAutoString uriStr, nameStr;
   nsCOMPtr<nsIContent> content = do_QueryInterface(aContextNode);
   // just in case we have a text node
-  if (content && !content->IsNodeOfType(nsINode::eELEMENT))
+  if (content && !content->IsElement())
     content = content->GetParent();
 
-  while (content && content->IsNodeOfType(nsINode::eELEMENT)) {
+  while (content && content->IsElement()) {
     nsString& tagName = *tagStack.AppendElement();
     NS_ENSURE_TRUE(&tagName, NS_ERROR_OUT_OF_MEMORY);
 
     content->NodeInfo()->GetQualifiedName(tagName);
 
     // see if we need to add xmlns declarations
     PRUint32 count = content->GetAttrCount();
     PRBool setDefaultNamespace = PR_FALSE;
@@ -3999,17 +3999,17 @@ nsContentUtils::SetNodeTextContent(nsICo
   return aContent->AppendChildTo(textContent, PR_TRUE);
 }
 
 static void AppendNodeTextContentsRecurse(nsINode* aNode, nsAString& aResult)
 {
   nsIContent* child;
   PRUint32 i;
   for (i = 0; (child = aNode->GetChildAt(i)); ++i) {
-    if (child->IsNodeOfType(nsINode::eELEMENT)) {
+    if (child->IsElement()) {
       AppendNodeTextContentsRecurse(child, aResult);
     }
     else if (child->IsNodeOfType(nsINode::eTEXT)) {
       child->AppendTextTo(aResult);
     }
   }
 }
 
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2703,17 +2703,17 @@ nsDocument::ElementFromPointHelper(float
     *aReturn = CheckAncestryAndGetFrame(currentDoc).get();
     return NS_OK;
   }
 
   // If we have an anonymous element (such as an internal div from a textbox),
   // or a node that isn't an element (such as a text frame node),
   // replace it with the first non-anonymous parent node of type element.
   while (ptContent &&
-         (!ptContent->IsNodeOfType(nsINode::eELEMENT) ||
+         (!ptContent->IsElement() ||
           ptContent->IsInAnonymousSubtree())) {
     // XXXldb: Faster to jump to GetBindingParent if non-null?
     ptContent = ptContent->GetParent();
   }
  
   if (ptContent)
     CallQueryInterface(ptContent, aReturn);
   return NS_OK;
@@ -2787,17 +2787,17 @@ nsDocument::NodesFromRectHelper(float aX
       }
       continue;
     }
 
     // If we have an anonymous element (such as an internal div from a textbox),
     // or a node that isn't an element or a text node,
     // replace it with the first non-anonymous parent node.
     while (ptContent &&
-           (!(ptContent->IsNodeOfType(nsINode::eELEMENT) ||
+           (!(ptContent->IsElement() ||
               ptContent->IsNodeOfType(nsINode::eTEXT)) ||
             ptContent->IsInAnonymousSubtree())) {
       // XXXldb: Faster to jump to GetBindingParent if non-null?
       ptContent = ptContent->GetParent();
     }
    
     if (ptContent && ptContent != lastAdded) {
       elements->AppendElement(ptContent);
@@ -3402,17 +3402,17 @@ nsresult
 nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent)
 {
   NS_ASSERTION(aMutationEvent, "Someone tried to inhibit mutations on document child removal.");
   nsCOMPtr<nsIContent> oldKid = GetChildAt(aIndex);
   if (!oldKid) {
     return NS_OK;
   }
 
-  if (oldKid->IsNodeOfType(nsINode::eELEMENT)) {
+  if (oldKid->IsElement()) {
     // Destroy the link map up front before we mess with the child list.
     DestroyLinkMap();
   }
 
   nsresult rv = nsGenericElement::doRemoveChildAt(aIndex, aNotify, oldKid,
                                                   nsnull, this, mChildren, 
                                                   aMutationEvent);
   mCachedRootElement = nsnull;
@@ -5983,17 +5983,17 @@ BlastFunc(nsAttrHashKey::KeyType aKey, n
 
   return PL_DHASH_STOP;
 }
 
 static void
 BlastSubtreeToPieces(nsINode *aNode)
 {
   PRUint32 i, count;
-  if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
+  if (aNode->IsElement()) {
     nsGenericElement *element = static_cast<nsGenericElement*>(aNode);
     const nsDOMAttributeMap *map = element->GetAttributeMap();
     if (map) {
       nsCOMPtr<nsIAttribute> attr;
       while (map->Enumerate(BlastFunc, &attr) > 0) {
         BlastSubtreeToPieces(attr);
 
 #ifdef DEBUG
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -338,17 +338,17 @@ nsDocumentEncoder::SerializeNodeStart(ns
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
                                     nsAString& aStr)
 {
   //XXX Remove QIing to nsIDOM* when fixing bug 562321.
-  if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
+  if (aNode->IsElement()) {
     nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
     mSerializer->AppendElementEnd(element, aStr);
   }
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -322,18 +322,18 @@ static nsIContent* GetEditorRootContent(
 }
 
 nsIContent*
 nsINode::GetTextEditorRootContent(nsIEditor** aEditor)
 {
   if (aEditor)
     *aEditor = nsnull;
   for (nsINode* node = this; node; node = node->GetNodeParent()) {
-    if (!node->IsNodeOfType(eELEMENT) ||
-        !static_cast<nsIContent*>(node)->IsHTML())
+    if (!node->IsElement() ||
+        !node->AsElement()->IsHTML())
       continue;
 
     nsCOMPtr<nsIEditor> editor;
     static_cast<nsGenericHTMLElement*>(node)->
         GetEditorInternal(getter_AddRefs(editor));
     if (!editor)
       continue;
 
@@ -836,68 +836,71 @@ nsNode3Tearoff::AreNodesEqual(nsIContent
     docType1->GetInternalSubset(string1);
     docType2->GetInternalSubset(string2);
 
     if (!string1.Equals(string2)) {
       return PR_FALSE;
     }
   }
 
-  if (aContent1->IsNodeOfType(nsINode::eELEMENT)) {
-    // aContent1 is an element.  Do the check on attributes.
-    PRUint32 attrCount = aContent1->GetAttrCount();
-    if (attrCount != aContent2->GetAttrCount()) {
+  if (aContent1->IsElement()) {
+    // aContent1 is an element.  So is aContent2, since the nodeinfos
+    // were equal.  Do the check on attributes.
+    Element* element1 = aContent1->AsElement();
+    Element* element2 = aContent2->AsElement();
+    PRUint32 attrCount = element1->GetAttrCount();
+    if (attrCount != element2->GetAttrCount()) {
       return PR_FALSE;
     }
 
     // Iterate over attributes.
     for (PRUint32 i = 0; i < attrCount; ++i) {
-      const nsAttrName* attrName1 = aContent1->GetAttrNameAt(i);
+      const nsAttrName* attrName1 = element1->GetAttrNameAt(i);
 #ifdef DEBUG
       PRBool hasAttr =
 #endif
-      aContent1->GetAttr(attrName1->NamespaceID(),
-                         attrName1->LocalName(),
-                         string1);
+      element1->GetAttr(attrName1->NamespaceID(),
+                        attrName1->LocalName(),
+                        string1);
       NS_ASSERTION(hasAttr, "Why don't we have an attr?");
 
-      if (!aContent2->AttrValueIs(attrName1->NamespaceID(),
-                                  attrName1->LocalName(),
-                                  string1,
-                                  eCaseMatters)) {
+      if (!element2->AttrValueIs(attrName1->NamespaceID(),
+                                 attrName1->LocalName(),
+                                 string1,
+                                 eCaseMatters)) {
+        return PR_FALSE;
+      }
+    }
+
+    // Child nodes count.
+    PRUint32 childCount = element1->GetChildCount();
+    if (childCount != element2->GetChildCount()) {
+      return PR_FALSE;
+    }
+
+    // Iterate over child nodes.
+    for (PRUint32 i = 0; i < childCount; ++i) {
+      nsIContent* child1 = element1->GetChildAt(i);
+      nsIContent* child2 = element2->GetChildAt(i);
+      if (!AreNodesEqual(child1, child2)) {
         return PR_FALSE;
       }
     }
   } else {
     // aContent1 is not an element.  Node value check.
     nsCOMPtr<nsIDOMNode> domNode1 = do_QueryInterface(aContent1);
     nsCOMPtr<nsIDOMNode> domNode2 = do_QueryInterface(aContent2);
     NS_ASSERTION(domNode1 && domNode2, "How'd we get nsIContent without nsIDOMNode?");
     domNode1->GetNodeValue(string1);
     domNode2->GetNodeValue(string2);
     if (!string1.Equals(string2)) {
       return PR_FALSE;
     }
   }
 
-  // Child nodes count.
-  PRUint32 childCount = aContent1->GetChildCount();
-  if (childCount != aContent2->GetChildCount()) {
-    return PR_FALSE;
-  }
-
-  // Iterate over child nodes.
-  for (PRUint32 i = 0; i < childCount; ++i) {
-    nsIContent* child1 = aContent1->GetChildAt(i);
-    nsIContent* child2 = aContent2->GetChildAt(i);
-    if (!AreNodesEqual(child1, child2)) {
-      return PR_FALSE;
-    }
-  }
-
   return PR_TRUE;
 }
 
 NS_IMETHODIMP
 nsNode3Tearoff::IsEqualNode(nsIDOMNode* aOther, PRBool* aReturn)
 {
   *aReturn = PR_FALSE;
 
@@ -1001,34 +1004,34 @@ NS_IMETHODIMP
 nsNSElementTearoff::GetFirstElementChild(nsIDOMElement** aResult)
 {
   *aResult = nsnull;
 
   nsAttrAndChildArray& children = mContent->mAttrsAndChildren;
   PRUint32 i, count = children.ChildCount();
   for (i = 0; i < count; ++i) {
     nsIContent* child = children.ChildAt(i);
-    if (child->IsNodeOfType(nsINode::eELEMENT)) {
+    if (child->IsElement()) {
       return CallQueryInterface(child, aResult);
     }
   }
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNSElementTearoff::GetLastElementChild(nsIDOMElement** aResult)
 {
   *aResult = nsnull;
 
   nsAttrAndChildArray& children = mContent->mAttrsAndChildren;
   PRUint32 i = children.ChildCount();
   while (i > 0) {
     nsIContent* child = children.ChildAt(--i);
-    if (child->IsNodeOfType(nsINode::eELEMENT)) {
+    if (child->IsElement()) {
       return CallQueryInterface(child, aResult);
     }
   }
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1036,31 +1039,31 @@ nsNSElementTearoff::GetPreviousElementSi
 {
   *aResult = nsnull;
 
   nsIContent* parent = mContent->GetParent();
   if (!parent) {
     return NS_OK;
   }
 
-  NS_ASSERTION(parent->IsNodeOfType(nsINode::eELEMENT) ||
+  NS_ASSERTION(parent->IsElement() ||
                parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
                "Parent content must be an element or a doc fragment");
 
   nsAttrAndChildArray& children =
     static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
   PRInt32 index = children.IndexOfChild(mContent);
   if (index < 0) {
     return NS_OK;
   }
 
   PRUint32 i = index;
   while (i > 0) {
     nsIContent* child = children.ChildAt((PRUint32)--i);
-    if (child->IsNodeOfType(nsINode::eELEMENT)) {
+    if (child->IsElement()) {
       return CallQueryInterface(child, aResult);
     }
   }
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1068,31 +1071,31 @@ nsNSElementTearoff::GetNextElementSiblin
 {
   *aResult = nsnull;
 
   nsIContent* parent = mContent->GetParent();
   if (!parent) {
     return NS_OK;
   }
 
-  NS_ASSERTION(parent->IsNodeOfType(nsINode::eELEMENT) ||
+  NS_ASSERTION(parent->IsElement() ||
                parent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT),
                "Parent content must be an element or a doc fragment");
 
   nsAttrAndChildArray& children =
     static_cast<nsGenericElement*>(parent)->mAttrsAndChildren;
   PRInt32 index = children.IndexOfChild(mContent);
   if (index < 0) {
     return NS_OK;
   }
 
   PRUint32 i, count = children.ChildCount();
   for (i = (PRUint32)index + 1; i < count; ++i) {
     nsIContent* child = children.ChildAt(i);
-    if (child->IsNodeOfType(nsINode::eELEMENT)) {
+    if (child->IsElement()) {
       return CallQueryInterface(child, aResult);
     }
   }
   
   return NS_OK;
 }
 
 nsContentList*
@@ -3572,17 +3575,17 @@ PRBool IsAllowedAsChild(nsIContent* aNew
                         nsINode* aParent, PRBool aIsReplace,
                         nsIContent* aRefContent)
 {
   NS_PRECONDITION(aNewChild, "Must have new child");
   NS_PRECONDITION(!aIsReplace || aRefContent,
                   "Must have ref content for replace");
   NS_PRECONDITION(aParent->IsNodeOfType(nsINode::eDOCUMENT) ||
                   aParent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) ||
-                  aParent->IsNodeOfType(nsINode::eELEMENT),
+                  aParent->IsElement(),
                   "Nodes that are not documents, document fragments or "
                   "elements can't be parents!");
 #ifdef DEBUG
   PRUint16 debugNodeType = 0;
   nsCOMPtr<nsIDOMNode> debugNode(do_QueryInterface(aNewChild));
   nsresult debugRv = debugNode->GetNodeType(&debugNodeType);
 
   NS_PRECONDITION(NS_SUCCEEDED(debugRv) && debugNodeType == aNewNodeType,
@@ -3696,17 +3699,17 @@ PRBool IsAllowedAsChild(nsIContent* aNew
         return PR_TRUE;
       }
 
       PRBool sawElement = PR_FALSE;
       PRUint32 count = aNewChild->GetChildCount();
       for (PRUint32 index = 0; index < count; ++index) {
         nsIContent* childContent = aNewChild->GetChildAt(index);
         NS_ASSERTION(childContent, "Something went wrong");
-        if (childContent->IsNodeOfType(nsINode::eELEMENT)) {
+        if (childContent->IsElement()) {
           if (sawElement) {
             // Can't put two elements into a document
             return PR_FALSE;
           }
           sawElement = PR_TRUE;
         }
         // If we can put this content at the the right place, we might be ok;
         // if not, we bail out.
@@ -3925,17 +3928,18 @@ nsINode::ReplaceOrInsertBefore(PRBool aR
       insPos = refContent ? IndexOf(refContent) : GetChildCount();
       if (insPos < 0) {
         // Someone seriously messed up the childlist. We have no idea
         // where to insert the remaining children, so just bail.
         return NS_ERROR_DOM_NOT_FOUND_ERR;
       }
     }
 
-    PRBool appending = !IsNodeOfType(eDOCUMENT) && insPos == GetChildCount();
+    PRBool appending =
+      !IsNodeOfType(eDOCUMENT) && PRUint32(insPos) == GetChildCount();
     PRBool firstInsPos = insPos;
 
     // Iterate through the fragment's children, and insert them in the new
     // parent
     for (i = 0; i < count; ++i, ++insPos) {
       nsIContent* childContent = fragChildren[i];
 
       // XXXbz how come no reparenting here?  That seems odd...
@@ -5183,17 +5187,17 @@ TryMatchingElementsInSubtree(nsINode* aR
    * parent data chain, since we have those Around anyway */
   union { char c[2 * sizeof(RuleProcessorData)]; void *p; } databuf;
   RuleProcessorData* prevSibling = nsnull;
   RuleProcessorData* data = reinterpret_cast<RuleProcessorData*>(databuf.c);
 
   PRBool continueIteration = PR_TRUE;
   for (nsINode::ChildIterator iter(aRoot); !iter.IsDone(); iter.Next()) {
     nsIContent* kid = iter;
-    if (!kid->IsNodeOfType(nsINode::eELEMENT)) {
+    if (!kid->IsElement()) {
       continue;
     }
     /* See whether we match */
     new (data) RuleProcessorData(aPresContext, kid, nsnull);
     NS_ASSERTION(!data->mParentData, "Shouldn't happen");
     NS_ASSERTION(!data->mPreviousSiblingData, "Shouldn't happen");
     data->mParentData = aParentData;
     data->mPreviousSiblingData = prevSibling;
--- a/content/base/src/nsNodeUtils.cpp
+++ b/content/base/src/nsNodeUtils.cpp
@@ -34,16 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsNodeUtils.h"
 #include "nsContentUtils.h"
 #include "nsINode.h"
 #include "nsIContent.h"
+#include "Element.h"
 #include "nsIMutationObserver.h"
 #include "nsIDocument.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsIEventListenerManager.h"
 #include "nsIAttribute.h"
 #include "nsIXPConnect.h"
 #include "nsGenericElement.h"
 #include "pldhash.h"
@@ -55,16 +56,18 @@
 #include "nsXULElement.h"
 #endif
 #include "nsBindingManager.h"
 #include "nsGenericHTMLElement.h"
 #ifdef MOZ_MEDIA
 #include "nsHTMLMediaElement.h"
 #endif // MOZ_MEDIA
 
+using namespace mozilla::dom;
+
 // This macro expects the ownerDocument of content_ to be in scope as
 // |nsIDocument* doc|
 #define IMPL_MUTATION_NOTIFICATION(func_, content_, params_)      \
   PR_BEGIN_MACRO                                                  \
   nsINode* node = content_;                                       \
   NS_ASSERTION(node->GetOwnerDoc() == doc, "Bogus document");     \
   if (doc) {                                                      \
     static_cast<nsIMutationObserver*>(doc->BindingManager())->    \
@@ -257,20 +260,20 @@ nsNodeUtils::LastRelease(nsINode* aNode)
       }
     }
 #endif
 
     nsContentUtils::RemoveListenerManager(aNode);
     aNode->UnsetFlags(NODE_HAS_LISTENERMANAGER);
   }
 
-  if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
+  if (aNode->IsElement()) {
     nsIDocument* ownerDoc = aNode->GetOwnerDoc();
     if (ownerDoc) {
-      ownerDoc->ClearBoxObjectFor(static_cast<nsIContent*>(aNode));
+      ownerDoc->ClearBoxObjectFor(aNode->AsElement());
     }
   }
 
   nsContentUtils::ReleaseWrapper(aNode, aNode);
 
   delete aNode;
 }
 
@@ -564,17 +567,17 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
     newNodeInfo = nodeInfoManager->GetNodeInfo(nodeInfo->NameAtom(),
                                                nodeInfo->GetPrefixAtom(),
                                                nodeInfo->NamespaceID());
     NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
     nodeInfo = newNodeInfo;
   }
 
-  nsGenericElement *elem = aNode->IsNodeOfType(nsINode::eELEMENT) ?
+  nsGenericElement *elem = aNode->IsElement() ?
                            static_cast<nsGenericElement*>(aNode) :
                            nsnull;
 
   nsCOMPtr<nsINode> clone;
   PRBool isDeepDocumentClone = PR_FALSE;
   if (aClone) {
     rv = aNode->Clone(nodeInfo, getter_AddRefs(clone));
     NS_ENSURE_SUCCESS(rv, rv);
@@ -592,30 +595,30 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
       // the cloned document (somewhat like cloning and importing them into the
       // cloned document).
       nodeInfoManager = clone->mNodeInfo->NodeInfoManager();
     }
   }
   else if (nodeInfoManager) {
     nsIDocument* oldDoc = aNode->GetOwnerDoc();
     PRBool wasRegistered = PR_FALSE;
-    if (oldDoc && aNode->IsNodeOfType(nsINode::eELEMENT)) {
-      nsIContent* content = static_cast<nsIContent*>(aNode);
-      oldDoc->ClearBoxObjectFor(content);
-      wasRegistered = oldDoc->UnregisterFreezableElement(content);
+    if (oldDoc && aNode->IsElement()) {
+      Element* element = aNode->AsElement();
+      oldDoc->ClearBoxObjectFor(element);
+      wasRegistered = oldDoc->UnregisterFreezableElement(element);
     }
 
     aNode->mNodeInfo.swap(newNodeInfo);
 
     nsIDocument* newDoc = aNode->GetOwnerDoc();
     if (newDoc) {
       // XXX what if oldDoc is null, we don't know if this should be
       // registered or not! Can that really happen?
       if (wasRegistered) {
-        newDoc->RegisterFreezableElement(static_cast<nsIContent*>(aNode));
+        newDoc->RegisterFreezableElement(aNode->AsElement());
       }
 
       nsPIDOMWindow* window = newDoc->GetInnerWindow();
       if (window) {
         nsIEventListenerManager* elm = aNode->GetListenerManager(PR_FALSE);
         if (elm) {
           window->SetMutationListeners(elm->MutationListenerBits());
           if (elm->MayHavePaintEventListener()) {
@@ -718,17 +721,18 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNod
   // ChangeDocumentFor() call in nsXULElement::BindToTree as well.  Also,
   // remove the UnbindFromTree call in ~nsXULElement, and add back in the
   // precondition in nsXULElement::UnbindFromTree and remove the line in
   // nsXULElement.h that makes nsNodeUtils a friend of nsXULElement.
   // Note: Make sure to do this witchery _after_ we've done any deep
   // cloning, so kids of the new node aren't confused about whether they're
   // in a document.
 #ifdef MOZ_XUL
-  if (aClone && !aParent && aNode->IsNodeOfType(nsINode::eELEMENT) && static_cast<nsIContent*>(aNode)->IsXUL()) {
+  if (aClone && !aParent && aNode->IsElement() &&
+      aNode->AsElement()->IsXUL()) {
     nsXULElement *xulElem = static_cast<nsXULElement*>(elem);
     if (!xulElem->mPrototype || xulElem->IsInDoc()) {
       clone->SetFlags(NODE_FORCE_XBL_BINDINGS);
     }
   }
 #endif
 
   if (aNode->HasProperties()) {
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -864,18 +864,18 @@ RangeSubtreeIterator::Init(nsIDOMRange *
 
   nsCOMPtr<nsIDOMCharacterData> startData = do_QueryInterface(node);
   if (startData) {
     mStart = node;
   } else {
     PRInt32 startIndex;
     aRange->GetStartOffset(&startIndex);
     nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
-    if (iNode->IsNodeOfType(nsINode::eELEMENT) && 
-        PRInt32(iNode->GetChildCount()) == startIndex) {
+    if (iNode->IsElement() && 
+        PRInt32(iNode->AsElement()->GetChildCount()) == startIndex) {
       mStart = node;
     }
   }
 
   // Grab the end point of the range and QI it to
   // a CharacterData pointer. If it is CharacterData store
   // a pointer to the node.
 
@@ -884,17 +884,17 @@ RangeSubtreeIterator::Init(nsIDOMRange *
 
   nsCOMPtr<nsIDOMCharacterData> endData = do_QueryInterface(node);
   if (endData) {
     mEnd = node;
   } else {
     PRInt32 endIndex;
     aRange->GetEndOffset(&endIndex);
     nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
-    if (iNode->IsNodeOfType(nsINode::eELEMENT) && endIndex == 0) {
+    if (iNode->IsElement() && endIndex == 0) {
       mEnd = node;
     }
   }
 
   if (mStart && mStart == mEnd)
   {
     // The range starts and stops in the same CharacterData
     // node. Null out the end pointer so we only visit the
@@ -1340,20 +1340,20 @@ nsresult nsRange::CutContents(nsIDOMDocu
 
         handled = PR_TRUE;
       }       
     }
 
     if (!handled && (node == endContainer || node == startContainer))
     {
       nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
-      if (iNode && iNode->IsNodeOfType(nsINode::eELEMENT) &&
+      if (iNode && iNode->IsElement() &&
           ((node == endContainer && endOffset == 0) ||
            (node == startContainer &&
-            PRInt32(iNode->GetChildCount()) == startOffset)))
+            PRInt32(iNode->AsElement()->GetChildCount()) == startOffset)))
       {
         if (retval) {
           nsCOMPtr<nsIDOMNode> clone;
           rv = node->CloneNode(PR_FALSE, getter_AddRefs(clone));
           NS_ENSURE_SUCCESS(rv, rv);
           nodeToResult = clone;
         }
         handled = PR_TRUE;
@@ -1619,20 +1619,21 @@ nsresult nsRange::CloneContents(nsIDOMDo
   // that the Range spec requires us to return. This loop clones the
   // parent hierarchy, adds a cloned version of the subtree, to it, then
   // correctly places this new subtree into the doc fragment.
 
   while (!iter.IsDone())
   {
     nsCOMPtr<nsIDOMNode> node(iter.GetCurrentNode());
     nsCOMPtr<nsINode> iNode = do_QueryInterface(node);
-    PRBool deepClone = !(iNode->IsNodeOfType(nsINode::eELEMENT)) ||
+    PRBool deepClone = !iNode->IsElement() ||
                        (!(iNode == mEndParent && mEndOffset == 0) &&
                         !(iNode == mStartParent &&
-                          mStartOffset == PRInt32(iNode->GetChildCount())));
+                          mStartOffset ==
+                            PRInt32(iNode->AsElement()->GetChildCount())));
 
     // Clone the current subtree!
 
     nsCOMPtr<nsIDOMNode> clone;
     res = node->CloneNode(deepClone, getter_AddRefs(clone));
     if (NS_FAILED(res)) return res;
 
     // If it's CharacterData, make sure we only clone what
--- a/content/base/src/nsTraversal.cpp
+++ b/content/base/src/nsTraversal.cpp
@@ -77,17 +77,17 @@ nsresult nsTraversal::TestNode(nsINode* 
     NS_ENSURE_TRUE(!mInAcceptNode, NS_ERROR_DOM_INVALID_STATE_ERR);
 
     nsresult rv;
 
     *_filtered = nsIDOMNodeFilter::FILTER_SKIP;
 
     PRUint16 nodeType = 0;
     // Check the most common cases
-    if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
+    if (aNode->IsElement()) {
         nodeType = nsIDOMNode::ELEMENT_NODE;
     }
     else if (aNode->IsNodeOfType(nsINode::eCONTENT)) {
         nsIAtom* tag = static_cast<nsIContent*>(aNode)->Tag();
         if (tag == nsGkAtoms::textTagName) {
             nodeType = nsIDOMNode::TEXT_NODE;
         }
         else if (tag == nsGkAtoms::cdataTagName) {