From 01814e4e8531555d2c2f1394cf4727fe4b3a7960 Mon Sep 17 00:00:00 2001 From: "ginn.chen%sun.com" Date: Sat, 29 Sep 2007 07:04:27 +0000 Subject: [PATCH] Bug 388185 LABELLED_BY, LABEL_FOR relations shoudl be set for labels in panels r=aaronleventhal,mano a=dsicore --- accessible/src/base/nsAccessibilityAtomList.h | 1 + accessible/src/xul/nsXULTextAccessible.cpp | 30 +++++++++++++++++++ accessible/src/xul/nsXULTextAccessible.h | 2 ++ toolkit/content/widgets/groupbox.xml | 9 ------ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/accessible/src/base/nsAccessibilityAtomList.h b/accessible/src/base/nsAccessibilityAtomList.h index f940095f7df..c43295704a9 100755 --- a/accessible/src/base/nsAccessibilityAtomList.h +++ b/accessible/src/base/nsAccessibilityAtomList.h @@ -91,6 +91,7 @@ ACCESSIBILITY_ATOM(area, "area") ACCESSIBILITY_ATOM(blockquote, "blockquote") ACCESSIBILITY_ATOM(br, "br") ACCESSIBILITY_ATOM(body, "body") +ACCESSIBILITY_ATOM(caption, "caption") // XUL ACCESSIBILITY_ATOM(choices, "choices") // XForms ACCESSIBILITY_ATOM(description, "description") // XUL ACCESSIBILITY_ATOM(dd, "dd") diff --git a/accessible/src/xul/nsXULTextAccessible.cpp b/accessible/src/xul/nsXULTextAccessible.cpp index 10c57e59c44..bf413d8df6b 100644 --- a/accessible/src/xul/nsXULTextAccessible.cpp +++ b/accessible/src/xul/nsXULTextAccessible.cpp @@ -82,6 +82,36 @@ nsXULTextAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) return NS_OK; } +NS_IMETHODIMP +nsXULTextAccessible::GetAccessibleRelated(PRUint32 aRelationType, + nsIAccessible **aRelated) +{ + nsresult rv = + nsHyperTextAccessibleWrap::GetAccessibleRelated(aRelationType, aRelated); + NS_ENSURE_SUCCESS(rv, rv); + if (*aRelated) { + return NS_OK; + } + + nsIContent *content = GetRoleContent(mDOMNode); + if (!content) + return NS_ERROR_FAILURE; + + if (aRelationType == nsIAccessibleRelation::RELATION_LABEL_FOR) { + // Caption is the label for groupbox + nsIContent *parent = content->GetParent(); + if (parent && parent->Tag() == nsAccessibilityAtoms::caption) { + nsCOMPtr parentAccessible; + GetParent(getter_AddRefs(parentAccessible)); + if (Role(parentAccessible) == nsIAccessibleRole::ROLE_GROUPING) { + parentAccessible.swap(*aRelated); + } + } + } + + return NS_OK; +} + /** * For XUL tooltip */ diff --git a/accessible/src/xul/nsXULTextAccessible.h b/accessible/src/xul/nsXULTextAccessible.h index b3a6b5b6fc4..fcbbad5c64d 100644 --- a/accessible/src/xul/nsXULTextAccessible.h +++ b/accessible/src/xul/nsXULTextAccessible.h @@ -54,6 +54,8 @@ public: NS_IMETHOD GetName(nsAString& _retval); NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState); NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = nsIAccessibleRole::ROLE_LABEL; return NS_OK; } + NS_IMETHOD GetAccessibleRelated(PRUint32 aRelationType, + nsIAccessible **aRelated); }; class nsXULTooltipAccessible : public nsLeafAccessible diff --git a/toolkit/content/widgets/groupbox.xml b/toolkit/content/widgets/groupbox.xml index de86845fa3d..63130ab12c7 100644 --- a/toolkit/content/widgets/groupbox.xml +++ b/toolkit/content/widgets/groupbox.xml @@ -44,15 +44,6 @@ xbl:inherits="default,value=label,crop,accesskey"/> - - - - if (this.parentNode.id) { - document.getAnonymousNodes(this)[1] - .setAttribute("control", this.parentNode.id); - } - -