OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/accessibility/platform/ax_platform_node_auralinux.h" | 5 #include "ui/accessibility/platform/ax_platform_node_auralinux.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "ui/accessibility/ax_node_data.h" | 9 #include "ui/accessibility/ax_node_data.h" |
10 #include "ui/accessibility/platform/atk_util_auralinux.h" | 10 #include "ui/accessibility/platform/atk_util_auralinux.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 AtkObject* atk_object) { | 79 AtkObject* atk_object) { |
80 ui::AXPlatformNodeAuraLinux* obj = | 80 ui::AXPlatformNodeAuraLinux* obj = |
81 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 81 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
82 if (!obj) | 82 if (!obj) |
83 return nullptr; | 83 return nullptr; |
84 | 84 |
85 return obj->GetStringAttribute( | 85 return obj->GetStringAttribute( |
86 ui::AX_ATTR_DESCRIPTION).c_str(); | 86 ui::AX_ATTR_DESCRIPTION).c_str(); |
87 } | 87 } |
88 | 88 |
| 89 static gint ax_platform_node_auralinux_get_index_in_parent( |
| 90 AtkObject* atk_object) { |
| 91 ui::AXPlatformNodeAuraLinux* obj = |
| 92 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
| 93 |
| 94 if (!obj || !obj->GetParent()) |
| 95 return -1; |
| 96 |
| 97 AtkObject* obj_parent = obj->GetParent(); |
| 98 |
| 99 unsigned child_count = atk_object_get_n_accessible_children(obj_parent); |
| 100 for (unsigned index = 0; index < child_count; index++) { |
| 101 AtkObject* child = atk_object_ref_accessible_child(obj_parent, index); |
| 102 bool atk_object_found = child == atk_object; |
| 103 g_object_unref(child); |
| 104 if (atk_object_found) |
| 105 return index; |
| 106 } |
| 107 |
| 108 return obj->GetIndexInParent(); |
| 109 } |
| 110 |
89 static AtkObject* ax_platform_node_auralinux_get_parent(AtkObject* atk_object) { | 111 static AtkObject* ax_platform_node_auralinux_get_parent(AtkObject* atk_object) { |
90 ui::AXPlatformNodeAuraLinux* obj = | 112 ui::AXPlatformNodeAuraLinux* obj = |
91 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 113 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
92 if (!obj) | 114 if (!obj) |
93 return nullptr; | 115 return nullptr; |
94 | 116 |
95 return obj->GetParent(); | 117 return obj->GetParent(); |
96 } | 118 } |
97 | 119 |
98 static gint ax_platform_node_auralinux_get_n_children(AtkObject* atk_object) { | 120 static gint ax_platform_node_auralinux_get_n_children(AtkObject* atk_object) { |
(...skipping 11 matching lines...) Expand all Loading... |
110 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 132 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
111 if (!obj) | 133 if (!obj) |
112 return nullptr; | 134 return nullptr; |
113 | 135 |
114 AtkObject* result = obj->ChildAtIndex(index); | 136 AtkObject* result = obj->ChildAtIndex(index); |
115 if (result) | 137 if (result) |
116 g_object_ref(result); | 138 g_object_ref(result); |
117 return result; | 139 return result; |
118 } | 140 } |
119 | 141 |
| 142 static AtkRelationSet* ax_platform_node_auralinux_ref_relation_set( |
| 143 AtkObject* atk_object) { |
| 144 ui::AXPlatformNodeAuraLinux* obj = |
| 145 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
| 146 AtkRelationSet* atk_relation_set = |
| 147 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> |
| 148 ref_relation_set(atk_object); |
| 149 |
| 150 if (!obj) |
| 151 return atk_relation_set; |
| 152 |
| 153 obj->GetAtkRelations(atk_relation_set); |
| 154 return atk_relation_set; |
| 155 } |
| 156 |
120 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { | 157 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { |
121 ui::AXPlatformNodeAuraLinux* obj = | 158 ui::AXPlatformNodeAuraLinux* obj = |
122 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 159 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
123 if (!obj) | 160 if (!obj) |
124 return ATK_ROLE_INVALID; | 161 return ATK_ROLE_INVALID; |
125 return obj->GetAtkRole(); | 162 return obj->GetAtkRole(); |
126 } | 163 } |
127 | 164 |
128 static AtkStateSet* ax_platform_node_auralinux_ref_state_set( | 165 static AtkStateSet* ax_platform_node_auralinux_ref_state_set( |
129 AtkObject* atk_object) { | 166 AtkObject* atk_object) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 205 |
169 gobject_class->finalize = ax_platform_node_auralinux_finalize; | 206 gobject_class->finalize = ax_platform_node_auralinux_finalize; |
170 klass->initialize = ax_platform_node_auralinux_init; | 207 klass->initialize = ax_platform_node_auralinux_init; |
171 klass->get_name = ax_platform_node_auralinux_get_name; | 208 klass->get_name = ax_platform_node_auralinux_get_name; |
172 klass->get_description = ax_platform_node_auralinux_get_description; | 209 klass->get_description = ax_platform_node_auralinux_get_description; |
173 klass->get_parent = ax_platform_node_auralinux_get_parent; | 210 klass->get_parent = ax_platform_node_auralinux_get_parent; |
174 klass->get_n_children = ax_platform_node_auralinux_get_n_children; | 211 klass->get_n_children = ax_platform_node_auralinux_get_n_children; |
175 klass->ref_child = ax_platform_node_auralinux_ref_child; | 212 klass->ref_child = ax_platform_node_auralinux_ref_child; |
176 klass->get_role = ax_platform_node_auralinux_get_role; | 213 klass->get_role = ax_platform_node_auralinux_get_role; |
177 klass->ref_state_set = ax_platform_node_auralinux_ref_state_set; | 214 klass->ref_state_set = ax_platform_node_auralinux_ref_state_set; |
| 215 klass->get_index_in_parent = ax_platform_node_auralinux_get_index_in_parent; |
| 216 klass->ref_relation_set = ax_platform_node_auralinux_ref_relation_set; |
178 } | 217 } |
179 | 218 |
180 GType ax_platform_node_auralinux_get_type() { | 219 GType ax_platform_node_auralinux_get_type() { |
181 static volatile gsize type_volatile = 0; | 220 static volatile gsize type_volatile = 0; |
182 | 221 |
183 if (g_once_init_enter(&type_volatile)) { | 222 if (g_once_init_enter(&type_volatile)) { |
184 static const GTypeInfo tinfo = { | 223 static const GTypeInfo tinfo = { |
185 sizeof(AXPlatformNodeAuraLinuxClass), | 224 sizeof(AXPlatformNodeAuraLinuxClass), |
186 (GBaseInitFunc) 0, | 225 (GBaseInitFunc) 0, |
187 (GBaseFinalizeFunc) 0, | 226 (GBaseFinalizeFunc) 0, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 if (state & (1 << ui::AX_STATE_FOCUSED)) | 347 if (state & (1 << ui::AX_STATE_FOCUSED)) |
309 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); | 348 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); |
310 if (state & (1 << ui::AX_STATE_PRESSED)) | 349 if (state & (1 << ui::AX_STATE_PRESSED)) |
311 atk_state_set_add_state(state_set, ATK_STATE_PRESSED); | 350 atk_state_set_add_state(state_set, ATK_STATE_PRESSED); |
312 if (state & (1 << ui::AX_STATE_SELECTABLE)) | 351 if (state & (1 << ui::AX_STATE_SELECTABLE)) |
313 atk_state_set_add_state(state_set, ATK_STATE_SELECTABLE); | 352 atk_state_set_add_state(state_set, ATK_STATE_SELECTABLE); |
314 if (state & (1 << ui::AX_STATE_SELECTED)) | 353 if (state & (1 << ui::AX_STATE_SELECTED)) |
315 atk_state_set_add_state(state_set, ATK_STATE_SELECTED); | 354 atk_state_set_add_state(state_set, ATK_STATE_SELECTED); |
316 } | 355 } |
317 | 356 |
| 357 void AXPlatformNodeAuraLinux::GetAtkRelations(AtkRelationSet* atk_relation_set) |
| 358 { |
| 359 } |
| 360 |
318 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() | 361 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() |
319 : atk_object_(nullptr) { | 362 : atk_object_(nullptr) { |
320 } | 363 } |
321 | 364 |
322 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { | 365 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { |
323 g_object_unref(atk_object_); | 366 g_object_unref(atk_object_); |
324 } | 367 } |
325 | 368 |
326 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { | 369 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { |
327 // Initialize ATK. | 370 // Initialize ATK. |
(...skipping 11 matching lines...) Expand all Loading... |
339 } | 382 } |
340 | 383 |
341 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 384 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
342 } | 385 } |
343 | 386 |
344 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 387 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
345 return 0; | 388 return 0; |
346 } | 389 } |
347 | 390 |
348 } // namespace ui | 391 } // namespace ui |
OLD | NEW |