Closed Bug 723427 Opened 12 years ago Closed 12 years ago

dexpcom GetUnignoredChildren()

Categories

(Core :: Disability Access APIs, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla14

People

(Reporter: tbsaunde, Assigned: orangedaylily)

Details

(Whiteboard: [good first bug][mentor=trev.saunders@gmail.com][lang=c++])

Attachments

(1 file, 3 obsolete files)

GetUnignoredChildren() should take an out argument that is a nsTArray<nsAccessible*> not nsTArray<nsRefPtr<NsAccessible> > please make that change and then fix the callers.  See accessible/src/mac/nsAccessibleWrap.mm line 261

note you need to add ac_add_options --enable-accessibility to your mozconfig
Assignee: nobody → joey.blacksmith
Assignee: joey.blacksmith → nobody
I'll work on this.
Assignee: nobody → orangedaylily
Attached patch Bug723427 patch (obsolete) — Splinter Review
Attachment #611368 - Flags: review?(trev.saunders)
Attachment #611368 - Flags: feedback?(surkov.alexander)
Comment on attachment 611368 [details] [diff] [review]
Bug723427 patch

Review of attachment 611368 [details] [diff] [review]:
-----------------------------------------------------------------

::: accessible/src/mac/mozAccessible.mm
@@ +412,5 @@
>    int totalCount = childrenArray.Length();
>    int index = 0;
>     
>    for (; index < totalCount; index++) {
> +    nsAccessible *curAccessible = childrenArray.ElementAt(index);

nit: nsAccessible*

::: accessible/src/mac/nsAccessibleWrap.h
@@ +98,5 @@
>    /**
>     * Returns this accessible's all children, adhering to "flat" accessibles by 
>     * not returning their children.
>     */
> +  void GetUnignoredChildren(nsTArray<nsAccessible*> &aChildrenArray);

type& aType
actually I prefer to use pointer instead the reference when the method is supposed the value

::: accessible/src/mac/nsAccessibleWrap.mm
@@ +253,5 @@
>    NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
>  }
>  
>  void
> +nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsAccessible*> &aChildrenArray)

same: type& aType
Attachment #611368 - Flags: feedback?(surkov.alexander) → feedback+
(In reply to alexander :surkov from comment #3)
> Comment on attachment 611368 [details] [diff] [review]
> Bug723427 patch
> 
> Review of attachment 611368 [details] [diff] [review]:
> >    for (; index < totalCount; index++) {
> > +    nsAccessible *curAccessible = childrenArray.ElementAt(index);
> 
> nit: nsAccessible*
> 

What does this mean?
(In reply to lavina from comment #4)
> > nit: nsAccessible*
> What does this mean?

type* name, not type *name
It looks like the convention used in that whole function was "type *name". Should I change all of them? Or should I leave this alone just to be consistent with the rest? I looked through the whole file, it seems both convention were used.
(In reply to lavina from comment #6)
> It looks like the convention used in that whole function was "type *name".
> Should I change all of them? Or should I leave this alone just to be
> consistent with the rest? I looked through the whole file, it seems both
> convention were used.

just change lines you touch please
Attached patch Revised patch for bug 723427 (obsolete) — Splinter Review
Attachment #611368 - Attachment is obsolete: true
Attachment #611368 - Flags: review?(trev.saunders)
Comment on attachment 611383 [details] [diff] [review]
Revised patch for bug 723427

>-  nsTArray<nsRefPtr<nsAccessibleWrap> > childrenArray;
>+  nsTArray<nsAccessible*> childrenArray;

it'd be nice to use nsAutoTArray, with a size of say 10.

>   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++) {

you could move the declaration of index into the loop, and rename it idx while your here.

>     if (childAcc->IsIgnored()) {

I suspect this would be clearer flipped around.

>       // element is ignored, so try adding its children as substitutes, if it has any.
>       if (!nsAccUtils::MustPrune(childAcc)) {
>-        nsTArray<nsRefPtr<nsAccessibleWrap> > children;
>+        nsTArray<nsAccessible*> children;

just pass your argument array, copying between arrays sounds bad.
Attachment #611383 - Attachment is obsolete: true
Attachment #611731 - Flags: review?(trev.saunders)
Comment on attachment 611731 [details]
revised patch - modified per last review

>+  nsAutoTArray<nsAccessible*,10> childrenArray;

nit, space after ',' please

>+nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsAccessible*>& aChildrenArray)

nit, it'd be nice if this took a pointer instead of a reference.

>+    if (!childAcc->IsIgnored()) {        
>       // simply add the element, since it's not ignored.
>       aChildrenArray.AppendElement(childAcc);

kind of obvious comment, but ok, you might want to do continue in this case and not have else, but up to you.
Attachment #611731 - Flags: review?(trev.saunders) → review+
Attachment #611731 - Attachment is obsolete: true
Comment on attachment 611736 [details] [diff] [review]
revised patch per last review

I'll fix nits before landing but

>   // 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);
>+  for (int idx=0; idx < totalCount; idx++) {

int -> PRUint32, Gecko still don't use c++ types a lot and it should unsigned int.

also spaces around operator: idx = 0

>-    if (childAcc->IsIgnored()) {
>+    if (!childAcc->IsIgnored()) {        

whitespaces at the end of line

>+      aChildrenArray->AppendElement(childAcc);
>+    } else {
>       // 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);
>+    }

I prefer continue too.
I'll fix them tomorrow. 
By the way, can you enlighten me as to why "continue" instead of "else" is the preferred way? Thanks.
(In reply to lavina from comment #14)
> I'll fix them tomorrow. 

not necessary, I fixed them locally. Save tomorrow for next bug ;)

> By the way, can you enlighten me as to why "continue" instead of "else" is
> the preferred way? Thanks.

I meant something like
if (isIgnored()) {
  // traverse into children
  continue;
}

// add child into array
Target Milestone: --- → mozilla14
https://hg.mozilla.org/mozilla-central/rev/5964d3d4bc66
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
(In reply to alexander :surkov from comment #15)
> 
> I meant something like
> if (isIgnored()) {
>   // traverse into children
>   continue;
> }
> 
> // add child into array

I understood you meant this. I was just trying to understand why this is preferred over the if-then-else. Since both you and Trevor preferred it this way, I thought perhaps there is a reason that is more than personal preference. If so, I would like to know. Thanks.
(In reply to lavina from comment #18)
> I understood you meant this. I was just trying to understand why this is
> preferred over the if-then-else. Since both you and Trevor preferred it this
> way, I thought perhaps there is a reason that is more than personal
> preference. If so, I would like to know. Thanks.

I this just code style issue. Since we are both working in the same module then often we have similar preferences.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: