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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 | 176 |
177 AtkStateSet* atk_state_set = | 177 AtkStateSet* atk_state_set = |
178 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> | 178 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)-> |
179 ref_state_set(atk_object); | 179 ref_state_set(atk_object); |
180 | 180 |
181 obj->GetAtkState(atk_state_set); | 181 obj->GetAtkState(atk_state_set); |
182 return atk_state_set; | 182 return atk_state_set; |
183 } | 183 } |
184 | 184 |
185 // | 185 // |
186 // AtkComponent interface | |
187 // | |
188 | |
189 static void ax_platform_node_auralinux_get_extents(AtkComponent* atk_component, | |
190 gint* x, gint* y, | |
191 gint* width, gint* height, | |
192 AtkCoordType coord_type) { | |
193 *x = *y = *width = *height = 0; | |
194 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
195 ui::AXPlatformNodeAuraLinux* obj = | |
196 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
197 if (!obj) | |
198 return; | |
199 | |
200 obj->GetExtents(x, y, width, height, coord_type); | |
201 } | |
202 | |
203 static void ax_platform_node_auralinux_get_position(AtkComponent* atk_component, | |
204 gint* x, gint* y, | |
205 AtkCoordType coord_type) { | |
206 *x = *y = 0; | |
207 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
208 ui::AXPlatformNodeAuraLinux* obj = | |
209 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
210 if (!obj) | |
211 return; | |
212 | |
213 obj->GetPosition(x, y, coord_type); | |
214 } | |
215 | |
216 static void ax_platform_node_auralinux_get_size(AtkComponent* atk_component, | |
217 gint* width, gint* height) { | |
218 *width = *height = 0; | |
219 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
220 ui::AXPlatformNodeAuraLinux* obj = | |
221 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
222 if (!obj) | |
223 return; | |
224 | |
225 obj->GetSize(width, height); | |
226 } | |
227 | |
228 void ax_component_interface_base_init(AtkComponentIface* iface) { | |
229 iface->get_extents = ax_platform_node_auralinux_get_extents; | |
230 iface->get_position = ax_platform_node_auralinux_get_position; | |
231 iface->get_size = ax_platform_node_auralinux_get_size; | |
232 } | |
233 | |
234 static const GInterfaceInfo ComponentInfo = { | |
235 reinterpret_cast<GInterfaceInitFunc>(ax_component_interface_base_init), 0, 0 | |
236 }; | |
237 | |
238 // | |
186 // The rest of the AXPlatformNodeAuraLinux code, not specific to one | 239 // The rest of the AXPlatformNodeAuraLinux code, not specific to one |
187 // of the Atk* interfaces. | 240 // of the Atk* interfaces. |
188 // | 241 // |
189 | 242 |
190 static void ax_platform_node_auralinux_init(AtkObject* atk_object, | 243 static void ax_platform_node_auralinux_init(AtkObject* atk_object, |
191 gpointer data) { | 244 gpointer data) { |
192 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { | 245 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { |
193 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( | 246 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( |
194 atk_object, data); | 247 atk_object, data); |
195 } | 248 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 (GClassFinalizeFunc) 0, | 285 (GClassFinalizeFunc) 0, |
233 0, /* class data */ | 286 0, /* class data */ |
234 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ | 287 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ |
235 0, /* nb preallocs */ | 288 0, /* nb preallocs */ |
236 (GInstanceInitFunc) 0, | 289 (GInstanceInitFunc) 0, |
237 0 /* value table */ | 290 0 /* value table */ |
238 }; | 291 }; |
239 | 292 |
240 GType type = g_type_register_static( | 293 GType type = g_type_register_static( |
241 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); | 294 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); |
295 g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo); | |
242 g_once_init_leave(&type_volatile, type); | 296 g_once_init_leave(&type_volatile, type); |
243 } | 297 } |
244 | 298 |
245 return type_volatile; | 299 return type_volatile; |
246 } | 300 } |
247 | 301 |
248 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( | 302 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( |
249 ui::AXPlatformNodeAuraLinux* obj) { | 303 ui::AXPlatformNodeAuraLinux* obj) { |
250 #if !GLIB_CHECK_VERSION(2, 36, 0) | 304 #if !GLIB_CHECK_VERSION(2, 36, 0) |
251 static bool first_time = true; | 305 static bool first_time = true; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 return atk_object_; | 439 return atk_object_; |
386 } | 440 } |
387 | 441 |
388 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 442 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
389 } | 443 } |
390 | 444 |
391 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 445 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
392 return 0; | 446 return 0; |
393 } | 447 } |
394 | 448 |
449 void AXPlatformNodeAuraLinux::GetExtents(gint* x, gint* y, | |
450 gint* width, gint* height, | |
451 AtkCoordType coord_type) { | |
452 gfx::Rect extents = GetBoundsInScreen(); | |
453 | |
454 *x = extents.x(); | |
455 *y = extents.y(); | |
456 *width = extents.width(); | |
457 *height = extents.height(); | |
458 | |
459 if (coord_type == ATK_XY_WINDOW) { | |
460 gfx::Rect window_coords = GetWindowCoords(); | |
461 *x -= window_coords.x(); | |
462 *y -= window_coords.y(); | |
463 } | |
464 } | |
465 | |
466 void AXPlatformNodeAuraLinux::GetPosition(gint* x, gint* y, | |
467 AtkCoordType coord_type) { | |
468 gfx::Rect rect_pos = GetBoundsInScreen(); | |
469 | |
470 *x = rect_pos.x(); | |
471 *y = rect_pos.y(); | |
472 | |
473 if (coord_type == ATK_XY_WINDOW) { | |
474 gfx::Rect window_coords = GetWindowCoords(); | |
475 *x -= window_coords.x(); | |
476 *y -= window_coords.y(); | |
477 } | |
478 } | |
479 | |
480 void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) { | |
481 gfx::Rect rect_size = GetData().location; | |
shreeramk
2015/03/31 14:47:10
I think better would be to move this calculations
dmazzoni
2015/03/31 15:13:48
No, I prefer it this way. The C functions (ax_plat
| |
482 *width = rect_size.width(); | |
483 *height = rect_size.height(); | |
484 } | |
485 | |
486 gfx::Rect AXPlatformNodeAuraLinux::GetWindowCoords() { | |
487 AtkObject* parent = GetParent(); | |
488 | |
489 ui::AXPlatformNodeAuraLinux* obj = | |
490 AtkObjectToAXPlatformNodeAuraLinux(parent); | |
491 | |
492 if (atk_object_get_role(parent) == ATK_ROLE_WINDOW) { | |
493 gfx::Rect window_coords = obj->GetData().location; | |
494 return window_coords; | |
495 } | |
496 | |
497 return obj->GetWindowCoords(); | |
498 } | |
499 | |
395 } // namespace ui | 500 } // namespace ui |
OLD | NEW |