2011-04-27 06:42:18 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-27 15:37:24 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07: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 06:42:18 -07:00
|
|
|
|
|
|
|
#include <atk/atk.h>
|
|
|
|
#include "AtkSocketAccessible.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
|
|
|
|
#include "InterfaceInitFuncs.h"
|
2011-04-27 06:42:18 -07:00
|
|
|
#include "nsMai.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2011-04-27 06:42:18 -07:00
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2013-04-02 17:33:43 -07:00
|
|
|
AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = nullptr;
|
2011-04-27 06:42:18 -07: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-19 21:02:50 -07:00
|
|
|
extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
|
2011-04-27 06:42:18 -07: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-03-19 21:02:50 -07:00
|
|
|
static AtkObject*
|
2012-05-28 18:18:45 -07:00
|
|
|
mai_atk_socket_new(AccessibleWrap* aAccWrap)
|
2011-04-27 06:42:18 -07:00
|
|
|
{
|
2013-04-02 17:33:43 -07:00
|
|
|
NS_ENSURE_TRUE(aAccWrap, nullptr);
|
2011-04-27 06:42:18 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
MaiAtkSocket* acc = nullptr;
|
2013-04-02 17:33:43 -07:00
|
|
|
acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, nullptr));
|
|
|
|
NS_ENSURE_TRUE(acc, nullptr);
|
2011-04-27 06:42:18 -07:00
|
|
|
|
|
|
|
acc->accWrap = aAccWrap;
|
|
|
|
return ATK_OBJECT(acc);
|
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
extern "C" {
|
|
|
|
static AtkObject*
|
|
|
|
RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
|
|
|
|
AtkCoordType aCoordType)
|
2011-04-27 06:42:18 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
|
2011-04-27 06:42:18 -07:00
|
|
|
|
2015-09-01 14:57:57 -07:00
|
|
|
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
|
2011-04-27 06:42:18 -07:00
|
|
|
aX, aY, aCoordType);
|
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static void
|
|
|
|
GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
|
|
|
|
gint* aHeight, AtkCoordType aCoordType)
|
2011-04-27 06:42:18 -07:00
|
|
|
{
|
|
|
|
*aX = *aY = *aWidth = *aHeight = 0;
|
|
|
|
|
|
|
|
if (!MAI_IS_ATK_SOCKET(aComponent))
|
|
|
|
return;
|
|
|
|
|
2015-09-01 14:57:57 -07:00
|
|
|
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
|
2011-04-27 06:42:18 -07:00
|
|
|
aX, aY, aWidth, aHeight, aCoordType);
|
|
|
|
}
|
2012-03-19 21:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mai_atk_component_iface_init(AtkComponentIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "Invalid Interface");
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(!aIface))
|
2012-03-19 21:02:50 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->ref_accessible_at_point = RefAccessibleAtPoint;
|
|
|
|
aIface->get_extents = GetExtents;
|
|
|
|
}
|
2011-04-27 06:42:18 -07:00
|
|
|
|
|
|
|
AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
|
2012-05-27 02:01:40 -07:00
|
|
|
DocAccessible* aDoc,
|
2011-04-27 06:42:18 -07:00
|
|
|
const nsCString& aPlugId) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2011-04-27 06:42:18 -07: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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
void
|
2011-04-27 06:42:18 -07:00
|
|
|
AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
|
|
|
|
{
|
|
|
|
*aOutAccessible = mAtkObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AtkSocketAccessible::Shutdown()
|
|
|
|
{
|
|
|
|
if (mAtkObject) {
|
|
|
|
if (MAI_IS_ATK_SOCKET(mAtkObject))
|
2012-07-30 07:20:58 -07:00
|
|
|
MAI_ATK_SOCKET(mAtkObject)->accWrap = nullptr;
|
2011-04-27 06:42:18 -07:00
|
|
|
g_object_unref(mAtkObject);
|
2012-07-30 07:20:58 -07:00
|
|
|
mAtkObject = nullptr;
|
2011-04-27 06:42:18 -07:00
|
|
|
}
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap::Shutdown();
|
2011-04-27 06:42:18 -07:00
|
|
|
}
|