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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 (GBaseFinalizeFunc) 0, | 230 (GBaseFinalizeFunc) 0, |
| 231 (GClassInitFunc) ax_platform_node_auralinux_class_init, | 231 (GClassInitFunc) ax_platform_node_auralinux_class_init, |
| 232 (GClassFinalizeFunc) 0, | 232 (GClassFinalizeFunc) 0, |
| 233 0, /* class data */ | 233 0, /* class data */ |
| 234 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ | 234 sizeof(AXPlatformNodeAuraLinuxObject), /* instance size */ |
| 235 0, /* nb preallocs */ | 235 0, /* nb preallocs */ |
| 236 (GInstanceInitFunc) 0, | 236 (GInstanceInitFunc) 0, |
| 237 0 /* value table */ | 237 0 /* value table */ |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 GType type = g_type_register_static( | 240 GType type = g_type_register_static( |
|
dmazzoni
2015/03/30 16:21:22
Immediately after this call, you should add a line
| |
| 241 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); | 241 ATK_TYPE_OBJECT, "AXPlatformNodeAuraLinux", &tinfo, GTypeFlags(0)); |
| 242 g_once_init_leave(&type_volatile, type); | 242 g_once_init_leave(&type_volatile, type); |
| 243 } | 243 } |
| 244 | 244 |
| 245 return type_volatile; | 245 return type_volatile; |
| 246 } | 246 } |
| 247 | 247 |
| 248 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( | 248 AXPlatformNodeAuraLinuxObject* ax_platform_node_auralinux_new( |
| 249 ui::AXPlatformNodeAuraLinux* obj) { | 249 ui::AXPlatformNodeAuraLinux* obj) { |
| 250 #if !GLIB_CHECK_VERSION(2, 36, 0) | 250 #if !GLIB_CHECK_VERSION(2, 36, 0) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 // static | 284 // static |
| 285 AXPlatformNode* AXPlatformNodeAuraLinux::application_ = nullptr; | 285 AXPlatformNode* AXPlatformNodeAuraLinux::application_ = nullptr; |
| 286 | 286 |
| 287 // static | 287 // static |
| 288 void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) { | 288 void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) { |
| 289 application_ = application; | 289 application_ = application; |
| 290 AtkUtilAuraLinux::GetInstance(); | 290 AtkUtilAuraLinux::GetInstance(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { | 293 AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { |
| 294 GetWindowCoords(); | |
|
dmazzoni
2015/03/27 19:09:14
I don't think you need to call it here.
shreeramk
2015/03/28 16:59:48
Sorry, by mistake I wrote this. :(
| |
| 294 switch (GetData().role) { | 295 switch (GetData().role) { |
| 295 case ui::AX_ROLE_ALERT: | 296 case ui::AX_ROLE_ALERT: |
| 296 return ATK_ROLE_ALERT; | 297 return ATK_ROLE_ALERT; |
| 297 case ui::AX_ROLE_APPLICATION: | 298 case ui::AX_ROLE_APPLICATION: |
| 298 return ATK_ROLE_APPLICATION; | 299 return ATK_ROLE_APPLICATION; |
| 299 case ui::AX_ROLE_BUTTON: | 300 case ui::AX_ROLE_BUTTON: |
| 300 return ATK_ROLE_PUSH_BUTTON; | 301 return ATK_ROLE_PUSH_BUTTON; |
| 301 case ui::AX_ROLE_CHECK_BOX: | 302 case ui::AX_ROLE_CHECK_BOX: |
| 302 return ATK_ROLE_CHECK_BOX; | 303 return ATK_ROLE_CHECK_BOX; |
| 303 case ui::AX_ROLE_COMBO_BOX: | 304 case ui::AX_ROLE_COMBO_BOX: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 return atk_object_; | 386 return atk_object_; |
| 386 } | 387 } |
| 387 | 388 |
| 388 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 389 void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| 389 } | 390 } |
| 390 | 391 |
| 391 int AXPlatformNodeAuraLinux::GetIndexInParent() { | 392 int AXPlatformNodeAuraLinux::GetIndexInParent() { |
| 392 return 0; | 393 return 0; |
| 393 } | 394 } |
| 394 | 395 |
| 396 // | |
| 397 // ax_platform_node_auralinux AtkComponent interface implementation. | |
|
dmazzoni
2015/03/27 19:09:14
This belongs up above, just before the comment "Th
| |
| 398 // | |
| 399 | |
| 400 static void ax_component_interface_get_extents(AtkComponent* atk_component, | |
|
dmazzoni
2015/03/27 19:09:14
This should be named ax_platform_node_auralinux_ge
| |
| 401 gint* x, gint* y, | |
| 402 gint* width, gint* height, | |
| 403 AtkCoordType coord_type) { | |
| 404 *x = *y = *width = *height = 0; | |
| 405 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
| 406 ui::AXPlatformNodeAuraLinux* obj = | |
| 407 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
| 408 if (!obj) | |
| 409 return; | |
| 410 | |
| 411 obj->GetExtents(x, y, width, height, coord_type); | |
| 412 } | |
| 413 | |
| 414 static void ax_component_interface_get_position(AtkComponent* atk_component, | |
| 415 gint* x, gint* y, | |
| 416 AtkCoordType coord_type) { | |
| 417 *x = *y = 0; | |
| 418 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
| 419 ui::AXPlatformNodeAuraLinux* obj = | |
| 420 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
| 421 if (!obj) | |
| 422 return; | |
| 423 | |
| 424 obj->GetPosition(x, y, coord_type); | |
| 425 } | |
| 426 | |
| 427 static void ax_component_interface_get_size(AtkComponent* atk_component, | |
| 428 gint* width, gint* height) { | |
| 429 *width = *height = 0; | |
| 430 AtkObject* atk_object = ATK_OBJECT(atk_component); | |
| 431 ui::AXPlatformNodeAuraLinux* obj = | |
| 432 AtkObjectToAXPlatformNodeAuraLinux(atk_object); | |
| 433 if (!obj) | |
| 434 return; | |
| 435 | |
| 436 obj->GetSize(width, height); | |
| 437 } | |
| 438 | |
| 439 void ax_component_interface_base_init(AtkComponentIface* iface) { | |
| 440 iface->get_extents = ax_component_interface_get_extents; | |
|
dmazzoni
2015/03/27 19:09:14
nit: only indent 2 chars
| |
| 441 iface->get_position = ax_component_interface_get_position; | |
| 442 iface->get_size = ax_component_interface_get_size; | |
| 443 } | |
| 444 | |
| 445 GType ax_component_auralinux_get_type() { | |
|
dmazzoni
2015/03/27 19:09:14
Where is this called? I don't think we want a sepa
shreeramk
2015/03/28 16:59:48
Actually I don't know/understand like from where i
dmazzoni
2015/03/30 16:21:22
This is what you do when you define a new type. Wh
| |
| 446 static volatile gsize type_volatile = 0; | |
| 447 | |
| 448 if (g_once_init_enter(&type_volatile)) { | |
| 449 static const GTypeInfo tinfo = { | |
| 450 sizeof(AtkComponentIface), | |
| 451 (GBaseInitFunc) ax_component_interface_base_init, | |
| 452 (GBaseFinalizeFunc) 0, | |
| 453 }; | |
| 454 | |
| 455 GType type = g_type_register_static( | |
| 456 ATK_TYPE_COMPONENT, "AtkComponent", &tinfo, GTypeFlags(0)); | |
| 457 g_once_init_leave(&type_volatile, type); | |
| 458 } | |
| 459 | |
| 460 return type_volatile; | |
| 461 } | |
| 462 | |
| 463 void AXPlatformNodeAuraLinux::GetExtents(gint* x, gint* y, | |
| 464 gint* width, gint* height, | |
| 465 AtkCoordType coord_type) { | |
| 466 gfx::Rect extents = GetBoundsInScreen(); | |
| 467 | |
| 468 *x = extents.x(); | |
| 469 *y = extents.y(); | |
| 470 *width = extents.width(); | |
| 471 *height = extents.height(); | |
| 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 *width -= window_coords.width(); | |
| 478 *height -= window_coords.height(); | |
|
shreeramk
2015/03/27 16:09:13
This calculation is is not required for width n he
| |
| 479 } | |
| 480 } | |
| 481 | |
| 482 void AXPlatformNodeAuraLinux::GetPosition(gint* x, gint* y, | |
| 483 AtkCoordType coord_type) { | |
| 484 gfx::Rect rect_pos = GetBoundsInScreen(); | |
| 485 | |
| 486 *x = rect_pos.x(); | |
| 487 *y = rect_pos.y(); | |
| 488 | |
| 489 if (coord_type == ATK_XY_WINDOW) { | |
| 490 gfx::Rect window_coords = GetWindowCoords(); | |
| 491 *x -= window_coords.x(); | |
| 492 *y -= window_coords.y(); | |
| 493 } | |
| 494 } | |
| 495 | |
| 496 void AXPlatformNodeAuraLinux::GetSize(gint* width, gint* height) { | |
| 497 gfx::Rect rect_size = GetData().location; | |
| 498 *width = rect_size.width(); | |
| 499 *height = rect_size.height(); | |
| 500 } | |
| 501 | |
| 502 gfx::Rect AXPlatformNodeAuraLinux::GetWindowCoords() { | |
| 503 AtkObject* parent = GetParent(); | |
| 504 | |
| 505 ui::AXPlatformNodeAuraLinux* obj = | |
| 506 AtkObjectToAXPlatformNodeAuraLinux(parent); | |
|
dmazzoni
2015/03/27 19:09:14
You need to test this. It's possible that the pare
shreeramk
2015/04/01 11:50:14
Already a check is made in AtkObjectToAXPlatformNo
dmazzoni
2015/04/01 15:31:16
I think that's checking whether |this| is an AXPla
| |
| 507 | |
| 508 if (atk_object_get_role(parent) == ATK_ROLE_WINDOW) { | |
| 509 gfx::Rect window_coords = obj->GetData().location; | |
|
dmazzoni
2015/03/27 19:09:14
Do this using its AtkComponent interface
| |
| 510 return window_coords; | |
| 511 } | |
| 512 | |
| 513 return obj->GetWindowCoords(); | |
| 514 } | |
| 515 | |
| 395 } // namespace ui | 516 } // namespace ui |
| OLD | NEW |