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