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"
|
2009-03-10 18:59:25 -07:00
|
|
|
|
2012-04-17 02:56:02 -07:00
|
|
|
#include "Accessible-inl.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "nsMai.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2015-10-06 12:14:18 -07:00
|
|
|
#include "ProxyAccessible.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "nsString.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2012-01-11 19:07:35 -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 gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
doActionCB(AtkAction *aAction, gint aActionIndex)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
2015-10-06 12:14:18 -07:00
|
|
|
if (accWrap) {
|
|
|
|
return accWrap->DoAction(aActionIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction));
|
|
|
|
return proxy && proxy->DoAction(aActionIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gint
|
2007-03-22 10:30:00 -07:00
|
|
|
getActionCountCB(AtkAction *aAction)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
2015-10-06 12:14:18 -07:00
|
|
|
if (accWrap) {
|
|
|
|
return accWrap->ActionCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction));
|
|
|
|
return proxy ? proxy->ActionCount() : 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static const gchar*
|
2007-03-22 10:30:00 -07:00
|
|
|
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
|
|
|
|
{
|
2015-10-06 12:14:18 -07:00
|
|
|
nsAutoString description;
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
2015-10-06 12:14:18 -07:00
|
|
|
if (accWrap) {
|
|
|
|
accWrap->ActionDescriptionAt(aActionIndex, description);
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
|
|
|
|
proxy->ActionDescriptionAt(aActionIndex, description);
|
|
|
|
} else {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2015-10-06 12:14:18 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return AccessibleWrap::ReturnString(description);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static const gchar*
|
2007-03-22 10:30:00 -07:00
|
|
|
getActionNameCB(AtkAction *aAction, gint aActionIndex)
|
|
|
|
{
|
2015-10-06 12:14:18 -07:00
|
|
|
nsAutoString autoStr;
|
2014-09-16 10:30:23 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
|
2015-10-06 12:14:18 -07:00
|
|
|
if (accWrap) {
|
|
|
|
accWrap->ActionNameAt(aActionIndex, autoStr);
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
|
|
|
|
proxy->ActionNameAt(aActionIndex, autoStr);
|
|
|
|
} else {
|
2014-09-16 10:30:23 -07:00
|
|
|
return nullptr;
|
2015-10-06 12:14:18 -07:00
|
|
|
}
|
2014-09-16 10:30:23 -07:00
|
|
|
|
|
|
|
return AccessibleWrap::ReturnString(autoStr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static const gchar*
|
2007-03-22 10:30:00 -07:00
|
|
|
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
|
|
|
|
{
|
2011-07-19 01:30:24 -07:00
|
|
|
nsAutoString keyBindingsStr;
|
2015-10-06 12:14:18 -07:00
|
|
|
AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
|
|
|
|
if (acc) {
|
|
|
|
AccessibleWrap::GetKeyBinding(acc, keyBindingsStr);
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
|
|
|
|
proxy->AtkKeyBinding(keyBindingsStr);
|
2011-07-19 01:30:24 -07:00
|
|
|
} else {
|
2015-10-06 12:14:18 -07:00
|
|
|
return nullptr;
|
2011-07-19 01:30:24 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return AccessibleWrap::ReturnString(keyBindingsStr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-19 21:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
actionInterfaceInitCB(AtkActionIface* 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->do_action = doActionCB;
|
|
|
|
aIface->get_n_actions = getActionCountCB;
|
|
|
|
aIface->get_description = getActionDescriptionCB;
|
|
|
|
aIface->get_keybinding = getKeyBindingCB;
|
|
|
|
aIface->get_name = getActionNameCB;
|
|
|
|
}
|