| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_gtk.h" | 5 #include "content/browser/accessibility/browser_accessibility_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h" | 10 #include "content/browser/accessibility/browser_accessibility_manager_gtk.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 return NULL; | 189 return NULL; |
| 190 | 190 |
| 191 return obj->GetStringAttribute( | 191 return obj->GetStringAttribute( |
| 192 ui::AX_ATTR_DESCRIPTION).c_str(); | 192 ui::AX_ATTR_DESCRIPTION).c_str(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 static AtkObject* browser_accessibility_get_parent(AtkObject* atk_object) { | 195 static AtkObject* browser_accessibility_get_parent(AtkObject* atk_object) { |
| 196 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 196 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 197 if (!obj) | 197 if (!obj) |
| 198 return NULL; | 198 return NULL; |
| 199 if (obj->parent()) | 199 if (obj->GetParent()) |
| 200 return obj->parent()->ToBrowserAccessibilityGtk()->GetAtkObject(); | 200 return obj->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject(); |
| 201 | 201 |
| 202 BrowserAccessibilityManagerGtk* manager = | 202 BrowserAccessibilityManagerGtk* manager = |
| 203 static_cast<BrowserAccessibilityManagerGtk*>(obj->manager()); | 203 static_cast<BrowserAccessibilityManagerGtk*>(obj->manager()); |
| 204 return gtk_widget_get_accessible(manager->parent_widget()); | 204 return gtk_widget_get_accessible(manager->parent_widget()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 static gint browser_accessibility_get_n_children(AtkObject* atk_object) { | 207 static gint browser_accessibility_get_n_children(AtkObject* atk_object) { |
| 208 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 208 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 209 if (!obj) | 209 if (!obj) |
| 210 return 0; | 210 return 0; |
| 211 | 211 |
| 212 return obj->PlatformChildCount(); | 212 return obj->PlatformChildCount(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 static AtkObject* browser_accessibility_ref_child( | 215 static AtkObject* browser_accessibility_ref_child( |
| 216 AtkObject* atk_object, gint index) { | 216 AtkObject* atk_object, gint index) { |
| 217 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 217 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 218 if (!obj) | 218 if (!obj) |
| 219 return NULL; | 219 return NULL; |
| 220 | 220 |
| 221 if (index < 0 || index >= static_cast<gint>(obj->PlatformChildCount())) | 221 if (index < 0 || index >= static_cast<gint>(obj->PlatformChildCount())) |
| 222 return NULL; | 222 return NULL; |
| 223 | 223 |
| 224 AtkObject* result = | 224 AtkObject* result = |
| 225 obj->children()[index]->ToBrowserAccessibilityGtk()->GetAtkObject(); | 225 obj->InternalGetChild(index)->ToBrowserAccessibilityGtk()->GetAtkObject(); |
| 226 g_object_ref(result); | 226 g_object_ref(result); |
| 227 return result; | 227 return result; |
| 228 } | 228 } |
| 229 | 229 |
| 230 static gint browser_accessibility_get_index_in_parent(AtkObject* atk_object) { | 230 static gint browser_accessibility_get_index_in_parent(AtkObject* atk_object) { |
| 231 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 231 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 232 if (!obj) | 232 if (!obj) |
| 233 return 0; | 233 return 0; |
| 234 return obj->index_in_parent(); | 234 return obj->GetIndexInParent(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 static AtkAttributeSet* browser_accessibility_get_attributes( | 237 static AtkAttributeSet* browser_accessibility_get_attributes( |
| 238 AtkObject* atk_object) { | 238 AtkObject* atk_object) { |
| 239 return NULL; | 239 return NULL; |
| 240 } | 240 } |
| 241 | 241 |
| 242 static AtkRole browser_accessibility_get_role(AtkObject* atk_object) { | 242 static AtkRole browser_accessibility_get_role(AtkObject* atk_object) { |
| 243 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 243 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 244 if (!obj) | 244 if (!obj) |
| 245 return ATK_ROLE_INVALID; | 245 return ATK_ROLE_INVALID; |
| 246 return obj->atk_role(); | 246 return obj->atk_role(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { | 249 static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { |
| 250 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); | 250 BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); |
| 251 if (!obj) | 251 if (!obj) |
| 252 return NULL; | 252 return NULL; |
| 253 AtkStateSet* state_set = | 253 AtkStateSet* state_set = |
| 254 ATK_OBJECT_CLASS(browser_accessibility_parent_class)-> | 254 ATK_OBJECT_CLASS(browser_accessibility_parent_class)-> |
| 255 ref_state_set(atk_object); | 255 ref_state_set(atk_object); |
| 256 int32 state = obj->state(); | 256 int32 state = obj->GetState(); |
| 257 | 257 |
| 258 if (state & (1 << ui::AX_STATE_FOCUSABLE)) | 258 if (state & (1 << ui::AX_STATE_FOCUSABLE)) |
| 259 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); | 259 atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); |
| 260 if (obj->manager()->GetFocus(NULL) == obj) | 260 if (obj->manager()->GetFocus(NULL) == obj) |
| 261 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); | 261 atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); |
| 262 if (state & (1 << ui::AX_STATE_ENABLED)) | 262 if (state & (1 << ui::AX_STATE_ENABLED)) |
| 263 atk_state_set_add_state(state_set, ATK_STATE_ENABLED); | 263 atk_state_set_add_state(state_set, ATK_STATE_ENABLED); |
| 264 | 264 |
| 265 return state_set; | 265 return state_set; |
| 266 } | 266 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ATK_TEXT_INTERFACE, | 356 ATK_TEXT_INTERFACE, |
| 357 ATK_VALUE_INTERFACE, | 357 ATK_VALUE_INTERFACE, |
| 358 }; | 358 }; |
| 359 | 359 |
| 360 static int GetInterfaceMaskFromObject(BrowserAccessibilityGtk* obj) { | 360 static int GetInterfaceMaskFromObject(BrowserAccessibilityGtk* obj) { |
| 361 int interface_mask = 0; | 361 int interface_mask = 0; |
| 362 | 362 |
| 363 // Component interface is always supported. | 363 // Component interface is always supported. |
| 364 interface_mask |= 1 << ATK_COMPONENT_INTERFACE; | 364 interface_mask |= 1 << ATK_COMPONENT_INTERFACE; |
| 365 | 365 |
| 366 int role = obj->role(); | 366 int role = obj->GetRole(); |
| 367 if (role == ui::AX_ROLE_PROGRESS_INDICATOR || | 367 if (role == ui::AX_ROLE_PROGRESS_INDICATOR || |
| 368 role == ui::AX_ROLE_SCROLL_BAR || | 368 role == ui::AX_ROLE_SCROLL_BAR || |
| 369 role == ui::AX_ROLE_SLIDER) { | 369 role == ui::AX_ROLE_SLIDER) { |
| 370 interface_mask |= 1 << ATK_VALUE_INTERFACE; | 370 interface_mask |= 1 << ATK_VALUE_INTERFACE; |
| 371 } | 371 } |
| 372 | 372 |
| 373 return interface_mask; | 373 return interface_mask; |
| 374 } | 374 } |
| 375 | 375 |
| 376 static GType GetAccessibilityTypeFromObject(BrowserAccessibilityGtk* obj) { | 376 static GType GetAccessibilityTypeFromObject(BrowserAccessibilityGtk* obj) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 int interface_mask = GetInterfaceMaskFromObject(this); | 455 int interface_mask = GetInterfaceMaskFromObject(this); |
| 456 if (interface_mask != interface_mask_) { | 456 if (interface_mask != interface_mask_) { |
| 457 g_object_unref(atk_object_); | 457 g_object_unref(atk_object_); |
| 458 atk_object_ = NULL; | 458 atk_object_ = NULL; |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 if (!atk_object_) { | 462 if (!atk_object_) { |
| 463 interface_mask_ = GetInterfaceMaskFromObject(this); | 463 interface_mask_ = GetInterfaceMaskFromObject(this); |
| 464 atk_object_ = ATK_OBJECT(browser_accessibility_new(this)); | 464 atk_object_ = ATK_OBJECT(browser_accessibility_new(this)); |
| 465 if (this->parent()) { | 465 if (this->GetParent()) { |
| 466 atk_object_set_parent( | 466 atk_object_set_parent( |
| 467 atk_object_, | 467 atk_object_, |
| 468 this->parent()->ToBrowserAccessibilityGtk()->GetAtkObject()); | 468 this->GetParent()->ToBrowserAccessibilityGtk()->GetAtkObject()); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 | 472 |
| 473 bool BrowserAccessibilityGtk::IsNative() const { | 473 bool BrowserAccessibilityGtk::IsNative() const { |
| 474 return true; | 474 return true; |
| 475 } | 475 } |
| 476 | 476 |
| 477 void BrowserAccessibilityGtk::InitRoleAndState() { | 477 void BrowserAccessibilityGtk::InitRoleAndState() { |
| 478 switch(role()) { | 478 switch(GetRole()) { |
| 479 case ui::AX_ROLE_DOCUMENT: | 479 case ui::AX_ROLE_DOCUMENT: |
| 480 case ui::AX_ROLE_ROOT_WEB_AREA: | 480 case ui::AX_ROLE_ROOT_WEB_AREA: |
| 481 case ui::AX_ROLE_WEB_AREA: | 481 case ui::AX_ROLE_WEB_AREA: |
| 482 atk_role_ = ATK_ROLE_DOCUMENT_WEB; | 482 atk_role_ = ATK_ROLE_DOCUMENT_WEB; |
| 483 break; | 483 break; |
| 484 case ui::AX_ROLE_GROUP: | 484 case ui::AX_ROLE_GROUP: |
| 485 case ui::AX_ROLE_DIV: | 485 case ui::AX_ROLE_DIV: |
| 486 atk_role_ = ATK_ROLE_SECTION; | 486 atk_role_ = ATK_ROLE_SECTION; |
| 487 break; | 487 break; |
| 488 case ui::AX_ROLE_BUTTON: | 488 case ui::AX_ROLE_BUTTON: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 509 case ui::AX_ROLE_TEXT_FIELD: | 509 case ui::AX_ROLE_TEXT_FIELD: |
| 510 atk_role_ = ATK_ROLE_ENTRY; | 510 atk_role_ = ATK_ROLE_ENTRY; |
| 511 break; | 511 break; |
| 512 default: | 512 default: |
| 513 atk_role_ = ATK_ROLE_UNKNOWN; | 513 atk_role_ = ATK_ROLE_UNKNOWN; |
| 514 break; | 514 break; |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 | 517 |
| 518 } // namespace content | 518 } // namespace content |
| OLD | NEW |