Bug 740758 - dexpcom nsAccessible::GetValue, r=tbsaunde, f=surkov

This commit is contained in:
Mark Capella 2012-04-09 18:48:41 +09:00
parent 410f4e95ea
commit 85ec17c936
40 changed files with 156 additions and 203 deletions

View File

@ -1661,17 +1661,25 @@ nsAccessible::ApplyARIAState(PRUint64* aState)
aria::MapToState(mRoleMapEntry->attributeMap3, element, aState); aria::MapToState(mRoleMapEntry->attributeMap3, element, aState);
} }
/* DOMString getValue (); */
NS_IMETHODIMP NS_IMETHODIMP
nsAccessible::GetValue(nsAString& aValue) nsAccessible::GetValue(nsAString& aValue)
{ {
if (IsDefunct()) if (IsDefunct())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsAutoString value;
Value(value);
aValue.Assign(value);
return NS_OK;
}
void
nsAccessible::Value(nsString& aValue)
{
if (mRoleMapEntry) { if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) { if (mRoleMapEntry->valueRule == eNoValue)
return NS_OK; return;
}
// aria-valuenow is a number, and aria-valuetext is the optional text equivalent // aria-valuenow is a number, and aria-valuetext is the optional text equivalent
// For the string value, we will try the optional text equivalent first // For the string value, we will try the optional text equivalent first
@ -1683,18 +1691,16 @@ nsAccessible::GetValue(nsAString& aValue)
} }
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
return NS_OK; return;
// Check if it's a simple xlink. // Check if it's a simple xlink.
if (nsCoreUtils::IsXLink(mContent)) { if (nsCoreUtils::IsXLink(mContent)) {
nsIPresShell* presShell = mDoc->PresShell(); nsIPresShell* presShell = mDoc->PresShell();
if (presShell) { if (presShell) {
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return presShell->GetLinkLocation(DOMNode, aValue); presShell->GetLinkLocation(DOMNode, aValue);
} }
} }
return NS_OK;
} }
// nsIAccessibleValue // nsIAccessibleValue

View File

@ -131,10 +131,15 @@ public:
// Public methods // Public methods
/** /**
* get the description of this accessible * Get the description of this accessible.
*/ */
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
/**
* Get the value of this accessible.
*/
virtual void Value(nsString& aValue);
/** /**
* Return DOM node associated with this accessible. * Return DOM node associated with this accessible.
*/ */

View File

@ -124,19 +124,18 @@ nsApplicationAccessible::GetName(nsAString& aName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsApplicationAccessible::GetValue(nsAString &aValue)
{
aValue.Truncate();
return NS_OK;
}
void void
nsApplicationAccessible::Description(nsString &aDescription) nsApplicationAccessible::Description(nsString &aDescription)
{ {
aDescription.Truncate(); aDescription.Truncate();
} }
void
nsApplicationAccessible::Value(nsString& aValue)
{
aValue.Truncate();
}
PRUint64 PRUint64
nsApplicationAccessible::State() nsApplicationAccessible::State()
{ {

View File

@ -80,7 +80,6 @@ public:
NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling); NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling); NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
NS_IMETHOD GetName(nsAString &aName); NS_IMETHOD GetName(nsAString &aName);
NS_IMETHOD GetValue(nsAString &aValue);
NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes); NS_IMETHOD GetAttributes(nsIPersistentProperties **aAttributes);
NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup, NS_IMETHOD GroupPosition(PRInt32 *aGroupLevel, PRInt32 *aSimilarItemsInGroup,
PRInt32 *aPositionInGroup); PRInt32 *aPositionInGroup);
@ -104,6 +103,7 @@ public:
// nsAccessible // nsAccessible
virtual void ApplyARIAState(PRUint64* aState); virtual void ApplyARIAState(PRUint64* aState);
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 State(); virtual PRUint64 State();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -124,16 +124,17 @@ nsLinkableAccessible::NativeState()
return states; return states;
} }
NS_IMETHODIMP void
nsLinkableAccessible::GetValue(nsAString& aValue) nsLinkableAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
nsAccessible::GetValue(aValue); nsAccessible::Value(aValue);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
return NS_OK; return;
return mIsLink ? mActionAcc->GetValue(aValue) : NS_ERROR_NOT_IMPLEMENTED; if (aValue.IsEmpty() && mIsLink)
mActionAcc->Value(aValue);
} }

View File

@ -89,13 +89,13 @@ public:
// nsIAccessible // nsIAccessible
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetValue(nsAString& _retval);
NS_IMETHOD TakeFocus(); NS_IMETHOD TakeFocus();
// nsAccessNode // nsAccessNode
virtual void Shutdown(); virtual void Shutdown();
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
// ActionAccessible // ActionAccessible

View File

@ -110,32 +110,29 @@ ProgressMeterAccessible<Max>::IsWidget() const
// nsIAccessibleValue // nsIAccessibleValue
template<int Max> template<int Max>
NS_IMETHODIMP void
ProgressMeterAccessible<Max>::GetValue(nsAString& aValue) ProgressMeterAccessible<Max>::Value(nsString& aValue)
{ {
nsresult rv = nsFormControlAccessible::GetValue(aValue); nsFormControlAccessible::Value(aValue);
NS_ENSURE_SUCCESS(rv, rv);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
return NS_OK; return;
double maxValue = 0; double maxValue = 0;
rv = GetMaximumValue(&maxValue); nsresult rv = GetMaximumValue(&maxValue);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, );
if (maxValue == 0)
return;
double curValue = 0; double curValue = 0;
rv = GetCurrentValue(&curValue); GetCurrentValue(&curValue);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, );
// Treat the current value bigger than maximum as 100%. // Treat the current value bigger than maximum as 100%.
double percentValue = (curValue < maxValue) ? double percentValue = (curValue < maxValue) ?
(curValue / maxValue) * 100 : 100; (curValue / maxValue) * 100 : 100;
nsAutoString value; aValue.AppendFloat(percentValue);
value.AppendFloat(percentValue); // AppendFloat isn't available on nsAString aValue.AppendLiteral("%");
value.AppendLiteral("%");
aValue = value;
return NS_OK;
} }
template<int Max> template<int Max>

View File

@ -58,10 +58,8 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEVALUE NS_DECL_NSIACCESSIBLEVALUE
// nsIAccessible
NS_IMETHOD GetValue(nsAString &aValue);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -283,8 +283,7 @@ nsTextEquivUtils::AppendFromValue(nsAccessible *aAccessible,
nsAutoString text; nsAutoString text;
if (aAccessible != gInitiatorAcc) { if (aAccessible != gInitiatorAcc) {
nsresult rv = aAccessible->GetValue(text); aAccessible->Value(text);
NS_ENSURE_SUCCESS(rv, rv);
return AppendString(aString, text) ? return AppendString(aString, text) ?
NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED; NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED;
@ -304,8 +303,7 @@ nsTextEquivUtils::AppendFromValue(nsAccessible *aAccessible,
siblingContent = siblingContent->GetNextSibling()) { siblingContent = siblingContent->GetNextSibling()) {
// .. and subsequent text // .. and subsequent text
if (!siblingContent->TextIsOnlyWhitespace()) { if (!siblingContent->TextIsOnlyWhitespace()) {
nsresult rv = aAccessible->GetValue(text); aAccessible->Value(text);
NS_ENSURE_SUCCESS(rv, rv);
return AppendString(aString, text) ? return AppendString(aString, text) ?
NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED; NS_OK : NS_OK_NO_NAME_CLAUSE_HANDLED;

View File

@ -406,25 +406,23 @@ nsHTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval) void
nsHTMLTextFieldAccessible::Value(nsString& aValue)
{ {
if (IsDefunct()) aValue.Truncate();
return NS_ERROR_FAILURE;
if (NativeState() & states::PROTECTED) // Don't return password text! if (NativeState() & states::PROTECTED) // Don't return password text!
return NS_ERROR_FAILURE; return;
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
if (textArea) { if (textArea) {
return textArea->GetValue(_retval); textArea->GetValue(aValue);
return;
} }
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mContent));
if (inputElement) { if (inputElement) {
return inputElement->GetValue(_retval); inputElement->GetValue(aValue);
} }
return NS_ERROR_FAILURE;
} }
void void

View File

@ -134,7 +134,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& _retval);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
@ -142,6 +141,7 @@ public:
virtual already_AddRefed<nsIEditor> GetEditor() const; virtual already_AddRefed<nsIEditor> GetEditor() const;
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual void ApplyARIAState(PRUint64* aState); virtual void ApplyARIAState(PRUint64* aState);
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();

View File

@ -106,20 +106,18 @@ nsHTMLLinkAccessible::NativeState()
return states; return states;
} }
NS_IMETHODIMP void
nsHTMLLinkAccessible::GetValue(nsAString& aValue) nsHTMLLinkAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
nsresult rv = nsHyperTextAccessible::GetValue(aValue); nsHyperTextAccessible::Value(aValue);
NS_ENSURE_SUCCESS(rv, rv);
if (!aValue.IsEmpty()) if (!aValue.IsEmpty())
return NS_OK; return;
nsIPresShell* presShell(mDoc->PresShell()); nsIPresShell* presShell(mDoc->PresShell());
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return presShell->GetLinkLocation(DOMNode, aValue); presShell->GetLinkLocation(DOMNode, aValue);
} }
PRUint8 PRUint8

View File

@ -50,12 +50,11 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -587,11 +587,13 @@ nsHTMLComboboxAccessible::Description(nsString& aDescription)
option->Description(aDescription); option->Description(aDescription);
} }
NS_IMETHODIMP nsHTMLComboboxAccessible::GetValue(nsAString& aValue) void
nsHTMLComboboxAccessible::Value(nsString& aValue)
{ {
// Use accessible name of selected option. // Use accessible name of selected option.
nsAccessible* option = SelectedOption(); nsAccessible* option = SelectedOption();
return option ? option->GetName(aValue) : NS_OK; if (option)
option->GetName(aValue);
} }
PRUint8 PRUint8

View File

@ -187,7 +187,6 @@ public:
virtual ~nsHTMLComboboxAccessible() {} virtual ~nsHTMLComboboxAccessible() {}
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& _retval);
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
@ -196,6 +195,7 @@ public:
// nsAccessible // nsAccessible
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
virtual void InvalidateChildren(); virtual void InvalidateChildren();

View File

@ -116,12 +116,11 @@
- (NSURL*)url - (NSURL*)url
{ {
if (!mGeckoAccessible) if (!mGeckoAccessible || mGeckoAccessible->IsDefunct())
return nil; return nil;
nsAutoString value; nsAutoString value;
nsresult rv = mGeckoAccessible->GetValue(value); mGeckoAccessible->Value(value);
NS_ENSURE_SUCCESS(rv, nil);
NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value); NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
if (!urlString) if (!urlString)

View File

@ -285,9 +285,11 @@ __try {
if (!xpAccessible || xpAccessible->IsDefunct()) if (!xpAccessible || xpAccessible->IsDefunct())
return E_FAIL; return E_FAIL;
if (xpAccessible->NativeRole() == roles::PASSWORD_TEXT)
return E_ACCESSDENIED;
nsAutoString value; nsAutoString value;
if (NS_FAILED(xpAccessible->GetValue(value))) xpAccessible->Value(value);
return E_FAIL;
// See bug 438784: need to expose URL on doc's value attribute. For this, // See bug 438784: need to expose URL on doc's value attribute. For this,
// reverting part of fix for bug 425693 to make this MSAA method behave // reverting part of fix for bug 425693 to make this MSAA method behave

View File

@ -145,16 +145,6 @@ nsXFormsAccessible::CacheSelectChildren(nsIDOMNode *aContainerNode)
} }
} }
// nsIAccessible
NS_IMETHODIMP
nsXFormsAccessible::GetValue(nsAString& aValue)
{
NS_ENSURE_TRUE(sXFormsService, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return sXFormsService->GetValue(DOMNode, aValue);
}
PRUint64 PRUint64
nsXFormsAccessible::NativeState() nsXFormsAccessible::NativeState()
{ {
@ -213,6 +203,13 @@ nsXFormsAccessible::Description(nsString& aDescription)
GetBoundChildElementValue(NS_LITERAL_STRING("hint"), aDescription); GetBoundChildElementValue(NS_LITERAL_STRING("hint"), aDescription);
} }
void
nsXFormsAccessible::Value(nsString& aValue)
{
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
sXFormsService->GetValue(DOMNode, aValue);
}
bool bool
nsXFormsAccessible::CanHaveAnonChildren() nsXFormsAccessible::CanHaveAnonChildren()
{ {
@ -545,11 +542,11 @@ nsXFormsSelectableItemAccessible::
{ {
} }
NS_IMETHODIMP void
nsXFormsSelectableItemAccessible::GetValue(nsAString& aValue) nsXFormsSelectableItemAccessible::Value(nsString& aValue)
{ {
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(mContent));
return sXFormsService->GetValue(DOMNode, aValue); sXFormsService->GetValue(DOMNode, aValue);
} }
PRUint8 PRUint8

View File

@ -72,15 +72,13 @@ class nsXFormsAccessible : public nsHyperTextAccessibleWrap,
public: public:
nsXFormsAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXFormsAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible
// Returns value of instance node that xforms element is bound to.
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessible // nsAccessible
// Returns value of child xforms 'hint' element. // Returns value of child xforms 'hint' element.
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
// Returns value of instance node that xforms element is bound to.
virtual void Value(nsString& aValue);
// Returns value of child xforms 'label' element. // Returns value of child xforms 'label' element.
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
@ -189,9 +187,11 @@ public:
nsXFormsSelectableItemAccessible(nsIContent* aContent, nsXFormsSelectableItemAccessible(nsIContent* aContent,
nsDocAccessible* aDoc); nsDocAccessible* aDoc);
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessible
virtual void Value(nsString& aValue);
// ActionAccessible // ActionAccessible
virtual PRUint8 ActionCount(); virtual PRUint8 ActionCount();

View File

@ -109,11 +109,10 @@ nsXFormsTriggerAccessible::NativeRole()
return roles::PUSHBUTTON; return roles::PUSHBUTTON;
} }
NS_IMETHODIMP void
nsXFormsTriggerAccessible::GetValue(nsAString& aValue) nsXFormsTriggerAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
return NS_OK;
} }
PRUint8 PRUint8
@ -295,10 +294,10 @@ nsXFormsSecretAccessible::NativeState()
return nsXFormsInputAccessible::NativeState() | states::PROTECTED; return nsXFormsInputAccessible::NativeState() | states::PROTECTED;
} }
NS_IMETHODIMP void
nsXFormsSecretAccessible::GetValue(nsAString& aValue) nsXFormsSecretAccessible::Value(nsString& aValue)
{ {
return NS_ERROR_FAILURE; aValue.Truncate();
} }
@ -438,11 +437,10 @@ nsXFormsChoicesAccessible::NativeRole()
return roles::GROUPING; return roles::GROUPING;
} }
NS_IMETHODIMP void
nsXFormsChoicesAccessible::GetValue(nsAString& aValue) nsXFormsChoicesAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
return NS_OK;
} }
void void

View File

@ -79,12 +79,11 @@ public:
nsXFormsTriggerAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXFormsTriggerAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
// ActionAccessible // ActionAccessible
@ -156,10 +155,8 @@ class nsXFormsSecretAccessible : public nsXFormsInputAccessible
public: public:
nsXFormsSecretAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXFormsSecretAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
}; };
@ -211,9 +208,9 @@ public:
nsXFormsChoicesAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXFormsChoicesAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
protected: protected:

View File

@ -162,13 +162,6 @@ nsXFormsComboboxPopupWidgetAccessible::NativeState()
return state; return state;
} }
NS_IMETHODIMP
nsXFormsComboboxPopupWidgetAccessible::GetValue(nsAString& aValue)
{
aValue.Truncate();
return NS_OK;
}
nsresult nsresult
nsXFormsComboboxPopupWidgetAccessible::GetNameInternal(nsAString& aName) nsXFormsComboboxPopupWidgetAccessible::GetNameInternal(nsAString& aName)
{ {
@ -183,6 +176,12 @@ nsXFormsComboboxPopupWidgetAccessible::Description(nsString& aDescription)
aDescription.Truncate(); aDescription.Truncate();
} }
void
nsXFormsComboboxPopupWidgetAccessible::Value(nsString& aValue)
{
aValue.Truncate();
}
void void
nsXFormsComboboxPopupWidgetAccessible::CacheChildren() nsXFormsComboboxPopupWidgetAccessible::CacheChildren()
{ {

View File

@ -91,11 +91,9 @@ public:
nsXFormsComboboxPopupWidgetAccessible(nsIContent* aContent, nsXFormsComboboxPopupWidgetAccessible(nsIContent* aContent,
nsDocAccessible* aDoc); nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessible // nsAccessible
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -63,16 +63,12 @@ nsXULColorPickerTileAccessible::
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsXULColorPickerTileAccessible: nsIAccessible // nsXULColorPickerTileAccessible: nsIAccessible
NS_IMETHODIMP void
nsXULColorPickerTileAccessible::GetValue(nsAString& aValue) nsXULColorPickerTileAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue); mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
return NS_OK;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -50,10 +50,8 @@ public:
nsXULColorPickerTileAccessible(nsIContent* aContent, nsXULColorPickerTileAccessible(nsIContent* aContent,
nsDocAccessible* aDoc); nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetValue(nsAString& _retval);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -103,22 +103,6 @@ nsXULComboboxAccessible::NativeState()
return states; return states;
} }
NS_IMETHODIMP
nsXULComboboxAccessible::GetValue(nsAString& aValue)
{
aValue.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
// The value is the option or text shown entered in the combobox.
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
if (menuList)
return menuList->GetLabel(aValue);
return NS_ERROR_FAILURE;
}
void void
nsXULComboboxAccessible::Description(nsString& aDescription) nsXULComboboxAccessible::Description(nsString& aDescription)
{ {
@ -139,6 +123,17 @@ nsXULComboboxAccessible::Description(nsString& aDescription)
} }
} }
void
nsXULComboboxAccessible::Value(nsString& aValue)
{
aValue.Truncate();
// The value is the option or text shown entered in the combobox.
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
if (menuList)
menuList->GetLabel(aValue);
}
bool bool
nsXULComboboxAccessible::CanHaveAnonChildren() nsXULComboboxAccessible::CanHaveAnonChildren()
{ {

View File

@ -53,12 +53,12 @@ public:
nsXULComboboxAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXULComboboxAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
// nsAccessible // nsAccessible
virtual void Description(nsString& aDescription); virtual void Description(nsString& aDescription);
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
virtual bool CanHaveAnonChildren(); virtual bool CanHaveAnonChildren();

View File

@ -728,25 +728,22 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsXULTextFieldAccessible, nsAccessible, nsHyperText
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsXULTextFieldAccessible: nsIAccessible // nsXULTextFieldAccessible: nsIAccessible
NS_IMETHODIMP nsXULTextFieldAccessible::GetValue(nsAString& aValue) void
nsXULTextFieldAccessible::Value(nsString& aValue)
{ {
if (IsDefunct()) aValue.Truncate();
return NS_ERROR_FAILURE; if (NativeRole() == roles::PASSWORD_TEXT) // Don't return password text!
return;
PRUint64 state = NativeState();
if (state & states::PROTECTED) // Don't return password text!
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mContent));
if (textBox) { if (textBox) {
return textBox->GetValue(aValue); textBox->GetValue(aValue);
return;
} }
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
if (menuList) { if (menuList)
return menuList->GetLabel(aValue); menuList->GetLabel(aValue);
}
return NS_ERROR_FAILURE;
} }
void void

View File

@ -254,7 +254,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 index); NS_IMETHOD DoAction(PRUint8 index);
@ -262,6 +261,7 @@ public:
virtual already_AddRefed<nsIEditor> GetEditor() const; virtual already_AddRefed<nsIEditor> GetEditor() const;
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual void ApplyARIAState(PRUint64* aState); virtual void ApplyARIAState(PRUint64* aState);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -210,17 +210,18 @@ nsXULListboxAccessible::NativeState()
/** /**
* Our value is the label of our ( first ) selected child. * Our value is the label of our ( first ) selected child.
*/ */
NS_IMETHODIMP nsXULListboxAccessible::GetValue(nsAString& _retval) void
nsXULListboxAccessible::Value(nsString& aValue)
{ {
_retval.Truncate(); aValue.Truncate();
nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent)); nsCOMPtr<nsIDOMXULSelectControlElement> select(do_QueryInterface(mContent));
if (select) { if (select) {
nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem; nsCOMPtr<nsIDOMXULSelectControlItemElement> selectedItem;
select->GetSelectedItem(getter_AddRefs(selectedItem)); select->GetSelectedItem(getter_AddRefs(selectedItem));
if (selectedItem) if (selectedItem)
return selectedItem->GetLabel(_retval); selectedItem->GetLabel(aValue);
} }
return NS_ERROR_FAILURE;
} }
role role

View File

@ -104,13 +104,11 @@ public:
// nsIAccessibleTable // nsIAccessibleTable
NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE NS_DECL_OR_FORWARD_NSIACCESSIBLETABLE_WITH_XPCACCESSIBLETABLE
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessNode // nsAccessNode
virtual void Shutdown(); virtual void Shutdown();
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::TableAccessible* AsTable() { return this; } virtual mozilla::a11y::TableAccessible* AsTable() { return this; }
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -92,10 +92,10 @@ nsXULSliderAccessible::NativeState()
// nsIAccessible // nsIAccessible
NS_IMETHODIMP void
nsXULSliderAccessible::GetValue(nsAString& aValue) nsXULSliderAccessible::Value(nsString& aValue)
{ {
return GetSliderAttr(nsGkAtoms::curpos, aValue); GetSliderAttr(nsGkAtoms::curpos, aValue);
} }
PRUint8 PRUint8

View File

@ -55,7 +55,6 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
@ -63,6 +62,7 @@ public:
NS_DECL_NSIACCESSIBLEVALUE NS_DECL_NSIACCESSIBLEVALUE
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
virtual bool CanHaveAnonChildren(); virtual bool CanHaveAnonChildren();

View File

@ -187,10 +187,10 @@ nsXULTabsAccessible::ActionCount()
return 0; return 0;
} }
/** no value */ void
NS_IMETHODIMP nsXULTabsAccessible::GetValue(nsAString& _retval) nsXULTabsAccessible::Value(nsString& aValue)
{ {
return NS_OK; aValue.Truncate();
} }
nsresult nsresult

View File

@ -76,10 +76,8 @@ class nsXULTabsAccessible : public XULSelectControlAccessible
public: public:
nsXULTabsAccessible(nsIContent* aContent, nsDocAccessible* aDoc); nsXULTabsAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetValue(nsAString& _retval);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();

View File

@ -151,16 +151,12 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsXULLinkAccessible, nsHyperTextAccessibleWrap,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// nsXULLinkAccessible. nsIAccessible // nsXULLinkAccessible. nsIAccessible
NS_IMETHODIMP void
nsXULLinkAccessible::GetValue(nsAString& aValue) nsXULLinkAccessible::Value(nsString& aValue)
{ {
aValue.Truncate(); aValue.Truncate();
if (IsDefunct())
return NS_ERROR_FAILURE;
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, aValue); mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, aValue);
return NS_OK;
} }
nsresult nsresult

View File

@ -81,12 +81,11 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
// nsIAccessible // nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
NS_IMETHOD DoAction(PRUint8 aIndex); NS_IMETHOD DoAction(PRUint8 aIndex);
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual nsresult GetNameInternal(nsAString& aName); virtual nsresult GetNameInternal(nsAString& aName);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();

View File

@ -143,20 +143,17 @@ nsXULTreeAccessible::NativeState()
return state; return state;
} }
NS_IMETHODIMP void
nsXULTreeAccessible::GetValue(nsAString& aValue) nsXULTreeAccessible::Value(nsString& aValue)
{ {
// Return the value is the first selected child. // Return the value is the first selected child.
aValue.Truncate(); aValue.Truncate();
if (IsDefunct() || !mTreeView)
return NS_ERROR_FAILURE;
nsCOMPtr<nsITreeSelection> selection; nsCOMPtr<nsITreeSelection> selection;
mTreeView->GetSelection(getter_AddRefs(selection)); mTreeView->GetSelection(getter_AddRefs(selection));
if (!selection) if (!selection)
return NS_ERROR_FAILURE; return;
PRInt32 currentIndex; PRInt32 currentIndex;
nsCOMPtr<nsIDOMElement> selectItem; nsCOMPtr<nsIDOMElement> selectItem;
@ -169,10 +166,9 @@ nsXULTreeAccessible::GetValue(nsAString& aValue)
if (cols) if (cols)
cols->GetKeyColumn(getter_AddRefs(keyCol)); cols->GetKeyColumn(getter_AddRefs(keyCol));
return mTreeView->GetCellText(currentIndex, keyCol, aValue); mTreeView->GetCellText(currentIndex, keyCol, aValue);
} }
return NS_OK;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -74,13 +74,11 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeAccessible, NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsXULTreeAccessible,
nsAccessible) nsAccessible)
// nsIAccessible
NS_IMETHOD GetValue(nsAString& aValue);
// nsAccessNode // nsAccessNode
virtual void Shutdown(); virtual void Shutdown();
// nsAccessible // nsAccessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole(); virtual mozilla::a11y::role NativeRole();
virtual PRUint64 NativeState(); virtual PRUint64 NativeState();
virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY, virtual nsAccessible* ChildAtPoint(PRInt32 aX, PRInt32 aY,

View File

@ -1,16 +1,6 @@
function testValue(aID, aAcc, aValue, aRole) function testValue(aID, aAcc, aValue, aRole)
{ {
if (aRole == ROLE_PASSWORD_TEXT) { is(aAcc.value, aValue, "Wrong value for " + aID + "!");
var value;
try {
value = aAcc.value;
do_throw("We do not want a value on " + aID + "!");
} catch(e) {
is(e.result, Components.results.NS_ERROR_FAILURE,
"Wrong return value for getValue on " + aID + "!");
}
} else
is(aAcc.value, aValue, "Wrong value for " + aID + "!");
} }
function testAction(aID, aAcc, aNumActions, aActionName, aActionDescription) function testAction(aID, aAcc, aNumActions, aActionName, aActionDescription)