From 1a825a8d3e741e880d7ef751e838725db177f21d Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Wed, 10 Aug 2005 18:15:53 +0000 Subject: [PATCH] Bug 302359. Accessibility fixes for options dialogs. r=mconnor, r=parente, sr=darin, a=parente --- accessible/src/base/nsAccessible.cpp | 66 +++++++++---------- accessible/src/base/nsRootAccessible.cpp | 28 +++----- browser/components/preferences/advanced.xul | 19 +++--- .../components/preferences/changeaction.xul | 8 ++- browser/components/preferences/cookies.xul | 2 +- .../preferences/downloadactions.xul | 4 +- browser/components/preferences/downloads.xul | 5 +- browser/components/preferences/general.xul | 2 +- .../components/preferences/permissions.xul | 4 +- browser/components/preferences/privacy.xul | 47 +++++++------ browser/components/preferences/sanitize.xul | 4 +- .../resources/content/passwordManager.xul | 4 +- toolkit/content/widgets/preferences.xml | 18 +++-- toolkit/mozapps/preferences/changemp.js | 2 +- toolkit/mozapps/preferences/changemp.xul | 10 +-- toolkit/mozapps/preferences/fontscaling.xul | 2 +- toolkit/mozapps/preferences/ocsp.xul | 2 +- toolkit/mozapps/preferences/removemp.xul | 17 +++-- toolkit/mozapps/preferences/update.xul | 21 ++++-- 19 files changed, 146 insertions(+), 119 deletions(-) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 654a52bfb19f..e1c770e94037 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -217,15 +217,32 @@ NS_IMETHODIMP nsAccessible::GetDescription(nsAString& aDescription) } if (!content->IsContentOfType(nsIContent::eTEXT)) { nsAutoString description; - if (!mRoleMapEntry || - NS_FAILED(GetTextFromRelationID(nsAccessibilityAtoms::describedby, description))) { - if (NS_CONTENT_ATTR_HAS_VALUE != - content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::title, description)) { - nsAutoString name; - GetName(name); - if (name.IsEmpty() || description == name) { - // Has no name or description is not unique - description.Truncate(); + if (mRoleMapEntry) { + GetTextFromRelationID(nsAccessibilityAtoms::describedby, description); + } + if (description.IsEmpty()) { + PRBool isXUL = content->IsContentOfType(nsIContent::eXUL); + if (isXUL) { + // Try XUL description text + nsIContent *descriptionContent = + GetXULLabelContent(content, nsAccessibilityAtoms::description); + if (descriptionContent) { + // We have a description content node + AppendFlatStringFromSubtree(descriptionContent, &description); + } + } + if (description.IsEmpty()) { + nsIAtom *descAtom = isXUL ? nsAccessibilityAtoms::tooltiptext : + nsAccessibilityAtoms::title; + if (NS_CONTENT_ATTR_HAS_VALUE == + content->GetAttr(kNameSpaceID_None, descAtom, description)) { + nsAutoString name; + GetName(name); + if (name.IsEmpty() || description == name) { + // Don't use tooltip for a description if this object + // has no name or the tooltip is the same as the name + description.Truncate(); + } } } } @@ -1255,7 +1272,6 @@ nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsA if (textContent->TextLength() > 0) { nsAutoString text; textContent->AppendTextTo(text); - text.CompressWhitespace(); if (!text.IsEmpty()) aFlatString->Append(text); if (isHTMLBlock && !aFlatString->IsEmpty()) @@ -1271,11 +1287,12 @@ nsresult nsAccessible::AppendFlatStringFromContentNode(nsIContent *aContent, nsA aContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::value, textEquivalent); } - else { - aContent->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::tooltiptext, - textEquivalent); + else if (NS_CONTENT_ATTR_HAS_VALUE != + aContent->GetAttr(kNameSpaceID_None, + nsAccessibilityAtoms::tooltiptext, + textEquivalent)) { + AppendNameFromAccessibleFor(aContent, aFlatString, PR_TRUE /* use value */); } - textEquivalent.CompressWhitespace(); return AppendStringWithSpaces(aFlatString, textEquivalent); } return NS_OK; // Not HTML and not XUL -- we don't handle it yet @@ -1348,7 +1365,7 @@ nsresult nsAccessible::AppendFlatStringFromSubtreeRecurse(nsIContent *aContent, PRUint32 index; for (index = 0; index < numChildren; index++) { - AppendFlatStringFromSubtree(aContent->GetChildAt(index), aFlatString); + AppendFlatStringFromSubtreeRecurse(aContent->GetChildAt(index), aFlatString); } return NS_OK; } @@ -1384,7 +1401,7 @@ nsIContent* nsAccessible::GetXULLabelContent(nsIContent *aForNode, nsIAtom *aLab } // Look for label in subtrees of nearby ancestors - static const PRUint32 kAncestorLevelsToSearch = 3; + static const PRUint32 kAncestorLevelsToSearch = 5; PRUint32 count = 0; while (!labelContent && ++count <= kAncestorLevelsToSearch && (aForNode = aForNode->GetParent()) != nsnull) { @@ -1826,23 +1843,6 @@ NS_IMETHODIMP nsAccessible::GetFinalState(PRUint32 *aState) // via DHTML accessibility disabled property finalState &= ~(STATE_SELECTABLE | STATE_FOCUSABLE); } - else if (gLastFocusedNode == mDOMNode && (mRoleMapEntry->state & STATE_SELECTABLE)) { - // If we're focused and selectable and not inside a multiselect, - // then we're also selected - nsCOMPtr container = this; - PRUint32 containerState = 0, containerRole; - while (0 == (containerState & STATE_MULTISELECTABLE)) { - nsCOMPtr current; - current.swap(container); - current->GetParent(getter_AddRefs(container)); - if (!container || (NS_SUCCEEDED(container->GetFinalRole(&containerRole)) && - containerRole == ROLE_PANE)) { - finalState |= STATE_SELECTED; - break; - } - container->GetFinalState(&containerState); - } - } nsCOMPtr content(do_QueryInterface(mDOMNode)); if (content) { diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index ad0fb34b6f72..f2611a1d3a43 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -374,29 +374,17 @@ void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, // Special dynamic content handling PRUint32 role = ROLE_NOTHING; aAccessible->GetFinalRole(&role); - PRUint32 naturalRole; // The natural role is the role that this type of element normally has - aAccessible->GetRole(&naturalRole); - if (role != naturalRole) { - nsCOMPtr multiSelect = GetMultiSelectFor(aNode); - if (!multiSelect) { - // Selection events that mirror focus events - // Mirror selection events to focus, but only for widgets that are selectable - // but not a descendent of a multi-selectable widget - // Selection events for multiselects is handled separately - // in nsDocAccessible::AttributeChanged() for DHTML widgets and - // in nsRootAccessible::HandleEvent() via - // DOMItemSelected and DOMItemUnselected for everything else - FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION, - aAccessible, nsnull); - } - if (role == ROLE_MENUITEM) { - if (!mIsInDHTMLMenu) { // Entering menus - FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUSTART, this, nsnull); + if (role == ROLE_MENUITEM) { + if (!mIsInDHTMLMenu) { // Entering menus + PRUint32 naturalRole; // The natural role is the role that this type of element normally has + aAccessible->GetRole(&naturalRole); + if (role != naturalRole) { // Must be a DHTML menuitem + FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUSTART, this, nsnull); + mIsInDHTMLMenu = ROLE_MENUITEM; } - mIsInDHTMLMenu = PR_TRUE; } } - if (role != ROLE_MENUITEM && mIsInDHTMLMenu) { // Leaving menus + else if (mIsInDHTMLMenu) { FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUEND, this, nsnull); mIsInDHTMLMenu = PR_FALSE; } diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index bd7b443251f4..cbc5b8c84857 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -47,7 +47,10 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + helpURI="chrome://browser/locale/help/help.rdf" + xmlns:xhtml2="http://www.w3.org/TR/xhtml2" + xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#" + xmlns:aaa="http://www.w3.org/2005/07/aaa"> - &languagesInfo.label; + &languagesInfo.label;