diff --git a/accessible/src/atk/nsAccessNodeWrap.cpp b/accessible/src/atk/nsAccessNodeWrap.cpp
index 223fdc25ca5..741e4f09dc1 100644
--- a/accessible/src/atk/nsAccessNodeWrap.cpp
+++ b/accessible/src/atk/nsAccessNodeWrap.cpp
@@ -67,6 +67,9 @@ nsAccessNodeWrap::~nsAccessNodeWrap()
void nsAccessNodeWrap::InitAccessibility()
{
nsAccessNode::InitXPAccessibility();
+
+ // Init accessibility for ATK
+ nsAppRootAccessible::Load();
}
void nsAccessNodeWrap::ShutdownAccessibility()
diff --git a/accessible/src/atk/nsAppRootAccessible.cpp b/accessible/src/atk/nsAppRootAccessible.cpp
index bf60b1ac99a..19dcef8a5c8 100644
--- a/accessible/src/atk/nsAppRootAccessible.cpp
+++ b/accessible/src/atk/nsAppRootAccessible.cpp
@@ -51,6 +51,7 @@
typedef GType (* AtkGetTypeType) (void);
GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
static PRBool sATKChecked = PR_FALSE;
+static PRBool sInitialized = PR_FALSE;
static const char sATKLibName[] = "libatk-1.0.so";
static const char sATKHyperlinkImplGetTypeSymbol[] = "atk_hyperlink_impl_get_type";
@@ -61,6 +62,7 @@ static nsAppRootAccessible *sAppRoot = nsnull;
static guint (* gail_add_global_event_listener) (GSignalEmissionHook listener,
const gchar *event_type);
static void (* gail_remove_global_event_listener) (guint remove_listener);
+static AtkObject * (*gail_get_root) (void);
/* maiutil */
@@ -218,6 +220,7 @@ mai_util_class_init(MaiUtilClass *klass)
// save gail function pointer
gail_add_global_event_listener = atk_class->add_global_event_listener;
gail_remove_global_event_listener = atk_class->remove_global_event_listener;
+ gail_get_root = atk_class->get_root;
atk_class->add_global_event_listener =
mai_util_add_global_event_listener;
@@ -433,9 +436,15 @@ mai_util_get_root(void)
{
nsAppRootAccessible *root = nsAppRootAccessible::Create();
- if (!root)
- return nsnull;
- return root->GetAtkObject();
+ if (root)
+ return root->GetAtkObject();
+
+ // We've shutdown, try to use gail instead
+ // (to avoid assert in spi_atk_tidy_windows())
+ if (gail_get_root)
+ return gail_get_root();
+
+ return nsnull;
}
G_CONST_RETURN gchar *
@@ -515,37 +524,6 @@ nsAppRootAccessible::~nsAppRootAccessible()
/* virtual functions */
-#if 0
-#ifdef MAI_LOGGING
-void
-nsAppRootAccessible::DumpMaiObjectInfo(int aDepth)
-{
- --aDepth;
- if (aDepth < 0)
- return;
- g_print("nsAppRootAccessible: this=0x%x, aDepth=%d, type=%s\n",
- (unsigned int)this, aDepth, "nsAppRootAccessible");
- gint nChild = GetChildCount();
- g_print("#child=%d
\n", nChild);
- g_print("Iface num: 1=component, 2=action, 3=value, 4=editabletext,"
- "5=hyperlink, 6=hypertext, 7=selection, 8=table, 9=text\n");
- g_print("