Bug 1425440 - Get rid of GetChildAt_Deprecated in nsMenuX, r=catalinb
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 09 Jan 2018 11:44:54 +0100
changeset 452659 30b995a49772ed07790ea802c8501bf2cee444fa
parent 452658 34ae1d0d625e689433c3e21a9827afef01bad3ef
child 452660 90492852dfc9021f4b34b77f24b07e335b1629db
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscatalinb
bugs1425440
milestone59.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 1425440 - Get rid of GetChildAt_Deprecated in nsMenuX, r=catalinb
widget/cocoa/nsMenuX.mm
--- a/widget/cocoa/nsMenuX.mm
+++ b/widget/cocoa/nsMenuX.mm
@@ -433,27 +433,24 @@ void nsMenuX::MenuConstruct()
         xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
                               NS_GET_IID(nsISupports), ignoredObj.address());
         mXBLAttached = true;
       }
     }
   }
 
   // Iterate over the kids
-  uint32_t count = menuPopup->GetChildCount();
-  for (uint32_t i = 0; i < count; i++) {
-    nsIContent *child = menuPopup->GetChildAt_Deprecated(i);
-    if (child) {
-      // depending on the type, create a menu item, separator, or submenu
-      if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
-                                    nsGkAtoms::menuseparator)) {
-        LoadMenuItem(child);
-      } else if (child->IsXULElement(nsGkAtoms::menu)) {
-        LoadSubMenu(child);
-      }
+  for (nsIContent* child = menuPopup->GetFirstChild();
+       child; child = child->GetNextSibling()) {
+    // depending on the type, create a menu item, separator, or submenu
+    if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
+                                  nsGkAtoms::menuseparator)) {
+      LoadMenuItem(child);
+    } 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());
 }
 
@@ -637,33 +634,31 @@ bool nsMenuX::OnClose()
 // of a very few children so we won't be iterating over a bazillion menu items to find
 // it (so the strcmp won't kill us).
 void nsMenuX::GetMenuPopupContent(nsIContent** aResult)
 {
   if (!aResult)
     return;
   *aResult = nullptr;
 
+  int32_t dummy;
+
   // Check to see if we are a "menupopup" node (if we are a native menu).
   {
-    int32_t dummy;
     RefPtr<nsAtom> tag = mContent->OwnerDoc()->BindingManager()->ResolveTag(mContent, &dummy);
     if (tag == nsGkAtoms::menupopup) {
       NS_ADDREF(*aResult = mContent);
       return;
     }
   }
 
   // Otherwise check our child nodes.
 
-  uint32_t count = mContent->GetChildCount();
-
-  for (uint32_t i = 0; i < count; i++) {
-    int32_t dummy;
-    nsIContent *child = mContent->GetChildAt_Deprecated(i);
+  for (nsIContent* child = mContent->GetFirstChild();
+       child; child = child->GetNextSibling()) {
     RefPtr<nsAtom> tag = child->OwnerDoc()->BindingManager()->ResolveTag(child, &dummy);
     if (tag == nsGkAtoms::menupopup) {
       *aResult = child;
       NS_ADDREF(*aResult);
       return;
     }
   }
 }