Bug 363617. Missing support for some ARIA properties. r=ginn.chen, sr=neil

This commit is contained in:
aaronleventhal%moonset.net 2006-12-13 14:40:54 +00:00
Родитель e3592e43e4
Коммит a71f14b316
3 изменённых файлов: 47 добавлений и 0 удалений

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

@ -161,10 +161,13 @@ ACCESSIBILITY_ATOM(value, "value")
ACCESSIBILITY_ATOM(checked, "checked")
ACCESSIBILITY_ATOM(expanded, "expanded")
ACCESSIBILITY_ATOM(invalid, "invalid")
ACCESSIBILITY_ATOM(level, "level")
ACCESSIBILITY_ATOM(multiselect, "multiselect")
ACCESSIBILITY_ATOM(posinset, "posinset")
ACCESSIBILITY_ATOM(required, "required")
ACCESSIBILITY_ATOM(role, "role")
ACCESSIBILITY_ATOM(selected, "selected")
ACCESSIBILITY_ATOM(setsize, "setsize")
ACCESSIBILITY_ATOM(valuenow, "valuenow") // For DHTML widget values
ACCESSIBILITY_ATOM(valuemin, "valuemin")
ACCESSIBILITY_ATOM(valuemax, "valuemax")

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

@ -59,6 +59,7 @@
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsXPIDLString.h"
#include "nsUnicharUtils.h"
#include "prdtoa.h"
#include "nsIDOMComment.h"
#include "nsIDOMHTMLImageElement.h"
@ -1961,6 +1962,17 @@ NS_IMETHODIMP nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
if (GetRoleAttribute(content, xmlRole)) {
attributes->SetStringProperty(NS_LITERAL_CSTRING("xml-roles"), xmlRole, oldValueUnused);
}
char *ariaProperties[] = { "live", "atomic", "relevant", "datatype", "level", "posinset", "setsize", "sort" };
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(ariaProperties); index ++) {
nsAutoString value;
nsCOMPtr<nsIAtom> attr = do_GetAtom(ariaProperties[index]);
if (content->GetAttr(kNameSpaceID_WAIProperties, attr, value)) {
ToLowerCase(value);
attributes->SetStringProperty(nsDependentCString(ariaProperties[index]), value, oldValueUnused);
}
}
}
attributes.swap(*aAttributes);

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

@ -311,6 +311,38 @@ NS_IMETHODIMP nsAccessibleWrap::GetDescription(nsAString& aDescription)
// Tree items override this, because they provide the current level as well
aDescription.Truncate();
// Try ARIA properties first:
// If they exist then map them to positional description string
nsIContent *content = GetRoleContent(mDOMNode);
nsAutoString posInSet, setSize;
if (content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::posinset, posInSet) &&
content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::setsize, setSize)) {
PRInt32 errPosInSet, errSetSize;
PRInt32 intPosInSet = posInSet.ToInteger(&errPosInSet);
PRInt32 intSetSize = setSize.ToInteger(&errSetSize);
if (NS_SUCCEEDED(errPosInSet) && intPosInSet >=1 && NS_SUCCEEDED(errSetSize) && intSetSize >= 1) {
nsAutoString level;
if (content->GetAttr(kNameSpaceID_WAIProperties, nsAccessibilityAtoms::level, level)) {
// Position has a level
PRInt32 errLevel;
PRInt32 intLevel = level.ToInteger(&errLevel);
if (NS_SUCCEEDED(errLevel) && intLevel >= 1) {
// XXX How do we calculate the number of children?
// Normally we would append " with [numChildren]c" if we had that information
// In the future we may need to use the ARIA owns property to calculate that if it's present
nsTextFormatter::ssprintf(aDescription,
NS_LITERAL_STRING("L%d, %d of %d").get(), intLevel, intPosInSet, intSetSize);
}
}
else { // Position has no level
nsTextFormatter::ssprintf(aDescription,
NS_LITERAL_STRING("%d of %d").get(), intPosInSet, intSetSize);
}
return NS_OK;
}
}
PRUint32 currentRole;
nsresult rv = GetFinalRole(&currentRole);
if (NS_FAILED(rv) ||