2011-04-27 17:42:18 +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/. */
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
#include <atk/atk.h>
|
|
|
|
#include "AtkSocketAccessible.h"
|
2012-03-20 08:02:50 +04:00
|
|
|
|
|
|
|
#include "InterfaceInitFuncs.h"
|
2011-04-27 17:42:18 +04:00
|
|
|
#include "nsMai.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2011-04-27 17:42:18 +04:00
|
|
|
|
2012-11-18 06:01:44 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2013-04-03 04:33:43 +04:00
|
|
|
AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
|
2011-04-27 17:42:18 +04:00
|
|
|
GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
|
|
|
|
const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
|
|
|
|
const char* AtkSocketAccessible::sATKSocketGetTypeSymbol =
|
|
|
|
"atk_socket_get_type";
|
|
|
|
|
|
|
|
bool AtkSocketAccessible::gCanEmbed = FALSE;
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
|
|
|
|
AtkSocketAccessible::g_atk_socket_type, 0,
|
|
|
|
G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
|
|
|
|
mai_atk_component_iface_init))
|
|
|
|
|
|
|
|
void mai_atk_socket_class_init(MaiAtkSocketClass* aAcc) {}
|
|
|
|
|
|
|
|
void mai_atk_socket_init(MaiAtkSocket* aAcc) {}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
static AtkObject* mai_atk_socket_new(AccessibleWrap* aAccWrap) {
|
2013-04-03 04:33:43 +04:00
|
|
|
NS_ENSURE_TRUE(aAccWrap, nullptr);
|
2011-04-27 17:42:18 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
MaiAtkSocket* acc = nullptr;
|
2013-04-03 04:33:43 +04:00
|
|
|
acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, nullptr));
|
|
|
|
NS_ENSURE_TRUE(acc, nullptr);
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
acc->accWrap = aAccWrap;
|
|
|
|
return ATK_OBJECT(acc);
|
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
extern "C" {
|
|
|
|
static AtkObject* RefAccessibleAtPoint(AtkComponent* aComponent, gint aX,
|
|
|
|
gint aY, AtkCoordType aCoordType) {
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
|
2011-04-27 17:42:18 +04:00
|
|
|
|
2015-09-02 00:57:57 +03:00
|
|
|
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX,
|
2011-04-27 17:42:18 +04:00
|
|
|
aY, aCoordType);
|
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void GetExtents(AtkComponent* aComponent, gint* aX, gint* aY,
|
|
|
|
gint* aWidth, gint* aHeight, AtkCoordType aCoordType) {
|
2019-08-21 01:42:49 +03:00
|
|
|
*aX = *aY = *aWidth = *aHeight = -1;
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
if (!MAI_IS_ATK_SOCKET(aComponent)) return;
|
|
|
|
|
2015-09-02 00:57:57 +03:00
|
|
|
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)), aX, aY, aWidth,
|
2011-04-27 17:42:18 +04:00
|
|
|
aHeight, aCoordType);
|
|
|
|
}
|
2012-03-20 08:02:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void mai_atk_component_iface_init(AtkComponentIface* aIface) {
|
|
|
|
NS_ASSERTION(aIface, "Invalid Interface");
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(!aIface)) return;
|
2012-03-20 08:02:50 +04:00
|
|
|
|
|
|
|
aIface->ref_accessible_at_point = RefAccessibleAtPoint;
|
|
|
|
aIface->get_extents = GetExtents;
|
|
|
|
}
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* aDoc,
|
2011-04-27 17:42:18 +04:00
|
|
|
const nsCString& aPlugId)
|
2012-05-29 05:18:45 +04:00
|
|
|
: AccessibleWrap(aContent, aDoc) {
|
2011-04-27 17:42:18 +04:00
|
|
|
mAtkObject = mai_atk_socket_new(this);
|
|
|
|
if (!mAtkObject) return;
|
|
|
|
|
|
|
|
// Embeds the children of an AtkPlug, specified by plugId, as the children of
|
|
|
|
// this socket.
|
|
|
|
// Using G_TYPE macros instead of ATK_SOCKET macros to avoid undefined
|
|
|
|
// symbols.
|
|
|
|
if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
|
|
|
|
!aPlugId.IsVoid()) {
|
|
|
|
AtkSocket* accSocket =
|
|
|
|
G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
|
|
|
|
g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AtkSocketAccessible::GetNativeInterface(void** aOutAccessible) {
|
|
|
|
*aOutAccessible = mAtkObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AtkSocketAccessible::Shutdown() {
|
|
|
|
if (mAtkObject) {
|
2021-02-20 02:14:32 +03:00
|
|
|
if (MAI_IS_ATK_SOCKET(mAtkObject)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
|
2021-02-20 02:14:32 +03:00
|
|
|
}
|
2011-04-27 17:42:18 +04:00
|
|
|
g_object_unref(mAtkObject);
|
2012-07-30 18:20:58 +04:00
|
|
|
mAtkObject = nullptr;
|
2011-04-27 17:42:18 +04:00
|
|
|
}
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::Shutdown();
|
2011-04-27 17:42:18 +04:00
|
|
|
}
|