/src/mozilla-central/accessible/atk/AtkSocketAccessible.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 <atk/atk.h> |
8 | | #include "AtkSocketAccessible.h" |
9 | | |
10 | | #include "InterfaceInitFuncs.h" |
11 | | #include "nsMai.h" |
12 | | #include "mozilla/Likely.h" |
13 | | |
14 | | using namespace mozilla::a11y; |
15 | | |
16 | | AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr; |
17 | | GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID; |
18 | | const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed"; |
19 | | const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type"; |
20 | | |
21 | | bool AtkSocketAccessible::gCanEmbed = FALSE; |
22 | | |
23 | | extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface); |
24 | | |
25 | | G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket, |
26 | | AtkSocketAccessible::g_atk_socket_type, 0, |
27 | | G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT, |
28 | | mai_atk_component_iface_init)) |
29 | | |
30 | | void |
31 | | mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | void |
36 | | mai_atk_socket_init(MaiAtkSocket* aAcc) |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | static AtkObject* |
41 | | mai_atk_socket_new(AccessibleWrap* aAccWrap) |
42 | 0 | { |
43 | 0 | NS_ENSURE_TRUE(aAccWrap, nullptr); |
44 | 0 |
|
45 | 0 | MaiAtkSocket* acc = nullptr; |
46 | 0 | acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, nullptr)); |
47 | 0 | NS_ENSURE_TRUE(acc, nullptr); |
48 | 0 |
|
49 | 0 | acc->accWrap = aAccWrap; |
50 | 0 | return ATK_OBJECT(acc); |
51 | 0 | } |
52 | | |
53 | | extern "C" { |
54 | | static AtkObject* |
55 | | RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY, |
56 | | AtkCoordType aCoordType) |
57 | 0 | { |
58 | 0 | NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr); |
59 | 0 |
|
60 | 0 | return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), |
61 | 0 | aX, aY, aCoordType); |
62 | 0 | } |
63 | | |
64 | | static void |
65 | | GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth, |
66 | | gint* aHeight, AtkCoordType aCoordType) |
67 | 0 | { |
68 | 0 | *aX = *aY = *aWidth = *aHeight = 0; |
69 | 0 |
|
70 | 0 | if (!MAI_IS_ATK_SOCKET(aComponent)) |
71 | 0 | return; |
72 | 0 | |
73 | 0 | getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), |
74 | 0 | aX, aY, aWidth, aHeight, aCoordType); |
75 | 0 | } |
76 | | } |
77 | | |
78 | | void |
79 | | mai_atk_component_iface_init(AtkComponentIface* aIface) |
80 | 0 | { |
81 | 0 | NS_ASSERTION(aIface, "Invalid Interface"); |
82 | 0 | if (MOZ_UNLIKELY(!aIface)) |
83 | 0 | return; |
84 | 0 | |
85 | 0 | aIface->ref_accessible_at_point = RefAccessibleAtPoint; |
86 | 0 | aIface->get_extents = GetExtents; |
87 | 0 | } |
88 | | |
89 | | AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent, |
90 | | DocAccessible* aDoc, |
91 | | const nsCString& aPlugId) : |
92 | | AccessibleWrap(aContent, aDoc) |
93 | 0 | { |
94 | 0 | mAtkObject = mai_atk_socket_new(this); |
95 | 0 | if (!mAtkObject) |
96 | 0 | return; |
97 | 0 | |
98 | 0 | // Embeds the children of an AtkPlug, specified by plugId, as the children of |
99 | 0 | // this socket. |
100 | 0 | // Using G_TYPE macros instead of ATK_SOCKET macros to avoid undefined |
101 | 0 | // symbols. |
102 | 0 | if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) && |
103 | 0 | !aPlugId.IsVoid()) { |
104 | 0 | AtkSocket* accSocket = |
105 | 0 | G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket); |
106 | 0 | g_atk_socket_embed(accSocket, (gchar*)aPlugId.get()); |
107 | 0 | } |
108 | 0 | } |
109 | | |
110 | | void |
111 | | AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) |
112 | 0 | { |
113 | 0 | *aOutAccessible = mAtkObject; |
114 | 0 | } |
115 | | |
116 | | void |
117 | | AtkSocketAccessible::Shutdown() |
118 | 0 | { |
119 | 0 | if (mAtkObject) { |
120 | 0 | if (MAI_IS_ATK_SOCKET(mAtkObject)) |
121 | 0 | MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr; |
122 | 0 | g_object_unref(mAtkObject); |
123 | 0 | mAtkObject = nullptr; |
124 | 0 | } |
125 | 0 | AccessibleWrap::Shutdown(); |
126 | 0 | } |