Bug 1134280 - Get rid of Tag() - patch 2.1 - /accessible - Fix all the occurrences, m=smaug, r=surkov
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Mar 2015 11:08:59 +0000
changeset 260430 869306cc4c2f124e02124ca1306ecf6e813561da
parent 260429 133ec7304f2208e89f02ed943480a1b1f02188c9
child 260431 b80d9dc2137e804afbf4917aa54675c3da59df96
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [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.1 - /accessible - Fix all the occurrences, m=smaug, r=surkov
accessible/base/AccIterator.cpp
accessible/base/Logging.cpp
accessible/base/TextAttrs.cpp
accessible/base/nsAccessibilityService.cpp
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/generic/DocAccessible.cpp
accessible/generic/HyperTextAccessible.cpp
accessible/generic/RootAccessible.cpp
accessible/html/HTMLFormControlAccessible.cpp
accessible/html/HTMLListAccessible.cpp
accessible/html/HTMLSelectAccessible.cpp
accessible/html/HTMLTableAccessible.cpp
accessible/windows/msaa/AccessibleWrap.cpp
accessible/xul/XULElementAccessibles.cpp
accessible/xul/XULFormControlAccessible.cpp
--- a/accessible/base/AccIterator.cpp
+++ b/accessible/base/AccIterator.cpp
@@ -136,40 +136,38 @@ HTMLLabelIterator::
 
 Accessible*
 HTMLLabelIterator::Next()
 {
   // Get either <label for="[id]"> element which explicitly points to given
   // element, or <label> ancestor which implicitly point to it.
   Accessible* label = nullptr;
   while ((label = mRelIter.Next())) {
-    if (label->GetContent()->Tag() == nsGkAtoms::label)
+    if (label->GetContent()->IsHTMLElement(nsGkAtoms::label))
       return label;
   }
 
   // Ignore ancestor label on not widget accessible.
   if (mLabelFilter == eSkipAncestorLabel || !mAcc->IsWidget())
     return nullptr;
 
   // Go up tree to get a name of ancestor label if there is one (an ancestor
   // <label> implicitly points to us). Don't go up farther than form or
   // document.
   Accessible* walkUp = mAcc->Parent();
   while (walkUp && !walkUp->IsDoc()) {
     nsIContent* walkUpElm = walkUp->GetContent();
-    if (walkUpElm->IsHTMLElement()) {
-      if (walkUpElm->Tag() == nsGkAtoms::label &&
-          !walkUpElm->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
-        mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
-        return walkUp;
-      }
+    if (walkUpElm->IsHTMLElement(nsGkAtoms::label) &&
+        !walkUpElm->HasAttr(kNameSpaceID_None, nsGkAtoms::_for)) {
+      mLabelFilter = eSkipAncestorLabel; // prevent infinite loop
+      return walkUp;
+    }
 
-      if (walkUpElm->Tag() == nsGkAtoms::form)
-        break;
-    }
+    if (walkUpElm->IsHTMLElement(nsGkAtoms::form))
+      break;
 
     walkUp = walkUp->Parent();
   }
 
   return nullptr;
 }
 
 
@@ -183,17 +181,17 @@ HTMLOutputIterator(DocAccessible* aDocum
 {
 }
 
 Accessible*
 HTMLOutputIterator::Next()
 {
   Accessible* output = nullptr;
   while ((output = mRelIter.Next())) {
-    if (output->GetContent()->Tag() == nsGkAtoms::output)
+    if (output->GetContent()->IsHTMLElement(nsGkAtoms::output))
       return output;
   }
 
   return nullptr;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -206,17 +204,17 @@ XULLabelIterator::
 {
 }
 
 Accessible*
 XULLabelIterator::Next()
 {
   Accessible* label = nullptr;
   while ((label = mRelIter.Next())) {
-    if (label->GetContent()->Tag() == nsGkAtoms::label)
+    if (label->GetContent()->IsXULElement(nsGkAtoms::label))
       return label;
   }
 
   return nullptr;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -229,17 +227,17 @@ XULDescriptionIterator::
 {
 }
 
 Accessible*
 XULDescriptionIterator::Next()
 {
   Accessible* descr = nullptr;
   while ((descr = mRelIter.Next())) {
-    if (descr->GetContent()->Tag() == nsGkAtoms::description)
+    if (descr->GetContent()->IsXULElement(nsGkAtoms::description))
       return descr;
   }
 
   return nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // IDRefsIterator
--- a/accessible/base/Logging.cpp
+++ b/accessible/base/Logging.cpp
@@ -708,17 +708,17 @@ logging::Node(const char* aDescr, nsINod
     printf("%s: %p, not accessible node type, idx in parent: %d\n",
            aDescr, static_cast<void*>(aNode), idxInParent);
     return;
   }
 
   dom::Element* elm = aNode->AsElement();
 
   nsAutoCString tag;
-  elm->Tag()->ToUTF8String(tag);
+  elm->NodeInfo()->NameAtom()->ToUTF8String(tag);
 
   nsIAtom* idAtom = elm->GetID();
   nsAutoCString id;
   if (idAtom)
     idAtom->ToUTF8String(id);
 
   printf("%s: %p, %s@id='%s', idx in parent: %d\n",
          aDescr, static_cast<void*>(elm), tag.get(), id.get(), idxInParent);
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -867,18 +867,17 @@ TextAttrsMgr::TextPosTextAttr::
     case eStyleUnit_Turn:
     case eStyleUnit_FlexFraction:
     case eStyleUnit_Integer:
     case eStyleUnit_Calc:
       break;
   }
 
   const nsIContent* content = aFrame->GetContent();
-  if (content && content->IsHTMLElement()) {
-    const nsIAtom* tagName = content->Tag();
-    if (tagName == nsGkAtoms::sup)
+  if (content) {
+    if (content->IsHTMLElement(nsGkAtoms::sup))
       return eTextPosSuper;
-    if (tagName == nsGkAtoms::sub)
+    if (content->IsHTMLElement(nsGkAtoms::sub))
       return eTextPosSub;
   }
 
   return eTextPosNone;
 }
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -888,27 +888,25 @@ nsAccessibilityService::GetOrCreateAcces
     // elements return the image frame as their primary frame. The main content
     // for the image frame is the image content. If the frame is not an image
     // frame or the node is not an area element then null is returned.
     // This setup will change when bug 135040 is fixed. Make sure we don't
     // create area accessible here. Hopefully assertion below will handle that.
 
 #ifdef DEBUG
   nsImageFrame* imageFrame = do_QueryFrame(frame);
-  NS_ASSERTION(imageFrame && content->IsHTMLElement() &&
-               content->Tag() == nsGkAtoms::area,
+  NS_ASSERTION(imageFrame && content->IsHTMLElement(nsGkAtoms::area),
                "Unknown case of not main content for the frame!");
 #endif
     return nullptr;
   }
 
 #ifdef DEBUG
   nsImageFrame* imageFrame = do_QueryFrame(frame);
-  NS_ASSERTION(!imageFrame || !content->IsHTMLElement() ||
-               content->Tag() != nsGkAtoms::area,
+  NS_ASSERTION(!imageFrame || !content->IsHTMLElement(nsGkAtoms::area),
                "Image map manages the area accessible creation!");
 #endif
 
   // Attempt to create an accessible based on what we know.
   nsRefPtr<Accessible> newAcc;
 
   // Create accessible for visible text frames.
   if (content->IsNodeOfType(nsINode::eTEXT)) {
@@ -928,18 +926,17 @@ nsAccessibilityService::GetOrCreateAcces
     if (!aContext->IsAcceptableChild(newAcc))
       return nullptr;
 
     document->BindToDocument(newAcc, nullptr);
     newAcc->AsTextLeaf()->SetText(text);
     return newAcc;
   }
 
-  bool isHTML = content->IsHTMLElement();
-  if (isHTML && content->Tag() == nsGkAtoms::map) {
+  if (content->IsHTMLElement(nsGkAtoms::map)) {
     // Create hyper text accessible for HTML map if it is used to group links
     // (see http://www.w3.org/TR/WCAG10-HTML-TECHS/#group-bypass). If the HTML
     // map rect is empty then it is used for links grouping. Otherwise it should
     // be used in conjunction with HTML image element and in this case we don't
     // create any accessible for it and don't walk into it. The accessibles for
     // HTML area (HTMLAreaAccessible) the map contains are attached as
     // children of the appropriate accessible for HTML image
     // (ImageAccessible).
@@ -968,17 +965,17 @@ nsAccessibilityService::GetOrCreateAcces
       (roleMapEntry->Is(nsGkAtoms::presentation) ||
        roleMapEntry->Is(nsGkAtoms::none))) {
     if (!MustBeAccessible(content, document))
       return nullptr;
 
     roleMapEntry = nullptr;
   }
 
-  if (!newAcc && isHTML) {  // HTML accessibles
+  if (!newAcc && content->IsHTMLElement()) {  // HTML accessibles
     bool isARIATableOrCell = roleMapEntry &&
       (roleMapEntry->accTypes & (eTableCell | eTable));
 
     if (!isARIATableOrCell ||
         frame->AccessibleType() == eHTMLTableCellType ||
         frame->AccessibleType() == eHTMLTableType) {
       // Prefer to use markup (mostly tag name, perhaps attributes) to decide if
       // and what kind of accessible to create,
@@ -1006,19 +1003,19 @@ nsAccessibilityService::GetOrCreateAcces
         nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
         if (!contextRoleMap->IsOfType(eTable))
           roleMapEntry = &aria::gEmptyRoleMap;
 
       } else if (frame->AccessibleType() == eHTMLTableCellType &&
                  aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
         roleMapEntry = &aria::gEmptyRoleMap;
 
-      } else if (content->Tag() == nsGkAtoms::dt ||
-                 content->Tag() == nsGkAtoms::li ||
-                 content->Tag() == nsGkAtoms::dd ||
+      } else if (content->IsAnyOfHTMLElements(nsGkAtoms::dt,
+                                              nsGkAtoms::li,
+                                              nsGkAtoms::dd) ||
                  frame->AccessibleType() == eHTMLLiType) {
         nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
         if (!contextRoleMap->IsOfType(eList))
           roleMapEntry = &aria::gEmptyRoleMap;
       }
     }
   }
 
@@ -1054,38 +1051,40 @@ nsAccessibilityService::GetOrCreateAcces
   if (!newAcc) {
     if (content->IsSVGElement()) {
       nsSVGPathGeometryFrame* pathGeometryFrame = do_QueryFrame(frame);
       if (pathGeometryFrame) {
         // A graphic elements: rect, circle, ellipse, line, path, polygon,
         // polyline and image. A 'use' and 'text' graphic elements require
         // special support.
         newAcc = new EnumRoleAccessible(content, document, roles::GRAPHIC);
-      } else if (content->Tag() == nsGkAtoms::svg) {
+      } else if (content->IsSVGElement(nsGkAtoms::svg)) {
         newAcc = new EnumRoleAccessible(content, document, roles::DIAGRAM);
       }
     } else if (content->IsMathMLElement()) {
-      if (content->Tag() == nsGkAtoms::math)
+      if (content->IsMathMLElement(nsGkAtoms::math))
         newAcc = new EnumRoleAccessible(content, document, roles::EQUATION);
       else
         newAcc = new HyperTextAccessible(content, document);
     }
   }
 
   // If no accessible, see if we need to create a generic accessible because
   // of some property that makes this object interesting
   // We don't do this for <body>, <html>, <window>, <dialog> etc. which
   // correspond to the doc accessible and will be created in any case
-  if (!newAcc && content->Tag() != nsGkAtoms::body && content->GetParent() &&
+  if (!newAcc && !content->IsHTMLElement(nsGkAtoms::body) &&
+      content->GetParent() &&
       (roleMapEntry || MustBeAccessible(content, document) ||
-       (isHTML && nsCoreUtils::HasClickListener(content)))) {
+       (content->IsHTMLElement() &&
+        nsCoreUtils::HasClickListener(content)))) {
     // This content is focusable or has an interesting dynamic content accessibility property.
     // If it's interesting we need it in the accessibility hierarchy so that events or
     // other accessibles can point to it, or so that it can hold a state, etc.
-    if (isHTML) {
+    if (content->IsHTMLElement()) {
       // Interesting HTML container which may have selectable text and/or embedded objects
       newAcc = new HyperTextAccessibleWrap(content, document);
     } else {  // XUL, SVG, MathML etc.
       // Interesting generic non-HTML container
       newAcc = new AccessibleWrap(content, document);
     }
   }
 
@@ -1293,17 +1292,17 @@ nsAccessibilityService::CreateAccessible
   } else if (role.EqualsLiteral("xul:menupopup")) {
 #ifdef MOZ_ACCESSIBILITY_ATK
     // ATK considers this node to be redundant when within menubars, and it makes menu
     // navigation with assistive technologies more difficult
     // XXX In the future we will should this for consistency across the nsIAccessible
     // implementations on each platform for a consistent scripting environment, but
     // then strip out redundant accessibles in the AccessibleWrap class for each platform.
     nsIContent *parent = aContent->GetParent();
-    if (parent && parent->IsXULElement() && parent->Tag() == nsGkAtoms::menu)
+    if (parent && parent->IsXULElement(nsGkAtoms::menu))
       return nullptr;
 #endif
 
     accessible = new XULMenupopupAccessible(aContent, aDoc);
 
   } else if(role.EqualsLiteral("xul:menuseparator")) {
     accessible = new XULMenuSeparatorAccessible(aContent, aDoc);
 
@@ -1387,55 +1386,55 @@ nsAccessibilityService::CreateHTMLAccess
         new HTMLTableHeaderCellAccessibleWrap(aContent, document);
       return accessible.forget();
     }
 
     return nullptr;
   }
 
   // This method assumes we're in an HTML namespace.
-  nsIAtom* tag = aContent->Tag();
-  if (tag == nsGkAtoms::figcaption) {
+  if (aContent->IsHTMLElement(nsGkAtoms::figcaption)) {
     nsRefPtr<Accessible> accessible =
       new HTMLFigcaptionAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::figure) {
+  if (aContent->IsHTMLElement(nsGkAtoms::figure)) {
     nsRefPtr<Accessible> accessible =
       new HTMLFigureAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::legend) {
+  if (aContent->IsHTMLElement(nsGkAtoms::legend)) {
     nsRefPtr<Accessible> accessible =
       new HTMLLegendAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::option) {
+  if (aContent->IsHTMLElement(nsGkAtoms::option)) {
     nsRefPtr<Accessible> accessible =
       new HTMLSelectOptionAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::optgroup) {
+  if (aContent->IsHTMLElement(nsGkAtoms::optgroup)) {
     nsRefPtr<Accessible> accessible =
       new HTMLSelectOptGroupAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::ul || tag == nsGkAtoms::ol ||
-      tag == nsGkAtoms::dl) {
+  if (aContent->IsAnyOfHTMLElements(nsGkAtoms::ul,
+                                    nsGkAtoms::ol,
+                                    nsGkAtoms::dl)) {
     nsRefPtr<Accessible> accessible =
       new HTMLListAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::a) {
+  if (aContent->IsHTMLElement(nsGkAtoms::a)) {
     // Only some roles truly enjoy life as HTMLLinkAccessibles, for details
     // see closed bug 494807.
     nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aContent);
     if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
         roleMapEntry->role != roles::LINK) {
       nsRefPtr<Accessible> accessible =
         new HyperTextAccessibleWrap(aContent, document);
       return accessible.forget();
@@ -1446,68 +1445,68 @@ nsAccessibilityService::CreateHTMLAccess
     return accessible.forget();
   }
 
   if (aContext->IsList()) {
     // If list item is a child of accessible list then create an accessible for
     // it unconditionally by tag name. nsBlockFrame creates the list item
     // accessible for other elements styled as list items.
     if (aContext->GetContent() == aContent->GetParent()) {
-      if (tag == nsGkAtoms::dt || tag == nsGkAtoms::li) {
+      if (aContent->IsAnyOfHTMLElements(nsGkAtoms::dt, nsGkAtoms::li)) {
         nsRefPtr<Accessible> accessible =
           new HTMLLIAccessible(aContent, document);
         return accessible.forget();
       }
 
-      if (tag == nsGkAtoms::dd) {
+      if (aContent->IsHTMLElement(nsGkAtoms::dd)) {
         nsRefPtr<Accessible> accessible =
           new HyperTextAccessibleWrap(aContent, document);
         return accessible.forget();
       }
     }
 
     return nullptr;
   }
 
-  if (tag == nsGkAtoms::abbr ||
-      tag == nsGkAtoms::acronym ||
-      tag == nsGkAtoms::article ||
-      tag == nsGkAtoms::aside ||
-      tag == nsGkAtoms::blockquote ||
-      tag == nsGkAtoms::form ||
-      tag == nsGkAtoms::footer ||
-      tag == nsGkAtoms::header ||
-      tag == nsGkAtoms::h1 ||
-      tag == nsGkAtoms::h2 ||
-      tag == nsGkAtoms::h3 ||
-      tag == nsGkAtoms::h4 ||
-      tag == nsGkAtoms::h5 ||
-      tag == nsGkAtoms::h6 ||
-      tag == nsGkAtoms::nav ||
-      tag == nsGkAtoms::q ||
-      tag == nsGkAtoms::section ||
-      tag == nsGkAtoms::time) {
+  if (aContent->IsAnyOfHTMLElements(nsGkAtoms::abbr,
+                                    nsGkAtoms::acronym,
+                                    nsGkAtoms::article,
+                                    nsGkAtoms::aside,
+                                    nsGkAtoms::blockquote,
+                                    nsGkAtoms::form,
+                                    nsGkAtoms::footer,
+                                    nsGkAtoms::header,
+                                    nsGkAtoms::h1,
+                                    nsGkAtoms::h2,
+                                    nsGkAtoms::h3,
+                                    nsGkAtoms::h4,
+                                    nsGkAtoms::h5,
+                                    nsGkAtoms::h6,
+                                    nsGkAtoms::nav,
+                                    nsGkAtoms::q,
+                                    nsGkAtoms::section,
+                                    nsGkAtoms::time)) {
     nsRefPtr<Accessible> accessible =
       new HyperTextAccessibleWrap(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::label) {
+  if (aContent->IsHTMLElement(nsGkAtoms::label)) {
     nsRefPtr<Accessible> accessible =
       new HTMLLabelAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::output) {
+  if (aContent->IsHTMLElement(nsGkAtoms::output)) {
     nsRefPtr<Accessible> accessible =
       new HTMLOutputAccessible(aContent, document);
     return accessible.forget();
   }
 
-  if (tag == nsGkAtoms::progress) {
+  if (aContent->IsHTMLElement(nsGkAtoms::progress)) {
     nsRefPtr<Accessible> accessible =
       new HTMLProgressMeterAccessible(aContent, document);
     return accessible.forget();
   }
 
   return nullptr;
  }
 
@@ -1615,17 +1614,17 @@ nsAccessibilityService::CreateAccessible
         }
       }
       break;
     }
     case eHTMLTextFieldType:
       newAcc = new HTMLTextFieldAccessible(aContent, document);
       break;
     case eHyperTextType:
-      if (aContent->Tag() != nsGkAtoms::dt && aContent->Tag() != nsGkAtoms::dd)
+      if (!aContent->IsAnyOfHTMLElements(nsGkAtoms::dt, nsGkAtoms::dd))
         newAcc = new HyperTextAccessibleWrap(aContent, document);
       break;
 
     case eImageType:
       newAcc = new ImageAccessibleWrap(aContent, document);
       break;
     case eOuterDocType:
       newAcc = new OuterDocAccessible(aContent, document);
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -349,18 +349,17 @@ Accessible::VisibilityState()
     if (nsLayoutUtils::IsPopup(curFrame))
       return 0;
 
     // Offscreen state for background tab content and invisible for not selected
     // deck panel.
     nsIFrame* parentFrame = curFrame->GetParent();
     nsDeckFrame* deckFrame = do_QueryFrame(parentFrame);
     if (deckFrame && deckFrame->GetSelectedBox() != curFrame) {
-      if (deckFrame->GetContent()->IsXULElement() &&
-          deckFrame->GetContent()->Tag() == nsGkAtoms::tabpanels)
+      if (deckFrame->GetContent()->IsXULElement(nsGkAtoms::tabpanels))
         return states::OFFSCREEN;
 
       NS_NOTREACHED("Children of not selected deck panel are not accessible.");
       return states::INVISIBLE;
     }
 
     // If contained by scrollable frame then check that at least 12 pixels
     // around the object is visible, otherwise the object is offscreen.
@@ -815,17 +814,17 @@ Accessible::XULElmName(DocAccessible* aD
   if (!aName.IsEmpty())
     return;
 
   // Can get text from title of <toolbaritem> if we're a child of a <toolbaritem>
   nsIContent *bindingParent = aElm->GetBindingParent();
   nsIContent* parent =
     bindingParent? bindingParent->GetParent() : aElm->GetParent();
   while (parent) {
-    if (parent->Tag() == nsGkAtoms::toolbaritem &&
+    if (parent->IsXULElement(nsGkAtoms::toolbaritem) &&
         parent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName)) {
       aName.CompressWhitespace();
       return;
     }
     parent = parent->GetParent();
   }
 }
 
@@ -1526,17 +1525,17 @@ Accessible::RelationByType(RelationType 
       }
 
       return rel;
     }
 
     case RelationType::LABEL_FOR: {
       Relation rel(new RelatedAccIterator(Document(), mContent,
                                           nsGkAtoms::aria_labelledby));
-      if (mContent->Tag() == nsGkAtoms::label && mContent->IsXULElement())
+      if (mContent->IsXULElement(nsGkAtoms::label))
         rel.AppendIter(new IDRefsIterator(mDoc, mContent, nsGkAtoms::control));
 
       return rel;
     }
 
     case RelationType::DESCRIBED_BY: {
       Relation rel(new IDRefsIterator(mDoc, mContent,
                                       nsGkAtoms::aria_describedby));
@@ -1548,18 +1547,17 @@ Accessible::RelationByType(RelationType 
 
     case RelationType::DESCRIPTION_FOR: {
       Relation rel(new RelatedAccIterator(Document(), mContent,
                                           nsGkAtoms::aria_describedby));
 
       // This affectively adds an optional control attribute to xul:description,
       // which only affects accessibility, by allowing the description to be
       // tied to a control.
-      if (mContent->Tag() == nsGkAtoms::description &&
-          mContent->IsXULElement())
+      if (mContent->IsXULElement(nsGkAtoms::description))
         rel.AppendIter(new IDRefsIterator(mDoc, mContent,
                                           nsGkAtoms::control));
 
       return rel;
     }
 
     case RelationType::NODE_CHILD_OF: {
       Relation rel(new ARIAOwnedByIterator(this));
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -560,18 +560,17 @@ public:
    */
   virtual void GetNativeInterface(void** aNativeAccessible);
 
   //////////////////////////////////////////////////////////////////////////////
   // Downcasting and types
 
   inline bool IsAbbreviation() const
   {
-    return mContent->IsHTMLElement() &&
-      (mContent->Tag() == nsGkAtoms::abbr || mContent->Tag() == nsGkAtoms::acronym);
+    return mContent->IsAnyOfHTMLElements(nsGkAtoms::abbr, nsGkAtoms::acronym);
   }
 
   bool IsApplication() const { return mType == eApplicationType; }
   ApplicationAccessible* AsApplication();
 
   bool IsAutoComplete() const { return HasGenericType(eAutoComplete); }
 
   bool IsAutoCompletePopup() const
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1495,25 +1495,23 @@ DocAccessible::AddDependentIDsFor(dom::E
                                   nsIAtom* aRelAttr)
 {
   for (uint32_t idx = 0; idx < kRelationAttrsLen; idx++) {
     nsIAtom* relAttr = *kRelationAttrs[idx];
     if (aRelAttr && aRelAttr != relAttr)
       continue;
 
     if (relAttr == nsGkAtoms::_for) {
-      if (!aRelProviderElm->IsHTMLElement() ||
-          (aRelProviderElm->Tag() != nsGkAtoms::label &&
-           aRelProviderElm->Tag() != nsGkAtoms::output))
+      if (!aRelProviderElm->IsAnyOfHTMLElements(nsGkAtoms::label,
+                                                nsGkAtoms::output))
         continue;
 
     } else if (relAttr == nsGkAtoms::control) {
-      if (!aRelProviderElm->IsXULElement() ||
-          (aRelProviderElm->Tag() != nsGkAtoms::label &&
-           aRelProviderElm->Tag() != nsGkAtoms::description))
+      if (!aRelProviderElm->IsAnyOfXULElements(nsGkAtoms::label,
+                                               nsGkAtoms::description))
         continue;
     }
 
     IDRefsIterator iter(this, aRelProviderElm, relAttr);
     while (true) {
       const nsDependentSubstring id = iter.NextID();
       if (id.IsEmpty())
         break;
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -54,44 +54,44 @@ HyperTextAccessible::
   mGenericTypes |= eHyperText;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(HyperTextAccessible, Accessible)
 
 role
 HyperTextAccessible::NativeRole()
 {
-  nsIAtom *tag = mContent->Tag();
-
-  if (tag == nsGkAtoms::dd)
+  if (mContent->IsHTMLElement(nsGkAtoms::dd))
     return roles::DEFINITION;
 
-  if (tag == nsGkAtoms::form)
+  if (mContent->IsHTMLElement(nsGkAtoms::form))
     return roles::FORM;
 
-  if (tag == nsGkAtoms::blockquote || tag == nsGkAtoms::div ||
-      tag == nsGkAtoms::section || tag == nsGkAtoms::nav)
+  if (mContent->IsAnyOfHTMLElements(nsGkAtoms::blockquote,
+                                    nsGkAtoms::div,
+                                    nsGkAtoms::section,
+                                    nsGkAtoms::nav))
     return roles::SECTION;
 
-  if (tag == nsGkAtoms::h1 || tag == nsGkAtoms::h2 ||
-      tag == nsGkAtoms::h3 || tag == nsGkAtoms::h4 ||
-      tag == nsGkAtoms::h5 || tag == nsGkAtoms::h6)
+  if (mContent->IsAnyOfHTMLElements(nsGkAtoms::h1, nsGkAtoms::h2,
+                                    nsGkAtoms::h3, nsGkAtoms::h4,
+                                    nsGkAtoms::h5, nsGkAtoms::h6))
     return roles::HEADING;
 
-  if (tag == nsGkAtoms::article)
+  if (mContent->IsHTMLElement(nsGkAtoms::article))
     return roles::DOCUMENT;
 
   // Deal with html landmark elements
-  if (tag == nsGkAtoms::header)
+  if (mContent->IsHTMLElement(nsGkAtoms::header))
     return roles::HEADER;
 
-  if (tag == nsGkAtoms::footer)
+  if (mContent->IsHTMLElement(nsGkAtoms::footer))
     return roles::FOOTER;
 
-  if (tag == nsGkAtoms::aside)
+  if (mContent->IsHTMLElement(nsGkAtoms::aside))
     return roles::NOTE;
 
   // Treat block frames as paragraphs
   nsIFrame *frame = GetFrame();
   if (frame && frame->GetType() == nsGkAtoms::blockFrame)
     return roles::PARAGRAPH;
 
   return roles::TEXT_CONTAINER; // In ATK this works
@@ -100,17 +100,17 @@ HyperTextAccessible::NativeRole()
 uint64_t
 HyperTextAccessible::NativeState()
 {
   uint64_t states = AccessibleWrap::NativeState();
 
   if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_MOZ_READWRITE)) {
     states |= states::EDITABLE;
 
-  } else if (mContent->Tag() == nsGkAtoms::article) {
+  } else if (mContent->IsHTMLElement(nsGkAtoms::article)) {
     // We want <article> to behave like a document in terms of readonly state.
     states |= states::READONLY;
   }
 
   if (HasChildren())
     states |= states::SELECTABLE_TEXT;
 
   return states;
@@ -895,28 +895,27 @@ HyperTextAccessible::DefaultTextAttribut
   TextAttrsMgr textAttrsMgr(this);
   textAttrsMgr.GetAttributes(attributes);
   return attributes.forget();
 }
 
 int32_t
 HyperTextAccessible::GetLevelInternal()
 {
-  nsIAtom *tag = mContent->Tag();
-  if (tag == nsGkAtoms::h1)
+  if (mContent->IsHTMLElement(nsGkAtoms::h1))
     return 1;
-  if (tag == nsGkAtoms::h2)
+  if (mContent->IsHTMLElement(nsGkAtoms::h2))
     return 2;
-  if (tag == nsGkAtoms::h3)
+  if (mContent->IsHTMLElement(nsGkAtoms::h3))
     return 3;
-  if (tag == nsGkAtoms::h4)
+  if (mContent->IsHTMLElement(nsGkAtoms::h4))
     return 4;
-  if (tag == nsGkAtoms::h5)
+  if (mContent->IsHTMLElement(nsGkAtoms::h5))
     return 5;
-  if (tag == nsGkAtoms::h6)
+  if (mContent->IsHTMLElement(nsGkAtoms::h6))
     return 6;
 
   return AccessibleWrap::GetLevelInternal();
 }
 
 already_AddRefed<nsIPersistentProperties>
 HyperTextAccessible::NativeAttributes()
 {
@@ -939,24 +938,23 @@ HyperTextAccessible::NativeAttributes()
       strLineNumber.AppendInt(lineNumber);
       nsAccUtils::SetAccAttr(attributes, nsGkAtoms::lineNumber, strLineNumber);
     }
   }
 
   if (!HasOwnContent())
     return attributes.forget();
 
-  nsIAtom* tag = mContent->Tag();
-  if (tag == nsGkAtoms::section)  {
+  if (mContent->IsHTMLElement(nsGkAtoms::section)) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("region"));
-  } else if (tag == nsGkAtoms::article) {
+  } else if (mContent->IsHTMLElement(nsGkAtoms::article)) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("article"));
-  } else if (tag == nsGkAtoms::time) {
+  } else if (mContent->IsHTMLElement(nsGkAtoms::time)) {
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::xmlroles,
                            NS_LITERAL_STRING("time"));
 
     if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::datetime)) {
       nsAutoString datetime;
       mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::datetime, datetime);
       nsAccUtils::SetAccAttr(attributes, nsGkAtoms::datetime, datetime);
     }
@@ -965,48 +963,52 @@ HyperTextAccessible::NativeAttributes()
   return attributes.forget();
 }
 
 nsIAtom*
 HyperTextAccessible::LandmarkRole() const
 {
   // For the html landmark elements we expose them like we do ARIA landmarks to
   // make AT navigation schemes "just work".
-  nsIAtom* tag = mContent->Tag();
-  if (tag == nsGkAtoms::nav)
+  if (mContent->IsHTMLElement(nsGkAtoms::nav)) {
     return nsGkAtoms::navigation;
+  }
 
-  if (tag == nsGkAtoms::header || tag == nsGkAtoms::footer) {
+  if (mContent->IsAnyOfHTMLElements(nsGkAtoms::header,
+                                    nsGkAtoms::footer)) {
     // Only map header and footer if they are not descendants of an article
     // or section tag.
     nsIContent* parent = mContent->GetParent();
     while (parent) {
-      if (parent->Tag() == nsGkAtoms::article ||
-          parent->Tag() == nsGkAtoms::section)
+      if (parent->IsAnyOfHTMLElements(nsGkAtoms::article, nsGkAtoms::section)) {
         break;
+      }
       parent = parent->GetParent();
     }
 
     // No article or section elements found.
     if (!parent) {
-      if (tag == nsGkAtoms::header)
+      if (mContent->IsHTMLElement(nsGkAtoms::header)) {
         return nsGkAtoms::banner;
+      }
 
-      if (tag == nsGkAtoms::footer) {
+      if (mContent->IsHTMLElement(nsGkAtoms::footer)) {
         return nsGkAtoms::contentinfo;
       }
     }
     return nullptr;
   }
 
-  if (tag == nsGkAtoms::aside)
+  if (mContent->IsHTMLElement(nsGkAtoms::aside)) {
     return nsGkAtoms::complementary;
+  }
 
-  if (tag == nsGkAtoms::main)
+  if (mContent->IsHTMLElement(nsGkAtoms::main)) {
     return nsGkAtoms::main;
+  }
 
   return nullptr;
 }
 
 int32_t
 HyperTextAccessible::OffsetAtPoint(int32_t aX, int32_t aY, uint32_t aCoordType)
 {
   nsIFrame* hyperFrame = GetFrame();
--- a/accessible/generic/RootAccessible.cpp
+++ b/accessible/generic/RootAccessible.cpp
@@ -87,18 +87,18 @@ RootAccessible::Name(nsString& aName)
   return eNameOK;
 }
 
 role
 RootAccessible::NativeRole()
 {
   // If it's a <dialog> or <wizard>, use roles::DIALOG instead
   dom::Element* rootElm = mDocumentNode->GetRootElement();
-  if (rootElm && (rootElm->Tag() == nsGkAtoms::dialog ||
-                  rootElm->Tag() == nsGkAtoms::wizard))
+  if (rootElm && rootElm->IsAnyOfXULElements(nsGkAtoms::dialog,
+                                             nsGkAtoms::wizard))
     return roles::DIALOG;
 
   return DocAccessibleWrap::NativeRole();
 }
 
 // RootAccessible protected member
 #ifdef MOZ_XUL
 uint32_t
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -245,17 +245,17 @@ HTMLButtonAccessible::NativeName(nsStrin
   // The same magic works for @alt and @value attributes in case of type="image"
   // element that has no valid @src (note if input@type="image" has an image
   // then neither @alt nor @value attributes are used to generate a visual label
   // and thus we need to obtain the accessible name directly from attribute
   // value). Also the same algorithm works in case of default labels for
   // type="submit"/"reset"/"image" elements.
 
   ENameValueFlag nameFlag = Accessible::NativeName(aName);
-  if (!aName.IsEmpty() || mContent->Tag() != nsGkAtoms::input ||
+  if (!aName.IsEmpty() || !mContent->IsHTMLElement(nsGkAtoms::input) ||
       !mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                              nsGkAtoms::image, eCaseMatters))
     return nameFlag;
 
   if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt, aName))
     mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aName);
 
   aName.CompressWhitespace();
--- a/accessible/html/HTMLListAccessible.cpp
+++ b/accessible/html/HTMLListAccessible.cpp
@@ -21,17 +21,17 @@ using namespace mozilla::a11y;
 // HTMLListAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(HTMLListAccessible, HyperTextAccessible)
 
 role
 HTMLListAccessible::NativeRole()
 {
-  if (mContent->Tag() == nsGkAtoms::dl)
+  if (mContent->IsHTMLElement(nsGkAtoms::dl))
     return roles::DEFINITION_LIST;
 
   return roles::LIST;
 }
 
 uint64_t
 HTMLListAccessible::NativeState()
 {
@@ -64,17 +64,17 @@ HTMLLIAccessible::Shutdown()
   mBullet = nullptr;
 
   HyperTextAccessibleWrap::Shutdown();
 }
 
 role
 HTMLLIAccessible::NativeRole()
 {
-  if (mContent->Tag() == nsGkAtoms::dt)
+  if (mContent->IsHTMLElement(nsGkAtoms::dt))
     return roles::TERM;
 
   return roles::LISTITEM;
 }
 
 uint64_t
 HTMLLIAccessible::NativeState()
 {
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -125,19 +125,18 @@ HTMLSelectListAccessible::CacheChildren(
   // to count all the <optgroup>s and <option>s as children because we want
   // a flat tree under the Select List.
   for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
        childContent = childContent->GetNextSibling()) {
     if (!childContent->IsHTMLElement()) {
       continue;
     }
 
-    nsIAtom* tag = childContent->Tag();
-    if (tag == nsGkAtoms::option ||
-        tag == nsGkAtoms::optgroup) {
+    if (childContent->IsAnyOfHTMLElements(nsGkAtoms::option,
+                                          nsGkAtoms::optgroup)) {
 
       // Get an accessible for option or optgroup and cache it.
       nsRefPtr<Accessible> accessible =
         GetAccService()->GetOrCreateAccessible(childContent, this);
       if (accessible)
         AppendChild(accessible);
     }
   }
--- a/accessible/html/HTMLTableAccessible.cpp
+++ b/accessible/html/HTMLTableAccessible.cpp
@@ -924,17 +924,17 @@ HTMLTableAccessible::IsProbablyLayoutTab
 
   if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::role)) {
     // Role attribute is present, but overridden roles have already been dealt with.
     // Only landmarks and other roles that don't override the role from native
     // markup are left to deal with here.
     RETURN_LAYOUT_ANSWER(false, "Has role attribute, weak role, and role is table");
   }
 
-  if (mContent->Tag() != nsGkAtoms::table)
+  if (!mContent->IsHTMLElement(nsGkAtoms::table))
     RETURN_LAYOUT_ANSWER(true, "table built by CSS display:table style");
 
   // Check if datatable attribute has "0" value.
   if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::datatable,
                             NS_LITERAL_STRING("0"), eCaseMatters)) {
     RETURN_LAYOUT_ANSWER(true, "Has datatable = 0 attribute, it's for layout");
   }
 
@@ -949,28 +949,28 @@ HTMLTableAccessible::IsProbablyLayoutTab
   if (caption && caption->Role() == roles::CAPTION && caption->HasChildren()) 
     RETURN_LAYOUT_ANSWER(false, "Not empty caption -- legitimate table structures");
 
   for (nsIContent* childElm = mContent->GetFirstChild(); childElm;
        childElm = childElm->GetNextSibling()) {
     if (!childElm->IsHTMLElement())
       continue;
 
-    if (childElm->Tag() == nsGkAtoms::col ||
-        childElm->Tag() == nsGkAtoms::colgroup ||
-        childElm->Tag() == nsGkAtoms::tfoot ||
-        childElm->Tag() == nsGkAtoms::thead) {
+    if (childElm->IsAnyOfHTMLElements(nsGkAtoms::col,
+                                      nsGkAtoms::colgroup,
+                                      nsGkAtoms::tfoot,
+                                      nsGkAtoms::thead)) {
       RETURN_LAYOUT_ANSWER(false,
                            "Has col, colgroup, tfoot or thead -- legitimate table structures");
     }
 
-    if (childElm->Tag() == nsGkAtoms::tbody) {
+    if (childElm->IsHTMLElement(nsGkAtoms::tbody)) {
       for (nsIContent* rowElm = childElm->GetFirstChild(); rowElm;
            rowElm = rowElm->GetNextSibling()) {
-        if (rowElm->IsHTMLElement() && rowElm->Tag() == nsGkAtoms::tr) {
+        if (rowElm->IsHTMLElement(nsGkAtoms::tr)) {
           for (nsIContent* cellElm = rowElm->GetFirstChild(); cellElm;
                cellElm = cellElm->GetNextSibling()) {
             if (cellElm->IsHTMLElement()) {
 
               if (cellElm->NodeInfo()->Equals(nsGkAtoms::th)) {
                 RETURN_LAYOUT_ANSWER(false,
                                      "Has th -- legitimate table structures");
               }
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -1216,17 +1216,17 @@ AccessibleWrap::HandleAccEvent(AccEvent*
 
   HWND hWnd = GetHWNDFor(accessible);
   NS_ENSURE_TRUE(hWnd, NS_ERROR_FAILURE);
 
   nsAutoString tag;
   nsAutoCString id;
   nsIContent* cnt = accessible->GetContent();
   if (cnt) {
-    cnt->Tag()->ToString(tag);
+    cnt->NodeInfo()->NameAtom()->ToString(tag);
     nsIAtom* aid = cnt->GetID();
     if (aid)
       aid->ToUTF8String(id);
   }
 
 #ifdef A11Y_LOG
   if (logging::IsEnabled(logging::ePlatforms)) {
     printf("\n\nMSAA event: event: %d, target: %s@id='%s', childid: %d, hwnd: %p\n\n",
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -87,17 +87,17 @@ XULLabelAccessible::NativeState()
 
 Relation
 XULLabelAccessible::RelationByType(RelationType aType)
 {
   Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
   if (aType == RelationType::LABEL_FOR) {
     // Caption is the label for groupbox
     nsIContent* parent = mContent->GetFlattenedTreeParent();
-    if (parent && parent->Tag() == nsGkAtoms::caption) {
+    if (parent && parent->IsXULElement(nsGkAtoms::caption)) {
       Accessible* parent = Parent();
       if (parent && parent->Role() == roles::GROUPING)
         rel.AppendTarget(parent);
     }
   }
 
   return rel;
 }
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -177,17 +177,17 @@ XULButtonAccessible::IsAcceptableChild(A
 
   // Get an accessible for menupopup or panel elements.
   if (role == roles::MENUPOPUP)
     return true;
 
   // Button type="menu-button" contains a real button. Get an accessible
   // for it. Ignore dropmarker button which is placed as a last child.
   if (role != roles::PUSHBUTTON ||
-      aPossibleChild->GetContent()->Tag() == nsGkAtoms::dropMarker)
+      aPossibleChild->GetContent()->IsXULElement(nsGkAtoms::dropMarker))
     return false;
 
   return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                                nsGkAtoms::menuButton, eCaseMatters);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULButtonAccessible protected
@@ -564,19 +564,20 @@ XULToolbarButtonAccessible::GetPositionA
   *aPosInSet = posInSet;
   *aSetSize = setSize;
 }
 
 bool
 XULToolbarButtonAccessible::IsSeparator(Accessible* aAccessible)
 {
   nsIContent* content = aAccessible->GetContent();
-  return content && ((content->Tag() == nsGkAtoms::toolbarseparator) ||
-                     (content->Tag() == nsGkAtoms::toolbarspacer) ||
-                     (content->Tag() == nsGkAtoms::toolbarspring)); }
+  return content && content->IsAnyOfXULElements(nsGkAtoms::toolbarseparator,
+                                                nsGkAtoms::toolbarspacer,
+                                                nsGkAtoms::toolbarspring);
+}
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULToolbarAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULToolbarAccessible::
   XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc) :