From d5757e19d998bcd8f11fad2c0a17f2870dcf2b01 Mon Sep 17 00:00:00 2001 From: "aaronleventhal%moonset.net" Date: Tue, 18 Sep 2007 21:48:04 +0000 Subject: [PATCH] Bug 394896. Implement ARIA autocomplete. r=david.bolter, a=dsicore --- accessible/src/base/nsARIAMap.cpp | 7 ++++++- accessible/src/base/nsAccessible.cpp | 30 +++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/accessible/src/base/nsARIAMap.cpp b/accessible/src/base/nsARIAMap.cpp index 8745ade6488..c92f25402f5 100644 --- a/accessible/src/base/nsARIAMap.cpp +++ b/accessible/src/base/nsARIAMap.cpp @@ -78,7 +78,9 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = {"selected", kBoolState, nsIAccessibleStates::STATE_SELECTED | nsIAccessibleStates::STATE_SELECTABLE}, {"selected", "false", nsIAccessibleStates::STATE_SELECTABLE}, {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry}, - {"combobox", nsIAccessibleRole::ROLE_COMBOBOX, eNameLabelOrTitle, eHasValueMinMax, nsIAccessibleStates::STATE_COLLAPSED, + {"combobox", nsIAccessibleRole::ROLE_COMBOBOX, eNameLabelOrTitle, eHasValueMinMax, + nsIAccessibleStates::STATE_COLLAPSED | nsIAccessibleStates::STATE_HASPOPUP, + // Manually map EXT_STATE_SUPPORTS_AUTOCOMPLETION aaa:autocomplete {"disabled", kBoolState, nsIAccessibleStates::STATE_UNAVAILABLE}, {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, {"expanded", kBoolState, nsIAccessibleStates::STATE_EXPANDED}, kEndEntry}, @@ -172,6 +174,9 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = {"tabpanel", nsIAccessibleRole::ROLE_PROPERTYPAGE, eNameLabelOrTitle, eNoValue, kNoReqStates, kEndEntry}, {"textbox", nsIAccessibleRole::ROLE_ENTRY, eNameLabelOrTitle, eNoValue, kNoReqStates, // Manually map EXT_STATE_SINGLE_LINE and EXT_STATE_MULTI_LINE FROM aaa:multiline + // Manually map EXT_STATE_SUPPORTS_AUTOCOMPLETION aaa:autocomplete + {"autocomplete", "list", nsIAccessibleStates::STATE_HASPOPUP}, + {"autocomplete", "both", nsIAccessibleStates::STATE_HASPOPUP}, {"secret", kBoolState, nsIAccessibleStates::STATE_PROTECTED}, {"disabled", kBoolState, nsIAccessibleStates::STATE_UNAVAILABLE}, {"readonly", kBoolState, nsIAccessibleStates::STATE_READONLY}, kEndEntry}, diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index ebceb3cf23c..57a1c654585 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2337,17 +2337,29 @@ nsAccessible::GetFinalState(PRUint32 *aState, PRUint32 *aExtraState) } } - // XXX We can remove this hack once we support RDF-based role & state maps - if (mRoleMapEntry && (mRoleMapEntry->role == nsIAccessibleRole::ROLE_ENTRY || - mRoleMapEntry->role == nsIAccessibleRole::ROLE_PASSWORD_TEXT)) { - nsCOMPtr content = do_QueryInterface(mDOMNode); + PRUint32 role; + GetFinalRole(&role); + if (role == nsIAccessibleRole::ROLE_ENTRY || + role == nsIAccessibleRole::ROLE_PASSWORD_TEXT || + role == nsIAccessibleRole::ROLE_COMBOBOX) { + nsIContent *content = frame->GetContent(); NS_ENSURE_TRUE(content, NS_ERROR_FAILURE); - if (content->AttrValueIs(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::multiline, - nsAccessibilityAtoms::_true, eCaseMatters)) { - *aExtraState |= nsIAccessibleStates::EXT_STATE_MULTI_LINE; + nsAutoString autocomplete; + if (content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::autocomplete, autocomplete) && + (autocomplete.EqualsIgnoreCase("inline") || + autocomplete.EqualsIgnoreCase("list") || + autocomplete.EqualsIgnoreCase("both"))) { + *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION; } - else { - *aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE; + // XXX We can remove this hack once we support RDF-based role & state maps + if (mRoleMapEntry && mRoleMapEntry->role == nsIAccessibleRole::ROLE_ENTRY) { + if (content->AttrValueIs(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::multiline, + nsAccessibilityAtoms::_true, eCaseMatters)) { + *aExtraState |= nsIAccessibleStates::EXT_STATE_MULTI_LINE; + } + else { + *aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE; + } } } }