1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "InterfaceInitFuncs.h"
9 #include "LocalAccessible-inl.h"
11 #include "mozilla/Likely.h"
12 #include "nsAccessibilityService.h"
13 #include "RemoteAccessible.h"
16 using namespace mozilla
;
17 using namespace mozilla::a11y
;
21 static gboolean
doActionCB(AtkAction
* aAction
, gint aActionIndex
) {
22 AtkObject
* atkObject
= ATK_OBJECT(aAction
);
23 if (Accessible
* acc
= GetInternalObj(atkObject
)) {
24 return acc
->DoAction(aActionIndex
);
30 static gint
getActionCountCB(AtkAction
* aAction
) {
31 AtkObject
* atkObject
= ATK_OBJECT(aAction
);
32 if (Accessible
* acc
= GetInternalObj(atkObject
)) {
33 return acc
->ActionCount();
39 static const gchar
* getActionDescriptionCB(AtkAction
* aAction
,
41 AtkObject
* atkObject
= ATK_OBJECT(aAction
);
42 nsAutoString description
;
43 if (Accessible
* acc
= GetInternalObj(atkObject
)) {
44 acc
->ActionDescriptionAt(aActionIndex
, description
);
45 return AccessibleWrap::ReturnString(description
);
51 static const gchar
* getActionNameCB(AtkAction
* aAction
, gint aActionIndex
) {
52 AtkObject
* atkObject
= ATK_OBJECT(aAction
);
54 if (Accessible
* acc
= GetInternalObj(atkObject
)) {
55 acc
->ActionNameAt(aActionIndex
, autoStr
);
56 return AccessibleWrap::ReturnString(autoStr
);
62 static const gchar
* getKeyBindingCB(AtkAction
* aAction
, gint aActionIndex
) {
63 Accessible
* acc
= GetInternalObj(ATK_OBJECT(aAction
));
67 nsAutoString keyBindingsStr
;
68 AccessibleWrap::GetKeyBinding(acc
, keyBindingsStr
);
70 return AccessibleWrap::ReturnString(keyBindingsStr
);
74 void actionInterfaceInitCB(AtkActionIface
* aIface
) {
75 NS_ASSERTION(aIface
, "Invalid aIface");
76 if (MOZ_UNLIKELY(!aIface
)) return;
78 aIface
->do_action
= doActionCB
;
79 aIface
->get_n_actions
= getActionCountCB
;
80 aIface
->get_description
= getActionDescriptionCB
;
81 aIface
->get_keybinding
= getKeyBindingCB
;
82 aIface
->get_name
= getActionNameCB
;