Bug 1134280 - Get rid of Tag() - patch 2.13 - Fix all the occurrences, m=smaug, r=surkov
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 03 Mar 2015 11:09:00 +0000
changeset 231604 5f8986f5a56099cba588b2e415327d2ec9607e96
parent 231603 4d58f27af3fc557e293eab98f0b0a49c597b23bf
child 231605 a1815f880a88048e3e9ec319ecd88aa860b6eda3
push id28355
push userkwierso@gmail.com
push dateWed, 04 Mar 2015 00:49:07 +0000
treeherdermozilla-central@f42b9946f08f [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.13 - Fix all the occurrences, m=smaug, r=surkov
embedding/browser/nsDocShellTreeOwner.cpp
embedding/components/find/nsFind.cpp
widget/cocoa/nsMenuBarX.mm
widget/cocoa/nsMenuX.mm
widget/cocoa/nsNativeThemeCocoa.mm
widget/cocoa/nsStandaloneNativeMenu.mm
widget/nsNativeTheme.cpp
--- a/embedding/browser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/nsDocShellTreeOwner.cpp
@@ -1046,20 +1046,19 @@ DefaultTooltipTextProvider::GetNodeText(
     }
   }
 
   while (!found && current) {
     nsCOMPtr<nsIDOMElement> currElement(do_QueryInterface(current));
     if (currElement) {
       nsCOMPtr<nsIContent> content(do_QueryInterface(currElement));
       if (content) {
-        nsIAtom *tagAtom = content->Tag();
-        if (tagAtom != mTag_dialog &&
-            tagAtom != mTag_dialogheader &&
-            tagAtom != mTag_window) {
+        if (!content->IsAnyOfXULElements(mTag_dialog,
+                                         mTag_dialogheader,
+                                         mTag_window)) {
           // first try the normal title attribute...
           currElement->GetAttribute(NS_LITERAL_STRING("title"), outText);
           if (outText.Length()) {
             found = true;
           } else {
             // ...ok, that didn't work, try it in the XLink namespace
             NS_NAMED_LITERAL_STRING(xlinkNS, "http://www.w3.org/1999/xlink");
             nsCOMPtr<mozilla::dom::Link> linkContent(do_QueryInterface(currElement));
--- a/embedding/components/find/nsFind.cpp
+++ b/embedding/components/find/nsFind.cpp
@@ -732,29 +732,25 @@ nsFind::NextNode(nsIDOMRange* aSearchRan
 #ifdef DEBUG_FIND
   printf("Iterator gave: "); DumpNode(mIterNode);
 #endif
   return NS_OK;
 }
 
 bool nsFind::IsBlockNode(nsIContent* aContent)
 {
-  if (!aContent->IsHTMLElement()) {
-    return false;
+  if (aContent->IsAnyOfHTMLElements(nsGkAtoms::img,
+                                    nsGkAtoms::hr,
+                                    nsGkAtoms::th,
+                                    nsGkAtoms::td)) {
+    return true;
   }
 
-  nsIAtom *atom = aContent->Tag();
-
-  if (atom == nsGkAtoms::img ||
-      atom == nsGkAtoms::hr ||
-      atom == nsGkAtoms::th ||
-      atom == nsGkAtoms::td)
-    return true;
-
-  return nsContentUtils::IsHTMLBlock(atom);
+  return aContent->IsHTMLElement() &&
+         nsContentUtils::IsHTMLBlock(aContent->NodeInfo()->NameAtom());
 }
 
 bool nsFind::IsTextNode(nsIDOMNode* aNode)
 {
   uint16_t nodeType;
   aNode->GetNodeType(&nodeType);
 
   return nodeType == nsIDOMNode::TEXT_NODE ||
@@ -773,45 +769,37 @@ bool nsFind::IsVisibleNode(nsIDOMNode *a
     return false;
   }
 
   return frame->StyleVisibility()->IsVisible();
 }
 
 bool nsFind::SkipNode(nsIContent* aContent)
 {
-  nsIAtom *atom;
-
 #ifdef HAVE_BIDI_ITERATOR
-  atom = aContent->Tag();
-
   // We may not need to skip comment nodes,
   // now that IsTextNode distinguishes them from real text nodes.
   return (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
-          (aContent->IsHTMLElement() &&
-           (atom == sScriptAtom ||
-            atom == sNoframesAtom ||
-            atom == sSelectAtom)));
+          aContent->IsAnyOfHTMLElements(sScriptAtom,
+                                        sNoframesAtom,
+                                        sSelectAtom));
 
 #else /* HAVE_BIDI_ITERATOR */
   // Temporary: eventually we will have an iterator to do this,
   // but for now, we have to climb up the tree for each node
   // and see whether any parent is a skipped node,
   // and take the performance hit.
 
   nsIContent *content = aContent;
   while (content)
   {
-    atom = content->Tag();
-
     if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
-        (content->IsHTMLElement() &&
-         (atom == nsGkAtoms::script ||
-          atom == nsGkAtoms::noframes ||
-          atom == nsGkAtoms::select)))
+        content->IsAnyOfHTMLElements(nsGkAtoms::script,
+                                     nsGkAtoms::noframes,
+                                     nsGkAtoms::select))
     {
 #ifdef DEBUG_FIND
       printf("Skipping node: ");
       nsCOMPtr<nsIDOMNode> node (do_QueryInterface(content));
       DumpNode(node);
 #endif
 
       return true;
--- a/widget/cocoa/nsMenuBarX.mm
+++ b/widget/cocoa/nsMenuBarX.mm
@@ -127,18 +127,17 @@ nsresult nsMenuBarX::Create(nsIWidget* a
 }
 
 void nsMenuBarX::ConstructNativeMenus()
 {
   uint32_t count = mContent->GetChildCount();
   for (uint32_t i = 0; i < count; i++) { 
     nsIContent *menuContent = mContent->GetChildAt(i);
     if (menuContent &&
-        menuContent->Tag() == nsGkAtoms::menu &&
-        menuContent->IsXULElement()) {
+        menuContent->IsXULElement(nsGkAtoms::menu)) {
       nsMenuX* newMenu = new nsMenuX();
       if (newMenu) {
         nsresult rv = newMenu->Create(this, this, menuContent);
         if (NS_SUCCEEDED(rv))
           InsertMenuAtIndex(newMenu, GetMenuCount());
         else
           delete newMenu;
       }
--- a/widget/cocoa/nsMenuX.mm
+++ b/widget/cocoa/nsMenuX.mm
@@ -427,21 +427,22 @@ void nsMenuX::MenuConstruct()
   }
 
   // Iterate over the kids
   uint32_t count = menuPopup->GetChildCount();
   for (uint32_t i = 0; i < count; i++) {
     nsIContent *child = menuPopup->GetChildAt(i);
     if (child) {
       // depending on the type, create a menu item, separator, or submenu
-      nsIAtom *tag = child->Tag();
-      if (tag == nsGkAtoms::menuitem || tag == nsGkAtoms::menuseparator)
+      if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
+                                    nsGkAtoms::menuseparator)) {
         LoadMenuItem(child);
-      else if (tag == nsGkAtoms::menu)
+      } else if (child->IsXULElement(nsGkAtoms::menu)) {
         LoadSubMenu(child);
+      }
     }
   } // for each menu item
 
   gConstructingMenu = false;
   mNeedsRebuild = false;
   // printf("Done building, mMenuObjectsArray.Count() = %d \n", mMenuObjectsArray.Count());
 }
 
@@ -496,17 +497,17 @@ void nsMenuX::LoadMenuItem(nsIContent* i
     return;
 
   nsAutoString menuitemName;
   inMenuItemContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, menuitemName);
 
   // printf("menuitem %s \n", NS_LossyConvertUTF16toASCII(menuitemName).get());
 
   EMenuItemType itemType = eRegularMenuItemType;
-  if (inMenuItemContent->Tag() == nsGkAtoms::menuseparator) {
+  if (inMenuItemContent->IsXULElement(nsGkAtoms::menuseparator)) {
     itemType = eSeparatorMenuItemType;
   }
   else {
     static nsIContent::AttrValuesArray strings[] =
   {&nsGkAtoms::checkbox, &nsGkAtoms::radio, nullptr};
     switch (inMenuItemContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type,
                                                strings, eCaseMatters)) {
       case 0: itemType = eCheckboxMenuItemType; break;
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -275,19 +275,19 @@ DrawCellIncludingFocusRing(NSCell* aCell
 }
 
 static BOOL IsToolbarStyleContainer(nsIFrame* aFrame)
 {
   nsIContent* content = aFrame->GetContent();
   if (!content)
     return NO;
 
-  if (content->Tag() == nsGkAtoms::toolbar ||
-      content->Tag() == nsGkAtoms::toolbox ||
-      content->Tag() == nsGkAtoms::statusbar)
+  if (content->IsAnyOfXULElements(nsGkAtoms::toolbar,
+                                  nsGkAtoms::toolbox,
+                                  nsGkAtoms::statusbar))
     return YES;
 
   switch (aFrame->StyleDisplay()->mAppearance) {
     case NS_THEME_TOOLBAR:
     case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR:
     case NS_THEME_STATUSBAR:
       return YES;
     default:
--- a/widget/cocoa/nsStandaloneNativeMenu.mm
+++ b/widget/cocoa/nsStandaloneNativeMenu.mm
@@ -32,19 +32,17 @@ nsStandaloneNativeMenu::Init(nsIDOMEleme
 {
   NS_ASSERTION(mMenu == nullptr, "nsNativeMenu::Init - mMenu not null!");
 
   nsresult rv;
 
   nsCOMPtr<nsIContent> content = do_QueryInterface(aDOMElement, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsIAtom * tag = content->Tag();
-  if (!content->IsXULElement() ||
-      (tag != nsGkAtoms::menu && tag != nsGkAtoms::menupopup))
+  if (!content->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menupopup))
     return NS_ERROR_FAILURE;
 
   rv = nsMenuGroupOwnerX::Create(content);
   if (NS_FAILED(rv))
     return rv;
 
   mMenu = new nsMenuX();
   rv = mMenu->Create(this, this, content);
--- a/widget/nsNativeTheme.cpp
+++ b/widget/nsNativeTheme.cpp
@@ -444,22 +444,22 @@ nsNativeTheme::GetTreeSortDirection(nsIF
 
 bool
 nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame)
 {
   if (!aFrame)
     return false;
 
   // A tree column picker is always the last header cell.
-  if (aFrame->GetContent()->Tag() == nsGkAtoms::treecolpicker)
+  if (aFrame->GetContent()->IsXULElement(nsGkAtoms::treecolpicker))
     return true;
 
   // Find the parent tree.
   nsIContent* parent = aFrame->GetContent()->GetParent();
-  while (parent && parent->Tag() != nsGkAtoms::tree) {
+  while (parent && !parent->IsXULElement(nsGkAtoms::tree)) {
     parent = parent->GetParent();
   }
 
   // If the column picker is visible, this can't be the last column.
   if (parent && !parent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidecolumnpicker,
                                      NS_LITERAL_STRING("true"), eCaseMatters))
     return false;
 
@@ -485,17 +485,18 @@ nsNativeTheme::IsBottomTab(nsIFrame* aFr
 bool
 nsNativeTheme::IsFirstTab(nsIFrame* aFrame)
 {
   if (!aFrame)
     return false;
 
   nsIFrame* first = aFrame->GetParent()->GetFirstPrincipalChild();
   while (first) {
-    if (first->GetRect().width > 0 && first->GetContent()->Tag() == nsGkAtoms::tab)
+    if (first->GetRect().width > 0 &&
+        first->GetContent()->IsXULElement(nsGkAtoms::tab))
       return (first == aFrame);
     first = first->GetNextSibling();
   }
   return false;
 }
 
 bool
 nsNativeTheme::IsHorizontal(nsIFrame* aFrame)
@@ -570,17 +571,17 @@ nsNativeTheme::IsVerticalMeter(nsIFrame*
 // menupopup:
 bool
 nsNativeTheme::IsSubmenu(nsIFrame* aFrame, bool* aLeftOfParent)
 {
   if (!aFrame)
     return false;
 
   nsIContent* parentContent = aFrame->GetContent()->GetParent();
-  if (!parentContent || parentContent->Tag() != nsGkAtoms::menu)
+  if (!parentContent || !parentContent->IsXULElement(nsGkAtoms::menu))
     return false;
 
   nsIFrame* parent = aFrame;
   while ((parent = parent->GetParent())) {
     if (parent->GetContent() == parentContent) {
       if (aLeftOfParent) {
         nsIntRect selfBounds, parentBounds;
         aFrame->GetNearestWidget()->GetScreenBounds(selfBounds);