17285
|
1 |
diff --git a/accessible/src/atk/nsAccessibleWrap.cpp b/accessible/src/atk/nsAccessibleWrap.cpp
|
|
2 |
--- a/accessible/src/atk/nsAccessibleWrap.cpp
|
|
3 |
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
|
|
4 |
@@ -920,20 +920,20 @@ refChildCB(AtkObject *aAtkObj, gint aChi
|
|
5 |
if (!accChild)
|
|
6 |
return nsnull;
|
|
7 |
|
|
8 |
AtkObject* childAtkObj = nsAccessibleWrap::GetAtkObject(accChild);
|
|
9 |
|
|
10 |
NS_ASSERTION(childAtkObj, "Fail to get AtkObj");
|
|
11 |
if (!childAtkObj)
|
|
12 |
return nsnull;
|
|
13 |
+ g_object_ref(childAtkObj);
|
|
14 |
|
|
15 |
//this will addref parent
|
|
16 |
atk_object_set_parent(childAtkObj, aAtkObj);
|
|
17 |
- g_object_ref(childAtkObj);
|
|
18 |
return childAtkObj;
|
|
19 |
}
|
|
20 |
|
|
21 |
gint
|
|
22 |
getIndexInParentCB(AtkObject *aAtkObj)
|
|
23 |
{
|
|
24 |
// We don't use nsIAccessible::GetIndexInParent() because
|
|
25 |
// for ATK we don't want to include text leaf nodes as children
|
|
26 |
diff --git a/accessible/src/atk/nsAppRootAccessible.cpp b/accessible/src/atk/nsAppRootAccessible.cpp
|
|
27 |
--- a/accessible/src/atk/nsAppRootAccessible.cpp
|
|
28 |
+++ b/accessible/src/atk/nsAppRootAccessible.cpp
|
|
29 |
@@ -629,44 +629,63 @@ nsApplicationAccessibleWrap::GetNativeIn
|
|
30 |
mAtkObject->role = ATK_ROLE_INVALID;
|
|
31 |
mAtkObject->layer = ATK_LAYER_INVALID;
|
|
32 |
}
|
|
33 |
|
|
34 |
*aOutAccessible = mAtkObject;
|
|
35 |
return NS_OK;
|
|
36 |
}
|
|
37 |
|
|
38 |
+struct AtkRootAccessibleAddedEvent {
|
|
39 |
+ AtkObject *app_accessible;
|
|
40 |
+ AtkObject *root_accessible;
|
|
41 |
+ PRUint32 index;
|
|
42 |
+};
|
|
43 |
+
|
|
44 |
+gboolean fireRootAccessibleAddedCB(gpointer data)
|
|
45 |
+{
|
|
46 |
+ AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)data;
|
|
47 |
+ g_signal_emit_by_name(eventData->app_accessible, "children_changed::add",
|
|
48 |
+ eventData->index, eventData->root_accessible, NULL);
|
|
49 |
+ g_object_unref(eventData->app_accessible);
|
|
50 |
+ g_object_unref(eventData->root_accessible);
|
|
51 |
+ free(data);
|
|
52 |
+
|
|
53 |
+ return FALSE;
|
|
54 |
+}
|
|
55 |
+
|
|
56 |
nsresult
|
|
57 |
nsApplicationAccessibleWrap::AddRootAccessible(nsIAccessible *aRootAccWrap)
|
|
58 |
{
|
|
59 |
NS_ENSURE_ARG_POINTER(aRootAccWrap);
|
|
60 |
|
|
61 |
// add by weak reference
|
|
62 |
nsresult rv = nsApplicationAccessible::AddRootAccessible(aRootAccWrap);
|
|
63 |
NS_ENSURE_SUCCESS(rv, rv);
|
|
64 |
|
|
65 |
AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
|
|
66 |
atk_object_set_parent(atkAccessible, mAtkObject);
|
|
67 |
|
|
68 |
PRUint32 count = 0;
|
|
69 |
mChildren->GetLength(&count);
|
|
70 |
- g_signal_emit_by_name(mAtkObject, "children_changed::add", count - 1,
|
|
71 |
- atkAccessible, NULL);
|
|
72 |
|
|
73 |
-#ifdef MAI_LOGGING
|
|
74 |
- if (NS_SUCCEEDED(rv)) {
|
|
75 |
- MAI_LOG_DEBUG(("\nAdd RootAcc=%p OK, count=%d\n",
|
|
76 |
- (void*)aRootAccWrap, count));
|
|
77 |
+ // Emit children_changed::add in a timeout
|
|
78 |
+ // to make sure aRootAccWrap is fully initialized.
|
|
79 |
+ AtkRootAccessibleAddedEvent* eventData = (AtkRootAccessibleAddedEvent*)
|
|
80 |
+ malloc(sizeof(AtkRootAccessibleAddedEvent));
|
|
81 |
+ if (eventData) {
|
|
82 |
+ eventData->app_accessible = mAtkObject;
|
|
83 |
+ eventData->root_accessible = atkAccessible;
|
|
84 |
+ eventData->index = count -1;
|
|
85 |
+ g_object_ref(mAtkObject);
|
|
86 |
+ g_object_ref(atkAccessible);
|
|
87 |
+ g_timeout_add(0, fireRootAccessibleAddedCB, eventData);
|
|
88 |
}
|
|
89 |
- else
|
|
90 |
- MAI_LOG_DEBUG(("\nAdd RootAcc=%p Failed, count=%d\n",
|
|
91 |
- (void*)aRootAccWrap, count));
|
|
92 |
-#endif
|
|
93 |
|
|
94 |
- return rv;
|
|
95 |
+ return NS_OK;
|
|
96 |
}
|
|
97 |
|
|
98 |
nsresult
|
|
99 |
nsApplicationAccessibleWrap::RemoveRootAccessible(nsIAccessible *aRootAccWrap)
|
|
100 |
{
|
|
101 |
NS_ENSURE_ARG_POINTER(aRootAccWrap);
|
|
102 |
|
|
103 |
PRUint32 index = 0;
|
|
104 |
@@ -676,33 +695,19 @@ nsApplicationAccessibleWrap::RemoveRootA
|
|
105 |
nsCOMPtr<nsIWeakReference> weakPtr = do_GetWeakReference(aRootAccWrap);
|
|
106 |
rv = mChildren->IndexOf(0, weakPtr, &index);
|
|
107 |
|
|
108 |
AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
|
|
109 |
atk_object_set_parent(atkAccessible, NULL);
|
|
110 |
g_signal_emit_by_name(mAtkObject, "children_changed::remove", index,
|
|
111 |
atkAccessible, NULL);
|
|
112 |
|
|
113 |
-#ifdef MAI_LOGGING
|
|
114 |
- PRUint32 count = 0;
|
|
115 |
- mChildren->GetLength(&count);
|
|
116 |
-
|
|
117 |
- if (NS_SUCCEEDED(rv)) {
|
|
118 |
- rv = mChildren->RemoveElementAt(index);
|
|
119 |
- MAI_LOG_DEBUG(("\nRemove RootAcc=%p, count=%d\n",
|
|
120 |
- (void*)aRootAccWrap, (count-1)));
|
|
121 |
- }
|
|
122 |
- else
|
|
123 |
- MAI_LOG_DEBUG(("\nFail to Remove RootAcc=%p, count=%d\n",
|
|
124 |
- (void*)aRootAccWrap, count));
|
|
125 |
-#else
|
|
126 |
NS_ENSURE_SUCCESS(rv, rv);
|
|
127 |
rv = mChildren->RemoveElementAt(index);
|
|
128 |
|
|
129 |
-#endif
|
|
130 |
InvalidateChildren();
|
|
131 |
return rv;
|
|
132 |
}
|
|
133 |
|
|
134 |
void
|
|
135 |
nsApplicationAccessibleWrap::PreCreate()
|
|
136 |
{
|
|
137 |
if (!sATKChecked) {
|