2011-04-27 17:42:27 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-28 02:37:24 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
#include "AccessibleWrap.h"
|
2012-03-20 08:02:50 +04:00
|
|
|
#include "nsMai.h"
|
2015-03-27 01:06:38 +03:00
|
|
|
#include "ProxyAccessible.h"
|
2013-11-20 01:01:15 +04:00
|
|
|
#include "mozilla/FloatingPoint.h"
|
|
|
|
#include "mozilla/Likely.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-11-18 06:01:44 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
extern "C" {
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void
|
2003-05-06 06:23:50 +04:00
|
|
|
getCurrentValueCB(AtkValue *obj, GValue *value)
|
|
|
|
{
|
2015-03-27 01:06:38 +03:00
|
|
|
ProxyAccessible* proxy = nullptr;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
2015-03-27 01:06:38 +03:00
|
|
|
if (!accWrap) {
|
|
|
|
proxy = GetProxy(ATK_OBJECT(obj));
|
|
|
|
if (!proxy) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
memset (value, 0, sizeof (GValue));
|
2015-03-27 01:06:38 +03:00
|
|
|
double accValue = accWrap ? accWrap->CurValue() : proxy->CurValue();
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(accValue))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_value_init (value, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double (value, accValue);
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void
|
2003-05-06 06:23:50 +04:00
|
|
|
getMaximumValueCB(AtkValue *obj, GValue *value)
|
|
|
|
{
|
2015-03-27 01:06:38 +03:00
|
|
|
ProxyAccessible* proxy = nullptr;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
2015-03-27 01:06:38 +03:00
|
|
|
if (!accWrap) {
|
|
|
|
proxy = GetProxy(ATK_OBJECT(obj));
|
|
|
|
if (!proxy) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
memset(value, 0, sizeof (GValue));
|
2015-03-27 01:06:38 +03:00
|
|
|
double accValue = accWrap ? accWrap->MaxValue() : proxy->MaxValue();
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(accValue))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_value_init(value, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double(value, accValue);
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void
|
2003-05-06 06:23:50 +04:00
|
|
|
getMinimumValueCB(AtkValue *obj, GValue *value)
|
|
|
|
{
|
2015-03-27 01:06:38 +03:00
|
|
|
ProxyAccessible* proxy = nullptr;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
2015-03-27 01:06:38 +03:00
|
|
|
if (!accWrap) {
|
|
|
|
proxy = GetProxy(ATK_OBJECT(obj));
|
|
|
|
if (!proxy) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
memset(value, 0, sizeof (GValue));
|
2015-03-27 01:06:38 +03:00
|
|
|
double accValue = accWrap ? accWrap->MinValue() : proxy->MinValue();
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(accValue))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_value_init(value, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double(value, accValue);
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void
|
2006-06-15 20:55:32 +04:00
|
|
|
getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
|
|
|
|
{
|
2015-03-27 01:06:38 +03:00
|
|
|
ProxyAccessible* proxy = nullptr;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
2015-03-27 01:06:38 +03:00
|
|
|
if (!accWrap) {
|
|
|
|
proxy = GetProxy(ATK_OBJECT(obj));
|
|
|
|
if (!proxy) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2006-06-15 20:55:32 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
memset(minimumIncrement, 0, sizeof (GValue));
|
2015-03-27 01:06:38 +03:00
|
|
|
double accValue = accWrap ? accWrap->Step() : proxy->Step();
|
2013-11-20 01:01:15 +04:00
|
|
|
if (IsNaN(accValue))
|
|
|
|
accValue = 0; // zero if the minimum increment is undefined
|
|
|
|
|
|
|
|
g_value_init(minimumIncrement, G_TYPE_DOUBLE);
|
|
|
|
g_value_set_double(minimumIncrement, accValue);
|
2006-06-15 20:55:32 +04:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static gboolean
|
2003-05-06 06:23:50 +04:00
|
|
|
setCurrentValueCB(AtkValue *obj, const GValue *value)
|
|
|
|
{
|
2015-03-27 01:06:38 +03:00
|
|
|
ProxyAccessible* proxy = nullptr;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
|
2015-03-27 01:06:38 +03:00
|
|
|
if (!accWrap) {
|
|
|
|
proxy = GetProxy(ATK_OBJECT(obj));
|
|
|
|
if (!proxy) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2013-11-20 01:01:15 +04:00
|
|
|
double accValue =g_value_get_double(value);
|
2015-03-27 01:06:38 +03:00
|
|
|
return accWrap ? accWrap->SetCurValue(accValue) : proxy->SetCurValue(accValue);
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
2012-03-20 08:02:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
valueInterfaceInitCB(AtkValueIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "Invalid aIface");
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(!aIface))
|
2012-03-20 08:02:50 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->get_current_value = getCurrentValueCB;
|
|
|
|
aIface->get_maximum_value = getMaximumValueCB;
|
|
|
|
aIface->get_minimum_value = getMinimumValueCB;
|
|
|
|
aIface->get_minimum_increment = getMinimumIncrementCB;
|
|
|
|
aIface->set_current_value = setCurrentValueCB;
|
|
|
|
}
|