Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/accessible/atk/nsMaiInterfaceAction.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#include "InterfaceInitFuncs.h"
8
9
#include "Accessible-inl.h"
10
#include "nsMai.h"
11
#include "Role.h"
12
#include "mozilla/Likely.h"
13
#include "ProxyAccessible.h"
14
#include "nsString.h"
15
16
using namespace mozilla::a11y;
17
18
extern "C" {
19
20
static gboolean
21
doActionCB(AtkAction *aAction, gint aActionIndex)
22
0
{
23
0
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
24
0
  if (accWrap) {
25
0
    return accWrap->DoAction(aActionIndex);
26
0
  }
27
0
28
0
  ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction));
29
0
  return proxy && proxy->DoAction(aActionIndex);
30
0
}
31
32
static gint
33
getActionCountCB(AtkAction *aAction)
34
0
{
35
0
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
36
0
  if (accWrap) {
37
0
    return accWrap->ActionCount();
38
0
  }
39
0
40
0
  ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction));
41
0
  return proxy ? proxy->ActionCount() : 0;
42
0
}
43
44
static const gchar*
45
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
46
0
{
47
0
  nsAutoString description;
48
0
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
49
0
  if (accWrap) {
50
0
    accWrap->ActionDescriptionAt(aActionIndex, description);
51
0
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
52
0
    proxy->ActionDescriptionAt(aActionIndex, description);
53
0
  } else {
54
0
    return nullptr;
55
0
  }
56
0
57
0
  return AccessibleWrap::ReturnString(description);
58
0
}
59
60
static const gchar*
61
getActionNameCB(AtkAction *aAction, gint aActionIndex)
62
0
{
63
0
  nsAutoString autoStr;
64
0
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
65
0
  if (accWrap) {
66
0
    accWrap->ActionNameAt(aActionIndex, autoStr);
67
0
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
68
0
    proxy->ActionNameAt(aActionIndex, autoStr);
69
0
  } else {
70
0
    return nullptr;
71
0
  }
72
0
73
0
  return AccessibleWrap::ReturnString(autoStr);
74
0
}
75
76
static const gchar*
77
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
78
0
{
79
0
  nsAutoString keyBindingsStr;
80
0
  AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
81
0
  if (acc) {
82
0
    AccessibleWrap::GetKeyBinding(acc, keyBindingsStr);
83
0
  } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aAction))) {
84
0
    proxy->AtkKeyBinding(keyBindingsStr);
85
0
  } else {
86
0
    return nullptr;
87
0
  }
88
0
89
0
  return AccessibleWrap::ReturnString(keyBindingsStr);
90
0
}
91
}
92
93
void
94
actionInterfaceInitCB(AtkActionIface* aIface)
95
0
{
96
0
  NS_ASSERTION(aIface, "Invalid aIface");
97
0
  if (MOZ_UNLIKELY(!aIface))
98
0
    return;
99
0
100
0
  aIface->do_action = doActionCB;
101
0
  aIface->get_n_actions = getActionCountCB;
102
0
  aIface->get_description = getActionDescriptionCB;
103
0
  aIface->get_keybinding = getKeyBindingCB;
104
0
  aIface->get_name = getActionNameCB;
105
0
}