Bug 109215 - Implement accessibility API support for slider, r=ginn.chen, sr=neil

This commit is contained in:
surkov.alexander%gmail.com 2007-07-26 16:41:01 +00:00
Родитель 8f03a500e7
Коммит 4d60a9c3ab
9 изменённых файлов: 138 добавлений и 113 удалений

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

@ -45,7 +45,7 @@
object. For that XBL binding of element should implement the interface.
*/
[scriptable, uuid(7250d0f0-732d-4981-b73e-dd5d71b16183)]
[scriptable, uuid(3f7f9194-c625-4a85-8148-6d92d34897fa)]
interface nsIAccessibleProvider : nsISupports
{
/**
@ -69,37 +69,39 @@ interface nsIAccessibleProvider : nsISupports
const long XULDropmarker = 0x00001007;
const long XULGroupbox = 0x00001008;
const long XULImage = 0x00001009;
const long XULLink = 0x00001010;
const long XULListbox = 0x00001011;
const long XULListitem = 0x00001012;
const long XULMenubar = 0x00001013;
const long XULMenuitem = 0x00001014;
const long XULMenupopup = 0x00001015;
const long XULMenuSeparator = 0x00001016;
const long XULProgressMeter = 0x00001017;
const long XULStatusBar = 0x00001018;
const long XULRadioButton = 0x00001019;
const long XULRadioGroup = 0x00001020;
const long XULLink = 0x0000100A;
const long XULListbox = 0x0000100B;
const long XULListitem = 0x0000100C;
const long XULMenubar = 0x0000100D;
const long XULMenuitem = 0x0000100E;
const long XULMenupopup = 0x0000100F;
const long XULMenuSeparator = 0x00001010;
const long XULProgressMeter = 0x00001011;
const long XULScale = 0x00001012;
const long XULStatusBar = 0x00001013;
const long XULRadioButton = 0x00001014;
const long XULRadioGroup = 0x00001015;
/** The single tab in a dialog or tabbrowser/editor interface */
const long XULTab = 0x00001021;
const long XULTab = 0x00001016;
/** A combination of a tabs object and a tabpanels object */
const long XULTabBox = 0x00001022;
const long XULTabBox = 0x00001017;
/** The collection of tab objects, useable in the TabBox and independant of
as well */
const long XULTabs = 0x00001023;
const long XULTabs = 0x00001018;
const long XULText = 0x00001024;
const long XULTextBox = 0x00001025;
const long XULTree = 0x00001026;
const long XULTreeColumns = 0x00001027;
const long XULTreeColumnitem = 0x00001028;
const long XULToolbar = 0x00001029;
const long XULToolbarSeparator = 0x00001030;
const long XULTooltip = 0x00001031;
const long XULToolbarButton = 0x00001032;
const long XULText = 0x00001019;
const long XULTextBox = 0x0000101A;
const long XULThumb = 0x0000101B;
const long XULTree = 0x0000101C;
const long XULTreeColumns = 0x0000101D;
const long XULTreeColumnitem = 0x0000101E;
const long XULToolbar = 0x0000101F;
const long XULToolbarSeparator = 0x00001020;
const long XULTooltip = 0x00001021;
const long XULToolbarButton = 0x00001022;
/**

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

@ -155,13 +155,17 @@ 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(curpos, "curpos") // XUL slider
ACCESSIBILITY_ATOM(data, "data")
ACCESSIBILITY_ATOM(disabled, "disabled")
ACCESSIBILITY_ATOM(editable, "editable")
ACCESSIBILITY_ATOM(_for, "for")
ACCESSIBILITY_ATOM(href, "href")
ACCESSIBILITY_ATOM(id, "id")
ACCESSIBILITY_ATOM(increment, "increment") // XUL slider
ACCESSIBILITY_ATOM(lang, "lang")
ACCESSIBILITY_ATOM(maxpos, "maxpos") // XUL slider
ACCESSIBILITY_ATOM(minpos, "minpos") // XUL slider
ACCESSIBILITY_ATOM(multiline, "multiline")
ACCESSIBILITY_ATOM(name, "name")
ACCESSIBILITY_ATOM(onclick, "onclick")

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

@ -87,6 +87,7 @@
#include "nsXULFormControlAccessible.h"
#include "nsXULMenuAccessibleWrap.h"
#include "nsXULSelectAccessible.h"
#include "nsXULSliderAccessible.h"
#include "nsXULTabAccessible.h"
#include "nsXULTextAccessible.h"
#include "nsXULTreeAccessibleWrap.h"
@ -1602,6 +1603,9 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
case nsIAccessibleProvider::XULStatusBar:
*aAccessible = new nsXULStatusBarAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULScale:
*aAccessible = new nsXULSliderAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULRadioButton:
*aAccessible = new nsXULRadioButtonAccessible(aNode, weakShell);
break;
@ -1623,6 +1627,9 @@ nsresult nsAccessibilityService::GetAccessibleByType(nsIDOMNode *aNode,
case nsIAccessibleProvider::XULTextBox:
*aAccessible = new nsXULTextFieldAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULThumb:
*aAccessible = new nsXULThumbAccessible(aNode, weakShell);
break;
case nsIAccessibleProvider::XULTree:
*aAccessible = new nsXULTreeAccessibleWrap(aNode, weakShell);
break;

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

@ -2336,110 +2336,68 @@ NS_IMETHODIMP nsAccessible::GetValue(nsAString& aValue)
return NS_OK;
}
NS_IMETHODIMP nsAccessible::GetMaximumValue(double *aMaximumValue)
// nsIAccessibleValue
NS_IMETHODIMP
nsAccessible::GetMaximumValue(double *aMaximumValue)
{
*aMaximumValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString valueMax;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemax, valueMax) &&
valueMax.IsEmpty() == PR_FALSE) {
*aMaximumValue = PR_strtod(NS_LossyConvertUTF16toASCII(valueMax).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No maximum
return GetAttrValue(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemax, aMaximumValue);
}
NS_IMETHODIMP nsAccessible::GetMinimumValue(double *aMinimumValue)
NS_IMETHODIMP
nsAccessible::GetMinimumValue(double *aMinimumValue)
{
*aMinimumValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString valueMin;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemin, valueMin) &&
valueMin.IsEmpty() == PR_FALSE) {
*aMinimumValue = PR_strtod(NS_LossyConvertUTF16toASCII(valueMin).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No minimum
return GetAttrValue(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemin, aMinimumValue);
}
NS_IMETHODIMP nsAccessible::GetMinimumIncrement(double *aMinIncrement)
NS_IMETHODIMP
nsAccessible::GetMinimumIncrement(double *aMinIncrement)
{
NS_ENSURE_ARG_POINTER(aMinIncrement);
*aMinIncrement = 0;
return NS_ERROR_NOT_IMPLEMENTED; // No mimimum increment in dynamic content spec right now
// No mimimum increment in dynamic content spec right now
return NS_OK_NO_ARIA_VALUE;
}
NS_IMETHODIMP nsAccessible::GetCurrentValue(double *aValue)
NS_IMETHODIMP
nsAccessible::GetCurrentValue(double *aValue)
{
*aValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString value;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, value) &&
value.IsEmpty() == PR_FALSE) {
*aValue = PR_strtod(NS_LossyConvertUTF16toASCII(value).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No value
return GetAttrValue(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, aValue);
}
NS_IMETHODIMP nsAccessible::SetCurrentValue(double aValue)
NS_IMETHODIMP
nsAccessible::SetCurrentValue(double aValue)
{
if (!mDOMNode) {
if (!mDOMNode)
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
const PRUint32 kValueCannotChange = nsIAccessibleStates::STATE_READONLY |
nsIAccessibleStates::STATE_UNAVAILABLE;
if (State(this) & kValueCannotChange) {
return NS_ERROR_FAILURE;
}
double minValue;
if (NS_SUCCEEDED(GetMinimumValue(&minValue)) && aValue < minValue) {
return NS_ERROR_INVALID_ARG;
}
double maxValue;
if (NS_SUCCEEDED(GetMaximumValue(&maxValue)) && aValue > maxValue) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content) {
nsAutoString newValue;
newValue.AppendFloat(aValue);
return content->SetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, newValue, PR_TRUE);
}
}
return NS_ERROR_FAILURE; // Not in a role that can accept value
if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
return NS_OK_NO_ARIA_VALUE;
const PRUint32 kValueCannotChange = nsIAccessibleStates::STATE_READONLY |
nsIAccessibleStates::STATE_UNAVAILABLE;
if (State(this) & kValueCannotChange)
return NS_ERROR_FAILURE;
double minValue = 0;
if (NS_SUCCEEDED(GetMinimumValue(&minValue)) && aValue < minValue)
return NS_ERROR_INVALID_ARG;
double maxValue = 0;
if (NS_SUCCEEDED(GetMaximumValue(&maxValue)) && aValue > maxValue)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_STATE(content);
nsAutoString newValue;
newValue.AppendFloat(aValue);
return content->SetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, newValue, PR_TRUE);
}
/* void setName (in DOMString name); */
@ -3231,3 +3189,28 @@ PRBool nsAccessible::CheckVisibilityInParentChain(nsIDocument* aDocument, nsIVie
return PR_TRUE;
}
nsresult
nsAccessible::GetAttrValue(PRUint32 aNameSpaceID, nsIAtom *aName,
double *aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
*aValue = 0;
if (!mDOMNode)
return NS_ERROR_FAILURE; // Node already shut down
if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
return NS_OK_NO_ARIA_VALUE;
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_STATE(content);
PRInt32 result = NS_OK;
nsAutoString value;
if (content->GetAttr(aNameSpaceID, aName, value) && !value.IsEmpty())
*aValue = value.ToFloat(&result);
return result;
}

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

@ -67,6 +67,9 @@ class nsIDOMNode;
class nsIAtom;
class nsIView;
#define NS_OK_NO_ARIA_VALUE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x21)
// When mNextSibling is set to this, it indicates there ar eno more siblings
#define DEAD_END_ACCESSIBLE static_cast<nsIAccessible*>((void*)1)
@ -275,6 +278,17 @@ protected:
// Check the visibility across both parent content and chrome
PRBool CheckVisibilityInParentChain(nsIDocument* aDocument, nsIView* aView);
/**
* Get numeric value of the given attribute.
*
* @param aNameSpaceID - namespace ID of the attribute
* @param aName - name of the attribute
* @param aValue - value of the attribute
*
* @return - NS_OK_NO_ARIA_VALUE if there is no setted ARIA attribute
*/
nsresult GetAttrValue(PRUint32 aNameSpaceID, nsIAtom *aName, double *aValue);
// Data Members
nsCOMPtr<nsIAccessible> mParent;
nsIAccessible *mFirstChild, *mNextSibling;

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

@ -72,6 +72,7 @@ CPPSRCS = \
nsXULFormControlAccessible.cpp \
nsXULMenuAccessible.cpp \
nsXULSelectAccessible.cpp \
nsXULSliderAccessible.cpp \
nsXULTabAccessible.cpp \
nsXULTextAccessible.cpp \
nsXULTreeAccessible.cpp \

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

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

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

@ -9,6 +9,14 @@
<resources>
<stylesheet src="chrome://global/skin/scale.css"/>
</resources>
<implementation implements="nsIAccessibleProvider">
<property name="accessibleType" readonly="true">
<getter>
return Components.interfaces.nsIAccessibleProvider.XULThumb;
</getter>
</property>
</implementation>
</binding>
<binding id="scaleslider" display="xul:slider"
@ -31,7 +39,13 @@
</xul:slider>
</content>
<implementation>
<implementation implements="nsIAccessibleProvider">
<property name="accessibleType" readonly="true">
<getter>
return Components.interfaces.nsIAccessibleProvider.XULScale;
</getter>
</property>
<property name="value" onget="return this._getIntegerAttribute('curpos', 0);"
onset="return this._setIntegerAttribute('curpos', val);"/>
<property name="min" onget="return this._getIntegerAttribute('minpos', 0);"