OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/accessibility/browser_accessibility_auralinux.h" | 5 #include "content/browser/accessibility/browser_accessibility_auralinux.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/accessibility/browser_accessibility_manager_auralinux.
h" | 8 #include "content/browser/accessibility/browser_accessibility_manager_auralinux.
h" |
9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
10 | 10 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 static void DocumentInterfaceInit(AtkDocumentIface* iface) { | 262 static void DocumentInterfaceInit(AtkDocumentIface* iface) { |
263 iface->get_document_attribute_value = | 263 iface->get_document_attribute_value = |
264 browser_accessibility_get_attribute_value; | 264 browser_accessibility_get_attribute_value; |
265 iface->get_document_attributes = browser_accessibility_get_attributes; | 265 iface->get_document_attributes = browser_accessibility_get_attributes; |
266 } | 266 } |
267 | 267 |
268 static const GInterfaceInfo DocumentInfo = { | 268 static const GInterfaceInfo DocumentInfo = { |
269 reinterpret_cast<GInterfaceInitFunc>(DocumentInterfaceInit), 0, 0}; | 269 reinterpret_cast<GInterfaceInitFunc>(DocumentInterfaceInit), 0, 0}; |
270 | 270 |
271 // | 271 // |
| 272 // AtkImage interface. |
| 273 // |
| 274 |
| 275 static BrowserAccessibilityAuraLinux* ToBrowserAccessibilityAuraLinux( |
| 276 AtkImage* atk_img) { |
| 277 if (!IS_BROWSER_ACCESSIBILITY(atk_img)) |
| 278 return NULL; |
| 279 |
| 280 return ToBrowserAccessibilityAuraLinux(BROWSER_ACCESSIBILITY(atk_img)); |
| 281 } |
| 282 |
| 283 void GetImagePositionSize(BrowserAccessibilityAuraLinux* obj, |
| 284 gint* x, |
| 285 gint* y, |
| 286 gint* width, |
| 287 gint* height) { |
| 288 gfx::Rect img_pos_size = obj->GetGlobalBoundsRect(); |
| 289 |
| 290 if (x) |
| 291 *x = img_pos_size.x(); |
| 292 if (y) |
| 293 *y = img_pos_size.y(); |
| 294 if (width) |
| 295 *width = img_pos_size.width(); |
| 296 if (height) |
| 297 *height = img_pos_size.height(); |
| 298 } |
| 299 |
| 300 static void browser_accessibility_get_image_position(AtkImage* atk_img, |
| 301 gint* x, |
| 302 gint* y, |
| 303 AtkCoordType coordType) { |
| 304 g_return_if_fail(ATK_IMAGE(atk_img)); |
| 305 BrowserAccessibilityAuraLinux* obj = ToBrowserAccessibilityAuraLinux(atk_img); |
| 306 if (!obj) |
| 307 return; |
| 308 |
| 309 GetImagePositionSize(obj, x, y, nullptr, nullptr); |
| 310 } |
| 311 |
| 312 static const gchar* browser_accessibility_get_image_description( |
| 313 AtkImage* atk_img) { |
| 314 g_return_val_if_fail(ATK_IMAGE(atk_img), 0); |
| 315 BrowserAccessibilityAuraLinux* obj = ToBrowserAccessibilityAuraLinux(atk_img); |
| 316 if (!obj) |
| 317 return 0; |
| 318 |
| 319 return obj->GetStringAttribute(ui::AX_ATTR_DESCRIPTION).c_str(); |
| 320 } |
| 321 |
| 322 static void browser_accessibility_get_image_size(AtkImage* atk_img, |
| 323 gint* width, |
| 324 gint* height) { |
| 325 g_return_if_fail(ATK_IMAGE(atk_img)); |
| 326 BrowserAccessibilityAuraLinux* obj = ToBrowserAccessibilityAuraLinux(atk_img); |
| 327 if (!obj) |
| 328 return; |
| 329 |
| 330 GetImagePositionSize(obj, nullptr, nullptr, width, height); |
| 331 } |
| 332 |
| 333 void ImageInterfaceInit(AtkImageIface* iface) { |
| 334 iface->get_image_position = browser_accessibility_get_image_position; |
| 335 iface->get_image_description = browser_accessibility_get_image_description; |
| 336 iface->get_image_size = browser_accessibility_get_image_size; |
| 337 } |
| 338 |
| 339 static const GInterfaceInfo ImageInfo = { |
| 340 reinterpret_cast<GInterfaceInitFunc>(ImageInterfaceInit), 0, 0}; |
| 341 |
| 342 // |
272 // AtkValue interface. | 343 // AtkValue interface. |
273 // | 344 // |
274 | 345 |
275 static BrowserAccessibilityAuraLinux* ToBrowserAccessibilityAuraLinux( | 346 static BrowserAccessibilityAuraLinux* ToBrowserAccessibilityAuraLinux( |
276 AtkValue* atk_object) { | 347 AtkValue* atk_object) { |
277 if (!IS_BROWSER_ACCESSIBILITY(atk_object)) | 348 if (!IS_BROWSER_ACCESSIBILITY(atk_object)) |
278 return NULL; | 349 return NULL; |
279 | 350 |
280 return ToBrowserAccessibilityAuraLinux(BROWSER_ACCESSIBILITY(atk_object)); | 351 return ToBrowserAccessibilityAuraLinux(BROWSER_ACCESSIBILITY(atk_object)); |
281 } | 352 } |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 if (role == ui::AX_ROLE_PROGRESS_INDICATOR || | 654 if (role == ui::AX_ROLE_PROGRESS_INDICATOR || |
584 role == ui::AX_ROLE_SCROLL_BAR || role == ui::AX_ROLE_SLIDER) { | 655 role == ui::AX_ROLE_SCROLL_BAR || role == ui::AX_ROLE_SLIDER) { |
585 interface_mask |= 1 << ATK_VALUE_INTERFACE; | 656 interface_mask |= 1 << ATK_VALUE_INTERFACE; |
586 } | 657 } |
587 | 658 |
588 // Document Interface | 659 // Document Interface |
589 if (role == ui::AX_ROLE_DOCUMENT || role == ui::AX_ROLE_ROOT_WEB_AREA || | 660 if (role == ui::AX_ROLE_DOCUMENT || role == ui::AX_ROLE_ROOT_WEB_AREA || |
590 role == ui::AX_ROLE_WEB_AREA) | 661 role == ui::AX_ROLE_WEB_AREA) |
591 interface_mask |= 1 << ATK_DOCUMENT_INTERFACE; | 662 interface_mask |= 1 << ATK_DOCUMENT_INTERFACE; |
592 | 663 |
| 664 // Image Interface |
| 665 if (role == ui::AX_ROLE_IMAGE || role == ui::AX_ROLE_IMAGE_MAP) |
| 666 interface_mask |= 1 << ATK_IMAGE_INTERFACE; |
| 667 |
593 return interface_mask; | 668 return interface_mask; |
594 } | 669 } |
595 | 670 |
596 static GType GetAccessibilityTypeFromObject( | 671 static GType GetAccessibilityTypeFromObject( |
597 BrowserAccessibilityAuraLinux* obj) { | 672 BrowserAccessibilityAuraLinux* obj) { |
598 static const GTypeInfo type_info = { | 673 static const GTypeInfo type_info = { |
599 sizeof(BrowserAccessibilityAtkClass), | 674 sizeof(BrowserAccessibilityAtkClass), |
600 (GBaseInitFunc)0, | 675 (GBaseInitFunc)0, |
601 (GBaseFinalizeFunc)0, | 676 (GBaseFinalizeFunc)0, |
602 (GClassInitFunc)0, | 677 (GClassInitFunc)0, |
(...skipping 12 matching lines...) Expand all Loading... |
615 return type; | 690 return type; |
616 | 691 |
617 type = g_type_register_static(BROWSER_ACCESSIBILITY_TYPE, atk_type_name, | 692 type = g_type_register_static(BROWSER_ACCESSIBILITY_TYPE, atk_type_name, |
618 &type_info, GTypeFlags(0)); | 693 &type_info, GTypeFlags(0)); |
619 if (interface_mask & (1 << ATK_ACTION_INTERFACE)) | 694 if (interface_mask & (1 << ATK_ACTION_INTERFACE)) |
620 g_type_add_interface_static(type, ATK_TYPE_ACTION, &ActionInfo); | 695 g_type_add_interface_static(type, ATK_TYPE_ACTION, &ActionInfo); |
621 if (interface_mask & (1 << ATK_COMPONENT_INTERFACE)) | 696 if (interface_mask & (1 << ATK_COMPONENT_INTERFACE)) |
622 g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo); | 697 g_type_add_interface_static(type, ATK_TYPE_COMPONENT, &ComponentInfo); |
623 if (interface_mask & (1 << ATK_DOCUMENT_INTERFACE)) | 698 if (interface_mask & (1 << ATK_DOCUMENT_INTERFACE)) |
624 g_type_add_interface_static(type, ATK_TYPE_DOCUMENT, &DocumentInfo); | 699 g_type_add_interface_static(type, ATK_TYPE_DOCUMENT, &DocumentInfo); |
| 700 if (interface_mask & (1 << ATK_IMAGE_INTERFACE)) |
| 701 g_type_add_interface_static(type, ATK_TYPE_IMAGE, &ImageInfo); |
625 if (interface_mask & (1 << ATK_VALUE_INTERFACE)) | 702 if (interface_mask & (1 << ATK_VALUE_INTERFACE)) |
626 g_type_add_interface_static(type, ATK_TYPE_VALUE, &ValueInfo); | 703 g_type_add_interface_static(type, ATK_TYPE_VALUE, &ValueInfo); |
627 | 704 |
628 return type; | 705 return type; |
629 } | 706 } |
630 | 707 |
631 BrowserAccessibilityAtk* browser_accessibility_new( | 708 BrowserAccessibilityAtk* browser_accessibility_new( |
632 BrowserAccessibilityAuraLinux* obj) { | 709 BrowserAccessibilityAuraLinux* obj) { |
633 GType type = GetAccessibilityTypeFromObject(obj); | 710 GType type = GetAccessibilityTypeFromObject(obj); |
634 AtkObject* atk_object = static_cast<AtkObject*>(g_object_new(type, 0)); | 711 AtkObject* atk_object = static_cast<AtkObject*>(g_object_new(type, 0)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 case ui::AX_ROLE_TREE_ITEM: | 917 case ui::AX_ROLE_TREE_ITEM: |
841 atk_role_ = ATK_ROLE_TREE_ITEM; | 918 atk_role_ = ATK_ROLE_TREE_ITEM; |
842 break; | 919 break; |
843 default: | 920 default: |
844 atk_role_ = ATK_ROLE_UNKNOWN; | 921 atk_role_ = ATK_ROLE_UNKNOWN; |
845 break; | 922 break; |
846 } | 923 } |
847 } | 924 } |
848 | 925 |
849 } // namespace content | 926 } // namespace content |
OLD | NEW |