Bug 368012. Expose STATE_CHECKABLE for each checkable widget. Patch by David Bolter. r=aaronlev

This commit is contained in:
aaronleventhal@moonset.net 2007-05-06 07:50:03 -07:00
Родитель 8c19e57b2c
Коммит ecc5ecc833
4 изменённых файлов: 49 добавлений и 11 удалений

Просмотреть файл

@ -147,6 +147,7 @@ ACCESSIBILITY_ATOM(alt, "alt")
ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
ACCESSIBILITY_ATOM(autocomplete, "autocomplete") // Used as attribute value too
ACCESSIBILITY_ATOM(control, "control")
ACCESSIBILITY_ATOM(cycles, "cycles") // used for XUL cycler attribute
ACCESSIBILITY_ATOM(data, "data")
ACCESSIBILITY_ATOM(disabled, "disabled")
ACCESSIBILITY_ATOM(editable, "editable")

Просмотреть файл

@ -102,6 +102,8 @@ nsHTMLCheckboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState);
NS_ENSURE_SUCCESS(rv, rv);
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
@ -127,6 +129,8 @@ nsHTMLRadioButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
nsresult rv = nsAccessibleWrap::GetState(aState, aExtraState);
NS_ENSURE_SUCCESS(rv, rv);
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
PRBool checked = PR_FALSE; // Radio buttons and check boxes can be checked
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement(do_QueryInterface(mDOMNode));

Просмотреть файл

@ -133,14 +133,20 @@ nsXULButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
// Buttons can be checked -- they simply appear pressed in rather than checked
nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement(do_QueryInterface(mDOMNode));
if (xulButtonElement) {
PRBool checked = PR_FALSE;
PRInt32 checkState = 0;
xulButtonElement->GetChecked(&checked);
if (checked) {
*aState |= nsIAccessibleStates::STATE_PRESSED;
xulButtonElement->GetCheckState(&checkState);
if (checkState == nsIDOMXULButtonElement::CHECKSTATE_MIXED)
*aState |= nsIAccessibleStates::STATE_MIXED;
nsAutoString type;
xulButtonElement->GetType(type);
if (type.EqualsLiteral("checkbox") || type.EqualsLiteral("radio")) {
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
PRBool checked = PR_FALSE;
PRInt32 checkState = 0;
xulButtonElement->GetChecked(&checked);
if (checked) {
*aState |= nsIAccessibleStates::STATE_PRESSED;
xulButtonElement->GetCheckState(&checkState);
if (checkState == nsIDOMXULButtonElement::CHECKSTATE_MIXED) {
*aState |= nsIAccessibleStates::STATE_MIXED;
}
}
}
}
@ -365,7 +371,9 @@ nsXULCheckboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
// Get focus and disable status from base class
nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState);
NS_ENSURE_SUCCESS(rv, rv);
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
// Determine Checked state
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
if (xulCheckboxElement) {
@ -531,6 +539,8 @@ nsXULRadioButtonAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
nsresult rv = nsFormControlAccessible::GetState(aState, aExtraState);
NS_ENSURE_SUCCESS(rv, rv);
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
PRBool selected = PR_FALSE; // Radio buttons can be selected
nsCOMPtr<nsIDOMXULSelectControlItemElement> radioButton(do_QueryInterface(mDOMNode));

Просмотреть файл

@ -577,7 +577,8 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetRole(PRUint32 *aRole)
return NS_OK;
}
// Possible states: focused, focusable, selected, expanded/collapsed
// Possible states: focused, focusable, selected, checkable, checked,
// expanded/collapsed, invisible
NS_IMETHODIMP
nsXULTreeitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
{
@ -587,7 +588,7 @@ nsXULTreeitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
if (aExtraState)
*aExtraState = 0;
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mColumn && mTree && mTreeView, NS_ERROR_FAILURE);
*aState = nsIAccessibleStates::STATE_FOCUSABLE |
nsIAccessibleStates::STATE_SELECTABLE;
@ -630,6 +631,18 @@ nsXULTreeitemAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
if (mRow < firstVisibleRow || mRow > lastVisibleRow)
*aState |= nsIAccessibleStates::STATE_INVISIBLE;
PRInt16 type;
mColumn->GetType(&type);
if (type == nsITreeColumn::TYPE_CHECKBOX) {
*aState |= nsIAccessibleStates::STATE_CHECKABLE;
nsAutoString checked;
mTreeView->GetCellValue(mRow, mColumn, checked);
if (checked.EqualsIgnoreCase("true")) {
*aState |= nsIAccessibleStates::STATE_CHECKED;
}
}
return NS_OK;
}
@ -716,9 +729,19 @@ nsXULTreeitemAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribu
PRInt32 setSize = endIndex - startIndex + 1;
PRInt32 posInSet = mRow - startIndex + 1;
// set the group attributes
nsAccessibilityUtils::
SetAccGroupAttrs(aAttributes, level + 1, posInSet, setSize);
// set the "cycles" attribute
PRBool isCycler;
mColumn->GetCycler(&isCycler);
if (isCycler) {
nsAccessibilityUtils::SetAccAttr(aAttributes,
nsAccessibilityAtoms::cycles,
NS_LITERAL_STRING("true"));
}
return NS_OK;
}