Bug 1134280 - Get rid of Tag() - patch 2.11 - layout/xul - Fix all the occurrences, m=smaug, r=surkov
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Mar 2015 11:09:00 +0000
changeset 261902 70f156455f82408d801e1ffb4bfa377793ffcf1e
parent 261901 9e7aa092d6ec34e71fb70e9530120762cee2a4cb
child 261903 4d58f27af3fc557e293eab98f0b0a49c597b23bf
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1134280
milestone39.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 1134280 - Get rid of Tag() - patch 2.11 - layout/xul - Fix all the occurrences, m=smaug, r=surkov
layout/xul/ListBoxObject.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsListBoxBodyFrame.cpp
layout/xul/nsMenuPopupFrame.cpp
layout/xul/nsScrollbarButtonFrame.cpp
layout/xul/nsXULPopupManager.cpp
layout/xul/nsXULTooltipListener.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeContentView.cpp
layout/xul/tree/nsTreeUtils.cpp
--- a/layout/xul/ListBoxObject.cpp
+++ b/layout/xul/ListBoxObject.cpp
@@ -140,17 +140,17 @@ ListBoxObject::GetIndexOfItem(Element& a
   return ret;
 }
 
 //////////////////////
 
 static nsIContent*
 FindBodyContent(nsIContent* aParent)
 {
-  if (aParent->Tag() == nsGkAtoms::listboxbody) {
+  if (aParent->IsXULElement(nsGkAtoms::listboxbody)) {
     return aParent;
   }
 
   mozilla::dom::FlattenedChildIterator iter(aParent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
     nsIContent* result = FindBodyContent(child);
     if (result) {
       return result;
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1111,21 +1111,20 @@ nsBoxFrame::AttributeChanged(int32_t aNa
                              nsIAtom* aAttribute,
                              int32_t aModType)
 {
   nsresult rv = nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute,
                                                    aModType);
 
   // Ignore 'width', 'height', 'screenX', 'screenY' and 'sizemode' on a
   // <window>.
-  nsIAtom *tag = mContent->Tag();
-  if ((tag == nsGkAtoms::window ||
-       tag == nsGkAtoms::page ||
-       tag == nsGkAtoms::dialog ||
-       tag == nsGkAtoms::wizard) &&
+  if (mContent->IsAnyOfXULElements(nsGkAtoms::window,
+                                   nsGkAtoms::page,
+                                   nsGkAtoms::dialog,
+                                   nsGkAtoms::wizard) &&
       (nsGkAtoms::width == aAttribute ||
        nsGkAtoms::height == aAttribute ||
        nsGkAtoms::screenX == aAttribute ||
        nsGkAtoms::screenY == aAttribute ||
        nsGkAtoms::sizemode == aAttribute)) {
     return rv;
   }
 
@@ -1241,17 +1240,17 @@ nsBoxFrame::AttributeChanged(int32_t aNa
     }
   }
   // If the accesskey changed, register for the new value
   // The old value has been unregistered in nsXULElement::SetAttr
   else if (aAttribute == nsGkAtoms::accesskey) {
     RegUnregAccessKey(true);
   }
   else if (aAttribute == nsGkAtoms::rows &&
-           tag == nsGkAtoms::tree) {
+           mContent->IsXULElement(nsGkAtoms::tree)) {
     // Reflow ourselves and all our children if "rows" changes, since
     // nsTreeBodyFrame's layout reads this from its parent (this frame).
     PresContext()->PresShell()->
       FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
   }
 
   return rv;
 }
@@ -1872,26 +1871,23 @@ nsBoxFrame::GetFrameSizeWithMargin(nsIFr
 
 // If you make changes to this function, check its counterparts
 // in nsTextBoxFrame and nsXULLabelFrame
 void
 nsBoxFrame::RegUnregAccessKey(bool aDoReg)
 {
   MOZ_ASSERT(mContent);
 
-  // find out what type of element this is
-  nsIAtom *atom = mContent->Tag();
-
   // only support accesskeys for the following elements
-  if (atom != nsGkAtoms::button &&
-      atom != nsGkAtoms::toolbarbutton &&
-      atom != nsGkAtoms::checkbox &&
-      atom != nsGkAtoms::textbox &&
-      atom != nsGkAtoms::tab &&
-      atom != nsGkAtoms::radio) {
+  if (!mContent->IsAnyOfXULElements(nsGkAtoms::button,
+                                    nsGkAtoms::toolbarbutton,
+                                    nsGkAtoms::checkbox,
+                                    nsGkAtoms::textbox,
+                                    nsGkAtoms::tab,
+                                    nsGkAtoms::radio)) {
     return;
   }
 
   nsAutoString accessKey;
   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey, accessKey);
 
   if (accessKey.IsEmpty())
     return;
--- a/layout/xul/nsListBoxBodyFrame.cpp
+++ b/layout/xul/nsListBoxBodyFrame.cpp
@@ -576,17 +576,17 @@ nsListBoxBodyFrame::GetIndexOfItem(nsIDO
 {
   if (aItem) {
     *_retval = 0;
     nsCOMPtr<nsIContent> itemContent(do_QueryInterface(aItem));
 
     FlattenedChildIterator iter(mContent);
     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
       // we hit a list row, count it
-      if (child->Tag() == nsGkAtoms::listitem) {
+      if (child->IsXULElement(nsGkAtoms::listitem)) {
         // is this it?
         if (child == itemContent)
           return NS_OK;
 
         ++(*_retval);
       }
     }
   }
@@ -602,17 +602,17 @@ nsListBoxBodyFrame::GetItemAtIndex(int32
   *aItem = nullptr;
   if (aIndex < 0)
     return NS_OK;
 
   int32_t itemCount = 0;
   FlattenedChildIterator iter(mContent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
     // we hit a list row, check if it is the one we are looking for
-    if (child->Tag() == nsGkAtoms::listitem) {
+    if (child->IsXULElement(nsGkAtoms::listitem)) {
       // is this it?
       if (itemCount == aIndex) {
         return CallQueryInterface(child, aItem);
       }
       ++itemCount;
     }
   }
 
@@ -704,17 +704,17 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
     if (styleContext->StylePadding()->GetPadding(margin))
       width += margin.LeftRight();
     width += styleContext->StyleBorder()->GetComputedBorder().LeftRight();
     if (styleContext->StyleMargin()->GetMargin(margin))
       width += margin.LeftRight();
 
     FlattenedChildIterator iter(mContent);
     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-      if (child->Tag() == nsGkAtoms::listitem) {
+      if (child->IsXULElement(nsGkAtoms::listitem)) {
         nsRenderingContext* rendContext = aBoxLayoutState.GetRenderingContext();
         if (rendContext) {
           nsAutoString value;
           uint32_t textCount = child->GetChildCount();
           for (uint32_t j = 0; j < textCount; ++j) {
             nsIContent* text = child->GetChildAt(j);
             if (text && text->IsNodeOfType(nsINode::eTEXT)) {
               text->AppendTextTo(value);
@@ -742,17 +742,17 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
 }
 
 void
 nsListBoxBodyFrame::ComputeTotalRowCount()
 {
   mRowCount = 0;
   FlattenedChildIterator iter(mContent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-    if (child->Tag() == nsGkAtoms::listitem) {
+    if (child->IsXULElement(nsGkAtoms::listitem)) {
       ++mRowCount;
     }
   }
 }
 
 void
 nsListBoxBodyFrame::PostReflowCallback()
 {
@@ -1094,17 +1094,17 @@ nsListBoxBodyFrame::ReverseDestroyRows(i
                      NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 static bool
 IsListItemChild(nsListBoxBodyFrame* aParent, nsIContent* aChild,
                 nsIFrame** aChildFrame)
 {
   *aChildFrame = nullptr;
-  if (!aChild->IsXULElement() || aChild->Tag() != nsGkAtoms::listitem) {
+  if (!aChild->IsXULElement(nsGkAtoms::listitem)) {
     return false;
   }
   nsIFrame* existingFrame = aChild->GetPrimaryFrame();
   if (existingFrame && existingFrame->GetParent() != aParent) {
     return false;
   }
   *aChildFrame = existingFrame;
   return true;
@@ -1458,17 +1458,17 @@ nsListBoxBodyFrame::OnContentRemoved(nsP
 void
 nsListBoxBodyFrame::GetListItemContentAt(int32_t aIndex, nsIContent** aContent)
 {
   *aContent = nullptr;
 
   int32_t itemsFound = 0;
   FlattenedChildIterator iter(mContent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-    if (child->Tag() == nsGkAtoms::listitem) {
+    if (child->IsXULElement(nsGkAtoms::listitem)) {
       ++itemsFound;
       if (itemsFound-1 == aIndex) {
         *aContent = child;
         NS_IF_ADDREF(*aContent);
         return;
       }
     }
   }
@@ -1477,17 +1477,17 @@ nsListBoxBodyFrame::GetListItemContentAt
 void
 nsListBoxBodyFrame::GetListItemNextSibling(nsIContent* aListItem, nsIContent** aContent, int32_t& aSiblingIndex)
 {
   *aContent = nullptr;
   aSiblingIndex = -1;
   nsIContent *prevKid = nullptr;
   FlattenedChildIterator iter(mContent);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-    if (child->Tag() == nsGkAtoms::listitem) {
+    if (child->IsXULElement(nsGkAtoms::listitem)) {
       ++aSiblingIndex;
       if (prevKid == aListItem) {
         *aContent = child;
         NS_IF_ADDREF(*aContent);
         return;
       }
     }
     prevKid = child;
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -274,18 +274,18 @@ nsMenuPopupFrame::CreateWidgetForView(ns
           static_cast<enum nsBorderStyle>(widgetData.mBorderStyle | eBorderStyle_close);
       }
     }
   }
 
   nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(this, this);
   nsIContent* parentContent = GetContent()->GetParent();
   nsIAtom *tag = nullptr;
-  if (parentContent)
-    tag = parentContent->Tag();
+  if (parentContent && parentContent->IsXULElement())
+    tag = parentContent->NodeInfo()->NameAtom();
   widgetData.mSupportTranslucency = mode == eTransparencyTransparent;
   widgetData.mDropShadow = !(mode == eTransparencyTransparent || tag == nsGkAtoms::menulist);
   widgetData.mPopupLevel = PopupLevel(widgetData.mNoAutoHide);
 
   // panels which have a parent level need a parent widget. This allows them to
   // always appear in front of the parent window but behind other windows that
   // should be in front of it.
   nsCOMPtr<nsIWidget> parentWidget;
--- a/layout/xul/nsScrollbarButtonFrame.cpp
+++ b/layout/xul/nsScrollbarButtonFrame.cpp
@@ -227,17 +227,17 @@ nsScrollbarButtonFrame::GetChildWithTag(
   nsIFrame* childFrame = start->GetFirstPrincipalChild();
   while (nullptr != childFrame) 
   {    
     // get the content node
     nsIContent* child = childFrame->GetContent();
 
     if (child) {
       // see if it is the child
-       if (child->Tag() == atom)
+       if (child->IsXULElement(atom))
        {
          result = childFrame;
 
          return NS_OK;
        }
     }
 
      // recursive search the child
@@ -259,17 +259,17 @@ nsScrollbarButtonFrame::GetParentWithTag
    while (start)
    {
       start = start->GetParent();
 
       if (start) {
         // get the content node
         nsIContent* child = start->GetContent();
 
-        if (child && child->Tag() == toFind) {
+        if (child && child->IsXULElement(toFind)) {
           result = start;
           return NS_OK;
         }
       }
    }
 
    result = nullptr;
    return NS_OK;
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -1564,17 +1564,17 @@ nsXULPopupManager::GetLastTriggerNode(ns
     return nullptr;
 
   nsCOMPtr<nsIDOMNode> node;
 
   // if mOpeningPopup is set, it means that a popupshowing event is being
   // fired. In this case, just use the cached node, as the popup is not yet in
   // the list of open popups.
   if (mOpeningPopup && mOpeningPopup->GetCurrentDoc() == aDocument &&
-      aIsTooltip == (mOpeningPopup->Tag() == nsGkAtoms::tooltip)) {
+      aIsTooltip == mOpeningPopup->IsXULElement(nsGkAtoms::tooltip)) {
     node = do_QueryInterface(nsMenuPopupFrame::GetTriggerContent(GetPopupFrameForContent(mOpeningPopup, false)));
   }
   else {
     nsMenuChainItem* item = aIsTooltip ? mNoHidePanels : mPopups;
     while (item) {
       // look for a popup of the same type and document.
       if ((item->PopupType() == ePopupTypeTooltip) == aIsTooltip &&
           item->Content()->GetCurrentDoc() == aDocument) {
@@ -2353,23 +2353,22 @@ nsXULPopupManager::GetPreviousMenuItem(n
   return aStart;
 }
 
 bool
 nsXULPopupManager::IsValidMenuItem(nsPresContext* aPresContext,
                                    nsIContent* aContent,
                                    bool aOnPopup)
 {
-  int32_t ns = aContent->GetNameSpaceID();
-  nsIAtom *tag = aContent->Tag();
-  if (ns == kNameSpaceID_XUL) {
-    if (tag != nsGkAtoms::menu && tag != nsGkAtoms::menuitem)
+  if (aContent->IsXULElement()) {
+    if (!aContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem)) {
       return false;
+    }
   }
-  else if (ns != kNameSpaceID_XHTML || !aOnPopup || tag != nsGkAtoms::option) {
+  else if (!aOnPopup || !aContent->IsHTMLElement(nsGkAtoms::option)) {
     return false;
   }
 
   bool skipNavigatingDisabledMenuItem = true;
   if (aOnPopup) {
     skipNavigatingDisabledMenuItem =
       LookAndFeel::GetInt(LookAndFeel::eIntID_SkipNavigatingDisabledMenuItem,
                           0) != 0;
--- a/layout/xul/nsXULTooltipListener.cpp
+++ b/layout/xul/nsXULTooltipListener.cpp
@@ -153,17 +153,17 @@ nsXULTooltipListener::MouseMove(nsIDOMEv
     return;
   mMouseScreenX = newMouseX;
   mMouseScreenY = newMouseY;
 
   nsCOMPtr<nsIContent> sourceContent = do_QueryInterface(
     aEvent->InternalDOMEvent()->GetCurrentTarget());
   mSourceNode = do_GetWeakReference(sourceContent);
 #ifdef MOZ_XUL
-  mIsSourceTree = sourceContent->Tag() == nsGkAtoms::treechildren;
+  mIsSourceTree = sourceContent->IsXULElement(nsGkAtoms::treechildren);
   if (mIsSourceTree)
     CheckTreeBodyMove(mouseEvent);
 #endif
 
   // as the mouse moves, we want to make sure we reset the timer to show it, 
   // so that the delay is from when the mouse stops moving, not when it enters
   // the node.
   KillTooltipTimer();
@@ -177,21 +177,19 @@ nsXULTooltipListener::MouseMove(nsIDOMEv
     // don't show tooltips attached to elements outside of a menu popup
     // when hovering over an element inside it. The popupsinherittooltip
     // attribute may be used to disable this behaviour, which is useful for
     // large menu hierarchies such as bookmarks.
     if (!sourceContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::popupsinherittooltip,
                                     nsGkAtoms::_true, eCaseMatters)) {
       nsCOMPtr<nsIContent> targetContent = do_QueryInterface(eventTarget);
       while (targetContent && targetContent != sourceContent) {
-        nsIAtom* tag = targetContent->Tag();
-        if (targetContent->GetNameSpaceID() == kNameSpaceID_XUL &&
-            (tag == nsGkAtoms::menupopup ||
-             tag == nsGkAtoms::panel ||
-             tag == nsGkAtoms::tooltip)) {
+        if (targetContent->IsAnyOfXULElements(nsGkAtoms::menupopup,
+                                              nsGkAtoms::panel,
+                                              nsGkAtoms::tooltip)) {
           mSourceNode = nullptr;
           return;
         }
 
         targetContent = targetContent->GetParent();
       }
     }
 
@@ -534,17 +532,17 @@ nsXULTooltipListener::HideTooltip()
 static void
 GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult) 
 {
   *aResult = nullptr;
   uint32_t childCount = aContent->GetChildCount();
   for (uint32_t i = 0; i < childCount; i++) {
     nsIContent *child = aContent->GetChildAt(i);
 
-    if (child->Tag() == aTag) {
+    if (child->IsXULElement(aTag)) {
       *aResult = child;
       NS_ADDREF(*aResult);
       return;
     }
   }
 
   return;
 }
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -189,18 +189,17 @@ nsTreeBodyFrame::GetMinSize(nsBoxLayoutS
 
   nsIContent* baseElement = GetBaseElement();
 
   nsSize min(0,0);
   int32_t desiredRows;
   if (MOZ_UNLIKELY(!baseElement)) {
     desiredRows = 0;
   }
-  else if (baseElement->Tag() == nsGkAtoms::select &&
-           baseElement->IsHTMLElement()) {
+  else if (baseElement->IsHTMLElement(nsGkAtoms::select)) {
     min.width = CalcMaxRowWidth();
     nsAutoString size;
     baseElement->GetAttr(kNameSpaceID_None, nsGkAtoms::size, size);
     if (!size.IsEmpty()) {
       nsresult err;
       desiredRows = size.ToInteger(&err);
       mHasFixedRowCount = true;
       mPageLength = desiredRows;
@@ -1781,18 +1780,17 @@ nsTreeBodyFrame::IsCellCropped(int32_t a
   return NS_OK;
 }
 
 void
 nsTreeBodyFrame::MarkDirtyIfSelect()
 {
   nsIContent* baseElement = GetBaseElement();
 
-  if (baseElement && baseElement->Tag() == nsGkAtoms::select &&
-      baseElement->IsHTMLElement()) {
+  if (baseElement && baseElement->IsHTMLElement(nsGkAtoms::select)) {
     // If we are an intrinsically sized select widget, we may need to
     // resize, if the widest item was removed or a new item was added.
     // XXX optimize this more
 
     mStringWidth = -1;
     PresContext()->PresShell()->FrameNeedsReflow(this,
                                                  nsIPresShell::eTreeChange,
                                                  NS_FRAME_IS_DIRTY);
--- a/layout/xul/tree/nsTreeContentView.cpp
+++ b/layout/xul/tree/nsTreeContentView.cpp
@@ -444,18 +444,17 @@ nsTreeContentView::GetCellText(int32_t a
   Row* row = mRows[aRow];
 
   // Check for a "label" attribute - this is valid on an <treeitem>
   // with a single implied column.
   if (row->mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, _retval)
       && !_retval.IsEmpty())
     return NS_OK;
 
-  nsIAtom *rowTag = row->mContent->Tag();
-  if (rowTag == nsGkAtoms::treeitem && row->mContent->IsXULElement()) {
+  if (row->mContent->IsXULElement(nsGkAtoms::treeitem)) {
     nsIContent* realRow =
       nsTreeUtils::GetImmediateChild(row->mContent, nsGkAtoms::treerow);
     if (realRow) {
       nsIContent* cell = GetCell(realRow, aCol);
       if (cell)
         cell->GetAttr(kNameSpaceID_None, nsGkAtoms::label, _retval);
     }
   }
@@ -718,51 +717,50 @@ nsTreeContentView::AttributeChanged(nsID
                                     nsIAtom*      aAttribute,
                                     int32_t       aModType)
 {
   // Lots of codepaths under here that do all sorts of stuff, so be safe.
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
   // Make sure this notification concerns us.
   // First check the tag to see if it's one that we care about.
-  nsIAtom* tag = aElement->Tag();
 
   if (mBoxObject && (aElement == mRoot || aElement == mBody)) {
     mBoxObject->ClearStyleAndImageCaches();
     mBoxObject->Invalidate();
   }
 
   // We don't consider non-XUL nodes.
   nsIContent* parent = nullptr;
   if (!aElement->IsXULElement() ||
       ((parent = aElement->GetParent()) && !parent->IsXULElement())) {
     return;
   }
-  if (tag != nsGkAtoms::treecol &&
-      tag != nsGkAtoms::treeitem &&
-      tag != nsGkAtoms::treeseparator &&
-      tag != nsGkAtoms::treerow &&
-      tag != nsGkAtoms::treecell) {
+  if (!aElement->IsAnyOfXULElements(nsGkAtoms::treecol,
+                                    nsGkAtoms::treeitem,
+                                    nsGkAtoms::treeseparator,
+                                    nsGkAtoms::treerow,
+                                    nsGkAtoms::treecell)) {
     return;
   }
 
   // If we have a legal tag, go up to the tree/select and make sure
   // that it's ours.
 
   for (nsIContent* element = aElement; element != mBody; element = element->GetParent()) {
     if (!element)
       return; // this is not for us
-    nsIAtom *parentTag = element->Tag();
-    if (element->IsXULElement() && parentTag == nsGkAtoms::tree)
+    if (element->IsXULElement(nsGkAtoms::tree))
       return; // this is not for us
   }
 
   // Handle changes of the hidden attribute.
   if (aAttribute == nsGkAtoms::hidden &&
-     (tag == nsGkAtoms::treeitem || tag == nsGkAtoms::treeseparator)) {
+      aElement->IsAnyOfXULElements(nsGkAtoms::treeitem,
+                                   nsGkAtoms::treeseparator)) {
     bool hidden = aElement->AttrValueIs(kNameSpaceID_None,
                                           nsGkAtoms::hidden,
                                           nsGkAtoms::_true, eCaseMatters);
  
     int32_t index = FindContent(aElement);
     if (hidden && index >= 0) {
       // Hide this row along with its children.
       int32_t count = RemoveRow(index);
@@ -775,31 +773,31 @@ nsTreeContentView::AttributeChanged(nsID
       if (parent) {
         InsertRowFor(parent, aElement);
       }
     }
 
     return;
   }
 
-  if (tag == nsGkAtoms::treecol) {
+  if (aElement->IsXULElement(nsGkAtoms::treecol)) {
     if (aAttribute == nsGkAtoms::properties) {
       if (mBoxObject) {
         nsCOMPtr<nsITreeColumns> cols;
         mBoxObject->GetColumns(getter_AddRefs(cols));
         if (cols) {
           nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aElement);
           nsCOMPtr<nsITreeColumn> col;
           cols->GetColumnFor(element, getter_AddRefs(col));
           mBoxObject->InvalidateColumn(col);
         }
       }
     }
   }
-  else if (tag == nsGkAtoms::treeitem) {
+  else if (aElement->IsXULElement(nsGkAtoms::treeitem)) {
     int32_t index = FindContent(aElement);
     if (index >= 0) {
       Row* row = mRows[index];
       if (aAttribute == nsGkAtoms::container) {
         bool isContainer =
           aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
                                 nsGkAtoms::_true, eCaseMatters);
         row->SetContainer(isContainer);
@@ -821,36 +819,36 @@ nsTreeContentView::AttributeChanged(nsID
           aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::empty,
                                 nsGkAtoms::_true, eCaseMatters);
         row->SetEmpty(isEmpty);
         if (mBoxObject)
           mBoxObject->InvalidateRow(index);
       }
     }
   }
-  else if (tag == nsGkAtoms::treeseparator) {
+  else if (aElement->IsXULElement(nsGkAtoms::treeseparator)) {
     int32_t index = FindContent(aElement);
     if (index >= 0) {
       if (aAttribute == nsGkAtoms::properties && mBoxObject) {
         mBoxObject->InvalidateRow(index);
       }
     }
   }
-  else if (tag == nsGkAtoms::treerow) {
+  else if (aElement->IsXULElement(nsGkAtoms::treerow)) {
     if (aAttribute == nsGkAtoms::properties) {
       nsCOMPtr<nsIContent> parent = aElement->GetParent();
       if (parent) {
         int32_t index = FindContent(parent);
         if (index >= 0 && mBoxObject) {
           mBoxObject->InvalidateRow(index);
         }
       }
     }
   }
-  else if (tag == nsGkAtoms::treecell) {
+  else if (aElement->IsXULElement(nsGkAtoms::treecell)) {
     if (aAttribute == nsGkAtoms::ref ||
         aAttribute == nsGkAtoms::properties ||
         aAttribute == nsGkAtoms::mode ||
         aAttribute == nsGkAtoms::src ||
         aAttribute == nsGkAtoms::value ||
         aAttribute == nsGkAtoms::label) {
       nsIContent* parent = aElement->GetParent();
       if (parent) {
@@ -884,67 +882,66 @@ nsTreeContentView::ContentInserted(nsIDo
                                    nsIContent* aContainer,
                                    nsIContent* aChild,
                                    int32_t /* unused */)
 {
   NS_ASSERTION(aChild, "null ptr");
 
   // Make sure this notification concerns us.
   // First check the tag to see if it's one that we care about.
-  nsIAtom *childTag = aChild->Tag();
 
   // Don't allow non-XUL nodes.
   if (!aChild->IsXULElement() || !aContainer->IsXULElement())
     return;
-  if (childTag != nsGkAtoms::treeitem &&
-      childTag != nsGkAtoms::treeseparator &&
-      childTag != nsGkAtoms::treechildren &&
-      childTag != nsGkAtoms::treerow &&
-      childTag != nsGkAtoms::treecell) {
+
+  if (!aChild->IsAnyOfXULElements(nsGkAtoms::treeitem,
+                                  nsGkAtoms::treeseparator,
+                                  nsGkAtoms::treechildren,
+                                  nsGkAtoms::treerow,
+                                  nsGkAtoms::treecell)) {
     return;
   }
 
   // If we have a legal tag, go up to the tree/select and make sure
   // that it's ours.
 
   for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) {
     if (!element)
       return; // this is not for us
-    nsIAtom *parentTag = element->Tag();
-    if (element->IsXULElement() && parentTag == nsGkAtoms::tree)
+    if (element->IsXULElement(nsGkAtoms::tree))
       return; // this is not for us
   }
 
   // Lots of codepaths under here that do all sorts of stuff, so be safe.
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
-  if (childTag == nsGkAtoms::treechildren) {
+  if (aChild->IsXULElement(nsGkAtoms::treechildren)) {
     int32_t index = FindContent(aContainer);
     if (index >= 0) {
       Row* row = mRows[index];
       row->SetEmpty(false);
       if (mBoxObject)
         mBoxObject->InvalidateRow(index);
       if (row->IsContainer() && row->IsOpen()) {
         int32_t count = EnsureSubtree(index);
         if (mBoxObject)
           mBoxObject->RowCountChanged(index + 1, count);
       }
     }
   }
-  else if (childTag == nsGkAtoms::treeitem ||
-           childTag == nsGkAtoms::treeseparator) {
+  else if (aChild->IsAnyOfXULElements(nsGkAtoms::treeitem,
+                                      nsGkAtoms::treeseparator)) {
     InsertRowFor(aContainer, aChild);
   }
-  else if (childTag == nsGkAtoms::treerow) {
+  else if (aChild->IsXULElement(nsGkAtoms::treerow)) {
     int32_t index = FindContent(aContainer);
     if (index >= 0 && mBoxObject)
       mBoxObject->InvalidateRow(index);
   }
-  else if (childTag == nsGkAtoms::treecell) {
+  else if (aChild->IsXULElement(nsGkAtoms::treecell)) {
     nsCOMPtr<nsIContent> parent = aContainer->GetParent();
     if (parent) {
       int32_t index = FindContent(parent);
       if (index >= 0 && mBoxObject)
         mBoxObject->InvalidateRow(index);
     }
   }
 }
@@ -955,72 +952,70 @@ nsTreeContentView::ContentRemoved(nsIDoc
                                   nsIContent* aChild,
                                   int32_t aIndexInContainer,
                                   nsIContent* aPreviousSibling)
 {
   NS_ASSERTION(aChild, "null ptr");
 
   // Make sure this notification concerns us.
   // First check the tag to see if it's one that we care about.
-  nsIAtom *tag = aChild->Tag();
 
   // We don't consider non-XUL nodes.
   if (!aChild->IsXULElement() || !aContainer->IsXULElement())
     return;
-  if (tag != nsGkAtoms::treeitem &&
-      tag != nsGkAtoms::treeseparator &&
-      tag != nsGkAtoms::treechildren &&
-      tag != nsGkAtoms::treerow &&
-      tag != nsGkAtoms::treecell) {
+
+  if (!aChild->IsAnyOfXULElements(nsGkAtoms::treeitem,
+                                  nsGkAtoms::treeseparator,
+                                  nsGkAtoms::treechildren,
+                                  nsGkAtoms::treerow,
+                                  nsGkAtoms::treecell)) {
     return;
   }
 
   // If we have a legal tag, go up to the tree/select and make sure
   // that it's ours.
 
   for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) {
     if (!element)
       return; // this is not for us
-    nsIAtom *parentTag = element->Tag();
-    if (element->IsXULElement() && parentTag == nsGkAtoms::tree)
+    if (element->IsXULElement(nsGkAtoms::tree))
       return; // this is not for us
   }
 
   // Lots of codepaths under here that do all sorts of stuff, so be safe.
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
-  if (tag == nsGkAtoms::treechildren) {
+  if (aChild->IsXULElement(nsGkAtoms::treechildren)) {
     int32_t index = FindContent(aContainer);
     if (index >= 0) {
       Row* row = mRows[index];
       row->SetEmpty(true);
       int32_t count = RemoveSubtree(index);
       // Invalidate also the row to update twisty.
       if (mBoxObject) {
         mBoxObject->InvalidateRow(index);
         mBoxObject->RowCountChanged(index + 1, -count);
       }
     }
   }
-  else if (tag == nsGkAtoms::treeitem ||
-           tag == nsGkAtoms::treeseparator
-          ) {
+  else if (aChild->IsAnyOfXULElements(nsGkAtoms::treeitem,
+                                      nsGkAtoms::treeseparator)) {
     int32_t index = FindContent(aChild);
     if (index >= 0) {
       int32_t count = RemoveRow(index);
       if (mBoxObject)
         mBoxObject->RowCountChanged(index, -count);
     }
   }
-  else if (tag == nsGkAtoms::treerow) {
+  else if (aChild->IsXULElement(nsGkAtoms::treerow)) {
     int32_t index = FindContent(aContainer);
     if (index >= 0 && mBoxObject)
       mBoxObject->InvalidateRow(index);
   }
-  else if (tag == nsGkAtoms::treecell) {
+  else if (aChild->IsXULElement(nsGkAtoms::treecell)) {
     nsCOMPtr<nsIContent> parent = aContainer->GetParent();
     if (parent) {
       int32_t index = FindContent(parent);
       if (index >= 0 && mBoxObject)
         mBoxObject->InvalidateRow(index);
     }
   }
 }
@@ -1040,25 +1035,24 @@ nsTreeContentView::Serialize(nsIContent*
                              int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows)
 {
   // Don't allow non-XUL nodes.
   if (!aContent->IsXULElement())
     return;
 
   dom::FlattenedChildIterator iter(aContent);
   for (nsIContent* content = iter.GetNextChild(); content; content = iter.GetNextChild()) {
-    nsIAtom *tag = content->Tag();
     int32_t count = aRows.Length();
 
-    if (content->IsXULElement()) {
-      if (tag == nsGkAtoms::treeitem)
-        SerializeItem(content, aParentIndex, aIndex, aRows);
-      else if (tag == nsGkAtoms::treeseparator)
-        SerializeSeparator(content, aParentIndex, aIndex, aRows);
+    if (content->IsXULElement(nsGkAtoms::treeitem)) {
+      SerializeItem(content, aParentIndex, aIndex, aRows);
+    } else if (content->IsXULElement(nsGkAtoms::treeseparator)) {
+      SerializeSeparator(content, aParentIndex, aIndex, aRows);
     }
+
     *aIndex += aRows.Length() - count;
   }
 }
 
 void
 nsTreeContentView::SerializeItem(nsIContent* aContent, int32_t aParentIndex,
                                  int32_t* aIndex, nsTArray<nsAutoPtr<Row> >& aRows)
 {
@@ -1117,39 +1111,35 @@ nsTreeContentView::GetIndexInSubtree(nsI
     return;
 
   for (uint32_t i = 0; i < childCount; i++) {
     nsIContent *content = aContainer->GetChildAt(i);
 
     if (content == aContent)
       break;
 
-    nsIAtom *tag = content->Tag();
-
-    if (content->IsXULElement()) {
-      if (tag == nsGkAtoms::treeitem) {
-        if (! content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
-                                   nsGkAtoms::_true, eCaseMatters)) {
-          (*aIndex)++;
-          if (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
-                                   nsGkAtoms::_true, eCaseMatters) &&
-              content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
-                                   nsGkAtoms::_true, eCaseMatters)) {
-            nsIContent* child =
-              nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treechildren);
-            if (child && child->IsXULElement())
-              GetIndexInSubtree(child, aContent, aIndex);
-          }
+    if (content->IsXULElement(nsGkAtoms::treeitem)) {
+      if (! content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
+                                 nsGkAtoms::_true, eCaseMatters)) {
+        (*aIndex)++;
+        if (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
+                                 nsGkAtoms::_true, eCaseMatters) &&
+            content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
+                                 nsGkAtoms::_true, eCaseMatters)) {
+          nsIContent* child =
+            nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treechildren);
+          if (child && child->IsXULElement())
+            GetIndexInSubtree(child, aContent, aIndex);
         }
       }
-      else if (tag == nsGkAtoms::treeseparator) {
-        if (! content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
-                                   nsGkAtoms::_true, eCaseMatters))
-          (*aIndex)++;
-      }
+    }
+    else if (content->IsXULElement(nsGkAtoms::treeseparator)) {
+      if (! content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
+                                 nsGkAtoms::_true, eCaseMatters))
+        (*aIndex)++;
     }
   }
 }
 
 int32_t
 nsTreeContentView::EnsureSubtree(int32_t aIndex)
 {
   Row* row = mRows[aIndex];
@@ -1199,19 +1189,18 @@ nsTreeContentView::RemoveSubtree(int32_t
 
 void
 nsTreeContentView::InsertRowFor(nsIContent* aParent, nsIContent* aChild)
 {
   int32_t grandParentIndex = -1;
   bool insertRow = false;
 
   nsCOMPtr<nsIContent> grandParent = aParent->GetParent();
-  nsIAtom* grandParentTag = grandParent->Tag();
 
-  if (grandParent->IsXULElement() && grandParentTag == nsGkAtoms::tree) {
+  if (grandParent->IsXULElement(nsGkAtoms::tree)) {
     // Allow insertion to the outermost container.
     insertRow = true;
   }
   else {
     // Test insertion to an inner container.
 
     // First try to find this parent in our array of rows, if we find one
     // we can be sure that all other parents are open too.
@@ -1232,22 +1221,20 @@ nsTreeContentView::InsertRowFor(nsIConte
       mBoxObject->RowCountChanged(grandParentIndex + index + 1, count);
   }
 }
 
 int32_t
 nsTreeContentView::InsertRow(int32_t aParentIndex, int32_t aIndex, nsIContent* aContent)
 {
   nsAutoTArray<nsAutoPtr<Row>, 8> rows;
-  nsIAtom *tag = aContent->Tag();
-  if (aContent->IsXULElement()) {
-    if (tag == nsGkAtoms::treeitem)
-      SerializeItem(aContent, aParentIndex, &aIndex, rows);
-    else if (tag == nsGkAtoms::treeseparator)
-      SerializeSeparator(aContent, aParentIndex, &aIndex, rows);
+  if (aContent->IsXULElement(nsGkAtoms::treeitem)) {
+    SerializeItem(aContent, aParentIndex, &aIndex, rows);
+  } else if (aContent->IsXULElement(nsGkAtoms::treeseparator)) {
+    SerializeSeparator(aContent, aParentIndex, &aIndex, rows);
   }
 
   // We can't use InsertElementsAt since the destination can't steal
   // ownership from its const source argument.
   for (nsTArray<Row>::index_type i = 0; i < rows.Length(); i++) {
     nsAutoPtr<Row>* newRow = mRows.InsertElementAt(aParentIndex + aIndex + i + 1);
     *newRow = rows[i];
   }
@@ -1360,17 +1347,17 @@ nsTreeContentView::GetCell(nsIContent* a
   aCol->GetIndex(&colIndex);
 
   // Traverse through cells, try to find the cell by "ref" attribute or by cell
   // index in a row. "ref" attribute has higher priority.
   nsIContent* result = nullptr;
   int32_t j = 0;
   dom::FlattenedChildIterator iter(aContainer);
   for (nsIContent* cell = iter.GetNextChild(); cell; cell = iter.GetNextChild()) {
-    if (cell->Tag() == nsGkAtoms::treecell) {
+    if (cell->IsXULElement(nsGkAtoms::treecell)) {
       if (colAtom && cell->AttrValueIs(kNameSpaceID_None, nsGkAtoms::ref,
                                        colAtom, eCaseMatters)) {
         result = cell;
         break;
       }
       else if (j == colIndex) {
         result = cell;
       }
--- a/layout/xul/tree/nsTreeUtils.cpp
+++ b/layout/xul/tree/nsTreeUtils.cpp
@@ -51,30 +51,30 @@ nsTreeUtils::TokenizeProperties(const ns
   return NS_OK;
 }
 
 nsIContent*
 nsTreeUtils::GetImmediateChild(nsIContent* aContainer, nsIAtom* aTag)
 {
   dom::FlattenedChildIterator iter(aContainer);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-    if (child->Tag() == aTag) {
+    if (child->IsXULElement(aTag)) {
       return child;
     }
   }
 
   return nullptr;
 }
 
 nsIContent*
 nsTreeUtils::GetDescendantChild(nsIContent* aContainer, nsIAtom* aTag)
 {
   dom::FlattenedChildIterator iter(aContainer);
   for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
-    if (child->Tag() == aTag) {
+    if (child->IsXULElement(aTag)) {
       return child;
     }
 
     child = GetDescendantChild(child, aTag);
     if (child) {
       return child;
     }
   }