From 77ef333b0c493fe7f1895cc9fe92926024c7de26 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Wed, 15 Aug 2007 21:02:32 +0000 Subject: [PATCH] Bug 390154. Prune subtrees consistently across platform accessibility APIs for a number of widgets that we will impose a 'must be leaf' rule, to simplify compatibility across a number of assistive technologies which expect that. r=ginn.chen, a=dsicore --- accessible/src/atk/nsAccessibleWrap.cpp | 5 ----- accessible/src/atk/nsAccessibleWrap.h | 3 --- accessible/src/base/nsAccessible.cpp | 13 +++++++++++++ accessible/src/base/nsAccessible.h | 6 +++++- accessible/src/mac/nsAccessibleWrap.h | 20 ++++---------------- accessible/src/msaa/nsAccessibleWrap.cpp | 11 ----------- accessible/src/msaa/nsAccessibleWrap.h | 3 --- 7 files changed, 22 insertions(+), 39 deletions(-) diff --git a/accessible/src/atk/nsAccessibleWrap.cpp b/accessible/src/atk/nsAccessibleWrap.cpp index e398bc21ca4..9a1a3346d3d 100644 --- a/accessible/src/atk/nsAccessibleWrap.cpp +++ b/accessible/src/atk/nsAccessibleWrap.cpp @@ -1550,8 +1550,3 @@ nsAccessibleWrap::FireAtkShowHideEvent(nsIAccessibleEvent *aEvent, return NS_OK; } -PRBool nsAccessibleWrap::MustPrune(nsIAccessible *aAccessible) -{ - PRUint32 role = Role(aAccessible); - return role == nsIAccessibleRole::ROLE_GRAPHIC; -} diff --git a/accessible/src/atk/nsAccessibleWrap.h b/accessible/src/atk/nsAccessibleWrap.h index a75a87c1271..421c257530b 100644 --- a/accessible/src/atk/nsAccessibleWrap.h +++ b/accessible/src/atk/nsAccessibleWrap.h @@ -115,9 +115,6 @@ public: return returnedString.get(); } - // Should this accessible be allowed to have any ATK children - static PRBool MustPrune(nsIAccessible *aAccessible); - protected: nsresult FireAtkStateChangeEvent(nsIAccessibleEvent *aEvent, AtkObject *aObject); diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 085856f1dc3..174ecd4bdb2 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -3273,3 +3273,16 @@ nsAccessible::GetAttrValue(PRUint32 aNameSpaceID, nsIAtom *aName, return result; } +PRBool nsAccessible::MustPrune(nsIAccessible *aAccessible) +{ + PRUint32 role = Role(aAccessible); + return role == nsIAccessibleRole::ROLE_MENUITEM || + role == nsIAccessibleRole::ROLE_ENTRY || + role == nsIAccessibleRole::ROLE_PASSWORD_TEXT || + role == nsIAccessibleRole::ROLE_PUSHBUTTON || + role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON || + role == nsIAccessibleRole::ROLE_GRAPHIC || + role == nsIAccessibleRole::ROLE_SLIDER || + role == nsIAccessibleRole::ROLE_PROGRESSBAR || + role == nsIAccessibleRole::ROLE_SEPARATOR; +} diff --git a/accessible/src/base/nsAccessible.h b/accessible/src/base/nsAccessible.h index 025aa9df693..39a10d4c39c 100644 --- a/accessible/src/base/nsAccessible.h +++ b/accessible/src/base/nsAccessible.h @@ -155,13 +155,17 @@ public: static PRInt32 TextLength(nsIAccessible *aAccessible); // Returns -1 on failure static PRBool IsLeaf(nsIAccessible *aAcc) { PRInt32 numChildren; aAcc->GetChildCount(&numChildren); return numChildren > 0; } static PRBool IsNodeRelevant(nsIDOMNode *aNode); // Is node something that could have an attached accessible + /** + * When exposing to platform accessibility APIs, should the children be pruned off? + */ + static PRBool MustPrune(nsIAccessible *aAccessible); already_AddRefed GetParent() { nsIAccessible *parent = nsnull; GetParent(&parent); return parent; } - + protected: PRBool MappedAttrState(nsIContent *aContent, PRUint32 *aStateInOut, nsStateMapEntry *aStateMapEntry); virtual nsIFrame* GetBoundsFrame(); diff --git a/accessible/src/mac/nsAccessibleWrap.h b/accessible/src/mac/nsAccessibleWrap.h index ad407d9b046..8b1db8c17e5 100644 --- a/accessible/src/mac/nsAccessibleWrap.h +++ b/accessible/src/mac/nsAccessibleWrap.h @@ -78,19 +78,6 @@ class nsAccessibleWrap : public nsAccessible virtual nsresult InvalidateChildren (); NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent); - - // we'll flatten buttons and checkboxes. usually they have a text node - // child, that is their title. Works in conjunction with IsPruned() below. - // XXX There is no IsPruned() method, so what does that comment mean? - PRBool IsFlat() { - PRUint32 role = Role(this); - return (role == nsIAccessibleRole::ROLE_CHECKBUTTON || - role == nsIAccessibleRole::ROLE_PUSHBUTTON || - role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON || - role == nsIAccessibleRole::ROLE_SPLITBUTTON || - role == nsIAccessibleRole::ROLE_ENTRY || - role == nsIAccessibleRole::ROLE_GRAPHIC); - } // ignored means that the accessible might still have children, but is not displayed // to the user. it also has no native accessible object represented for it. @@ -119,10 +106,11 @@ class nsAccessibleWrap : public nsAccessible nsCOMPtr curParent = GetParent(); while (curParent) { - nsAccessibleWrap *ancestorWrap = static_cast((nsIAccessible*)curParent.get()); - if (ancestorWrap->IsFlat()) + if (MustPrune(curParent)) return PR_TRUE; - curParent = static_cast((nsIAccessible*)curParent.get())->GetParent(); + nsCOMPtr newParent; + curParent->GetParent(getter_AddRefs(newParent)); + curParent.swap(newParent); } // no parent was flat return PR_FALSE; diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index c7ec0ba4a8f..1debd3f7448 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -1715,14 +1715,3 @@ void nsAccessibleWrap::UpdateSystemCaret() ::DeleteObject(caretBitMap); } } - -PRBool nsAccessibleWrap::MustPrune(nsIAccessible *aAccessible) -{ - PRUint32 role = Role(aAccessible); - return role == nsIAccessibleRole::ROLE_MENUITEM || - role == nsIAccessibleRole::ROLE_ENTRY || - role == nsIAccessibleRole::ROLE_PASSWORD_TEXT || - role == nsIAccessibleRole::ROLE_PUSHBUTTON || - role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON || - role == nsIAccessibleRole::ROLE_GRAPHIC; -} diff --git a/accessible/src/msaa/nsAccessibleWrap.h b/accessible/src/msaa/nsAccessibleWrap.h index 922b4b16b8c..6aca2691400 100644 --- a/accessible/src/msaa/nsAccessibleWrap.h +++ b/accessible/src/msaa/nsAccessibleWrap.h @@ -322,9 +322,6 @@ protected: // nsIEnumVariant::Reset(), Skip() and Next(). PRUint16 mEnumVARIANTPosition; - // Should this accessible be allowed to have any MSAA children - static PRBool MustPrune(nsIAccessible *aAccessible); - enum navRelations { NAVRELATION_CONTROLLED_BY = 0x1000, NAVRELATION_CONTROLLER_FOR = 0x1001,