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