gecko-dev/accessible/atk/ApplicationAccessibleWrap.cpp

170 строки
4.9 KiB
C++
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
Bug 653086 - clean up editor configuration in a11y files r=fernando From 4a69f14cec60e25aca096b75b1be265b11a31244 Mon Sep 17 00:00:00 2001 --- accessible/src/atk/AtkSocketAccessible.cpp | 3 +-- accessible/src/atk/AtkSocketAccessible.h | 3 +-- accessible/src/atk/nsARIAGridAccessibleWrap.h | 2 +- accessible/src/atk/nsAccessNodeWrap.cpp | 2 +- accessible/src/atk/nsAccessNodeWrap.h | 2 +- accessible/src/atk/nsAccessibleRelationWrap.h | 2 +- accessible/src/atk/nsAccessibleWrap.cpp | 2 +- accessible/src/atk/nsAccessibleWrap.h | 2 +- accessible/src/atk/nsApplicationAccessibleWrap.cpp | 2 +- accessible/src/atk/nsApplicationAccessibleWrap.h | 2 +- accessible/src/atk/nsDocAccessibleWrap.cpp | 2 +- accessible/src/atk/nsDocAccessibleWrap.h | 2 +- accessible/src/atk/nsHTMLImageAccessibleWrap.h | 2 +- accessible/src/atk/nsHTMLTableAccessibleWrap.h | 2 +- accessible/src/atk/nsHyperTextAccessibleWrap.h | 2 +- accessible/src/atk/nsMai.h | 2 +- accessible/src/atk/nsMaiHyperlink.cpp | 2 +- accessible/src/atk/nsMaiHyperlink.h | 2 +- accessible/src/atk/nsMaiInterfaceAction.cpp | 2 +- accessible/src/atk/nsMaiInterfaceAction.h | 2 +- accessible/src/atk/nsMaiInterfaceComponent.cpp | 3 +-- accessible/src/atk/nsMaiInterfaceComponent.h | 3 +-- accessible/src/atk/nsMaiInterfaceDocument.cpp | 2 +- accessible/src/atk/nsMaiInterfaceDocument.h | 2 +- accessible/src/atk/nsMaiInterfaceEditableText.cpp | 2 +- accessible/src/atk/nsMaiInterfaceEditableText.h | 2 +- accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp | 2 +- accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h | 2 +- accessible/src/atk/nsMaiInterfaceHypertext.cpp | 2 +- accessible/src/atk/nsMaiInterfaceHypertext.h | 2 +- accessible/src/atk/nsMaiInterfaceImage.cpp | 2 +- accessible/src/atk/nsMaiInterfaceImage.h | 2 +- accessible/src/atk/nsMaiInterfaceSelection.cpp | 2 +- accessible/src/atk/nsMaiInterfaceSelection.h | 2 +- accessible/src/atk/nsMaiInterfaceTable.cpp | 2 +- accessible/src/atk/nsMaiInterfaceTable.h | 2 +- accessible/src/atk/nsMaiInterfaceText.cpp | 2 +- accessible/src/atk/nsMaiInterfaceText.h | 2 +- accessible/src/atk/nsMaiInterfaceValue.cpp | 2 +- accessible/src/atk/nsMaiInterfaceValue.h | 2 +- accessible/src/atk/nsRoleMap.h | 2 +- accessible/src/atk/nsRootAccessibleWrap.cpp | 2 +- accessible/src/atk/nsRootAccessibleWrap.h | 2 +- accessible/src/atk/nsStateMap.h | 2 +- accessible/src/atk/nsTextAccessibleWrap.h | 2 +- accessible/src/atk/nsXULListboxAccessibleWrap.h | 2 +- accessible/src/atk/nsXULMenuAccessibleWrap.h | 2 +- accessible/src/atk/nsXULTreeGridAccessibleWrap.h | 2 +- 48 files changed, 48 insertions(+), 52 deletions(-)
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/. */
#include "ApplicationAccessibleWrap.h"
#include "nsCOMPtr.h"
#include "nsMai.h"
#include "nsAutoPtr.h"
#include "nsAccessibilityService.h"
#include <gtk/gtk.h>
#include <atk/atk.h>
using namespace mozilla;
using namespace mozilla::a11y;
// ApplicationAccessibleWrap
ApplicationAccessibleWrap::ApplicationAccessibleWrap():
ApplicationAccessible()
{
}
ApplicationAccessibleWrap::~ApplicationAccessibleWrap()
{
AccessibleWrap::ShutdownAtkObject();
}
gboolean
toplevel_event_watcher(GSignalInvocationHint* ihint,
guint n_param_values,
const GValue* param_values,
gpointer data)
{
static GQuark sQuark_gecko_acc_obj = 0;
if (!sQuark_gecko_acc_obj)
sQuark_gecko_acc_obj = g_quark_from_static_string("GeckoAccObj");
if (nsAccessibilityService::IsShutdown())
return TRUE;
GObject* object = reinterpret_cast<GObject*>(g_value_get_object(param_values));
if (!GTK_IS_WINDOW(object))
return TRUE;
AtkObject* child = gtk_widget_get_accessible(GTK_WIDGET(object));
// GTK native dialog
if (!IS_MAI_OBJECT(child) &&
(atk_object_get_role(child) == ATK_ROLE_DIALOG)) {
if (data == reinterpret_cast<gpointer>(nsIAccessibleEvent::EVENT_SHOW)) {
// Attach the dialog accessible to app accessible tree
Accessible* windowAcc = GetAccService()->AddNativeRootAccessible(child);
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj,
reinterpret_cast<gpointer>(windowAcc));
} else {
// Deattach the dialog accessible
Accessible* windowAcc =
reinterpret_cast<Accessible*>
(g_object_get_qdata(G_OBJECT(child), sQuark_gecko_acc_obj));
if (windowAcc) {
GetAccService()->RemoveNativeRootAccessible(windowAcc);
g_object_set_qdata(G_OBJECT(child), sQuark_gecko_acc_obj, nullptr);
}
}
}
return TRUE;
}
ENameValueFlag
ApplicationAccessibleWrap::Name(nsString& aName)
{
// ATK doesn't provide a way to obtain an application name (for example,
// Firefox or Thunderbird) like IA2 does. Thus let's return an application
// name as accessible name that was used to get a branding name (for example,
// Minefield aka nightly Firefox or Daily aka nightly Thunderbird).
GetAppName(aName);
return eNameOK;
}
NS_IMETHODIMP
ApplicationAccessibleWrap::GetNativeInterface(void** aOutAccessible)
{
*aOutAccessible = nullptr;
if (!mAtkObject) {
mAtkObject =
reinterpret_cast<AtkObject *>
(g_object_new(MAI_TYPE_ATK_OBJECT, nullptr));
NS_ENSURE_TRUE(mAtkObject, NS_ERROR_OUT_OF_MEMORY);
atk_object_initialize(mAtkObject, this);
mAtkObject->role = ATK_ROLE_INVALID;
mAtkObject->layer = ATK_LAYER_INVALID;
}
*aOutAccessible = mAtkObject;
return NS_OK;
}
struct AtkRootAccessibleAddedEvent {
AtkObject *app_accessible;
AtkObject *root_accessible;
uint32_t index;
};
gboolean fireRootAccessibleAddedCB(gpointer data)
{
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
eventData->index, eventData->root_accessible, nullptr);
g_object_unref(eventData->app_accessible);
g_object_unref(eventData->root_accessible);
free(data);
return FALSE;
}
bool
ApplicationAccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aChild)
{
if (!ApplicationAccessible::InsertChildAt(aIdx, aChild))
return false;
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
atk_object_set_parent(atkAccessible, mAtkObject);
uint32_t count = mChildren.Length();
// Emit children_changed::add in a timeout
// to make sure aRootAccWrap is fully initialized.
AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)
malloc(sizeof(AtkRootAccessibleAddedEvent));
if (eventData) {
eventData->app_accessible = mAtkObject;
eventData->root_accessible = atkAccessible;
eventData->index = count -1;
g_object_ref(mAtkObject);
g_object_ref(atkAccessible);
g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
}
return true;
}
bool
ApplicationAccessibleWrap::RemoveChild(Accessible* aChild)
{
int32_t index = aChild->IndexInParent();
AtkObject* atkAccessible = AccessibleWrap::GetAtkObject(aChild);
atk_object_set_parent(atkAccessible, nullptr);
g_signal_emit_by_name(mAtkObject, "children_changed::remove", index,
atkAccessible, nullptr);
return ApplicationAccessible::RemoveChild(aChild);
}