Index: ui/accessibility/platform/ax_platform_node_auralinux.cc |
diff --git a/ui/accessibility/platform/ax_platform_node_auralinux.cc b/ui/accessibility/platform/ax_platform_node_auralinux.cc |
index 85382004c3c9a5e300fc492e0204625296409d1e..8d5adabe4e10c3e71990a264c9d9a1b0b9419cb8 100644 |
--- a/ui/accessibility/platform/ax_platform_node_auralinux.cc |
+++ b/ui/accessibility/platform/ax_platform_node_auralinux.cc |
@@ -183,6 +183,59 @@ static AtkStateSet* ax_platform_node_auralinux_ref_state_set( |
} |
// |
+// AtkComponent interface |
+// |
+ |
+static void ax_platform_node_auralinux_get_extents(AtkComponent* atk_component, |
+ gint* x, gint* y, |
+ gint* width, gint* height, |
+ AtkCoordType coord_type) { |
+ *x = *y = *width = *height = 0; |
+ AtkObject* atk_object = ATK_OBJECT(atk_component); |
+ ui::AXPlatformNodeAuraLinux* obj = |
+ AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
+ if (!obj) |
+ return; |
+ |
+ obj->GetExtents(x, y, width, height, coord_type); |
+} |
+ |
+static void ax_platform_node_auralinux_get_position(AtkComponent* atk_component, |
+ gint* x, gint* y, |
+ AtkCoordType coord_type) { |
+ *x = *y = 0; |
+ AtkObject* atk_object = ATK_OBJECT(atk_component); |
+ ui::AXPlatformNodeAuraLinux* obj = |
+ AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
+ if (!obj) |
+ return; |
+ |
+ obj->GetPosition(x, y, coord_type); |
+} |
+ |
+static void ax_platform_node_auralinux_get_size(AtkComponent* atk_component, |
+ gint* width, gint* height) { |
+ *width = *height = 0; |
+ AtkObject* atk_object = ATK_OBJECT(atk_component); |
+ ui::AXPlatformNodeAuraLinux* obj = |
+ AtkObjectToAXPlatformNodeAuraLinux(atk_object); |
+ if (!obj) |
+ return; |
+ |
+ obj->GetSize(width, height); |
+} |
+ |
+void ax_component_interface_base_init(AtkComponentIface* iface) { |
+ iface->get_extents = ax_platform_node_auralinux_get_extents; |
+ iface->get_position = ax_platform_node_auralinux_get_position; |
+ iface->get_size = ax_platform_node_auralinux_get_size; |
+} |
+ |
+static const GInterfaceInfo ComponentInfo = { |
+ reinterpret_cast<GInterfaceInitFunc>(ax_component_interface_base_init), 0, 0 |
+}; |
+ |
+// |
// The rest of the AXPlatformNodeAuraLinux code, not specific to one |
// of the Atk* interfaces. |
// |
@@ -239,6 +292,7 @@ GType ax_platform_node_auralinux_get_type() { |
GType type = g_type_register_static( |
ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); |
+ g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo); |
g_once_init_leave(&type_volatile, type); |
} |
@@ -392,4 +446,55 @@ int AXPlatformNodeAuraLinux::GetIndexInParent() { |
return 0; |
} |
+void AXPlatformNodeAuraLinux::GetExtents(gint* x, gint* y, |
+ gint* width, gint* height, |
+ AtkCoordType coord_type) { |
+ gfx::Rect extents = GetBoundsInScreen(); |
+ |
+ *x = extents.x(); |
+ *y = extents.y(); |
+ *width = extents.width(); |
+ *height = extents.height(); |
+ |
+ if (coord_type == ATK_XY_WINDOW) { |
+ gfx::Rect window_coords = GetWindowCoords(); |
+ *x -= window_coords.x(); |
+ *y -= window_coords.y(); |
+ } |
+} |
+ |
+void AXPlatformNodeAuraLinux::GetPosition(gint* x, gint* y, |
+ AtkCoordType coord_type) { |
+ gfx::Rect rect_pos = GetBoundsInScreen(); |
+ |
+ *x = rect_pos.x(); |
+ *y = rect_pos.y(); |
+ |
+ if (coord_type == ATK_XY_WINDOW) { |
+ gfx::Rect window_coords = GetWindowCoords(); |
+ *x -= window_coords.x(); |
+ *y -= window_coords.y(); |
+ } |
+} |
+ |
+void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) { |
+ 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
|
+ *width = rect_size.width(); |
+ *height = rect_size.height(); |
+} |
+ |
+gfx::Rect AXPlatformNodeAuraLinux::GetWindowCoords() { |
+ AtkObject* parent = GetParent(); |
+ |
+ ui::AXPlatformNodeAuraLinux* obj = |
+ AtkObjectToAXPlatformNodeAuraLinux(parent); |
+ |
+ if (atk_object_get_role(parent) == ATK_ROLE_WINDOW) { |
+ gfx::Rect window_coords = obj->GetData().location; |
+ return window_coords; |
+ } |
+ |
+ return obj->GetWindowCoords(); |
+} |
+ |
} // namespace ui |