Closed Bug 523118 Opened 15 years ago Closed 15 years ago

we mistake 'cell' and text' xul tree seltypes for multiselects

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: davidb, Assigned: davidb)

Details

(Keywords: access)

Attachments

(1 file, 5 obsolete files)

Attached patch first pass (obsolete) — Splinter Review
Spun off from Neil's catch: bug 414302 comment 42. We should at least do this in nsXULTreeAccessible.
Alexander, what do you think?
Probably need a few more mochitests.
Comment on attachment 407044 [details] [diff] [review]
first pass


>+    nsCOMPtr<nsITreeSelection> selection;
>+    mTreeView->GetSelection(getter_AddRefs(selection));
>+    if (selection) {
>+      PRBool single;
>+      selection->GetSingle(&single);

it can fail

technically we don't need to check if it's single because SelectAll() makes this for us (http://mxr.mozilla.org/mozilla-central/source/layout/xul/base/src/tree/src/nsTreeSelection.cpp#537)

>+      if (!single) {
>+        *_retval = PR_TRUE;

nit: would be nice to rename it since you're here

>+        nsCOMPtr<nsITreeSelection> selection;
>+        mTreeView->GetSelection(getter_AddRefs(selection));
>+        if (selection)

it doesn't make sense to get selection second time and test it on null ;)

yeah, mochitests are good idea :)

otherwise is good :)
> >+        nsCOMPtr<nsITreeSelection> selection;
> >+        mTreeView->GetSelection(getter_AddRefs(selection));
> >+        if (selection)
> 
> it doesn't make sense to get selection second time and test it on null ;)
> 
> 

Ha! yeah my cut and paste forgot the cut part ;)
Summary: use nsTreeSelection::GetSingle to determine if trees are single or multi select → we mistake 'cell' and text' xul tree seltypes for multiselects
Attached patch patch (obsolete) — Splinter Review
Fixes comments and adds tests.
Assignee: nobody → bolterbugz
Attachment #407044 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #407091 - Flags: review?(surkov.alexander)
Comment on attachment 407091 [details] [diff] [review]
patch


>+NS_IMETHODIMP
>+nsXULTreeAccessible::SelectAllSelection(PRBool *success)

don't forget to use prefix 'a'

it's preferable to have more descriptive name like aIsMultiSelectable

> {
>-  *_retval = PR_FALSE;
>+  *success = PR_FALSE;

check by NS_ENSURE_ARG_POINTER

>+    nsCOMPtr<nsITreeSelection> selection;
>+    mTreeView->GetSelection(getter_AddRefs(selection));
>+    if (selection) {
>+          if (selection->SelectAll() == NS_OK) {

NS_SUCCEEDED in general

but nsresult of SelectAll doesn't point if tree is multiselectable, therefore you need to test this manually - I missed this in previous review.

>+            *success = PR_TRUE;

> 
>-        if (this.DOMNode.getAttribute("seltype") != "single")
>+        var seltype = this.DOMNode.getAttribute("seltype");
>+        if (seltype != "single" &&
>+            seltype != "cell" &&
>+            seltype != "text")
>           testStates(tree, STATE_MULTISELECTABLE);

this is nice, we need to keep this, possibly you should use GetSingle as well though I don't have strong opinion. But your tests don't test your patch.
Attachment #407091 - Flags: review?(surkov.alexander)
(In reply to comment #6)
> But your tests don't test your patch.

Doh! Thanks for the catches! I'll post a new patch later.
Attached patch patch2 (obsolete) — Splinter Review
Tests select all implementation for xul tree accessibles. Addresses comments.
Attachment #407091 - Attachment is obsolete: true
Comment on attachment 407294 [details] [diff] [review]
patch2


>       this.check = function check()
>       {
>         var tree = getAccessible(this.DOMNode);
> 
>         // tree states
>         testStates(tree, STATE_READONLY);
> 
>-        if (this.DOMNode.getAttribute("seltype") != "single")
>+        function ismultiselect(node) {

nit: isMultiSelectable ?

I'm not fun of function defining inside of other function

>+        // test SelectAllSelection correctly discerns multiselect vs single
>+        var accSelectable = getAccessible(this.DOMNode,
>+                                          [nsIAccessibleSelectable]);
>+        ok(accSelectable, "tree is not selectable!");
>+        if (accSelectable)
>+          is(accSelectable.selectAllSelection(), ismultiselect(this.DOMNode),
>+             "SelectAllSelection doesn't match ismultiselect");

I would prefer to have this test in separate file like test_selectable_tree.xul or something

You need to test tree selection additionally to see if all rows were selected
Attached patch probably needs polish (obsolete) — Splinter Review
Just want to get your eyes on this before you go to bed :)
Attachment #407294 - Attachment is obsolete: true
Attachment #407534 - Flags: review?(surkov.alexander)
Oops please ignore straggling mods to test_states_tree - I'll remove locally.
Attached patch patch 3 (obsolete) — Splinter Review
If you are still awake :)
Attachment #407534 - Attachment is obsolete: true
Attachment #407541 - Flags: review?(surkov.alexander)
Attachment #407534 - Flags: review?(surkov.alexander)
Attached patch better testSplinter Review
Attachment #407541 - Attachment is obsolete: true
Attachment #407561 - Flags: review?(surkov.alexander)
Attachment #407541 - Flags: review?(surkov.alexander)
Comment on attachment 407561 [details] [diff] [review]
better test

sounds ok, thank you.
Attachment #407561 - Flags: review?(surkov.alexander) → review+
http://hg.mozilla.org/mozilla-central/rev/b81fc13d9045
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: