2011-04-27 17:42:27 +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/. */
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
#include "AccessibleWrap.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
|
2012-04-17 13:56:02 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-04-25 15:29:40 +04:00
|
|
|
#include "ApplicationAccessibleWrap.h"
|
2012-03-20 08:02:50 +04:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
2014-10-24 13:29:48 +04:00
|
|
|
#include "mozilla/a11y/PDocAccessible.h"
|
2014-03-08 01:35:19 +04:00
|
|
|
#include "ProxyAccessible.h"
|
2012-05-04 10:09:22 +04:00
|
|
|
#include "RootAccessible.h"
|
2012-03-20 08:02:50 +04:00
|
|
|
#include "nsMai.h"
|
|
|
|
#include "nsMaiHyperlink.h"
|
2003-04-23 09:28:41 +04:00
|
|
|
#include "nsString.h"
|
2007-06-02 07:01:38 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2006-04-28 07:27:15 +04:00
|
|
|
#include "prprf.h"
|
2007-01-28 06:58:18 +03:00
|
|
|
#include "nsStateMap.h"
|
2014-03-08 01:35:19 +04:00
|
|
|
#include "mozilla/a11y/Platform.h"
|
2011-08-10 05:44:00 +04:00
|
|
|
#include "Relation.h"
|
2012-05-04 10:09:22 +04:00
|
|
|
#include "RootAccessible.h"
|
2011-04-10 03:38:06 +04:00
|
|
|
#include "States.h"
|
2013-09-23 21:29:27 +04:00
|
|
|
#include "nsISimpleEnumerator.h"
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2006-09-01 01:07:41 +04:00
|
|
|
#include "nsXPCOMStrings.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsIPersistentProperties2.h"
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::EAvailableAtkSignals AccessibleWrap::gAvailableAtkSignals =
|
2011-07-04 17:49:44 +04:00
|
|
|
eUnknown;
|
|
|
|
|
2012-04-25 15:29:40 +04:00
|
|
|
//defined in ApplicationAccessibleWrap.cpp
|
2009-08-21 16:33:31 +04:00
|
|
|
extern "C" GType g_atk_hyperlink_impl_type;
|
2006-08-30 13:03:45 +04:00
|
|
|
|
2003-05-06 06:23:50 +04:00
|
|
|
/* MaiAtkObject */
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2004-03-25 21:36:08 +03:00
|
|
|
enum {
|
|
|
|
ACTIVATE,
|
|
|
|
CREATE,
|
|
|
|
DEACTIVATE,
|
|
|
|
DESTROY,
|
|
|
|
MAXIMIZE,
|
|
|
|
MINIMIZE,
|
|
|
|
RESIZE,
|
|
|
|
RESTORE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2006-05-29 09:46:38 +04:00
|
|
|
enum MaiInterfaceType {
|
|
|
|
MAI_INTERFACE_COMPONENT, /* 0 */
|
|
|
|
MAI_INTERFACE_ACTION,
|
|
|
|
MAI_INTERFACE_VALUE,
|
|
|
|
MAI_INTERFACE_EDITABLE_TEXT,
|
|
|
|
MAI_INTERFACE_HYPERTEXT,
|
2006-08-30 13:03:45 +04:00
|
|
|
MAI_INTERFACE_HYPERLINK_IMPL,
|
2006-05-29 09:46:38 +04:00
|
|
|
MAI_INTERFACE_SELECTION,
|
|
|
|
MAI_INTERFACE_TABLE,
|
2006-08-16 07:06:42 +04:00
|
|
|
MAI_INTERFACE_TEXT,
|
2007-02-12 10:04:58 +03:00
|
|
|
MAI_INTERFACE_DOCUMENT,
|
|
|
|
MAI_INTERFACE_IMAGE /* 10 */
|
2006-05-29 09:46:38 +04:00
|
|
|
};
|
|
|
|
|
2006-06-06 07:40:08 +04:00
|
|
|
static GType GetAtkTypeForMai(MaiInterfaceType type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case MAI_INTERFACE_COMPONENT:
|
|
|
|
return ATK_TYPE_COMPONENT;
|
|
|
|
case MAI_INTERFACE_ACTION:
|
|
|
|
return ATK_TYPE_ACTION;
|
|
|
|
case MAI_INTERFACE_VALUE:
|
|
|
|
return ATK_TYPE_VALUE;
|
|
|
|
case MAI_INTERFACE_EDITABLE_TEXT:
|
|
|
|
return ATK_TYPE_EDITABLE_TEXT;
|
|
|
|
case MAI_INTERFACE_HYPERTEXT:
|
|
|
|
return ATK_TYPE_HYPERTEXT;
|
2006-08-30 13:03:45 +04:00
|
|
|
case MAI_INTERFACE_HYPERLINK_IMPL:
|
|
|
|
return g_atk_hyperlink_impl_type;
|
2006-06-06 07:40:08 +04:00
|
|
|
case MAI_INTERFACE_SELECTION:
|
|
|
|
return ATK_TYPE_SELECTION;
|
|
|
|
case MAI_INTERFACE_TABLE:
|
|
|
|
return ATK_TYPE_TABLE;
|
|
|
|
case MAI_INTERFACE_TEXT:
|
|
|
|
return ATK_TYPE_TEXT;
|
2006-08-16 07:06:42 +04:00
|
|
|
case MAI_INTERFACE_DOCUMENT:
|
|
|
|
return ATK_TYPE_DOCUMENT;
|
2007-02-12 10:04:58 +03:00
|
|
|
case MAI_INTERFACE_IMAGE:
|
|
|
|
return ATK_TYPE_IMAGE;
|
2006-06-06 07:40:08 +04:00
|
|
|
}
|
|
|
|
return G_TYPE_INVALID;
|
|
|
|
}
|
2006-05-29 09:46:38 +04:00
|
|
|
|
2007-09-19 01:40:04 +04:00
|
|
|
static const char* kNonUserInputEvent = ":system";
|
|
|
|
|
2006-05-29 09:46:38 +04:00
|
|
|
static const GInterfaceInfo atk_if_infos[] = {
|
|
|
|
{(GInterfaceInitFunc)componentInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)actionInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)valueInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)editableTextInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)hypertextInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-08-30 13:03:45 +04:00
|
|
|
{(GInterfaceInitFunc)hyperlinkImplInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)selectionInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)tableInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-05-29 09:46:38 +04:00
|
|
|
{(GInterfaceInitFunc)textInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2006-08-16 07:06:42 +04:00
|
|
|
{(GInterfaceInitFunc)documentInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr},
|
2007-02-12 10:04:58 +03:00
|
|
|
{(GInterfaceInitFunc)imageInterfaceInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInterfaceFinalizeFunc) nullptr, nullptr}
|
2006-05-29 09:46:38 +04:00
|
|
|
};
|
|
|
|
|
2015-04-08 18:32:40 +03:00
|
|
|
static GQuark quark_mai_hyperlink = 0;
|
|
|
|
|
2015-04-17 22:21:36 +03:00
|
|
|
AtkHyperlink*
|
|
|
|
MaiAtkObject::GetAtkHyperlink()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(quark_mai_hyperlink, "quark_mai_hyperlink not initialized");
|
|
|
|
MaiHyperlink* maiHyperlink =
|
|
|
|
(MaiHyperlink*)g_object_get_qdata(G_OBJECT(this), quark_mai_hyperlink);
|
|
|
|
if (!maiHyperlink) {
|
2015-04-21 23:31:58 +03:00
|
|
|
maiHyperlink = new MaiHyperlink(accWrap);
|
2015-04-17 22:21:36 +03:00
|
|
|
g_object_set_qdata(G_OBJECT(this), quark_mai_hyperlink, maiHyperlink);
|
|
|
|
}
|
|
|
|
|
|
|
|
return maiHyperlink->GetAtkHyperlink();
|
|
|
|
}
|
|
|
|
|
2015-04-08 18:14:42 +03:00
|
|
|
void
|
|
|
|
MaiAtkObject::Shutdown()
|
|
|
|
{
|
|
|
|
accWrap = 0;
|
|
|
|
MaiHyperlink* maiHyperlink =
|
|
|
|
(MaiHyperlink*)g_object_get_qdata(G_OBJECT(this), quark_mai_hyperlink);
|
|
|
|
if (maiHyperlink) {
|
|
|
|
delete maiHyperlink;
|
|
|
|
g_object_set_qdata(G_OBJECT(this), quark_mai_hyperlink, nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-06 06:23:50 +04:00
|
|
|
struct MaiAtkObjectClass
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
|
|
|
AtkObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
2004-03-25 21:36:08 +03:00
|
|
|
static guint mai_atk_object_signals [LAST_SIGNAL] = { 0, };
|
|
|
|
|
2013-04-17 12:29:35 +04:00
|
|
|
static void MaybeFireNameChange(AtkObject* aAtkObj, const nsString& aNewName);
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
/* callbacks for MaiAtkObject */
|
|
|
|
static void classInitCB(AtkObjectClass *aClass);
|
|
|
|
static void initializeCB(AtkObject *aAtkObj, gpointer aData);
|
|
|
|
static void finalizeCB(GObject *aObj);
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
/* callbacks for AtkObject virtual functions */
|
|
|
|
static const gchar* getNameCB (AtkObject *aAtkObj);
|
2007-02-12 10:04:58 +03:00
|
|
|
/* getDescriptionCB is also used by image interface */
|
|
|
|
const gchar* getDescriptionCB (AtkObject *aAtkObj);
|
2003-04-23 09:28:41 +04:00
|
|
|
static AtkRole getRoleCB(AtkObject *aAtkObj);
|
2006-09-01 01:07:41 +04:00
|
|
|
static AtkAttributeSet* getAttributesCB(AtkObject *aAtkObj);
|
2013-11-14 12:03:57 +04:00
|
|
|
static const gchar* GetLocaleCB(AtkObject*);
|
2003-04-23 09:28:41 +04:00
|
|
|
static AtkObject* getParentCB(AtkObject *aAtkObj);
|
|
|
|
static gint getChildCountCB(AtkObject *aAtkObj);
|
|
|
|
static AtkObject* refChildCB(AtkObject *aAtkObj, gint aChildIndex);
|
|
|
|
static gint getIndexInParentCB(AtkObject *aAtkObj);
|
2003-05-21 07:30:28 +04:00
|
|
|
static AtkStateSet* refStateSetCB(AtkObject *aAtkObj);
|
2005-06-24 20:29:15 +04:00
|
|
|
static AtkRelationSet* refRelationSetCB(AtkObject *aAtkObj);
|
2003-04-23 09:28:41 +04:00
|
|
|
|
|
|
|
/* the missing atkobject virtual functions */
|
|
|
|
/*
|
2003-05-21 07:30:28 +04:00
|
|
|
static AtkLayer getLayerCB(AtkObject *aAtkObj);
|
|
|
|
static gint getMdiZorderCB(AtkObject *aAtkObj);
|
2003-04-23 09:28:41 +04:00
|
|
|
static void SetNameCB(AtkObject *aAtkObj,
|
|
|
|
const gchar *name);
|
|
|
|
static void SetDescriptionCB(AtkObject *aAtkObj,
|
|
|
|
const gchar *description);
|
|
|
|
static void SetParentCB(AtkObject *aAtkObj,
|
|
|
|
AtkObject *parent);
|
|
|
|
static void SetRoleCB(AtkObject *aAtkObj,
|
|
|
|
AtkRole role);
|
|
|
|
static guint ConnectPropertyChangeHandlerCB(
|
|
|
|
AtkObject *aObj,
|
|
|
|
AtkPropertyChangeHandler *handler);
|
|
|
|
static void RemovePropertyChangeHandlerCB(
|
|
|
|
AtkObject *aAtkObj,
|
|
|
|
guint handler_id);
|
|
|
|
static void InitializeCB(AtkObject *aAtkObj,
|
|
|
|
gpointer data);
|
|
|
|
static void ChildrenChangedCB(AtkObject *aAtkObj,
|
|
|
|
guint change_index,
|
|
|
|
gpointer changed_child);
|
|
|
|
static void FocusEventCB(AtkObject *aAtkObj,
|
|
|
|
gboolean focus_in);
|
|
|
|
static void PropertyChangeCB(AtkObject *aAtkObj,
|
|
|
|
AtkPropertyValues *values);
|
|
|
|
static void StateChangeCB(AtkObject *aAtkObj,
|
|
|
|
const gchar *name,
|
|
|
|
gboolean state_set);
|
|
|
|
static void VisibleDataChangedCB(AtkObject *aAtkObj);
|
|
|
|
*/
|
|
|
|
G_END_DECLS
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static GType GetMaiAtkType(uint16_t interfacesBits);
|
|
|
|
static const char * GetUniqueMaiAtkTypeName(uint16_t interfacesBits);
|
2004-10-14 06:31:58 +04:00
|
|
|
|
2013-04-03 04:33:43 +04:00
|
|
|
static gpointer parent_class = nullptr;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
|
|
|
GType
|
|
|
|
mai_atk_object_get_type(void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
static const GTypeInfo tinfo = {
|
|
|
|
sizeof(MaiAtkObjectClass),
|
2013-04-03 04:33:43 +04:00
|
|
|
(GBaseInitFunc)nullptr,
|
|
|
|
(GBaseFinalizeFunc)nullptr,
|
2003-04-23 09:28:41 +04:00
|
|
|
(GClassInitFunc)classInitCB,
|
2013-04-03 04:33:43 +04:00
|
|
|
(GClassFinalizeFunc)nullptr,
|
|
|
|
nullptr, /* class data */
|
2003-04-23 09:28:41 +04:00
|
|
|
sizeof(MaiAtkObject), /* instance size */
|
|
|
|
0, /* nb preallocs */
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInstanceInitFunc)nullptr,
|
|
|
|
nullptr /* value table */
|
2003-04-23 09:28:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
type = g_type_register_static(ATK_TYPE_OBJECT,
|
|
|
|
"MaiAtkObject", &tinfo, GTypeFlags(0));
|
2007-05-29 10:41:14 +04:00
|
|
|
quark_mai_hyperlink = g_quark_from_static_string("MaiHyperlink");
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::
|
|
|
|
AccessibleWrap(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-07-30 18:20:58 +04:00
|
|
|
Accessible(aContent, aDoc), mAtkObject(nullptr)
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2003-04-02 00:02:51 +04:00
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::~AccessibleWrap()
|
2003-04-02 00:02:51 +04:00
|
|
|
{
|
2008-01-22 08:29:40 +03:00
|
|
|
NS_ASSERTION(!mAtkObject, "ShutdownAtkObject() is not called");
|
2007-05-29 10:41:14 +04:00
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
void
|
|
|
|
AccessibleWrap::ShutdownAtkObject()
|
2007-05-29 10:41:14 +04:00
|
|
|
{
|
2015-04-07 23:17:09 +03:00
|
|
|
if (!mAtkObject)
|
|
|
|
return;
|
|
|
|
|
2015-04-08 18:32:40 +03:00
|
|
|
NS_ASSERTION(IS_MAI_OBJECT(mAtkObject), "wrong type of atk object");
|
2015-04-08 18:14:42 +03:00
|
|
|
if (IS_MAI_OBJECT(mAtkObject))
|
|
|
|
MAI_ATK_OBJECT(mAtkObject)->Shutdown();
|
2015-04-07 23:17:09 +03:00
|
|
|
|
|
|
|
g_object_unref(mAtkObject);
|
|
|
|
mAtkObject = nullptr;
|
2007-07-02 15:18:07 +04:00
|
|
|
}
|
|
|
|
|
2010-06-12 08:04:35 +04:00
|
|
|
void
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::Shutdown()
|
2007-07-02 15:18:07 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
ShutdownAtkObject();
|
|
|
|
Accessible::Shutdown();
|
2007-05-29 10:41:14 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
void
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::GetNativeInterface(void** aOutAccessible)
|
2003-05-21 07:32:55 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
*aOutAccessible = nullptr;
|
2003-05-21 07:32:55 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
if (!mAtkObject) {
|
|
|
|
if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) {
|
|
|
|
// We don't create ATK objects for node which has been shutdown or
|
|
|
|
// plain text leaves
|
|
|
|
return;
|
|
|
|
}
|
2007-06-04 12:37:33 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
GType type = GetMaiAtkType(CreateMaiInterfaces());
|
|
|
|
if (!type)
|
|
|
|
return;
|
2003-05-21 07:32:55 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
mAtkObject = reinterpret_cast<AtkObject*>(g_object_new(type, nullptr));
|
|
|
|
if (!mAtkObject)
|
|
|
|
return;
|
2003-05-21 07:32:55 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
atk_object_initialize(mAtkObject, this);
|
|
|
|
mAtkObject->role = ATK_ROLE_INVALID;
|
|
|
|
mAtkObject->layer = ATK_LAYER_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aOutAccessible = mAtkObject;
|
2003-05-21 07:32:55 +04:00
|
|
|
}
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
AtkObject *
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::GetAtkObject(void)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
void *atkObj = nullptr;
|
2003-05-21 07:32:55 +04:00
|
|
|
GetNativeInterface(&atkObj);
|
2007-07-08 11:08:04 +04:00
|
|
|
return static_cast<AtkObject *>(atkObj);
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
// Get AtkObject from Accessible interface
|
2007-06-08 13:09:24 +04:00
|
|
|
/* static */
|
|
|
|
AtkObject *
|
2014-10-22 04:49:28 +04:00
|
|
|
AccessibleWrap::GetAtkObject(Accessible* acc)
|
2007-06-08 13:09:24 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
void *atkObjPtr = nullptr;
|
2007-06-08 13:09:24 +04:00
|
|
|
acc->GetNativeInterface(&atkObjPtr);
|
2012-07-30 18:20:58 +04:00
|
|
|
return atkObjPtr ? ATK_OBJECT(atkObjPtr) : nullptr;
|
2007-06-08 13:09:24 +04:00
|
|
|
}
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
/* private */
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::CreateMaiInterfaces(void)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t interfacesBits = 0;
|
2014-10-22 04:49:28 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// The Component interface is supported by all accessibles.
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_COMPONENT;
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2011-06-05 23:35:43 +04:00
|
|
|
// Add Action interface if the action count is more than zero.
|
|
|
|
if (ActionCount() > 0)
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_ACTION;
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// Text, Editabletext, and Hypertext interface.
|
2012-05-31 12:04:41 +04:00
|
|
|
HyperTextAccessible* hyperText = AsHyperText();
|
2012-05-22 20:40:56 +04:00
|
|
|
if (hyperText && hyperText->IsTextRole()) {
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
|
|
|
|
if (!nsAccUtils::MustPrune(this))
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// Value interface.
|
2014-10-22 04:49:28 +04:00
|
|
|
if (HasNumericValue())
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_VALUE;
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// Document interface.
|
|
|
|
if (IsDoc())
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
|
2006-08-16 07:06:42 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
if (IsImage())
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
|
2007-02-12 10:04:58 +03:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// HyperLink interface.
|
2011-06-24 08:29:43 +04:00
|
|
|
if (IsLink())
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
|
2007-08-04 06:15:52 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
if (!nsAccUtils::MustPrune(this)) { // These interfaces require children
|
|
|
|
// Table interface.
|
2012-08-20 18:54:33 +04:00
|
|
|
if (AsTable())
|
2012-05-22 20:40:56 +04:00
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_TABLE;
|
2012-08-20 18:54:33 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
// Selection interface.
|
|
|
|
if (IsSelect()) {
|
|
|
|
interfacesBits |= 1 << MAI_INTERFACE_SELECTION;
|
2007-08-04 06:15:52 +04:00
|
|
|
}
|
2012-05-22 20:40:56 +04:00
|
|
|
}
|
2007-08-04 06:15:52 +04:00
|
|
|
|
2012-05-22 20:40:56 +04:00
|
|
|
return interfacesBits;
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
2004-10-14 06:31:58 +04:00
|
|
|
static GType
|
2012-08-22 19:56:38 +04:00
|
|
|
GetMaiAtkType(uint16_t interfacesBits)
|
2003-05-06 06:23:50 +04:00
|
|
|
{
|
|
|
|
GType type;
|
|
|
|
static const GTypeInfo tinfo = {
|
|
|
|
sizeof(MaiAtkObjectClass),
|
2013-04-03 04:33:43 +04:00
|
|
|
(GBaseInitFunc) nullptr,
|
|
|
|
(GBaseFinalizeFunc) nullptr,
|
|
|
|
(GClassInitFunc) nullptr,
|
|
|
|
(GClassFinalizeFunc) nullptr,
|
|
|
|
nullptr, /* class data */
|
2003-05-06 06:23:50 +04:00
|
|
|
sizeof(MaiAtkObject), /* instance size */
|
|
|
|
0, /* nb preallocs */
|
2013-04-03 04:33:43 +04:00
|
|
|
(GInstanceInitFunc) nullptr,
|
|
|
|
nullptr /* value table */
|
2003-05-06 06:23:50 +04:00
|
|
|
};
|
|
|
|
|
2006-04-28 07:27:15 +04:00
|
|
|
/*
|
2006-06-06 07:40:08 +04:00
|
|
|
* The members we use to register GTypes are GetAtkTypeForMai
|
|
|
|
* and atk_if_infos, which are constant values to each MaiInterface
|
|
|
|
* So we can reuse the registered GType when having
|
2006-04-28 07:27:15 +04:00
|
|
|
* the same MaiInterface types.
|
|
|
|
*/
|
2006-05-29 09:46:38 +04:00
|
|
|
const char *atkTypeName = GetUniqueMaiAtkTypeName(interfacesBits);
|
2006-04-28 07:27:15 +04:00
|
|
|
type = g_type_from_name(atkTypeName);
|
|
|
|
if (type) {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gobject limits the number of types that can directly derive from any
|
|
|
|
* given object type to 4095.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint16_t typeRegCount = 0;
|
2006-06-06 07:40:08 +04:00
|
|
|
if (typeRegCount++ >= 4095) {
|
|
|
|
return G_TYPE_INVALID;
|
2006-04-28 07:27:15 +04:00
|
|
|
}
|
2006-06-06 07:40:08 +04:00
|
|
|
type = g_type_register_static(MAI_TYPE_ATK_OBJECT,
|
|
|
|
atkTypeName,
|
|
|
|
&tinfo, GTypeFlags(0));
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t index = 0; index < ArrayLength(atk_if_infos); index++) {
|
2006-05-29 09:46:38 +04:00
|
|
|
if (interfacesBits & (1 << index)) {
|
2003-05-06 06:23:50 +04:00
|
|
|
g_type_add_interface_static(type,
|
2006-06-06 07:40:08 +04:00
|
|
|
GetAtkTypeForMai((MaiInterfaceType)index),
|
2006-05-29 09:46:38 +04:00
|
|
|
&atk_if_infos[index]);
|
|
|
|
}
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
2006-05-29 09:46:38 +04:00
|
|
|
|
2003-05-06 06:23:50 +04:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
static const char*
|
2012-08-22 19:56:38 +04:00
|
|
|
GetUniqueMaiAtkTypeName(uint16_t interfacesBits)
|
2003-05-06 06:23:50 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
#define MAI_ATK_TYPE_NAME_LEN (30) /* 10+sizeof(uint16_t)*8/4+1 < 30 */
|
2003-05-06 06:23:50 +04:00
|
|
|
|
|
|
|
static gchar namePrefix[] = "MaiAtkType"; /* size = 10 */
|
|
|
|
static gchar name[MAI_ATK_TYPE_NAME_LEN + 1];
|
|
|
|
|
2006-05-29 09:46:38 +04:00
|
|
|
PR_snprintf(name, MAI_ATK_TYPE_NAME_LEN, "%s%x", namePrefix,
|
|
|
|
interfacesBits);
|
2003-05-06 06:23:50 +04:00
|
|
|
name[MAI_ATK_TYPE_NAME_LEN] = '\0';
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
bool
|
|
|
|
AccessibleWrap::IsValidObject()
|
2003-09-14 16:56:21 +04:00
|
|
|
{
|
|
|
|
// to ensure we are not shut down
|
2010-06-11 12:23:18 +04:00
|
|
|
return !IsDefunct();
|
2003-09-14 16:56:21 +04:00
|
|
|
}
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
/* static functions for ATK callbacks */
|
|
|
|
void
|
|
|
|
classInitCB(AtkObjectClass *aClass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS(aClass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent(aClass);
|
|
|
|
|
|
|
|
aClass->get_name = getNameCB;
|
|
|
|
aClass->get_description = getDescriptionCB;
|
|
|
|
aClass->get_parent = getParentCB;
|
|
|
|
aClass->get_n_children = getChildCountCB;
|
|
|
|
aClass->ref_child = refChildCB;
|
|
|
|
aClass->get_index_in_parent = getIndexInParentCB;
|
|
|
|
aClass->get_role = getRoleCB;
|
2006-09-01 01:07:41 +04:00
|
|
|
aClass->get_attributes = getAttributesCB;
|
2013-11-14 12:03:57 +04:00
|
|
|
aClass->get_object_locale = GetLocaleCB;
|
2003-05-21 07:30:28 +04:00
|
|
|
aClass->ref_state_set = refStateSetCB;
|
2005-06-24 20:29:15 +04:00
|
|
|
aClass->ref_relation_set = refRelationSetCB;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
|
|
|
aClass->initialize = initializeCB;
|
|
|
|
|
|
|
|
gobject_class->finalize = finalizeCB;
|
2004-03-25 21:36:08 +03:00
|
|
|
|
|
|
|
mai_atk_object_signals [ACTIVATE] =
|
|
|
|
g_signal_new ("activate",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [CREATE] =
|
|
|
|
g_signal_new ("create",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [DEACTIVATE] =
|
|
|
|
g_signal_new ("deactivate",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [DESTROY] =
|
|
|
|
g_signal_new ("destroy",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [MAXIMIZE] =
|
|
|
|
g_signal_new ("maximize",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [MINIMIZE] =
|
|
|
|
g_signal_new ("minimize",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [RESIZE] =
|
|
|
|
g_signal_new ("resize",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
mai_atk_object_signals [RESTORE] =
|
|
|
|
g_signal_new ("restore",
|
|
|
|
MAI_TYPE_ATK_OBJECT,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0, /* default signal handler */
|
2013-04-03 04:33:43 +04:00
|
|
|
nullptr, nullptr,
|
2004-03-25 21:36:08 +03:00
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
initializeCB(AtkObject *aAtkObj, gpointer aData)
|
|
|
|
{
|
2006-08-30 09:19:06 +04:00
|
|
|
NS_ASSERTION((IS_MAI_OBJECT(aAtkObj)), "Invalid AtkObject");
|
2003-05-06 06:23:50 +04:00
|
|
|
NS_ASSERTION(aData, "Invalid Data to init AtkObject");
|
|
|
|
if (!aAtkObj || !aData)
|
|
|
|
return;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
|
|
|
/* call parent init function */
|
|
|
|
/* AtkObjectClass has not a "initialize" function now,
|
|
|
|
* maybe it has later
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (ATK_OBJECT_CLASS(parent_class)->initialize)
|
|
|
|
ATK_OBJECT_CLASS(parent_class)->initialize(aAtkObj, aData);
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
/* initialize object */
|
2014-03-08 01:35:19 +04:00
|
|
|
MAI_ATK_OBJECT(aAtkObj)->accWrap = reinterpret_cast<uintptr_t>(aData);
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
finalizeCB(GObject *aObj)
|
|
|
|
{
|
2006-08-30 09:19:06 +04:00
|
|
|
if (!IS_MAI_OBJECT(aObj))
|
2003-04-23 09:28:41 +04:00
|
|
|
return;
|
2014-03-08 01:35:19 +04:00
|
|
|
NS_ASSERTION(MAI_ATK_OBJECT(aObj)->accWrap == 0, "AccWrap NOT null");
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
// call parent finalize function
|
|
|
|
// finalize of GObjectClass will unref the accessible parent if has
|
|
|
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize(aObj);
|
|
|
|
}
|
|
|
|
|
2012-05-01 07:08:31 +04:00
|
|
|
const gchar*
|
|
|
|
getNameCB(AtkObject* aAtkObj)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2014-09-23 13:53:03 +04:00
|
|
|
nsAutoString name;
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2014-09-23 13:53:03 +04:00
|
|
|
if (accWrap)
|
|
|
|
accWrap->Name(name);
|
|
|
|
else if (ProxyAccessible* proxy = GetProxy(aAtkObj))
|
|
|
|
proxy->Name(name);
|
|
|
|
else
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2013-04-17 12:29:35 +04:00
|
|
|
// XXX Firing an event from here does not seem right
|
|
|
|
MaybeFireNameChange(aAtkObj, name);
|
2012-05-01 07:08:31 +04:00
|
|
|
|
|
|
|
return aAtkObj->name;
|
2003-04-02 00:02:51 +04:00
|
|
|
}
|
2001-05-12 01:11:38 +04:00
|
|
|
|
2013-04-17 12:29:35 +04:00
|
|
|
static void
|
|
|
|
MaybeFireNameChange(AtkObject* aAtkObj, const nsString& aNewName)
|
|
|
|
{
|
|
|
|
NS_ConvertUTF16toUTF8 newNameUTF8(aNewName);
|
|
|
|
if (aAtkObj->name && newNameUTF8.Equals(aAtkObj->name))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Below we duplicate the functionality of atk_object_set_name(),
|
|
|
|
// but without calling atk_object_get_name(). Instead of
|
|
|
|
// atk_object_get_name() we directly access aAtkObj->name. This is because
|
|
|
|
// atk_object_get_name() would call getNameCB() which would call
|
|
|
|
// MaybeFireNameChange() (or atk_object_set_name() before this problem was
|
|
|
|
// fixed) and we would get an infinite recursion.
|
|
|
|
// See http://bugzilla.mozilla.org/733712
|
|
|
|
|
|
|
|
// Do not notify for initial name setting.
|
|
|
|
// See bug http://bugzilla.gnome.org/665870
|
|
|
|
bool notify = !!aAtkObj->name;
|
|
|
|
|
|
|
|
free(aAtkObj->name);
|
|
|
|
aAtkObj->name = strdup(newNameUTF8.get());
|
|
|
|
|
|
|
|
if (notify)
|
|
|
|
g_object_notify(G_OBJECT(aAtkObj), "accessible-name");
|
|
|
|
}
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
const gchar *
|
|
|
|
getDescriptionCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2014-10-24 07:21:44 +04:00
|
|
|
nsAutoString uniDesc;
|
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
|
|
|
if (accWrap) {
|
|
|
|
if (accWrap->IsDefunct())
|
|
|
|
return nullptr;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2011-04-23 17:14:05 +04:00
|
|
|
accWrap->Description(uniDesc);
|
2014-10-24 07:21:44 +04:00
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
|
|
|
proxy->Description(uniDesc);
|
|
|
|
} else {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2007-06-08 13:09:24 +04:00
|
|
|
NS_ConvertUTF8toUTF16 objDesc(aAtkObj->description);
|
2011-04-23 17:14:05 +04:00
|
|
|
if (!uniDesc.Equals(objDesc))
|
2007-06-08 13:09:24 +04:00
|
|
|
atk_object_set_description(aAtkObj,
|
|
|
|
NS_ConvertUTF16toUTF8(uniDesc).get());
|
2011-04-23 17:14:05 +04:00
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
return aAtkObj->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
AtkRole
|
|
|
|
getRoleCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2014-03-08 01:35:19 +04:00
|
|
|
if (aAtkObj->role != ATK_ROLE_INVALID)
|
|
|
|
return aAtkObj->role;
|
2014-10-01 16:41:56 +04:00
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
|
|
|
a11y::role role;
|
|
|
|
if (!accWrap) {
|
|
|
|
ProxyAccessible* proxy = GetProxy(aAtkObj);
|
|
|
|
if (!proxy)
|
|
|
|
return ATK_ROLE_INVALID;
|
|
|
|
|
|
|
|
role = proxy->Role();
|
|
|
|
} else {
|
2012-05-08 03:49:41 +04:00
|
|
|
#ifdef DEBUG
|
2014-03-08 01:35:19 +04:00
|
|
|
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
|
2014-10-22 04:49:28 +04:00
|
|
|
"Does not support Text interface when it should");
|
2006-11-08 11:22:46 +03:00
|
|
|
#endif
|
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
role = accWrap->Role();
|
|
|
|
}
|
2012-04-26 22:25:33 +04:00
|
|
|
|
2012-07-21 22:32:25 +04:00
|
|
|
#define ROLE(geckoRole, stringRole, atkRole, macRole, \
|
|
|
|
msaaRole, ia2Role, nameRule) \
|
2012-05-02 15:13:34 +04:00
|
|
|
case roles::geckoRole: \
|
|
|
|
aAtkObj->role = atkRole; \
|
|
|
|
break;
|
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
switch (role) {
|
2012-05-02 15:13:34 +04:00
|
|
|
#include "RoleMap.h"
|
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Unknown role.");
|
2012-05-02 15:13:34 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef ROLE
|
|
|
|
|
2014-02-05 01:29:12 +04:00
|
|
|
if (aAtkObj->role == ATK_ROLE_LIST_BOX && !IsAtkVersionAtLeast(2, 1))
|
|
|
|
aAtkObj->role = ATK_ROLE_LIST;
|
2014-02-12 19:07:48 +04:00
|
|
|
else if (aAtkObj->role == ATK_ROLE_TABLE_ROW && !IsAtkVersionAtLeast(2, 1))
|
|
|
|
aAtkObj->role = ATK_ROLE_LIST_ITEM;
|
2015-03-12 02:05:57 +03:00
|
|
|
else if (aAtkObj->role == ATK_ROLE_MATH && !IsAtkVersionAtLeast(2, 12))
|
|
|
|
aAtkObj->role = ATK_ROLE_PANEL;
|
|
|
|
else if (aAtkObj->role == ATK_ROLE_STATIC && !IsAtkVersionAtLeast(2, 16))
|
|
|
|
aAtkObj->role = ATK_ROLE_TEXT;
|
2015-03-12 15:21:33 +03:00
|
|
|
else if ((aAtkObj->role == ATK_ROLE_MATH_FRACTION ||
|
|
|
|
aAtkObj->role == ATK_ROLE_MATH_ROOT) && !IsAtkVersionAtLeast(2, 16))
|
|
|
|
aAtkObj->role = ATK_ROLE_UNKNOWN;
|
2014-02-05 01:29:12 +04:00
|
|
|
|
2012-05-02 15:13:34 +04:00
|
|
|
return aAtkObj->role;
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
2013-11-18 22:52:21 +04:00
|
|
|
static AtkAttributeSet*
|
2008-07-17 16:06:24 +04:00
|
|
|
ConvertToAtkAttributeSet(nsIPersistentProperties* aAttributes)
|
|
|
|
{
|
|
|
|
if (!aAttributes)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-07-17 16:06:24 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
AtkAttributeSet *objAttributeSet = nullptr;
|
2008-07-17 16:06:24 +04:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> propEnum;
|
|
|
|
nsresult rv = aAttributes->Enumerate(getter_AddRefs(propEnum));
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2008-07-17 16:06:24 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasMore;
|
2008-07-17 16:06:24 +04:00
|
|
|
while (NS_SUCCEEDED(propEnum->HasMoreElements(&hasMore)) && hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> sup;
|
|
|
|
rv = propEnum->GetNext(getter_AddRefs(sup));
|
|
|
|
NS_ENSURE_SUCCESS(rv, objAttributeSet);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPropertyElement> propElem(do_QueryInterface(sup));
|
|
|
|
NS_ENSURE_TRUE(propElem, objAttributeSet);
|
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString name;
|
2008-07-17 16:06:24 +04:00
|
|
|
rv = propElem->GetKey(name);
|
|
|
|
NS_ENSURE_SUCCESS(rv, objAttributeSet);
|
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
rv = propElem->GetValue(value);
|
|
|
|
NS_ENSURE_SUCCESS(rv, objAttributeSet);
|
|
|
|
|
|
|
|
AtkAttribute *objAttr = (AtkAttribute *)g_malloc(sizeof(AtkAttribute));
|
|
|
|
objAttr->name = g_strdup(name.get());
|
|
|
|
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(value).get());
|
|
|
|
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
//libspi will free it
|
|
|
|
return objAttributeSet;
|
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
AtkAttributeSet*
|
2012-05-29 05:18:45 +04:00
|
|
|
GetAttributeSet(Accessible* aAccessible)
|
2006-09-01 01:07:41 +04:00
|
|
|
{
|
2012-10-19 11:15:23 +04:00
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes = aAccessible->Attributes();
|
|
|
|
if (attributes) {
|
|
|
|
// There is no ATK state for haspopup, must use object attribute to expose
|
|
|
|
// the same info.
|
|
|
|
if (aAccessible->State() & states::HASPOPUP) {
|
|
|
|
nsAutoString unused;
|
|
|
|
attributes->SetStringProperty(NS_LITERAL_CSTRING("haspopup"),
|
|
|
|
NS_LITERAL_STRING("true"), unused);
|
2006-09-01 01:07:41 +04:00
|
|
|
}
|
|
|
|
|
2012-10-19 11:15:23 +04:00
|
|
|
return ConvertToAtkAttributeSet(attributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
2006-09-01 01:07:41 +04:00
|
|
|
}
|
|
|
|
|
2006-09-12 21:06:12 +04:00
|
|
|
AtkAttributeSet *
|
|
|
|
getAttributesCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2014-10-24 13:29:48 +04:00
|
|
|
if (accWrap)
|
|
|
|
return GetAttributeSet(accWrap);
|
|
|
|
|
|
|
|
ProxyAccessible* proxy = GetProxy(aAtkObj);
|
|
|
|
if (!proxy)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
nsAutoTArray<Attribute, 10> attrs;
|
|
|
|
proxy->Attributes(&attrs);
|
|
|
|
if (attrs.IsEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
AtkAttributeSet* objAttributeSet = nullptr;
|
|
|
|
for (uint32_t i = 0; i < attrs.Length(); i++) {
|
|
|
|
AtkAttribute *objAttr = (AtkAttribute *)g_malloc(sizeof(AtkAttribute));
|
|
|
|
objAttr->name = g_strdup(attrs[i].Name().get());
|
|
|
|
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(attrs[i].Value()).get());
|
|
|
|
objAttributeSet = g_slist_prepend(objAttributeSet, objAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return objAttributeSet;
|
2006-09-12 21:06:12 +04:00
|
|
|
}
|
|
|
|
|
2013-11-14 12:03:57 +04:00
|
|
|
const gchar*
|
|
|
|
GetLocaleCB(AtkObject* aAtkObj)
|
|
|
|
{
|
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
|
|
|
if (!accWrap)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
nsAutoString locale;
|
|
|
|
accWrap->Language(locale);
|
|
|
|
return AccessibleWrap::ReturnString(locale);
|
|
|
|
}
|
|
|
|
|
2003-04-23 09:28:41 +04:00
|
|
|
AtkObject *
|
|
|
|
getParentCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2014-09-23 16:00:15 +04:00
|
|
|
if (aAtkObj->accessible_parent)
|
|
|
|
return aAtkObj->accessible_parent;
|
|
|
|
|
|
|
|
AtkObject* atkParent = nullptr;
|
|
|
|
if (AccessibleWrap* wrapper = GetAccessibleWrap(aAtkObj)) {
|
|
|
|
Accessible* parent = wrapper->Parent();
|
|
|
|
atkParent = parent ? AccessibleWrap::GetAtkObject(parent) : nullptr;
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
|
|
|
ProxyAccessible* parent = proxy->Parent();
|
|
|
|
atkParent = parent ? GetWrapperFor(parent) : nullptr;
|
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2014-09-23 16:00:15 +04:00
|
|
|
if (atkParent)
|
|
|
|
atk_object_set_parent(aAtkObj, atkParent);
|
2007-06-04 13:39:15 +04:00
|
|
|
|
2011-07-23 12:38:33 +04:00
|
|
|
return aAtkObj->accessible_parent;
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
getChildCountCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2008-10-17 14:10:43 +04:00
|
|
|
if (!accWrap || nsAccUtils::MustPrune(accWrap)) {
|
2007-06-08 13:09:24 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-25 14:53:45 +04:00
|
|
|
return static_cast<gint>(accWrap->EmbeddedChildCount());
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
AtkObject *
|
|
|
|
refChildCB(AtkObject *aAtkObj, gint aChildIndex)
|
|
|
|
{
|
2006-08-11 10:04:10 +04:00
|
|
|
// aChildIndex should not be less than zero
|
|
|
|
if (aChildIndex < 0) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-08-11 10:04:10 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2008-10-17 14:10:43 +04:00
|
|
|
if (!accWrap || nsAccUtils::MustPrune(accWrap)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-06-08 13:09:24 +04:00
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accChild = accWrap->GetEmbeddedChildAt(aChildIndex);
|
2007-08-07 10:10:31 +04:00
|
|
|
if (!accChild)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AtkObject* childAtkObj = AccessibleWrap::GetAtkObject(accChild);
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2007-06-08 13:09:24 +04:00
|
|
|
NS_ASSERTION(childAtkObj, "Fail to get AtkObj");
|
|
|
|
if (!childAtkObj)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-01-06 09:56:56 +03:00
|
|
|
g_object_ref(childAtkObj);
|
2012-02-28 00:30:32 +04:00
|
|
|
|
|
|
|
if (aAtkObj != childAtkObj->accessible_parent)
|
2007-06-04 13:39:15 +04:00
|
|
|
atk_object_set_parent(childAtkObj, aAtkObj);
|
2012-02-28 00:30:32 +04:00
|
|
|
|
|
|
|
return childAtkObj;
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2014-10-22 04:49:28 +04:00
|
|
|
getIndexInParentCB(AtkObject* aAtkObj)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2014-10-22 04:49:28 +04:00
|
|
|
// We don't use Accessible::IndexInParent() because we don't include text
|
|
|
|
// leaf nodes as children in ATK.
|
2015-05-07 19:59:17 +03:00
|
|
|
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
|
|
|
if (ProxyAccessible* parent = proxy->Parent())
|
|
|
|
return parent->IndexOfEmbeddedChild(proxy);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2007-06-08 13:09:24 +04:00
|
|
|
if (!accWrap) {
|
|
|
|
return -1;
|
|
|
|
}
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* parent = accWrap->Parent();
|
2011-07-23 12:38:33 +04:00
|
|
|
if (!parent)
|
2006-08-15 18:37:30 +04:00
|
|
|
return -1; // No parent
|
|
|
|
|
2010-08-15 15:29:02 +04:00
|
|
|
return parent->GetIndexOfEmbeddedChild(accWrap);
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
static void
|
2012-08-22 19:56:38 +04:00
|
|
|
TranslateStates(uint64_t aState, AtkStateSet* aStateSet)
|
2007-01-28 06:58:18 +03:00
|
|
|
{
|
2014-01-21 20:24:23 +04:00
|
|
|
// atk doesn't have a read only state so read only things shouldn't be
|
|
|
|
// editable.
|
|
|
|
if (aState & states::READONLY)
|
|
|
|
aState &= ~states::EDITABLE;
|
2007-01-28 06:58:18 +03:00
|
|
|
|
|
|
|
// Convert every state to an entry in AtkStateMap
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t stateIndex = 0;
|
|
|
|
uint64_t bitMask = 1;
|
2011-04-10 03:38:06 +04:00
|
|
|
while (gAtkStateMap[stateIndex].stateMapEntryType != kNoSuchState) {
|
|
|
|
if (gAtkStateMap[stateIndex].atkState) { // There's potentially an ATK state for this
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isStateOn = (aState & bitMask) != 0;
|
2011-04-10 03:38:06 +04:00
|
|
|
if (gAtkStateMap[stateIndex].stateMapEntryType == kMapOpposite) {
|
2007-01-28 06:58:18 +03:00
|
|
|
isStateOn = !isStateOn;
|
|
|
|
}
|
|
|
|
if (isStateOn) {
|
2011-04-10 03:38:06 +04:00
|
|
|
atk_state_set_add_state(aStateSet, gAtkStateMap[stateIndex].atkState);
|
2007-01-28 06:58:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
bitMask <<= 1;
|
|
|
|
++ stateIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-21 07:30:28 +04:00
|
|
|
AtkStateSet *
|
|
|
|
refStateSetCB(AtkObject *aAtkObj)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2014-09-23 12:35:33 +04:00
|
|
|
AtkStateSet *state_set = nullptr;
|
|
|
|
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);
|
2003-04-23 09:28:41 +04:00
|
|
|
|
2014-09-23 12:35:33 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
|
|
|
if (accWrap)
|
2011-04-10 03:38:06 +04:00
|
|
|
TranslateStates(accWrap->State(), state_set);
|
2014-09-23 12:35:33 +04:00
|
|
|
else if (ProxyAccessible* proxy = GetProxy(aAtkObj))
|
|
|
|
TranslateStates(proxy->State(), state_set);
|
|
|
|
else
|
|
|
|
TranslateStates(states::DEFUNCT, state_set);
|
2004-05-18 07:26:34 +04:00
|
|
|
|
2014-09-23 12:35:33 +04:00
|
|
|
return state_set;
|
2003-04-23 09:28:41 +04:00
|
|
|
}
|
|
|
|
|
2013-10-23 03:55:27 +04:00
|
|
|
static void
|
|
|
|
UpdateAtkRelation(RelationType aType, Accessible* aAcc,
|
|
|
|
AtkRelationType aAtkType, AtkRelationSet* aAtkSet)
|
|
|
|
{
|
|
|
|
if (aAtkType == ATK_RELATION_NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AtkRelation* atkRelation =
|
|
|
|
atk_relation_set_get_relation_by_type(aAtkSet, aAtkType);
|
|
|
|
if (atkRelation)
|
|
|
|
atk_relation_set_remove(aAtkSet, atkRelation);
|
|
|
|
|
|
|
|
Relation rel(aAcc->RelationByType(aType));
|
|
|
|
nsTArray<AtkObject*> targets;
|
|
|
|
Accessible* tempAcc = nullptr;
|
|
|
|
while ((tempAcc = rel.Next()))
|
|
|
|
targets.AppendElement(AccessibleWrap::GetAtkObject(tempAcc));
|
|
|
|
|
|
|
|
if (targets.Length()) {
|
|
|
|
atkRelation = atk_relation_new(targets.Elements(),
|
|
|
|
targets.Length(), aAtkType);
|
|
|
|
atk_relation_set_add(aAtkSet, atkRelation);
|
|
|
|
g_object_unref(atkRelation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 20:29:15 +04:00
|
|
|
AtkRelationSet *
|
|
|
|
refRelationSetCB(AtkObject *aAtkObj)
|
|
|
|
{
|
2011-08-10 05:44:00 +04:00
|
|
|
AtkRelationSet* relation_set =
|
|
|
|
ATK_OBJECT_CLASS(parent_class)->ref_relation_set(aAtkObj);
|
2005-06-24 20:29:15 +04:00
|
|
|
|
2015-01-29 19:58:34 +03:00
|
|
|
const AtkRelationType typeMap[] = {
|
|
|
|
#define RELATIONTYPE(gecko, s, atk, m, i) atk,
|
|
|
|
#include "RelationTypeMap.h"
|
|
|
|
#undef RELATIONTYPE
|
|
|
|
};
|
|
|
|
|
|
|
|
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
|
|
|
|
nsTArray<RelationType> types;
|
|
|
|
nsTArray<nsTArray<ProxyAccessible*>> targetSets;
|
|
|
|
proxy->Relations(&types, &targetSets);
|
|
|
|
|
|
|
|
size_t relationCount = types.Length();
|
|
|
|
for (size_t i = 0; i < relationCount; i++) {
|
|
|
|
if (typeMap[static_cast<uint32_t>(types[i])] == ATK_RELATION_NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
size_t targetCount = targetSets[i].Length();
|
|
|
|
nsAutoTArray<AtkObject*, 5> wrappers;
|
|
|
|
for (size_t j = 0; j < targetCount; j++)
|
|
|
|
wrappers.AppendElement(GetWrapperFor(targetSets[i][j]));
|
|
|
|
|
|
|
|
AtkRelationType atkType = typeMap[static_cast<uint32_t>(types[i])];
|
|
|
|
AtkRelation* atkRelation =
|
|
|
|
atk_relation_set_get_relation_by_type(relation_set, atkType);
|
|
|
|
if (atkRelation)
|
|
|
|
atk_relation_set_remove(relation_set, atkRelation);
|
|
|
|
|
|
|
|
atkRelation = atk_relation_new(wrappers.Elements(), wrappers.Length(),
|
|
|
|
atkType);
|
|
|
|
atk_relation_set_add(relation_set, atkRelation);
|
|
|
|
g_object_unref(atkRelation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
|
2011-08-10 05:44:00 +04:00
|
|
|
if (!accWrap)
|
|
|
|
return relation_set;
|
2006-09-15 09:10:58 +04:00
|
|
|
|
2013-10-23 03:55:27 +04:00
|
|
|
#define RELATIONTYPE(geckoType, geckoTypeName, atkType, msaaType, ia2Type) \
|
|
|
|
UpdateAtkRelation(RelationType::geckoType, accWrap, atkType, relation_set);
|
2011-08-10 05:44:00 +04:00
|
|
|
|
2013-10-23 03:55:27 +04:00
|
|
|
#include "RelationTypeMap.h"
|
|
|
|
|
|
|
|
#undef RELATIONTYPE
|
2005-06-24 20:29:15 +04:00
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
return relation_set;
|
2005-06-24 20:29:15 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
// Check if aAtkObj is a valid MaiAtkObject, and return the AccessibleWrap
|
2007-06-08 13:09:24 +04:00
|
|
|
// for it.
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap*
|
|
|
|
GetAccessibleWrap(AtkObject* aAtkObj)
|
2003-04-23 09:28:41 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nullptr);
|
2014-03-08 01:35:19 +04:00
|
|
|
|
|
|
|
// Make sure its native is an AccessibleWrap not a proxy.
|
|
|
|
if (MAI_ATK_OBJECT(aAtkObj)->accWrap & IS_PROXY)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
AccessibleWrap* accWrap =
|
|
|
|
reinterpret_cast<AccessibleWrap*>(MAI_ATK_OBJECT(aAtkObj)->accWrap);
|
2007-05-11 09:51:46 +04:00
|
|
|
|
2012-04-25 15:29:40 +04:00
|
|
|
// Check if the accessible was deconstructed.
|
|
|
|
if (!accWrap)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-06-08 13:09:24 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ENSURE_TRUE(accWrap->GetAtkObject() == aAtkObj, nullptr);
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2012-09-10 17:20:26 +04:00
|
|
|
AccessibleWrap* appAccWrap = ApplicationAcc();
|
2012-04-25 15:29:40 +04:00
|
|
|
if (appAccWrap != accWrap && !accWrap->IsValidObject())
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2003-05-06 06:23:50 +04:00
|
|
|
|
2012-04-25 15:29:40 +04:00
|
|
|
return accWrap;
|
2003-05-06 06:23:50 +04:00
|
|
|
}
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
ProxyAccessible*
|
|
|
|
GetProxy(AtkObject* aObj)
|
|
|
|
{
|
|
|
|
if (!aObj || !(MAI_ATK_OBJECT(aObj)->accWrap & IS_PROXY))
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return reinterpret_cast<ProxyAccessible*>(MAI_ATK_OBJECT(aObj)->accWrap
|
|
|
|
& ~IS_PROXY);
|
|
|
|
}
|
|
|
|
|
2014-09-23 16:00:15 +04:00
|
|
|
AtkObject*
|
|
|
|
GetWrapperFor(ProxyAccessible* aProxy)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<AtkObject*>(aProxy->GetWrapper() & ~IS_PROXY);
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
static uint16_t
|
2015-01-09 23:01:39 +03:00
|
|
|
GetInterfacesForProxy(ProxyAccessible* aProxy, uint32_t aInterfaces)
|
2014-03-08 01:35:19 +04:00
|
|
|
{
|
2015-01-09 23:01:39 +03:00
|
|
|
uint16_t interfaces = 1 << MAI_INTERFACE_COMPONENT;
|
|
|
|
if (aInterfaces & Interfaces::HYPERTEXT)
|
|
|
|
interfaces |= (1 << MAI_INTERFACE_HYPERTEXT) | (1 << MAI_INTERFACE_TEXT)
|
|
|
|
| (1 << MAI_INTERFACE_EDITABLE_TEXT);
|
|
|
|
|
2015-04-29 16:55:29 +03:00
|
|
|
if (aInterfaces & Interfaces::HYPERLINK)
|
|
|
|
interfaces |= MAI_INTERFACE_HYPERLINK_IMPL;
|
|
|
|
|
|
|
|
if (aInterfaces & Interfaces::VALUE)
|
|
|
|
interfaces |= MAI_INTERFACE_VALUE;
|
|
|
|
|
|
|
|
if (aInterfaces & Interfaces::TABLE)
|
|
|
|
interfaces |= MAI_INTERFACE_TABLE;
|
|
|
|
|
|
|
|
if (aInterfaces & Interfaces::IMAGE)
|
|
|
|
interfaces |= MAI_INTERFACE_IMAGE;
|
|
|
|
|
2015-05-07 20:31:56 +03:00
|
|
|
if (aInterfaces & Interfaces::DOCUMENT)
|
|
|
|
interfaces |= MAI_INTERFACE_DOCUMENT;
|
|
|
|
|
2015-01-09 23:01:39 +03:00
|
|
|
return interfaces;
|
2014-03-08 01:35:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-09 23:01:39 +03:00
|
|
|
a11y::ProxyCreated(ProxyAccessible* aProxy, uint32_t aInterfaces)
|
2014-03-08 01:35:19 +04:00
|
|
|
{
|
2015-01-09 23:01:39 +03:00
|
|
|
GType type = GetMaiAtkType(GetInterfacesForProxy(aProxy, aInterfaces));
|
2014-03-08 01:35:19 +04:00
|
|
|
NS_ASSERTION(type, "why don't we have a type!");
|
|
|
|
|
|
|
|
AtkObject* obj =
|
|
|
|
reinterpret_cast<AtkObject *>
|
|
|
|
(g_object_new(type, nullptr));
|
|
|
|
if (!obj)
|
|
|
|
return;
|
|
|
|
|
2014-09-30 01:10:39 +04:00
|
|
|
uintptr_t inner = reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY;
|
|
|
|
atk_object_initialize(obj, reinterpret_cast<gpointer>(inner));
|
2014-03-08 01:35:19 +04:00
|
|
|
obj->role = ATK_ROLE_INVALID;
|
|
|
|
obj->layer = ATK_LAYER_INVALID;
|
|
|
|
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(obj) | IS_PROXY);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
a11y::ProxyDestroyed(ProxyAccessible* aProxy)
|
|
|
|
{
|
|
|
|
auto obj = reinterpret_cast<MaiAtkObject*>(aProxy->GetWrapper() & ~IS_PROXY);
|
2015-04-08 18:14:42 +03:00
|
|
|
obj->Shutdown();
|
2014-03-08 01:35:19 +04:00
|
|
|
g_object_unref(obj);
|
|
|
|
aProxy->SetWrapper(0);
|
|
|
|
}
|
|
|
|
|
2009-06-18 11:37:38 +04:00
|
|
|
nsresult
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::HandleAccEvent(AccEvent* aEvent)
|
2007-04-16 06:21:49 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
nsresult rv = Accessible::HandleAccEvent(aEvent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible = aEvent->GetAccessible();
|
2007-06-04 13:39:15 +04:00
|
|
|
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
|
|
|
|
|
2013-05-24 22:24:19 +04:00
|
|
|
// The accessible can become defunct if we have an xpcom event listener
|
|
|
|
// which decides it would be fun to change the DOM and flush layout.
|
|
|
|
if (accessible->IsDefunct())
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t type = aEvent->GetEventType();
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accessible);
|
2007-06-08 13:09:24 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
// We don't create ATK objects for plain text leaves, just return NS_OK in
|
|
|
|
// such case.
|
2007-06-07 06:47:30 +04:00
|
|
|
if (!atkObj) {
|
2009-09-09 13:03:14 +04:00
|
|
|
NS_ASSERTION(type == nsIAccessibleEvent::EVENT_SHOW ||
|
|
|
|
type == nsIAccessibleEvent::EVENT_HIDE,
|
2007-06-07 06:47:30 +04:00
|
|
|
"Event other than SHOW and HIDE fired for plain text leaves");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(atkObj);
|
2007-06-21 13:16:32 +04:00
|
|
|
if (!accWrap) {
|
|
|
|
return NS_OK; // Node is shut down
|
|
|
|
}
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2007-04-16 06:21:49 +04:00
|
|
|
switch (type) {
|
|
|
|
case nsIAccessibleEvent::EVENT_STATE_CHANGE:
|
2007-04-20 11:29:08 +04:00
|
|
|
return FireAtkStateChangeEvent(aEvent, atkObj);
|
|
|
|
|
2007-08-11 05:44:44 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_TEXT_REMOVED:
|
|
|
|
case nsIAccessibleEvent::EVENT_TEXT_INSERTED:
|
2007-04-20 11:29:08 +04:00
|
|
|
return FireAtkTextChangedEvent(aEvent, atkObj);
|
|
|
|
|
2007-06-18 09:47:33 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_FOCUS:
|
|
|
|
{
|
2012-05-04 10:09:22 +04:00
|
|
|
a11y::RootAccessible* rootAccWrap = accWrap->RootAccessible();
|
2007-06-18 09:47:33 +04:00
|
|
|
if (rootAccWrap && rootAccWrap->mActivated) {
|
2013-11-18 17:16:21 +04:00
|
|
|
atk_focus_tracker_notify(atkObj);
|
2007-06-25 12:28:22 +04:00
|
|
|
// Fire state change event for focus
|
2013-11-09 00:31:20 +04:00
|
|
|
atk_object_notify_state_change(atkObj, ATK_STATE_FOCUSED, true);
|
|
|
|
return NS_OK;
|
2007-06-18 09:47:33 +04:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2011-06-16 09:12:32 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_NAME_CHANGE:
|
|
|
|
{
|
2012-05-01 07:08:31 +04:00
|
|
|
nsAutoString newName;
|
|
|
|
accessible->Name(newName);
|
2013-04-17 12:29:35 +04:00
|
|
|
|
|
|
|
MaybeFireNameChange(atkObj, newName);
|
2011-06-16 09:12:32 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2014-10-22 04:49:28 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
|
|
|
|
if (accessible->HasNumericValue()) {
|
|
|
|
// Make sure this is a numeric value. Don't fire for string value changes
|
|
|
|
// (e.g. text editing) ATK values are always numeric.
|
|
|
|
g_object_notify((GObject*)atkObj, "accessible-value");
|
|
|
|
}
|
|
|
|
break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2011-11-01 04:52:27 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_SELECTION:
|
|
|
|
case nsIAccessibleEvent::EVENT_SELECTION_ADD:
|
|
|
|
case nsIAccessibleEvent::EVENT_SELECTION_REMOVE:
|
|
|
|
{
|
|
|
|
// XXX: dupe events may be fired
|
|
|
|
AccSelChangeEvent* selChangeEvent = downcast_accEvent(aEvent);
|
2012-05-29 05:18:45 +04:00
|
|
|
g_signal_emit_by_name(AccessibleWrap::GetAtkObject(selChangeEvent->Widget()),
|
2011-11-01 04:52:27 +04:00
|
|
|
"selection_changed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_SELECTION_WITHIN:
|
|
|
|
{
|
|
|
|
g_signal_emit_by_name(atkObj, "selection_changed");
|
|
|
|
break;
|
|
|
|
}
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED:
|
|
|
|
g_signal_emit_by_name(atkObj, "text_selection_changed");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED:
|
2007-06-22 13:27:22 +04:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccCaretMoveEvent* caretMoveEvent = downcast_accEvent(aEvent);
|
2007-06-22 13:27:22 +04:00
|
|
|
NS_ASSERTION(caretMoveEvent, "Event needs event data");
|
|
|
|
if (!caretMoveEvent)
|
2007-06-18 09:47:33 +04:00
|
|
|
break;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t caretOffset = caretMoveEvent->GetCaretOffset();
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "text_caret_moved", caretOffset);
|
2007-06-22 13:27:22 +04:00
|
|
|
} break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2008-07-17 16:06:24 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_TEXT_ATTRIBUTE_CHANGED:
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "text-attributes-changed");
|
2008-07-17 16:06:24 +04:00
|
|
|
break;
|
|
|
|
|
2007-06-18 09:47:33 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_MODEL_CHANGED:
|
|
|
|
g_signal_emit_by_name(atkObj, "model_changed");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_ROW_INSERT:
|
2008-01-18 06:09:10 +03:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
|
2008-01-18 05:56:38 +03:00
|
|
|
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = tableEvent->GetIndex();
|
|
|
|
int32_t numRows = tableEvent->GetCount();
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "row_inserted", rowIndex, numRows);
|
2008-01-18 06:09:10 +03:00
|
|
|
} break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_ROW_DELETE:
|
2008-01-18 06:09:10 +03:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
|
2008-01-18 05:56:38 +03:00
|
|
|
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = tableEvent->GetIndex();
|
|
|
|
int32_t numRows = tableEvent->GetCount();
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "row_deleted", rowIndex, numRows);
|
2008-01-18 06:09:10 +03:00
|
|
|
} break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_ROW_REORDER:
|
2008-01-18 06:09:10 +03:00
|
|
|
{
|
2007-06-18 09:47:33 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "row_reordered");
|
|
|
|
break;
|
2008-01-18 06:09:10 +03:00
|
|
|
}
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_INSERT:
|
2008-01-18 06:09:10 +03:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
|
2008-01-18 05:56:38 +03:00
|
|
|
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = tableEvent->GetIndex();
|
|
|
|
int32_t numCols = tableEvent->GetCount();
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "column_inserted", colIndex, numCols);
|
2008-01-18 06:09:10 +03:00
|
|
|
} break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_DELETE:
|
2008-01-18 06:09:10 +03:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccTableChangeEvent* tableEvent = downcast_accEvent(aEvent);
|
2008-01-18 05:56:38 +03:00
|
|
|
NS_ENSURE_TRUE(tableEvent, NS_ERROR_FAILURE);
|
2007-06-18 09:47:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = tableEvent->GetIndex();
|
|
|
|
int32_t numCols = tableEvent->GetCount();
|
2012-12-01 22:49:24 +04:00
|
|
|
g_signal_emit_by_name(atkObj, "column_deleted", colIndex, numCols);
|
2008-01-18 06:09:10 +03:00
|
|
|
} break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_TABLE_COLUMN_REORDER:
|
|
|
|
g_signal_emit_by_name(atkObj, "column_reordered");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_SECTION_CHANGED:
|
|
|
|
g_signal_emit_by_name(atkObj, "visible_data_changed");
|
|
|
|
break;
|
|
|
|
|
2009-09-09 13:03:14 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_SHOW:
|
2011-10-17 18:59:28 +04:00
|
|
|
return FireAtkShowHideEvent(aEvent, atkObj, true);
|
2007-06-30 06:49:32 +04:00
|
|
|
|
2009-09-09 13:03:14 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_HIDE:
|
2014-02-09 05:55:52 +04:00
|
|
|
// XXX - Handle native dialog accessibles.
|
|
|
|
if (!accessible->IsRoot() && accessible->HasARIARole() &&
|
|
|
|
accessible->ARIARole() == roles::DIALOG) {
|
|
|
|
guint id = g_signal_lookup("deactivate", MAI_TYPE_ATK_OBJECT);
|
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return FireAtkShowHideEvent(aEvent, atkObj, false);
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Because dealing with menu is very different between nsIAccessible
|
|
|
|
* and ATK, and the menu activity is important, specially transfer the
|
|
|
|
* following two event.
|
|
|
|
* Need more verification by AT test.
|
|
|
|
*/
|
|
|
|
case nsIAccessibleEvent::EVENT_MENU_START:
|
|
|
|
case nsIAccessibleEvent::EVENT_MENU_END:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_WINDOW_ACTIVATE:
|
|
|
|
{
|
2012-05-04 10:09:22 +04:00
|
|
|
accessible->AsRoot()->mActivated = true;
|
2014-02-09 05:55:52 +04:00
|
|
|
guint id = g_signal_lookup("activate", MAI_TYPE_ATK_OBJECT);
|
2007-06-18 09:47:33 +04:00
|
|
|
g_signal_emit(atkObj, id, 0);
|
2008-07-03 11:10:16 +04:00
|
|
|
|
|
|
|
// Always fire a current focus event after activation.
|
2011-09-28 05:46:11 +04:00
|
|
|
FocusMgr()->ForceFocusEvent();
|
2007-06-18 09:47:33 +04:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_WINDOW_DEACTIVATE:
|
|
|
|
{
|
2012-05-04 10:09:22 +04:00
|
|
|
accessible->AsRoot()->mActivated = false;
|
2014-02-09 05:55:52 +04:00
|
|
|
guint id = g_signal_lookup("deactivate", MAI_TYPE_ATK_OBJECT);
|
2007-06-18 09:47:33 +04:00
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
} break;
|
|
|
|
|
2011-03-26 19:06:00 +03:00
|
|
|
case nsIAccessibleEvent::EVENT_WINDOW_MAXIMIZE:
|
|
|
|
{
|
2014-02-09 05:55:52 +04:00
|
|
|
guint id = g_signal_lookup("maximize", MAI_TYPE_ATK_OBJECT);
|
2011-03-26 19:06:00 +03:00
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_WINDOW_MINIMIZE:
|
|
|
|
{
|
2014-02-09 05:55:52 +04:00
|
|
|
guint id = g_signal_lookup("minimize", MAI_TYPE_ATK_OBJECT);
|
2011-03-26 19:06:00 +03:00
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_WINDOW_RESTORE:
|
|
|
|
{
|
2014-02-09 05:55:52 +04:00
|
|
|
guint id = g_signal_lookup("restore", MAI_TYPE_ATK_OBJECT);
|
2011-03-26 19:06:00 +03:00
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
} break;
|
|
|
|
|
2007-06-18 09:47:33 +04:00
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE:
|
|
|
|
g_signal_emit_by_name (atkObj, "load_complete");
|
2014-02-09 05:55:52 +04:00
|
|
|
// XXX - Handle native dialog accessibles.
|
|
|
|
if (!accessible->IsRoot() && accessible->HasARIARole() &&
|
|
|
|
accessible->ARIARole() == roles::DIALOG) {
|
|
|
|
guint id = g_signal_lookup("activate", MAI_TYPE_ATK_OBJECT);
|
|
|
|
g_signal_emit(atkObj, id, 0);
|
|
|
|
}
|
2012-12-01 22:49:24 +04:00
|
|
|
break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD:
|
|
|
|
g_signal_emit_by_name (atkObj, "reload");
|
2012-12-01 22:49:24 +04:00
|
|
|
break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED:
|
|
|
|
g_signal_emit_by_name (atkObj, "load_stopped");
|
2012-12-01 22:49:24 +04:00
|
|
|
break;
|
2007-06-18 09:47:33 +04:00
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_MENUPOPUP_START:
|
2013-11-18 17:16:21 +04:00
|
|
|
atk_focus_tracker_notify(atkObj); // fire extra focus event
|
2011-10-17 18:59:28 +04:00
|
|
|
atk_object_notify_state_change(atkObj, ATK_STATE_VISIBLE, true);
|
|
|
|
atk_object_notify_state_change(atkObj, ATK_STATE_SHOWING, true);
|
2007-06-18 09:47:33 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIAccessibleEvent::EVENT_MENUPOPUP_END:
|
2011-10-17 18:59:28 +04:00
|
|
|
atk_object_notify_state_change(atkObj, ATK_STATE_VISIBLE, false);
|
|
|
|
atk_object_notify_state_change(atkObj, ATK_STATE_SHOWING, false);
|
2007-06-30 06:49:32 +04:00
|
|
|
break;
|
2007-04-20 11:29:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2014-09-30 18:00:26 +04:00
|
|
|
void
|
|
|
|
a11y::ProxyEvent(ProxyAccessible* aTarget, uint32_t aEventType)
|
|
|
|
{
|
|
|
|
AtkObject* wrapper = GetWrapperFor(aTarget);
|
2015-05-12 23:16:10 +03:00
|
|
|
|
|
|
|
switch (aEventType) {
|
|
|
|
case nsIAccessibleEvent::EVENT_FOCUS:
|
2014-09-30 18:00:26 +04:00
|
|
|
atk_focus_tracker_notify(wrapper);
|
|
|
|
atk_object_notify_state_change(wrapper, ATK_STATE_FOCUSED, true);
|
2015-05-12 23:16:10 +03:00
|
|
|
break;
|
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE:
|
|
|
|
g_signal_emit_by_name(wrapper, "load_complete");
|
|
|
|
break;
|
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_RELOAD:
|
|
|
|
g_signal_emit_by_name(wrapper, "reload");
|
|
|
|
break;
|
|
|
|
case nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_STOPPED:
|
|
|
|
g_signal_emit_by_name(wrapper, "load_stopped");
|
|
|
|
break;
|
|
|
|
case nsIAccessibleEvent::EVENT_MENUPOPUP_START:
|
|
|
|
atk_focus_tracker_notify(wrapper); // fire extra focus event
|
|
|
|
atk_object_notify_state_change(wrapper, ATK_STATE_VISIBLE, true);
|
|
|
|
atk_object_notify_state_change(wrapper, ATK_STATE_SHOWING, true);
|
|
|
|
break;
|
|
|
|
case nsIAccessibleEvent::EVENT_MENUPOPUP_END:
|
|
|
|
atk_object_notify_state_change(wrapper, ATK_STATE_VISIBLE, false);
|
|
|
|
atk_object_notify_state_change(wrapper, ATK_STATE_SHOWING, false);
|
|
|
|
break;
|
2014-09-30 18:00:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-20 11:29:08 +04:00
|
|
|
nsresult
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::FireAtkStateChangeEvent(AccEvent* aEvent,
|
|
|
|
AtkObject* aObject)
|
2007-04-20 11:29:08 +04:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccStateChangeEvent* event = downcast_accEvent(aEvent);
|
2007-04-20 11:29:08 +04:00
|
|
|
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isEnabled = event->IsStateEnabled();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t stateIndex = AtkStateMap::GetStateIndexFor(event->GetState());
|
2007-04-20 11:29:08 +04:00
|
|
|
if (stateIndex >= 0) {
|
2011-04-10 03:38:06 +04:00
|
|
|
NS_ASSERTION(gAtkStateMap[stateIndex].stateMapEntryType != kNoSuchState,
|
2007-04-20 11:29:08 +04:00
|
|
|
"No such state");
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
if (gAtkStateMap[stateIndex].atkState != kNone) {
|
|
|
|
NS_ASSERTION(gAtkStateMap[stateIndex].stateMapEntryType != kNoStateChange,
|
2007-04-20 11:29:08 +04:00
|
|
|
"State changes should not fired for this state");
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
if (gAtkStateMap[stateIndex].stateMapEntryType == kMapOpposite)
|
2007-04-20 11:29:08 +04:00
|
|
|
isEnabled = !isEnabled;
|
2007-04-16 06:21:49 +04:00
|
|
|
|
2007-04-20 11:29:08 +04:00
|
|
|
// Fire state change for first state if there is one to map
|
|
|
|
atk_object_notify_state_change(aObject,
|
2011-04-10 03:38:06 +04:00
|
|
|
gAtkStateMap[stateIndex].atkState,
|
2007-04-20 11:29:08 +04:00
|
|
|
isEnabled);
|
2007-04-16 06:21:49 +04:00
|
|
|
}
|
2007-04-20 11:29:08 +04:00
|
|
|
}
|
2007-04-17 10:52:52 +04:00
|
|
|
|
2007-04-20 11:29:08 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-04-17 10:52:52 +04:00
|
|
|
|
2007-04-20 11:29:08 +04:00
|
|
|
nsresult
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::FireAtkTextChangedEvent(AccEvent* aEvent,
|
|
|
|
AtkObject* aObject)
|
2007-04-20 11:29:08 +04:00
|
|
|
{
|
2010-08-25 06:08:28 +04:00
|
|
|
AccTextChangeEvent* event = downcast_accEvent(aEvent);
|
2007-04-20 11:29:08 +04:00
|
|
|
NS_ENSURE_TRUE(event, NS_ERROR_FAILURE);
|
2007-04-17 10:52:52 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t start = event->GetStartOffset();
|
|
|
|
uint32_t length = event->GetLength();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isInserted = event->IsTextInserted();
|
|
|
|
bool isFromUserInput = aEvent->IsFromUserInput();
|
2012-07-30 18:20:58 +04:00
|
|
|
char* signal_name = nullptr;
|
2011-03-25 01:03:14 +03:00
|
|
|
|
2011-07-04 17:49:44 +04:00
|
|
|
if (gAvailableAtkSignals == eUnknown)
|
2011-12-21 15:26:08 +04:00
|
|
|
gAvailableAtkSignals =
|
|
|
|
g_signal_lookup("text-insert", G_OBJECT_TYPE(aObject)) ?
|
|
|
|
eHaveNewAtkTextSignals : eNoNewAtkSignals;
|
2011-07-04 17:49:44 +04:00
|
|
|
|
|
|
|
if (gAvailableAtkSignals == eNoNewAtkSignals) {
|
|
|
|
// XXX remove this code and the gHaveNewTextSignals check when we can
|
|
|
|
// stop supporting old atk since it doesn't really work anyway
|
|
|
|
// see bug 619002
|
|
|
|
signal_name = g_strconcat(isInserted ? "text_changed::insert" :
|
|
|
|
"text_changed::delete",
|
2013-04-03 04:33:43 +04:00
|
|
|
isFromUserInput ? "" : kNonUserInputEvent, nullptr);
|
2011-07-04 17:49:44 +04:00
|
|
|
g_signal_emit_by_name(aObject, signal_name, start, length);
|
|
|
|
} else {
|
|
|
|
nsAutoString text;
|
|
|
|
event->GetModifiedText(text);
|
|
|
|
signal_name = g_strconcat(isInserted ? "text-insert" : "text-remove",
|
2013-04-03 04:33:43 +04:00
|
|
|
isFromUserInput ? "" : "::system", nullptr);
|
2011-07-04 17:49:44 +04:00
|
|
|
g_signal_emit_by_name(aObject, signal_name, start, length,
|
|
|
|
NS_ConvertUTF16toUTF8(text).get());
|
|
|
|
}
|
2007-09-19 01:40:04 +04:00
|
|
|
|
2011-07-04 17:49:44 +04:00
|
|
|
g_free(signal_name);
|
|
|
|
return NS_OK;
|
2007-04-20 11:29:08 +04:00
|
|
|
}
|
|
|
|
|
2007-06-30 06:49:32 +04:00
|
|
|
nsresult
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap::FireAtkShowHideEvent(AccEvent* aEvent,
|
|
|
|
AtkObject* aObject, bool aIsAdded)
|
2007-06-30 06:49:32 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t indexInParent = getIndexInParentCB(aObject);
|
2008-01-30 00:41:58 +03:00
|
|
|
AtkObject *parentObject = getParentCB(aObject);
|
2007-06-30 06:49:32 +04:00
|
|
|
NS_ENSURE_STATE(parentObject);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isFromUserInput = aEvent->IsFromUserInput();
|
2007-09-19 01:40:04 +04:00
|
|
|
char *signal_name = g_strconcat(aIsAdded ? "children_changed::add" : "children_changed::remove",
|
2013-04-03 04:33:43 +04:00
|
|
|
isFromUserInput ? "" : kNonUserInputEvent, nullptr);
|
|
|
|
g_signal_emit_by_name(parentObject, signal_name, indexInParent, aObject, nullptr);
|
2007-09-19 01:40:04 +04:00
|
|
|
g_free(signal_name);
|
2007-06-30 06:49:32 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|