Chromium Code Reviews| 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 gfx::Rect findAtkObjectParentCoords(AtkObject* atk_object) { | |
|
dmazzoni
2015/04/29 21:26:48
Nit: FindAtkObjectParentCoords
Also, have it retu
| |
| 190 if (atk_object_get_role(atk_object) == ATK_ROLE_WINDOW) { | |
| 191 int x, y; | |
| 192 atk_component_get_position(ATK_COMPONENT(atk_object), | |
| 193 &x, &y, ATK_XY_WINDOW); | |
| 194 gfx::Rect window_coords(x,y,0,0); | |
|
dmazzoni
2015/04/29 21:26:48
nit: space after comma: (x, y, 0, 0)
| |
| 195 return window_coords; | |
| 196 } | |
| 197 atk_object = atk_object_get_parent(atk_object); | |
| 198 | |
| 199 return findAtkObjectParentCoords(atk_object); | |
| 200 } | |
| 201 | |
| 202 static void ax_platform_node_auralinux_get_extents(AtkComponent* atk_component, | |
| 203 gint* x, gint* y, | |
| 204 gint* width, gint* height, | |
| 205 AtkCoordType coord_type) { | |
| 206 *x = *y = *width = *height = 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->GetExtents(x, y, width, height, coord_type); | |
| 214 } | |
| 215 | |
| 216 static void ax_platform_node_auralinux_get_position(AtkComponent* atk_component, | |
| 217 gint* x, gint* y, | |
|
dmazzoni
2015/04/29 21:26:48
nit: indentation
| |
| 218 AtkCoordType coord_type) { | |
| 219 *x = *y = 0; | |
| 220 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
| 221 ui::AXPlatformNodeAuraLinux* obj = | |
| 222 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
| 223 if (!obj) | |
| 224 return; | |
| 225 | |
| 226 obj->GetPosition(x, y, coord_type); | |
| 227 } | |
| 228 | |
| 229 static void ax_platform_node_auralinux_get_size(AtkComponent* atk_component, | |
| 230 gint* width, gint* height) { | |
|
dmazzoni
2015/04/29 21:26:48
nit: indentation
| |
| 231 *width = *height = 0; | |
| 232 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
| 233 ui::AXPlatformNodeAuraLinux* obj = | |
| 234 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
| 235 if (!obj) | |
| 236 return; | |
| 237 | |
| 238 obj->GetSize(width, height); | |
| 239 } | |
| 240 | |
| 241 void ax_component_interface_base_init(AtkComponentIface* iface) { | |
| 242 iface->get_extents = ax_platform_node_auralinux_get_extents; | |
| 243 iface->get_position = ax_platform_node_auralinux_get_position; | |
| 244 iface->get_size = ax_platform_node_auralinux_get_size; | |
| 245 } | |
| 246 | |
| 247 static const GInterfaceInfo ComponentInfo = { | |
| 248 reinterpret_cast<GInterfaceInitFunc>(ax_component_interface_base_init), 0, 0 | |
| 249 }; | |
| 250 | |
| 251 // | |
| 186 // The rest of the AXPlatformNodeAuraLinux code, not specific to one | 252 // The rest of the AXPlatformNodeAuraLinux code, not specific to one |
| 187 // of the Atk* interfaces. | 253 // of the Atk* interfaces. |
| 188 // | 254 // |
| 189 | 255 |
| 190 static void ax_platform_node_auralinux_init(AtkObject* atk_object, | 256 static void ax_platform_node_auralinux_init(AtkObject* atk_object, |
| 191 gpointer data) { | 257 gpointer data) { |
| 192 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { | 258 if (ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize) { |
| 193 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( | 259 ATK_OBJECT_CLASS(ax_platform_node_auralinux_parent_class)->initialize( |
| 194 atk_object, data); | 260 atk_object, data); |
| 195 } | 261 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 (GClassFinalizeFunc) 0, | 298 (GClassFinalizeFunc) 0, |
| 233 0, /* class data */ | 299 0, /* class data */ |
| 234 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ | 300 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ |
| 235 0, /* nb preallocs */ | 301 0, /* nb preallocs */ |
| 236 (GInstanceInitFunc) 0, | 302 (GInstanceInitFunc) 0, |
| 237 0 /* value table */ | 303 0 /* value table */ |
| 238 }; | 304 }; |
| 239 | 305 |
| 240 GType type = g_type_register_static( | 306 GType type = g_type_register_static( |
| 241 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); | 307 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); |
| 308 g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo); | |
| 242 g_once_init_leave(&type_volatile, type); | 309 g_once_init_leave(&type_volatile, type); |
| 243 } | 310 } |
| 244 | 311 |
| 245 return type_volatile; | 312 return type_volatile; |
| 246 } | 313 } |
| 247 | 314 |
| 248 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( | 315 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( |
| 249 ui::AXPlatformNodeAuraLinux* obj) { | 316 ui::AXPlatformNodeAuraLinux* obj) { |
| 250 #if !GLIB_CHECK_VERSION(2, 36, 0) | 317 #if !GLIB_CHECK_VERSION(2, 36, 0) |
| 251 static bool first_time = true; | 318 static bool first_time = true; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 return atk_object_; | 452 return atk_object_; |
| 386 } | 453 } |
| 387 | 454 |
| 388 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 455 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| 389 } | 456 } |
| 390 | 457 |
| 391 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 458 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
| 392 return 0; | 459 return 0; |
| 393 } | 460 } |
| 394 | 461 |
| 462 void AXPlatformNodeAuraLinux::GetExtents(gint* x, gint* y, | |
| 463 gint* width, gint* height, | |
| 464 AtkCoordType coord_type) { | |
| 465 gfx::Rect extents = GetBoundsInScreen(); | |
| 466 | |
| 467 *x = extents.x(); | |
| 468 *y = extents.y(); | |
| 469 *width = extents.width(); | |
| 470 *height = extents.height(); | |
| 471 | |
| 472 if (coord_type == ATK_XY_WINDOW) { | |
| 473 AtkObject* atk_object = GetParent(); | |
| 474 gfx::Rect window_coords = findAtkObjectParentCoords(atk_object); | |
| 475 *x -= window_coords.x(); | |
| 476 *y -= window_coords.y(); | |
| 477 } | |
| 478 } | |
| 479 | |
| 480 void AXPlatformNodeAuraLinux::GetPosition(gint* x, gint* y, | |
| 481 AtkCoordType coord_type) { | |
| 482 gfx::Rect rect_pos = GetBoundsInScreen(); | |
| 483 | |
| 484 *x = rect_pos.x(); | |
| 485 *y = rect_pos.y(); | |
| 486 | |
| 487 if (coord_type == ATK_XY_WINDOW) { | |
| 488 AtkObject* atk_object = GetParent(); | |
| 489 gfx::Rect window_coords = findAtkObjectParentCoords(atk_object); | |
| 490 *x -= window_coords.x(); | |
| 491 *y -= window_coords.y(); | |
| 492 } | |
| 493 } | |
| 494 | |
| 495 void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) { | |
| 496 gfx::Rect rect_size = GetData().location; | |
| 497 *width = rect_size.width(); | |
| 498 *height = rect_size.height(); | |
| 499 } | |
| 500 | |
| 395 } // namespace ui | 501 } // namespace ui |
| OLD | NEW |