Bug 723427 - dexpcom GetUnignoredChildren(), r=tbsaunde, f=surkov
authorLavina Thong <orangedaylily@gmail.com>
Tue, 03 Apr 2012 18:54:07 +0900
changeset 94216 5964d3d4bc66b41b2042767139da40bba4c9c6b7
parent 94215 8f85a5488ffb5801e19b8d03123b9558c8865b37
child 94217 ab9a5eb634870263234596968ee74ae3f65fe231
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs723427
milestone14.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 723427 - dexpcom GetUnignoredChildren(), r=tbsaunde, f=surkov
accessible/src/mac/mozAccessible.mm
accessible/src/mac/nsAccessibleWrap.h
accessible/src/mac/nsAccessibleWrap.mm
--- a/accessible/src/mac/mozAccessible.mm
+++ b/accessible/src/mac/mozAccessible.mm
@@ -398,27 +398,25 @@ GetNativeFromGeckoAccessible(nsIAccessib
 - (NSArray*)children
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (mChildren || !mGeckoAccessible->AreChildrenCached())
     return mChildren;
 
   mChildren = [[NSMutableArray alloc] init];
-  
+
   // get the array of children.
-  nsTArray<nsRefPtr<nsAccessibleWrap> > childrenArray;
-  mGeckoAccessible->GetUnignoredChildren(childrenArray);
-  
+  nsAutoTArray<nsAccessible*, 10> childrenArray;
+  mGeckoAccessible->GetUnignoredChildren(&childrenArray);
+
   // now iterate through the children array, and get each native accessible.
-  int totalCount = childrenArray.Length();
-  int index = 0;
-   
-  for (; index < totalCount; index++) {
-    nsAccessibleWrap *curAccessible = childrenArray.ElementAt(index);
+  PRUint32 totalCount = childrenArray.Length();
+  for (PRUint32 idx = 0; idx < totalCount; idx++) {
+    nsAccessible* curAccessible = childrenArray.ElementAt(idx);
     if (curAccessible) {
       mozAccessible *curNative = GetNativeFromGeckoAccessible(curAccessible);
       if (curNative)
         [mChildren addObject:GetObjectOrRepresentedView(curNative)];
     }
   }
   
 #ifdef DEBUG_hakan
--- a/accessible/src/mac/nsAccessibleWrap.h
+++ b/accessible/src/mac/nsAccessibleWrap.h
@@ -94,17 +94,17 @@ public: // construction, destruction
   
   inline bool HasPopup () 
     { return (NativeState() & mozilla::a11y::states::HASPOPUP); }
   
   /**
    * Returns this accessible's all children, adhering to "flat" accessibles by 
    * not returning their children.
    */
-  void GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> >& aChildrenArray);
+  void GetUnignoredChildren(nsTArray<nsAccessible*>* aChildrenArray);
   nsAccessible* GetUnignoredParent() const;
     
 protected:
 
   virtual nsresult FirePlatformEvent(AccEvent* aEvent);
 
   /**
    * Return true if the parent doesn't have children to expose to AT.
--- a/accessible/src/mac/nsAccessibleWrap.mm
+++ b/accessible/src/mac/nsAccessibleWrap.mm
@@ -256,40 +256,34 @@ nsAccessibleWrap::IsIgnored()
   
   mozAccessible* nativeObject = GetNativeObject();
   return (!nativeObject) || [nativeObject accessibilityIsIgnored];
   
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
 void
-nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aChildrenArray)
+nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsAccessible*>* aChildrenArray)
 {
   // we're flat; there are no children.
   if (nsAccUtils::MustPrune(this))
     return;
 
   PRInt32 childCount = GetChildCount();
   for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
     nsAccessibleWrap *childAcc =
       static_cast<nsAccessibleWrap*>(GetChildAt(childIdx));
 
+    // If element is ignored, then add its children as substitutes.
     if (childAcc->IsIgnored()) {
-      // element is ignored, so try adding its children as substitutes, if it has any.
-      if (!nsAccUtils::MustPrune(childAcc)) {
-        nsTArray<nsRefPtr<nsAccessibleWrap> > children;
-        childAcc->GetUnignoredChildren(children);
-        if (!children.IsEmpty()) {
-          // add the found unignored descendants to the array.
-          aChildrenArray.AppendElements(children);
-        }
-      }
-    } else
-      // simply add the element, since it's not ignored.
-      aChildrenArray.AppendElement(childAcc);
+      childAcc->GetUnignoredChildren(aChildrenArray);
+      continue;
+    }
+
+    aChildrenArray->AppendElement(childAcc);
   }
 }
 
 nsAccessible*
 nsAccessibleWrap::GetUnignoredParent() const
 {
   // Go up the chain to find a parent that is not ignored.
   nsAccessibleWrap* parentWrap = static_cast<nsAccessibleWrap*>(Parent());