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 | |
dmazzoni
2015/03/23 22:19:57
nit: get rid of this blank line at the beginning o
| |
92 ui::AXPlatformNodeAuraLinux* obj = | |
93 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
94 | |
95 if (!obj || !obj->GetParent()) | |
96 return -1; | |
97 | |
98 AtkObject* obj_parent = obj->GetParent(); | |
99 | |
100 unsigned child_count = atk_object_get_n_accessible_children(obj_parent); | |
101 for (unsigned index = 0; index < child_count; index++) { | |
102 AtkObject* child = atk_object_ref_accessible_child(obj_parent, index); | |
103 bool atk_object_found = (child == atk_object)?true:false; | |
dmazzoni
2015/03/23 22:19:57
nit: git rid of "?true:false", it's not needed
| |
104 g_object_unref(child); | |
dmazzoni
2015/03/23 22:19:57
in a separate changelist, could you look into the
| |
105 if (atk_object_found) | |
106 return index; | |
107 } | |
108 | |
109 return obj->GetIndexInParent(); | |
110 } | |
111 | |
89 static AtkObject* ax_platform_node_auralinux_get_parent(AtkObject* atk_object) { | 112 static AtkObject* ax_platform_node_auralinux_get_parent(AtkObject* atk_object) { |
90 ui::AXPlatformNodeAuraLinux* obj = | 113 ui::AXPlatformNodeAuraLinux* obj = |
91 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 114 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
92 if (!obj) | 115 if (!obj) |
93 return nullptr; | 116 return nullptr; |
94 | 117 |
95 return obj->GetParent(); | 118 return obj->GetParent(); |
96 } | 119 } |
97 | 120 |
98 static gint ax_platform_node_auralinux_get_n_children(AtkObject* atk_object) { | 121 static gint ax_platform_node_auralinux_get_n_children(AtkObject* atk_object) { |
(...skipping 11 matching lines...) Expand all Loading... | |
110 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 133 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
111 if (!obj) | 134 if (!obj) |
112 return nullptr; | 135 return nullptr; |
113 | 136 |
114 AtkObject* result = obj->ChildAtIndex(index); | 137 AtkObject* result = obj->ChildAtIndex(index); |
115 if (result) | 138 if (result) |
116 g_object_ref(result); | 139 g_object_ref(result); |
117 return result; | 140 return result; |
118 } | 141 } |
119 | 142 |
143 static AtkRelationSet* ax_platform_node_auralinux_ref_relation_set( | |
144 AtkObject* atk_object) { | |
145 ui::AXPlatformNodeAuraLinux* obj = | |
146 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
147 AtkRelationSet* atk_relation_set = | |
148 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> | |
149 ref_relation_set(atk_object); | |
150 | |
151 if (!obj) | |
152 return atk_relation_set; | |
153 | |
154 obj->GetAtkRelation(atk_relation_set); | |
155 return atk_relation_set; | |
156 } | |
157 | |
120 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { | 158 static AtkRole ax_platform_node_auralinux_get_role(AtkObject* atk_object) { |
121 ui::AXPlatformNodeAuraLinux* obj = | 159 ui::AXPlatformNodeAuraLinux* obj = |
122 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | 160 AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
123 if (!obj) | 161 if (!obj) |
124 return ATK_ROLE_INVALID; | 162 return ATK_ROLE_INVALID; |
125 return obj->GetAtkRole(); | 163 return obj->GetAtkRole(); |
126 } | 164 } |
127 | 165 |
128 static AtkStateSet* ax_platform_node_auralinux_ref_state_set( | 166 static AtkStateSet* ax_platform_node_auralinux_ref_state_set( |
129 AtkObject* atk_object) { | 167 AtkObject* atk_object) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 | 206 |
169 gobject_class->finalize = ax_platform_node_auralinux_finalize; | 207 gobject_class->finalize = ax_platform_node_auralinux_finalize; |
170 klass->initialize = ax_platform_node_auralinux_init; | 208 klass->initialize = ax_platform_node_auralinux_init; |
171 klass->get_name = ax_platform_node_auralinux_get_name; | 209 klass->get_name = ax_platform_node_auralinux_get_name; |
172 klass->get_description = ax_platform_node_auralinux_get_description; | 210 klass->get_description = ax_platform_node_auralinux_get_description; |
173 klass->get_parent = ax_platform_node_auralinux_get_parent; | 211 klass->get_parent = ax_platform_node_auralinux_get_parent; |
174 klass->get_n_children = ax_platform_node_auralinux_get_n_children; | 212 klass->get_n_children = ax_platform_node_auralinux_get_n_children; |
175 klass->ref_child = ax_platform_node_auralinux_ref_child; | 213 klass->ref_child = ax_platform_node_auralinux_ref_child; |
176 klass->get_role = ax_platform_node_auralinux_get_role; | 214 klass->get_role = ax_platform_node_auralinux_get_role; |
177 klass->ref_state_set = ax_platform_node_auralinux_ref_state_set; | 215 klass->ref_state_set = ax_platform_node_auralinux_ref_state_set; |
216 klass->get_index_in_parent = ax_platform_node_auralinux_get_index_in_parent; | |
217 klass->ref_relation_set = ax_platform_node_auralinux_ref_relation_set; | |
178 } | 218 } |
179 | 219 |
180 GType ax_platform_node_auralinux_get_type() { | 220 GType ax_platform_node_auralinux_get_type() { |
181 static volatile gsize type_volatile = 0; | 221 static volatile gsize type_volatile = 0; |
182 | 222 |
183 if (g_once_init_enter(&type_volatile)) { | 223 if (g_once_init_enter(&type_volatile)) { |
184 static const GTypeInfo tinfo = { | 224 static const GTypeInfo tinfo = { |
185 sizeof(AXPlatformNodeAuraLinuxClass), | 225 sizeof(AXPlatformNodeAuraLinuxClass), |
186 (GBaseInitFunc) 0, | 226 (GBaseInitFunc) 0, |
187 (GBaseFinalizeFunc) 0, | 227 (GBaseFinalizeFunc) 0, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 if (state & (1 << ui::AX_STATE_FOCUSED)) | 348 if (state & (1 << ui::AX_STATE_FOCUSED)) |
309 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); | 349 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); |
310 if (state & (1 << ui::AX_STATE_PRESSED)) | 350 if (state & (1 << ui::AX_STATE_PRESSED)) |
311 atk_state_set_add_state(state_set, ATK_STATE_PRESSED); | 351 atk_state_set_add_state(state_set, ATK_STATE_PRESSED); |
312 if (state & (1 << ui::AX_STATE_SELECTABLE)) | 352 if (state & (1 << ui::AX_STATE_SELECTABLE)) |
313 atk_state_set_add_state(state_set, ATK_STATE_SELECTABLE); | 353 atk_state_set_add_state(state_set, ATK_STATE_SELECTABLE); |
314 if (state & (1 << ui::AX_STATE_SELECTED)) | 354 if (state & (1 << ui::AX_STATE_SELECTED)) |
315 atk_state_set_add_state(state_set, ATK_STATE_SELECTED); | 355 atk_state_set_add_state(state_set, ATK_STATE_SELECTED); |
316 } | 356 } |
317 | 357 |
358 void AXPlatformNodeAuraLinux::GetAtkRelation(AtkRelationSet* atk_relation_set) { | |
359 return; | |
dmazzoni
2015/03/23 22:19:57
nit: no "return", just leave it blank.
| |
360 } | |
361 | |
318 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() | 362 AXPlatformNodeAuraLinux::AXPlatformNodeAuraLinux() |
319 : atk_object_(nullptr) { | 363 : atk_object_(nullptr) { |
320 } | 364 } |
321 | 365 |
322 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { | 366 AXPlatformNodeAuraLinux::~AXPlatformNodeAuraLinux() { |
323 g_object_unref(atk_object_); | 367 g_object_unref(atk_object_); |
324 } | 368 } |
325 | 369 |
326 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { | 370 void AXPlatformNodeAuraLinux::Init(AXPlatformNodeDelegate* delegate) { |
327 // Initialize ATK. | 371 // Initialize ATK. |
(...skipping 11 matching lines...) Expand all Loading... | |
339 } | 383 } |
340 | 384 |
341 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 385 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
342 } | 386 } |
343 | 387 |
344 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 388 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
345 return 0; | 389 return 0; |
346 } | 390 } |
347 | 391 |
348 } // namespace ui | 392 } // namespace ui |
OLD | NEW |