mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 935698 - isolate nsIAccessibleValue implementation into separate class, r=tbsaunde
This commit is contained in:
parent
5727e36473
commit
7bb2451052
@ -5,11 +5,14 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "InterfaceInitFuncs.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
#include "AccessibleWrap.h"
|
||||
#include "nsMai.h"
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/Likely.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
extern "C" {
|
||||
@ -21,18 +24,13 @@ getCurrentValueCB(AtkValue *obj, GValue *value)
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleValue> accValue;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accValue));
|
||||
if (!accValue)
|
||||
return;
|
||||
memset (value, 0, sizeof (GValue));
|
||||
double accValue = accWrap->CurValue();
|
||||
if (IsNaN(accValue))
|
||||
return;
|
||||
|
||||
memset (value, 0, sizeof (GValue));
|
||||
double accDouble;
|
||||
if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
|
||||
return;
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, accDouble);
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, accValue);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -42,18 +40,13 @@ getMaximumValueCB(AtkValue *obj, GValue *value)
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleValue> accValue;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accValue));
|
||||
if (!accValue)
|
||||
return;
|
||||
memset(value, 0, sizeof (GValue));
|
||||
double accValue = accWrap->MaxValue();
|
||||
if (IsNaN(accValue))
|
||||
return;
|
||||
|
||||
memset (value, 0, sizeof (GValue));
|
||||
double accDouble;
|
||||
if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
|
||||
return;
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, accDouble);
|
||||
g_value_init(value, G_TYPE_DOUBLE);
|
||||
g_value_set_double(value, accValue);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -63,18 +56,13 @@ getMinimumValueCB(AtkValue *obj, GValue *value)
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleValue> accValue;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accValue));
|
||||
if (!accValue)
|
||||
return;
|
||||
memset(value, 0, sizeof (GValue));
|
||||
double accValue = accWrap->MinValue();
|
||||
if (IsNaN(accValue))
|
||||
return;
|
||||
|
||||
memset (value, 0, sizeof (GValue));
|
||||
double accDouble;
|
||||
if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
|
||||
return;
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, accDouble);
|
||||
g_value_init(value, G_TYPE_DOUBLE);
|
||||
g_value_set_double(value, accValue);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -84,18 +72,13 @@ getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
||||
if (!accWrap)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIAccessibleValue> accValue;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accValue));
|
||||
if (!accValue)
|
||||
return;
|
||||
memset(minimumIncrement, 0, sizeof (GValue));
|
||||
double accValue = accWrap->Step();
|
||||
if (IsNaN(accValue))
|
||||
accValue = 0; // zero if the minimum increment is undefined
|
||||
|
||||
memset (minimumIncrement, 0, sizeof (GValue));
|
||||
double accDouble;
|
||||
if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
|
||||
return;
|
||||
g_value_init (minimumIncrement, G_TYPE_DOUBLE);
|
||||
g_value_set_double (minimumIncrement, accDouble);
|
||||
g_value_init(minimumIncrement, G_TYPE_DOUBLE);
|
||||
g_value_set_double(minimumIncrement, accValue);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -105,13 +88,8 @@ setCurrentValueCB(AtkValue *obj, const GValue *value)
|
||||
if (!accWrap)
|
||||
return FALSE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleValue> accValue;
|
||||
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accValue));
|
||||
NS_ENSURE_TRUE(accValue, FALSE);
|
||||
|
||||
double accDouble =g_value_get_double (value);
|
||||
return !NS_FAILED(accValue->SetCurrentValue(accDouble));
|
||||
double accValue =g_value_get_double(value);
|
||||
return accWrap->SetCurValue(accValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@
|
||||
#endif
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -1672,61 +1673,53 @@ Accessible::Value(nsString& aValue)
|
||||
}
|
||||
}
|
||||
|
||||
// nsIAccessibleValue
|
||||
NS_IMETHODIMP
|
||||
Accessible::GetMaximumValue(double *aMaximumValue)
|
||||
double
|
||||
Accessible::MaxValue() const
|
||||
{
|
||||
return GetAttrValue(nsGkAtoms::aria_valuemax, aMaximumValue);
|
||||
return AttrNumericValue(nsGkAtoms::aria_valuemax);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Accessible::GetMinimumValue(double *aMinimumValue)
|
||||
double
|
||||
Accessible::MinValue() const
|
||||
{
|
||||
return GetAttrValue(nsGkAtoms::aria_valuemin, aMinimumValue);
|
||||
return AttrNumericValue(nsGkAtoms::aria_valuemin);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Accessible::GetMinimumIncrement(double *aMinIncrement)
|
||||
double
|
||||
Accessible::Step() const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMinIncrement);
|
||||
*aMinIncrement = 0;
|
||||
|
||||
// No mimimum increment in dynamic content spec right now
|
||||
return NS_OK_NO_ARIA_VALUE;
|
||||
return UnspecifiedNaN(); // no mimimum increment (step) in ARIA.
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Accessible::GetCurrentValue(double *aValue)
|
||||
double
|
||||
Accessible::CurValue() const
|
||||
{
|
||||
return GetAttrValue(nsGkAtoms::aria_valuenow, aValue);
|
||||
return AttrNumericValue(nsGkAtoms::aria_valuenow);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
Accessible::SetCurrentValue(double aValue)
|
||||
bool
|
||||
Accessible::SetCurValue(double aValue)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
|
||||
return NS_OK_NO_ARIA_VALUE;
|
||||
return false;
|
||||
|
||||
const uint32_t kValueCannotChange = states::READONLY | states::UNAVAILABLE;
|
||||
|
||||
if (State() & kValueCannotChange)
|
||||
return NS_ERROR_FAILURE;
|
||||
return false;
|
||||
|
||||
double minValue = 0;
|
||||
if (NS_SUCCEEDED(GetMinimumValue(&minValue)) && aValue < minValue)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
double checkValue = MinValue();
|
||||
if (!IsNaN(checkValue) && aValue < checkValue)
|
||||
return false;
|
||||
|
||||
double maxValue = 0;
|
||||
if (NS_SUCCEEDED(GetMaximumValue(&maxValue)) && aValue > maxValue)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
checkValue = MaxValue();
|
||||
if (!IsNaN(checkValue) && aValue > checkValue)
|
||||
return false;
|
||||
|
||||
nsAutoString newValue;
|
||||
newValue.AppendFloat(aValue);
|
||||
return mContent->SetAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::aria_valuenow, newValue, true);
|
||||
nsAutoString strValue;
|
||||
strValue.AppendFloat(aValue);
|
||||
|
||||
return NS_SUCCEEDED(
|
||||
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow, strValue, true));
|
||||
}
|
||||
|
||||
/* void setName (in DOMString name); */
|
||||
@ -3116,31 +3109,19 @@ Accessible::GetFirstAvailableAccessible(nsINode *aStartNode) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Accessible::GetAttrValue(nsIAtom *aProperty, double *aValue)
|
||||
double
|
||||
Accessible::AttrNumericValue(nsIAtom* aAttr) const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE; // Node already shut down
|
||||
|
||||
if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
|
||||
return NS_OK_NO_ARIA_VALUE;
|
||||
if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
|
||||
return UnspecifiedNaN();
|
||||
|
||||
nsAutoString attrValue;
|
||||
mContent->GetAttr(kNameSpaceID_None, aProperty, attrValue);
|
||||
|
||||
// Return zero value if there is no attribute or its value is empty.
|
||||
if (attrValue.IsEmpty())
|
||||
return NS_OK;
|
||||
if (!mContent->GetAttr(kNameSpaceID_None, aAttr, attrValue))
|
||||
return UnspecifiedNaN();
|
||||
|
||||
nsresult error = NS_OK;
|
||||
double value = attrValue.ToDouble(&error);
|
||||
if (NS_SUCCEEDED(error))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
return NS_FAILED(error) ? UnspecifiedNaN() : value;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
@ -13,9 +13,9 @@
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleHyperLink.h"
|
||||
#include "nsIAccessibleValue.h"
|
||||
#include "nsIAccessibleStates.h"
|
||||
#include "xpcAccessibleSelectable.h"
|
||||
#include "xpcAccessibleValue.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
@ -105,7 +105,7 @@ typedef nsRefPtrHashtable<nsPtrHashKey<const void>, Accessible>
|
||||
class Accessible : public nsIAccessible,
|
||||
public nsIAccessibleHyperLink,
|
||||
public xpcAccessibleSelectable,
|
||||
public nsIAccessibleValue
|
||||
public xpcAccessibleValue
|
||||
{
|
||||
public:
|
||||
Accessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
@ -116,7 +116,6 @@ public:
|
||||
|
||||
NS_DECL_NSIACCESSIBLE
|
||||
NS_DECL_NSIACCESSIBLEHYPERLINK
|
||||
NS_DECL_NSIACCESSIBLEVALUE
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -688,6 +687,15 @@ public:
|
||||
*/
|
||||
virtual bool UnselectAll();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Value (numeric value interface)
|
||||
|
||||
virtual double MaxValue() const;
|
||||
virtual double MinValue() const;
|
||||
virtual double CurValue() const;
|
||||
virtual double Step() const;
|
||||
virtual bool SetCurValue(double aValue);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Widgets
|
||||
|
||||
@ -911,14 +919,12 @@ protected:
|
||||
nsIContent* GetAtomicRegion() const;
|
||||
|
||||
/**
|
||||
* Get numeric value of the given ARIA attribute.
|
||||
* Return numeric value of the given ARIA attribute, NaN if not applicable.
|
||||
*
|
||||
* @param aAriaProperty - the ARIA property we're using
|
||||
* @param aValue - value of the attribute
|
||||
*
|
||||
* @return - NS_OK_NO_ARIA_VALUE if there is no setted ARIA attribute
|
||||
* @param aARIAProperty [in] the ARIA property we're using
|
||||
* @return a numeric value
|
||||
*/
|
||||
nsresult GetAttrValue(nsIAtom *aAriaProperty, double *aValue);
|
||||
double AttrNumericValue(nsIAtom* aARIAAttr) const;
|
||||
|
||||
/**
|
||||
* Return the action rule based on ARIA enum constants EActionRule
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "FormControlAccessible.h"
|
||||
#include "Role.h"
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMXULControlElement.h"
|
||||
@ -82,14 +83,12 @@ ProgressMeterAccessible<Max>::Value(nsString& aValue)
|
||||
if (!aValue.IsEmpty())
|
||||
return;
|
||||
|
||||
double maxValue = 0;
|
||||
nsresult rv = GetMaximumValue(&maxValue);
|
||||
if (NS_FAILED(rv) || maxValue == 0)
|
||||
double maxValue = MaxValue();
|
||||
if (IsNaN(maxValue) || maxValue == 0)
|
||||
return;
|
||||
|
||||
double curValue = 0;
|
||||
GetCurrentValue(&curValue);
|
||||
if (NS_FAILED(rv))
|
||||
double curValue = CurValue();
|
||||
if (IsNaN(curValue))
|
||||
return;
|
||||
|
||||
// Treat the current value bigger than maximum as 100%.
|
||||
@ -101,77 +100,62 @@ ProgressMeterAccessible<Max>::Value(nsString& aValue)
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
NS_IMETHODIMP
|
||||
ProgressMeterAccessible<Max>::GetMaximumValue(double* aMaximumValue)
|
||||
double
|
||||
ProgressMeterAccessible<Max>::MaxValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMaximumValue(aMaximumValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::MaxValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
nsAutoString value;
|
||||
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::max, value)) {
|
||||
nsAutoString strValue;
|
||||
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::max, strValue)) {
|
||||
nsresult result = NS_OK;
|
||||
*aMaximumValue = value.ToDouble(&result);
|
||||
return result;
|
||||
value = strValue.ToDouble(&result);
|
||||
if (NS_SUCCEEDED(result))
|
||||
return value;
|
||||
}
|
||||
|
||||
*aMaximumValue = Max;
|
||||
return NS_OK;
|
||||
return Max;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
NS_IMETHODIMP
|
||||
ProgressMeterAccessible<Max>::GetMinimumValue(double* aMinimumValue)
|
||||
double
|
||||
ProgressMeterAccessible<Max>::MinValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMinimumValue(aMinimumValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
*aMinimumValue = 0;
|
||||
return NS_OK;
|
||||
double value = LeafAccessible::MinValue();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
NS_IMETHODIMP
|
||||
ProgressMeterAccessible<Max>::GetMinimumIncrement(double* aMinimumIncrement)
|
||||
double
|
||||
ProgressMeterAccessible<Max>::Step() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMinimumIncrement(aMinimumIncrement);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
*aMinimumIncrement = 0;
|
||||
return NS_OK;
|
||||
double value = LeafAccessible::Step();
|
||||
return IsNaN(value) ? 0 : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
NS_IMETHODIMP
|
||||
ProgressMeterAccessible<Max>::GetCurrentValue(double* aCurrentValue)
|
||||
double
|
||||
ProgressMeterAccessible<Max>::CurValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetCurrentValue(aCurrentValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::CurValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
nsAutoString attrValue;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue);
|
||||
|
||||
// Return zero value if there is no attribute or its value is empty.
|
||||
if (attrValue.IsEmpty())
|
||||
return NS_OK;
|
||||
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue))
|
||||
return UnspecifiedNaN();
|
||||
|
||||
nsresult error = NS_OK;
|
||||
double value = attrValue.ToDouble(&error);
|
||||
if (NS_FAILED(error))
|
||||
return NS_OK; // Zero value because of wrong markup.
|
||||
|
||||
*aCurrentValue = value;
|
||||
return NS_OK;
|
||||
value = attrValue.ToDouble(&error);
|
||||
return NS_FAILED(error) ? UnspecifiedNaN() : value;
|
||||
}
|
||||
|
||||
template<int Max>
|
||||
NS_IMETHODIMP
|
||||
ProgressMeterAccessible<Max>::SetCurrentValue(double aValue)
|
||||
bool
|
||||
ProgressMeterAccessible<Max>::SetCurValue(double aValue)
|
||||
{
|
||||
return NS_ERROR_FAILURE; // Progress meters are readonly.
|
||||
return false; // progress meters are readonly.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -28,13 +28,19 @@ public:
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEVALUE
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
virtual double MinValue() const MOZ_OVERRIDE;
|
||||
virtual double CurValue() const MOZ_OVERRIDE;
|
||||
virtual double Step() const MOZ_OVERRIDE;
|
||||
virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
};
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -545,9 +546,6 @@ HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
|
||||
// HTMLRangeAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(HTMLRangeAccessible, LeafAccessible,
|
||||
nsIAccessibleValue)
|
||||
|
||||
role
|
||||
HTMLRangeAccessible::NativeRole()
|
||||
{
|
||||
@ -570,58 +568,53 @@ HTMLRangeAccessible::Value(nsString& aValue)
|
||||
HTMLInputElement::FromContent(mContent)->GetValue(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLRangeAccessible::GetMaximumValue(double* aMaximumValue)
|
||||
double
|
||||
HTMLRangeAccessible::MaxValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMaximumValue(aMaximumValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::MaxValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
*aMaximumValue = HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
||||
return NS_OK;
|
||||
return HTMLInputElement::FromContent(mContent)->GetMaximum().toDouble();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLRangeAccessible::GetMinimumValue(double* aMinimumValue)
|
||||
double
|
||||
HTMLRangeAccessible::MinValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMinimumValue(aMinimumValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::MinValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
*aMinimumValue = HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
||||
return NS_OK;
|
||||
return HTMLInputElement::FromContent(mContent)->GetMinimum().toDouble();
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLRangeAccessible::GetMinimumIncrement(double* aMinimumIncrement)
|
||||
double
|
||||
HTMLRangeAccessible::Step() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetMinimumIncrement(aMinimumIncrement);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::Step();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
*aMinimumIncrement = HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
||||
return NS_OK;
|
||||
return HTMLInputElement::FromContent(mContent)->GetStep().toDouble();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLRangeAccessible::GetCurrentValue(double* aCurrentValue)
|
||||
double
|
||||
HTMLRangeAccessible::CurValue() const
|
||||
{
|
||||
nsresult rv = LeafAccessible::GetCurrentValue(aCurrentValue);
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
double value = LeafAccessible::CurValue();
|
||||
if (!IsNaN(value))
|
||||
return value;
|
||||
|
||||
*aCurrentValue = HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
||||
return NS_OK;
|
||||
return HTMLInputElement::FromContent(mContent)->GetValueAsDecimal().toDouble();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLRangeAccessible::SetCurrentValue(double aValue)
|
||||
bool
|
||||
HTMLRangeAccessible::SetCurValue(double aValue)
|
||||
{
|
||||
ErrorResult er;
|
||||
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
|
||||
return er.ErrorCode();
|
||||
return !er.Failed();
|
||||
}
|
||||
|
||||
|
||||
|
@ -172,13 +172,17 @@ public:
|
||||
mStateFlags |= eHasNumericValue;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIACCESSIBLEVALUE
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual mozilla::a11y::role NativeRole();
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
virtual double MinValue() const MOZ_OVERRIDE;
|
||||
virtual double CurValue() const MOZ_OVERRIDE;
|
||||
virtual double Step() const MOZ_OVERRIDE;
|
||||
virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
|
||||
|
||||
// Widgets
|
||||
virtual bool IsWidget() const;
|
||||
};
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "Accessible-inl.h"
|
||||
#include "IUnknownImpl.h"
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
// IUnknown
|
||||
@ -55,10 +57,9 @@ ia2AccessibleValue::get_currentValue(VARIANT* aCurrentValue)
|
||||
if (valueAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
double currentValue = 0;
|
||||
nsresult rv = valueAcc->GetCurrentValue(¤tValue);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
double currentValue = valueAcc->CurValue();
|
||||
if (IsNaN(currentValue))
|
||||
return S_FALSE;
|
||||
|
||||
aCurrentValue->vt = VT_R8;
|
||||
aCurrentValue->dblVal = currentValue;
|
||||
@ -79,8 +80,7 @@ ia2AccessibleValue::setCurrentValue(VARIANT aValue)
|
||||
if (aValue.vt != VT_R8)
|
||||
return E_INVALIDARG;
|
||||
|
||||
nsresult rv = valueAcc->SetCurrentValue(aValue.dblVal);
|
||||
return GetHRESULT(rv);
|
||||
return valueAcc->SetCurValue(aValue.dblVal) ? S_OK : E_FAIL;
|
||||
|
||||
A11Y_TRYBLOCK_END
|
||||
}
|
||||
@ -99,10 +99,9 @@ ia2AccessibleValue::get_maximumValue(VARIANT* aMaximumValue)
|
||||
if (valueAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
double maximumValue = 0;
|
||||
nsresult rv = valueAcc->GetMaximumValue(&maximumValue);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
double maximumValue = valueAcc->MaxValue();
|
||||
if (IsNaN(maximumValue))
|
||||
return S_FALSE;
|
||||
|
||||
aMaximumValue->vt = VT_R8;
|
||||
aMaximumValue->dblVal = maximumValue;
|
||||
@ -125,10 +124,9 @@ ia2AccessibleValue::get_minimumValue(VARIANT* aMinimumValue)
|
||||
if (valueAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
double minimumValue = 0;
|
||||
nsresult rv = valueAcc->GetMinimumValue(&minimumValue);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
double minimumValue = valueAcc->MinValue();
|
||||
if (IsNaN(minimumValue))
|
||||
return S_FALSE;
|
||||
|
||||
aMinimumValue->vt = VT_R8;
|
||||
aMinimumValue->dblVal = minimumValue;
|
||||
|
@ -7,6 +7,7 @@
|
||||
EXPORTS += [
|
||||
'xpcAccessibleHyperText.h',
|
||||
'xpcAccessibleSelectable.h',
|
||||
'xpcAccessibleValue.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
@ -15,6 +16,7 @@ UNIFIED_SOURCES += [
|
||||
'xpcAccessibleSelectable.cpp',
|
||||
'xpcAccessibleTable.cpp',
|
||||
'xpcAccessibleTableCell.cpp',
|
||||
'xpcAccessibleValue.cpp',
|
||||
]
|
||||
|
||||
GENERATED_SOURCES += [
|
||||
|
90
accessible/src/xpcom/xpcAccessibleValue.cpp
Normal file
90
accessible/src/xpcom/xpcAccessibleValue.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "xpcAccessibleValue.h"
|
||||
#include "Accessible.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleValue::GetMaximumValue(double* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
Accessible* acc = static_cast<Accessible*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double value = acc->MaxValue();
|
||||
if (!IsNaN(value))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleValue::GetMinimumValue(double* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
Accessible* acc = static_cast<Accessible*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double value = acc->MinValue();
|
||||
if (!IsNaN(value))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleValue::GetCurrentValue(double* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
Accessible* acc = static_cast<Accessible*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double value = acc->CurValue();
|
||||
if (!IsNaN(value))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleValue::SetCurrentValue(double aValue)
|
||||
{
|
||||
Accessible* acc = static_cast<Accessible*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
acc->SetCurValue(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleValue::GetMinimumIncrement(double* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
Accessible* acc = static_cast<Accessible*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
double value = acc->Step();
|
||||
if (!IsNaN(value))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
}
|
35
accessible/src/xpcom/xpcAccessibleValue.h
Normal file
35
accessible/src/xpcom/xpcAccessibleValue.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_a11y_xpcAccessibleValue_h_
|
||||
#define mozilla_a11y_xpcAccessibleValue_h_
|
||||
|
||||
#include "nsIAccessibleValue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class xpcAccessibleValue : public nsIAccessibleValue
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD GetMaximumValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetMinimumValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetCurrentValue(double* aValue) MOZ_FINAL MOZ_OVERRIDE;
|
||||
NS_IMETHOD SetCurrentValue(double aValue) MOZ_FINAL MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetMinimumIncrement(double* aMinIncrement) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
xpcAccessibleValue() { }
|
||||
friend class Accessible;
|
||||
|
||||
xpcAccessibleValue(const xpcAccessibleValue&) MOZ_DELETE;
|
||||
xpcAccessibleValue& operator =(const xpcAccessibleValue&) MOZ_DELETE;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "nsIFrame.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
@ -25,12 +26,6 @@ XULSliderAccessible::
|
||||
mStateFlags |= eHasNumericValue;
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(XULSliderAccessible,
|
||||
AccessibleWrap,
|
||||
nsIAccessibleValue)
|
||||
|
||||
// Accessible
|
||||
|
||||
role
|
||||
@ -99,64 +94,39 @@ XULSliderAccessible::DoAction(uint8_t aIndex)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIAccessibleValue
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::GetMaximumValue(double* aValue)
|
||||
double
|
||||
XULSliderAccessible::MaxValue() const
|
||||
{
|
||||
nsresult rv = AccessibleWrap::GetMaximumValue(aValue);
|
||||
|
||||
// ARIA redefined maximum value.
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
return GetSliderAttr(nsGkAtoms::maxpos, aValue);
|
||||
double value = AccessibleWrap::MaxValue();
|
||||
return IsNaN(value) ? GetSliderAttr(nsGkAtoms::maxpos) : value;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::GetMinimumValue(double* aValue)
|
||||
double
|
||||
XULSliderAccessible::MinValue() const
|
||||
{
|
||||
nsresult rv = AccessibleWrap::GetMinimumValue(aValue);
|
||||
|
||||
// ARIA redefined minmum value.
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
return GetSliderAttr(nsGkAtoms::minpos, aValue);
|
||||
double value = AccessibleWrap::MinValue();
|
||||
return IsNaN(value) ? GetSliderAttr(nsGkAtoms::minpos) : value;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::GetMinimumIncrement(double* aValue)
|
||||
double
|
||||
XULSliderAccessible::Step() const
|
||||
{
|
||||
nsresult rv = AccessibleWrap::GetMinimumIncrement(aValue);
|
||||
|
||||
// ARIA redefined minimum increment value.
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
return GetSliderAttr(nsGkAtoms::increment, aValue);
|
||||
double value = AccessibleWrap::Step();
|
||||
return IsNaN(value) ? GetSliderAttr(nsGkAtoms::increment) : value;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::GetCurrentValue(double* aValue)
|
||||
double
|
||||
XULSliderAccessible::CurValue() const
|
||||
{
|
||||
nsresult rv = AccessibleWrap::GetCurrentValue(aValue);
|
||||
|
||||
// ARIA redefined current value.
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
|
||||
return GetSliderAttr(nsGkAtoms::curpos, aValue);
|
||||
double value = AccessibleWrap::CurValue();
|
||||
return IsNaN(value) ? GetSliderAttr(nsGkAtoms::curpos) : value;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSliderAccessible::SetCurrentValue(double aValue)
|
||||
bool
|
||||
XULSliderAccessible::SetCurValue(double aValue)
|
||||
{
|
||||
nsresult rv = AccessibleWrap::SetCurrentValue(aValue);
|
||||
|
||||
// ARIA redefined current value.
|
||||
if (rv != NS_OK_NO_ARIA_VALUE)
|
||||
return rv;
|
||||
if (AccessibleWrap::SetCurValue(aValue))
|
||||
return true;
|
||||
|
||||
return SetSliderAttr(nsGkAtoms::curpos, aValue);
|
||||
}
|
||||
@ -184,7 +154,7 @@ XULSliderAccessible::GetSliderElement() const
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSliderAccessible::GetSliderAttr(nsIAtom* aName, nsAString& aValue)
|
||||
XULSliderAccessible::GetSliderAttr(nsIAtom* aName, nsAString& aValue) const
|
||||
{
|
||||
aValue.Truncate();
|
||||
|
||||
@ -211,35 +181,26 @@ XULSliderAccessible::SetSliderAttr(nsIAtom* aName, const nsAString& aValue)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSliderAccessible::GetSliderAttr(nsIAtom* aName, double* aValue)
|
||||
double
|
||||
XULSliderAccessible::GetSliderAttr(nsIAtom* aName) const
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = 0;
|
||||
|
||||
nsAutoString attrValue;
|
||||
nsresult rv = GetSliderAttr(aName, attrValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Return zero value if there is no attribute or its value is empty.
|
||||
if (attrValue.IsEmpty())
|
||||
return NS_OK;
|
||||
if (NS_FAILED(rv))
|
||||
return UnspecifiedNaN();
|
||||
|
||||
nsresult error = NS_OK;
|
||||
double value = attrValue.ToDouble(&error);
|
||||
if (NS_SUCCEEDED(error))
|
||||
*aValue = value;
|
||||
|
||||
return NS_OK;
|
||||
return NS_FAILED(error) ? UnspecifiedNaN() : value;
|
||||
}
|
||||
|
||||
nsresult
|
||||
bool
|
||||
XULSliderAccessible::SetSliderAttr(nsIAtom* aName, double aValue)
|
||||
{
|
||||
nsAutoString value;
|
||||
value.AppendFloat(aValue);
|
||||
|
||||
return SetSliderAttr(aName, value);
|
||||
return NS_SUCCEEDED(SetSliderAttr(aName, value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,16 +21,10 @@ class XULSliderAccessible : public AccessibleWrap
|
||||
public:
|
||||
XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIAccessible
|
||||
NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(uint8_t aIndex);
|
||||
|
||||
// nsIAccessibleValue
|
||||
NS_DECL_NSIACCESSIBLEVALUE
|
||||
|
||||
// Accessible
|
||||
virtual void Value(nsString& aValue);
|
||||
virtual a11y::role NativeRole();
|
||||
@ -38,6 +32,13 @@ public:
|
||||
virtual bool NativelyUnavailable() const;
|
||||
virtual bool CanHaveAnonChildren();
|
||||
|
||||
// Value
|
||||
virtual double MaxValue() const MOZ_OVERRIDE;
|
||||
virtual double MinValue() const MOZ_OVERRIDE;
|
||||
virtual double CurValue() const MOZ_OVERRIDE;
|
||||
virtual double Step() const MOZ_OVERRIDE;
|
||||
virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
|
||||
|
||||
// ActionAccessible
|
||||
virtual uint8_t ActionCount();
|
||||
|
||||
@ -47,11 +48,11 @@ protected:
|
||||
*/
|
||||
nsIContent* GetSliderElement() const;
|
||||
|
||||
nsresult GetSliderAttr(nsIAtom *aName, nsAString& aValue);
|
||||
nsresult GetSliderAttr(nsIAtom *aName, nsAString& aValue) const;
|
||||
nsresult SetSliderAttr(nsIAtom *aName, const nsAString& aValue);
|
||||
|
||||
nsresult GetSliderAttr(nsIAtom *aName, double *aValue);
|
||||
nsresult SetSliderAttr(nsIAtom *aName, double aValue);
|
||||
double GetSliderAttr(nsIAtom *aName) const;
|
||||
bool SetSliderAttr(nsIAtom *aName, double aValue);
|
||||
|
||||
private:
|
||||
mutable nsCOMPtr<nsIContent> mSliderNode;
|
||||
|
@ -21,7 +21,7 @@
|
||||
function doTest()
|
||||
{
|
||||
// HTML5 progress element tests
|
||||
testValue("pr_indeterminate", "0%", 0, 0, 1, 0);
|
||||
testValue("pr_indeterminate", "", 0, 0, 1, 0);
|
||||
testValue("pr_zero", "0%", 0, 0, 1, 0);
|
||||
testValue("pr_zeropointfive", "50%", 0.5, 0, 1, 0);
|
||||
testValue("pr_one", "100%", 1, 0, 1, 0);
|
||||
|
@ -21,7 +21,7 @@
|
||||
// progressmeter
|
||||
testValue("pm1", "50%", 50, 0, 100, 0);
|
||||
testValue("pm2", "50%", 500, 0, 1000, 0);
|
||||
testValue("pm3", "0%", 0, 0, 100, 0);
|
||||
testValue("pm3", "", 0, 0, 100, 0);
|
||||
|
||||
// scale
|
||||
testValue("sc1", "500", 500, 0, 1000, 10);
|
||||
|
@ -863,8 +863,6 @@
|
||||
/* raised when current pivot's position is needed but it's not in the tree */
|
||||
ERROR(NS_ERROR_NOT_IN_TREE, FAILURE(38)),
|
||||
|
||||
/* see Accessible::GetAttrValue */
|
||||
ERROR(NS_OK_NO_ARIA_VALUE, SUCCESS(33)),
|
||||
/* see nsTextEquivUtils */
|
||||
ERROR(NS_OK_NO_NAME_CLAUSE_HANDLED, SUCCESS(34))
|
||||
#undef MODULE
|
||||
|
Loading…
Reference in New Issue
Block a user