Bug 1758984 - add status to mozlog crash so group summary is not marked as OK. r...
[gecko.git] / accessible / atk / AtkSocketAccessible.cpp
blob749ceb8aa068c450c3b5051176bcaa275ae52f26
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 <atk/atk.h>
8 #include "AtkSocketAccessible.h"
10 #include "InterfaceInitFuncs.h"
11 #include "nsMai.h"
12 #include "mozilla/Likely.h"
14 using namespace mozilla::a11y;
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 =
20 "atk_socket_get_type";
22 bool AtkSocketAccessible::gCanEmbed = FALSE;
24 extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
26 G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
27 AtkSocketAccessible::g_atk_socket_type, 0,
28 G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
29 mai_atk_component_iface_init))
31 void mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) {}
33 void mai_atk_socket_init(MaiAtkSocket* aAcc) {}
35 static AtkObject* mai_atk_socket_new(AccessibleWrap* aAccWrap) {
36 NS_ENSURE_TRUE(aAccWrap, nullptr);
38 MaiAtkSocket* acc = nullptr;
39 acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, nullptr));
40 NS_ENSURE_TRUE(acc, nullptr);
42 acc->accWrap = aAccWrap;
43 return ATK_OBJECT(acc);
46 extern "C" {
47 static AtkObject* RefAccessibleAtPoint(AtkComponent* aComponent, gint aX,
48 gint aY, AtkCoordType aCoordType) {
49 NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
51 return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX,
52 aY, aCoordType);
55 static void GetExtents(AtkComponent* aComponent, gint* aX, gint* aY,
56 gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
57 *aX = *aY = *aWidth = *aHeight = -1;
59 if (!MAI_IS_ATK_SOCKET(aComponent)) return;
61 getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX, aY, aWidth,
62 aHeight, aCoordType);
66 void mai_atk_component_iface_init(AtkComponentIface* aIface) {
67 NS_ASSERTION(aIface, "Invalid Interface");
68 if (MOZ_UNLIKELY(!aIface)) return;
70 aIface->ref_accessible_at_point = RefAccessibleAtPoint;
71 aIface->get_extents = GetExtents;
74 AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
75 DocAccessible* aDoc,
76 const nsCString& aPlugId)
77 : AccessibleWrap(aContent, aDoc) {
78 mAtkObject = mai_atk_socket_new(this);
79 if (!mAtkObject) return;
81 // Embeds the children of an AtkPlug, specified by plugId, as the children of
82 // this socket.
83 // Using G_TYPE macros instead of ATK_SOCKET macros to avoid undefined
84 // symbols.
85 if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
86 !aPlugId.IsVoid()) {
87 AtkSocket* accSocket =
88 G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
89 g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
93 void AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) {
94 *aOutAccessible = mAtkObject;
97 void AtkSocketAccessible::Shutdown() {
98 if (mAtkObject) {
99 if (MAI_IS_ATK_SOCKET(mAtkObject)) {
100 MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
102 g_object_unref(mAtkObject);
103 mAtkObject = nullptr;
105 AccessibleWrap::Shutdown();