mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 341745. Clean up accessible text entry classes and make sure nsIAccessible::ROLE_TEXT always refers to content. r=pilgrim
This commit is contained in:
parent
41e94d16e9
commit
1e7b9dc262
@ -603,11 +603,11 @@ interface nsIAccessible : nsISupports
|
||||
// Make up for ATK roles that we don't have in MSAA
|
||||
// When in doubt map them to ROLE_NOTHING so that the role string is exposed
|
||||
enum { ROLE_ICON = ROLE_NOTHING };
|
||||
enum { ROLE_PASSWORD_TEXT = ROLE_TEXT };
|
||||
enum { ROLE_PASSWORD_TEXT = 1000U };
|
||||
enum { ROLE_AUTOCOMPLETE = ROLE_COMBOBOX };
|
||||
enum { ROLE_EDITBAR = ROLE_NOTHING };
|
||||
enum { ROLE_EMBEDDED = ROLE_NOTHING };
|
||||
enum { ROLE_ENTRY = ROLE_NOTHING };
|
||||
enum { ROLE_ENTRY = 1001U };
|
||||
enum { ROLE_CAPTION = ROLE_NOTHING };
|
||||
enum { ROLE_DOCUMENT_FRAME = ROLE_NOTHING };
|
||||
enum { ROLE_HEADING = ROLE_NOTHING };
|
||||
|
@ -805,6 +805,11 @@ getRoleCB(AtkObject *aAtkObj)
|
||||
accRole = ATK_ROLE_COMBO_BOX;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_ENTRY
|
||||
else if (accRole == nsIAccessible::ROLE_ENTRY) {
|
||||
accRole = ATK_ROLE_TEXT;
|
||||
}
|
||||
#endif
|
||||
#ifndef USE_ATK_ROLE_CAPTION
|
||||
else if (accRole == nsIAccessible::ROLE_CAPTION) {
|
||||
accRole = ATK_ROLE_LABEL;
|
||||
|
@ -69,7 +69,7 @@
|
||||
#if ATK_MAJOR_VERSION >=2 || \
|
||||
(ATK_MAJOR_VERSION == 1 && ATK_MINOR_VERSION >= 11)
|
||||
#define USE_ATK_ROLE_CAPTION
|
||||
#define USE_ATK_ROLE_ENTRY // XXX not currently used
|
||||
#define USE_ATK_ROLE_ENTRY
|
||||
#define USE_ATK_ROLE_CHART // XXX not currently used
|
||||
#define USE_ATK_ROLE_DOCUMENT_FRAME // XXX not currently used
|
||||
#define USE_ATK_ROLE_HEADING // XXX not currently used
|
||||
|
@ -59,39 +59,6 @@ nsHTMLTextFieldAccessible(aNode, aShell), nsAccessibleEditableText(aNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessibleWrap::GetRole(PRUint32 *_retval)
|
||||
{
|
||||
PRUint32 state = 0;
|
||||
|
||||
nsresult rv = GetState(&state);
|
||||
if (NS_SUCCEEDED(rv) && (state & STATE_PROTECTED))
|
||||
*_retval = ROLE_PASSWORD_TEXT;
|
||||
else
|
||||
*_retval = ROLE_TEXT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessibleWrap::GetExtState(PRUint32 *aState)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAccessibleWrap::GetExtState(aState);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> htmlFormElement(do_QueryInterface(mDOMNode, &rv));
|
||||
if (NS_SUCCEEDED(rv) && htmlFormElement) {
|
||||
nsAutoString typeString;
|
||||
htmlFormElement->GetType(typeString);
|
||||
if (typeString.LowerCaseEqualsLiteral("text"))
|
||||
*aState |= EXT_STATE_SINGLE_LINE;
|
||||
}
|
||||
|
||||
PRUint32 state;
|
||||
nsHTMLTextFieldAccessible::GetState(&state);
|
||||
if (!(state & STATE_READONLY))
|
||||
*aState |= EXT_STATE_EDITABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessibleWrap::Shutdown()
|
||||
{
|
||||
|
@ -51,9 +51,6 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTextFieldAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetRole(PRUint32* aRole);
|
||||
|
||||
NS_IMETHOD GetExtState(PRUint32 *aState);
|
||||
NS_IMETHOD Shutdown();
|
||||
};
|
||||
|
||||
|
@ -77,30 +77,6 @@ nsXULTextFieldAccessible(aNode, aShell), nsAccessibleEditableText(aNode)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessibleWrap::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
PRUint32 state = 0;
|
||||
|
||||
nsresult rv = GetState(&state);
|
||||
if (NS_SUCCEEDED(rv) && (state & STATE_PROTECTED))
|
||||
*aRole = ROLE_PASSWORD_TEXT;
|
||||
else
|
||||
*aRole = ROLE_TEXT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessibleWrap::GetExtState(PRUint32 *aExtState)
|
||||
{
|
||||
nsAccessibleWrap::GetExtState(aExtState);
|
||||
|
||||
PRUint32 state;
|
||||
nsXULTextFieldAccessible::GetState(&state);
|
||||
if (!(state & STATE_READONLY))
|
||||
*aExtState |= EXT_STATE_EDITABLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessibleWrap::Shutdown()
|
||||
{
|
||||
nsAccessibleEditableText::ShutdownEditor();
|
||||
|
@ -51,9 +51,6 @@ public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsXULTextFieldAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetRole(PRUint32* aRole);
|
||||
|
||||
NS_IMETHOD GetExtState(PRUint32 *aExtState);
|
||||
NS_IMETHOD Shutdown();
|
||||
};
|
||||
|
||||
|
@ -1679,11 +1679,11 @@ nsRoleMapEntry nsAccessible::gWAIRoleMap[] =
|
||||
{"tab", ROLE_PAGETAB, eNameOkFromChildren, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"tablist", ROLE_PAGETABLIST, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"tabpanel", ROLE_PROPERTYPAGE, eNameLabelOrTitle, eNoValue, eNoReqStates, END_ENTRY},
|
||||
{"textarea", ROLE_TEXT, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
|
||||
{"textarea", ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
|
||||
{"readonly", BOOL_STATE, STATE_READONLY},
|
||||
{"invalid", BOOL_STATE, STATE_INVALID},
|
||||
{"required", BOOL_STATE, STATE_REQUIRED}, END_ENTRY}, // XXX EXT_STATE_MULTI_LINE
|
||||
{"textfield", ROLE_TEXT, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
|
||||
{"textfield", ROLE_ENTRY, eNameLabelOrTitle, eHasValueMinMax, eNoReqStates,
|
||||
{"readonly", BOOL_STATE, STATE_READONLY},
|
||||
{"invalid", BOOL_STATE, STATE_INVALID},
|
||||
{"required", BOOL_STATE, STATE_REQUIRED},
|
||||
@ -2161,7 +2161,7 @@ NS_IMETHODIMP nsAccessible::GetExtState(PRUint32 *aExtState)
|
||||
}
|
||||
*aExtState = 0;
|
||||
// XXX We can remove this hack once we support RDF-based role & state maps
|
||||
if (mRoleMapEntry && mRoleMapEntry->role == ROLE_TEXT) {
|
||||
if (mRoleMapEntry && (mRoleMapEntry->role == ROLE_ENTRY || mRoleMapEntry->role == ROLE_PASSWORD_TEXT)) {
|
||||
*aExtState = NS_LITERAL_CSTRING("textarea").Equals(mRoleMapEntry->roleString) ?
|
||||
EXT_STATE_MULTI_LINE : EXT_STATE_SINGLE_LINE;
|
||||
}
|
||||
|
@ -295,9 +295,17 @@ nsFormControlAccessible(aNode, aShell)
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLTextFieldAccessible, nsFormControlAccessible)
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetRole(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
*_retval = ROLE_TEXT;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node has been Shutdown()
|
||||
}
|
||||
*aRole = ROLE_ENTRY;
|
||||
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
||||
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
||||
*aRole = ROLE_PASSWORD_TEXT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -323,17 +331,20 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval)
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetState(PRUint32 *aState)
|
||||
{
|
||||
// can be focusable, focused, protected. readonly, unavailable, selected
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node has been Shutdown()
|
||||
nsresult rv = nsFormControlAccessible::GetState(aState);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsFormControlAccessible::GetState(aState);
|
||||
// can be focusable, focused, protected. readonly, unavailable, selected
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
NS_ASSERTION(content, "Should not have gotten here if upcalled GetExtState() succeeded");
|
||||
|
||||
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
||||
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
||||
*aState |= STATE_PROTECTED;
|
||||
}
|
||||
|
||||
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
|
||||
*aState |= STATE_READONLY;
|
||||
}
|
||||
@ -344,8 +355,22 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetState(PRUint32 *aState)
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetExtState(PRUint32 *aExtState)
|
||||
{
|
||||
nsresult rv = nsFormControlAccessible::GetExtState(aExtState);
|
||||
*aExtState |= EXT_STATE_SINGLE_LINE;
|
||||
return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode, &rv));
|
||||
// Is it an <input> or a <textarea> ?
|
||||
*aExtState |= htmlInput ? EXT_STATE_SINGLE_LINE : EXT_STATE_MULTI_LINE;
|
||||
|
||||
PRUint32 state;
|
||||
GetState(&state);
|
||||
const PRUint32 kNonEditableStates = STATE_READONLY | STATE_UNAVAILABLE;
|
||||
if (0 == (state & kNonEditableStates)) {
|
||||
*aExtState |= EXT_STATE_EDITABLE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetNumActions(PRUint8 *_retval)
|
||||
|
@ -110,7 +110,7 @@ class nsHTMLGroupboxAccessible : public nsAccessibleWrap
|
||||
public:
|
||||
nsHTMLGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetName(nsAString& _retval);
|
||||
void CacheChildren(PRBool aWalkAnonContent);
|
||||
};
|
||||
|
@ -430,6 +430,11 @@ STDMETHODIMP nsAccessibleWrap::get_accRole(
|
||||
if (NS_FAILED(xpAccessible->GetFinalRole(&role)))
|
||||
return E_FAIL;
|
||||
|
||||
// Begin check for extended roles that need to be mapped to something known
|
||||
if (role == ROLE_ENTRY || role == ROLE_PASSWORD_TEXT) {
|
||||
role = ROLE_TEXT;
|
||||
}
|
||||
|
||||
// -- Try enumerated role
|
||||
if (role != ROLE_NOTHING && role != ROLE_CLIENT) {
|
||||
pvarRole->vt = VT_I4;
|
||||
|
@ -662,6 +662,14 @@ NS_IMETHODIMP nsXULTextFieldAccessible::GetExtState(PRUint32 *aExtState)
|
||||
|
||||
PRBool isMultiLine = content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::multiline);
|
||||
*aExtState |= (isMultiLine ? EXT_STATE_MULTI_LINE : EXT_STATE_SINGLE_LINE);
|
||||
|
||||
PRUint32 state;
|
||||
GetState(&state);
|
||||
const PRUint32 kNonEditableStates = STATE_READONLY | STATE_UNAVAILABLE;
|
||||
if (0 == (state & kNonEditableStates)) {
|
||||
*aExtState |= EXT_STATE_EDITABLE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -686,9 +694,37 @@ NS_IMETHODIMP nsXULTextFieldAccessible::GetState(PRUint32 *aState)
|
||||
if (gLastFocusedNode == mDOMNode) {
|
||||
*aState |= STATE_FOCUSED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
NS_ASSERTION(content, "Not possible since we are a nsIDOMXULTextBoxElement");
|
||||
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
||||
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
||||
*aState |= STATE_PROTECTED;
|
||||
}
|
||||
|
||||
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::readonly,
|
||||
nsAccessibilityAtoms::_true, eIgnoreCase)) {
|
||||
*aState |= STATE_READONLY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node has been Shutdown()
|
||||
}
|
||||
*aRole = ROLE_ENTRY;
|
||||
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
||||
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
||||
*aRole = ROLE_PASSWORD_TEXT;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Only one actions available
|
||||
*/
|
||||
|
@ -152,7 +152,7 @@ public:
|
||||
NS_IMETHOD GetValue(nsAString& aValue);
|
||||
NS_IMETHOD GetState(PRUint32 *aState);
|
||||
NS_IMETHOD GetExtState(PRUint32 *aExtState);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole) { *aRole = ROLE_TEXT; return NS_OK; }
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole);
|
||||
NS_IMETHOD GetNumActions(PRUint8 *_retval);
|
||||
NS_IMETHOD GetActionName(PRUint8 index, nsAString& _retval);
|
||||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
|
Loading…
Reference in New Issue
Block a user