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 "chrome/browser/ui/views/accessibility/accessibility_event_router_views
.h" | 5 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views
.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 views::View* view, | 255 views::View* view, |
256 ui::AXEvent event, | 256 ui::AXEvent event, |
257 Profile* profile) { | 257 Profile* profile) { |
258 ui::AXViewState state; | 258 ui::AXViewState state; |
259 view->GetAccessibleState(&state); | 259 view->GetAccessibleState(&state); |
260 if (state.index == -1) | 260 if (state.index == -1) |
261 return; | 261 return; |
262 std::string name = base::UTF16ToUTF8(state.name); | 262 std::string name = base::UTF16ToUTF8(state.name); |
263 std::string context = GetViewContext(view); | 263 std::string context = GetViewContext(view); |
264 AccessibilityTabInfo info(profile, name, context, state.index, state.count); | 264 AccessibilityTabInfo info(profile, name, context, state.index, state.count); |
| 265 info.set_bounds(view->GetBoundsInScreen()); |
265 SendControlAccessibilityNotification(event, &info); | 266 SendControlAccessibilityNotification(event, &info); |
266 } | 267 } |
267 | 268 |
268 // static | 269 // static |
269 void AccessibilityEventRouterViews::SendButtonNotification( | 270 void AccessibilityEventRouterViews::SendButtonNotification( |
270 views::View* view, | 271 views::View* view, |
271 ui::AXEvent event, | 272 ui::AXEvent event, |
272 Profile* profile) { | 273 Profile* profile) { |
273 AccessibilityButtonInfo info( | 274 AccessibilityButtonInfo info( |
274 profile, GetViewName(view), GetViewContext(view)); | 275 profile, GetViewName(view), GetViewContext(view)); |
| 276 info.set_bounds(view->GetBoundsInScreen()); |
275 SendControlAccessibilityNotification(event, &info); | 277 SendControlAccessibilityNotification(event, &info); |
276 } | 278 } |
277 | 279 |
278 // static | 280 // static |
279 void AccessibilityEventRouterViews::SendStaticTextNotification( | 281 void AccessibilityEventRouterViews::SendStaticTextNotification( |
280 views::View* view, | 282 views::View* view, |
281 ui::AXEvent event, | 283 ui::AXEvent event, |
282 Profile* profile) { | 284 Profile* profile) { |
283 AccessibilityStaticTextInfo info( | 285 AccessibilityStaticTextInfo info( |
284 profile, GetViewName(view), GetViewContext(view)); | 286 profile, GetViewName(view), GetViewContext(view)); |
| 287 info.set_bounds(view->GetBoundsInScreen()); |
285 SendControlAccessibilityNotification(event, &info); | 288 SendControlAccessibilityNotification(event, &info); |
286 } | 289 } |
287 | 290 |
288 // static | 291 // static |
289 void AccessibilityEventRouterViews::SendLinkNotification( | 292 void AccessibilityEventRouterViews::SendLinkNotification( |
290 views::View* view, | 293 views::View* view, |
291 ui::AXEvent event, | 294 ui::AXEvent event, |
292 Profile* profile) { | 295 Profile* profile) { |
293 AccessibilityLinkInfo info(profile, GetViewName(view), GetViewContext(view)); | 296 AccessibilityLinkInfo info(profile, GetViewName(view), GetViewContext(view)); |
| 297 info.set_bounds(view->GetBoundsInScreen()); |
294 SendControlAccessibilityNotification(event, &info); | 298 SendControlAccessibilityNotification(event, &info); |
295 } | 299 } |
296 | 300 |
297 // static | 301 // static |
298 void AccessibilityEventRouterViews::SendMenuNotification( | 302 void AccessibilityEventRouterViews::SendMenuNotification( |
299 views::View* view, | 303 views::View* view, |
300 ui::AXEvent event, | 304 ui::AXEvent event, |
301 Profile* profile) { | 305 Profile* profile) { |
302 AccessibilityMenuInfo info(profile, GetViewName(view)); | 306 AccessibilityMenuInfo info(profile, GetViewName(view)); |
| 307 info.set_bounds(view->GetBoundsInScreen()); |
303 SendMenuAccessibilityNotification(event, &info); | 308 SendMenuAccessibilityNotification(event, &info); |
304 } | 309 } |
305 | 310 |
306 // static | 311 // static |
307 void AccessibilityEventRouterViews::SendMenuItemNotification( | 312 void AccessibilityEventRouterViews::SendMenuItemNotification( |
308 views::View* view, | 313 views::View* view, |
309 ui::AXEvent event, | 314 ui::AXEvent event, |
310 Profile* profile) { | 315 Profile* profile) { |
311 std::string name = GetViewName(view); | 316 std::string name = GetViewName(view); |
312 std::string context = GetViewContext(view); | 317 std::string context = GetViewContext(view); |
(...skipping 10 matching lines...) Expand all Loading... |
323 views::SubmenuView::kViewClassName)) { | 328 views::SubmenuView::kViewClassName)) { |
324 parent_menu = parent_menu->parent(); | 329 parent_menu = parent_menu->parent(); |
325 } | 330 } |
326 if (parent_menu) { | 331 if (parent_menu) { |
327 count = 0; | 332 count = 0; |
328 RecursiveGetMenuItemIndexAndCount(parent_menu, view, &index, &count); | 333 RecursiveGetMenuItemIndexAndCount(parent_menu, view, &index, &count); |
329 } | 334 } |
330 | 335 |
331 AccessibilityMenuItemInfo info( | 336 AccessibilityMenuItemInfo info( |
332 profile, name, context, has_submenu, index, count); | 337 profile, name, context, has_submenu, index, count); |
| 338 info.set_bounds(view->GetBoundsInScreen()); |
333 SendControlAccessibilityNotification(event, &info); | 339 SendControlAccessibilityNotification(event, &info); |
334 } | 340 } |
335 | 341 |
336 // static | 342 // static |
337 void AccessibilityEventRouterViews::SendTreeNotification( | 343 void AccessibilityEventRouterViews::SendTreeNotification( |
338 views::View* view, | 344 views::View* view, |
339 ui::AXEvent event, | 345 ui::AXEvent event, |
340 Profile* profile) { | 346 Profile* profile) { |
341 AccessibilityTreeInfo info(profile, GetViewName(view)); | 347 AccessibilityTreeInfo info(profile, GetViewName(view)); |
| 348 info.set_bounds(view->GetBoundsInScreen()); |
342 SendControlAccessibilityNotification(event, &info); | 349 SendControlAccessibilityNotification(event, &info); |
343 } | 350 } |
344 | 351 |
345 // static | 352 // static |
346 void AccessibilityEventRouterViews::SendTreeItemNotification( | 353 void AccessibilityEventRouterViews::SendTreeItemNotification( |
347 views::View* view, | 354 views::View* view, |
348 ui::AXEvent event, | 355 ui::AXEvent event, |
349 Profile* profile) { | 356 Profile* profile) { |
350 std::string name = GetViewName(view); | 357 std::string name = GetViewName(view); |
351 std::string context = GetViewContext(view); | 358 std::string context = GetViewContext(view); |
(...skipping 25 matching lines...) Expand all Loading... |
377 depth = 0; | 384 depth = 0; |
378 while (parent_node) { | 385 while (parent_node) { |
379 depth++; | 386 depth++; |
380 parent_node = model->GetParent(parent_node); | 387 parent_node = model->GetParent(parent_node); |
381 } | 388 } |
382 } | 389 } |
383 | 390 |
384 AccessibilityTreeItemInfo info( | 391 AccessibilityTreeItemInfo info( |
385 profile, name, context, depth, index, siblings_count, children_count, | 392 profile, name, context, depth, index, siblings_count, children_count, |
386 is_expanded); | 393 is_expanded); |
| 394 info.set_bounds(view->GetBoundsInScreen()); |
387 SendControlAccessibilityNotification(event, &info); | 395 SendControlAccessibilityNotification(event, &info); |
388 } | 396 } |
389 | 397 |
390 // static | 398 // static |
391 void AccessibilityEventRouterViews::SendTextfieldNotification( | 399 void AccessibilityEventRouterViews::SendTextfieldNotification( |
392 views::View* view, | 400 views::View* view, |
393 ui::AXEvent event, | 401 ui::AXEvent event, |
394 Profile* profile) { | 402 Profile* profile) { |
395 ui::AXViewState state; | 403 ui::AXViewState state; |
396 view->GetAccessibleState(&state); | 404 view->GetAccessibleState(&state); |
397 std::string name = base::UTF16ToUTF8(state.name); | 405 std::string name = base::UTF16ToUTF8(state.name); |
398 std::string context = GetViewContext(view); | 406 std::string context = GetViewContext(view); |
399 bool password = state.HasStateFlag(ui::AX_STATE_PROTECTED); | 407 bool password = state.HasStateFlag(ui::AX_STATE_PROTECTED); |
400 AccessibilityTextBoxInfo info(profile, name, context, password); | 408 AccessibilityTextBoxInfo info(profile, name, context, password); |
401 std::string value = base::UTF16ToUTF8(state.value); | 409 std::string value = base::UTF16ToUTF8(state.value); |
402 info.SetValue(value, state.selection_start, state.selection_end); | 410 info.SetValue(value, state.selection_start, state.selection_end); |
| 411 info.set_bounds(view->GetBoundsInScreen()); |
403 SendControlAccessibilityNotification(event, &info); | 412 SendControlAccessibilityNotification(event, &info); |
404 } | 413 } |
405 | 414 |
406 // static | 415 // static |
407 void AccessibilityEventRouterViews::SendComboboxNotification( | 416 void AccessibilityEventRouterViews::SendComboboxNotification( |
408 views::View* view, | 417 views::View* view, |
409 ui::AXEvent event, | 418 ui::AXEvent event, |
410 Profile* profile) { | 419 Profile* profile) { |
411 ui::AXViewState state; | 420 ui::AXViewState state; |
412 view->GetAccessibleState(&state); | 421 view->GetAccessibleState(&state); |
413 std::string name = base::UTF16ToUTF8(state.name); | 422 std::string name = base::UTF16ToUTF8(state.name); |
414 std::string value = base::UTF16ToUTF8(state.value); | 423 std::string value = base::UTF16ToUTF8(state.value); |
415 std::string context = GetViewContext(view); | 424 std::string context = GetViewContext(view); |
416 AccessibilityComboBoxInfo info( | 425 AccessibilityComboBoxInfo info( |
417 profile, name, context, value, state.index, state.count); | 426 profile, name, context, value, state.index, state.count); |
| 427 info.set_bounds(view->GetBoundsInScreen()); |
418 SendControlAccessibilityNotification(event, &info); | 428 SendControlAccessibilityNotification(event, &info); |
419 } | 429 } |
420 | 430 |
421 // static | 431 // static |
422 void AccessibilityEventRouterViews::SendCheckboxNotification( | 432 void AccessibilityEventRouterViews::SendCheckboxNotification( |
423 views::View* view, | 433 views::View* view, |
424 ui::AXEvent event, | 434 ui::AXEvent event, |
425 Profile* profile) { | 435 Profile* profile) { |
426 ui::AXViewState state; | 436 ui::AXViewState state; |
427 view->GetAccessibleState(&state); | 437 view->GetAccessibleState(&state); |
428 std::string name = base::UTF16ToUTF8(state.name); | 438 std::string name = base::UTF16ToUTF8(state.name); |
429 std::string context = GetViewContext(view); | 439 std::string context = GetViewContext(view); |
430 AccessibilityCheckboxInfo info( | 440 AccessibilityCheckboxInfo info( |
431 profile, | 441 profile, |
432 name, | 442 name, |
433 context, | 443 context, |
434 state.HasStateFlag(ui::AX_STATE_CHECKED)); | 444 state.HasStateFlag(ui::AX_STATE_CHECKED)); |
| 445 info.set_bounds(view->GetBoundsInScreen()); |
435 SendControlAccessibilityNotification(event, &info); | 446 SendControlAccessibilityNotification(event, &info); |
436 } | 447 } |
437 | 448 |
438 // static | 449 // static |
439 void AccessibilityEventRouterViews::SendWindowNotification( | 450 void AccessibilityEventRouterViews::SendWindowNotification( |
440 views::View* view, | 451 views::View* view, |
441 ui::AXEvent event, | 452 ui::AXEvent event, |
442 Profile* profile) { | 453 Profile* profile) { |
443 ui::AXViewState state; | 454 ui::AXViewState state; |
444 view->GetAccessibleState(&state); | 455 view->GetAccessibleState(&state); |
445 std::string window_text; | 456 std::string window_text; |
446 | 457 |
447 // If it's an alert, try to get the text from the contents of the | 458 // If it's an alert, try to get the text from the contents of the |
448 // static text, not the window title. | 459 // static text, not the window title. |
449 if (state.role == ui::AX_ROLE_ALERT) | 460 if (state.role == ui::AX_ROLE_ALERT) |
450 window_text = RecursiveGetStaticText(view); | 461 window_text = RecursiveGetStaticText(view); |
451 | 462 |
452 // Otherwise get it from the window's accessible name. | 463 // Otherwise get it from the window's accessible name. |
453 if (window_text.empty()) | 464 if (window_text.empty()) |
454 window_text = base::UTF16ToUTF8(state.name); | 465 window_text = base::UTF16ToUTF8(state.name); |
455 | 466 |
456 AccessibilityWindowInfo info(profile, window_text); | 467 AccessibilityWindowInfo info(profile, window_text); |
| 468 info.set_bounds(view->GetBoundsInScreen()); |
457 SendWindowAccessibilityNotification(event, &info); | 469 SendWindowAccessibilityNotification(event, &info); |
458 } | 470 } |
459 | 471 |
460 // static | 472 // static |
461 void AccessibilityEventRouterViews::SendSliderNotification( | 473 void AccessibilityEventRouterViews::SendSliderNotification( |
462 views::View* view, | 474 views::View* view, |
463 ui::AXEvent event, | 475 ui::AXEvent event, |
464 Profile* profile) { | 476 Profile* profile) { |
465 ui::AXViewState state; | 477 ui::AXViewState state; |
466 view->GetAccessibleState(&state); | 478 view->GetAccessibleState(&state); |
467 | 479 |
468 std::string name = base::UTF16ToUTF8(state.name); | 480 std::string name = base::UTF16ToUTF8(state.name); |
469 std::string value = base::UTF16ToUTF8(state.value); | 481 std::string value = base::UTF16ToUTF8(state.value); |
470 std::string context = GetViewContext(view); | 482 std::string context = GetViewContext(view); |
471 AccessibilitySliderInfo info( | 483 AccessibilitySliderInfo info( |
472 profile, | 484 profile, |
473 name, | 485 name, |
474 context, | 486 context, |
475 value); | 487 value); |
| 488 info.set_bounds(view->GetBoundsInScreen()); |
476 SendControlAccessibilityNotification(event, &info); | 489 SendControlAccessibilityNotification(event, &info); |
477 } | 490 } |
478 | 491 |
479 // static | 492 // static |
480 void AccessibilityEventRouterViews::SendAlertControlNotification( | 493 void AccessibilityEventRouterViews::SendAlertControlNotification( |
481 views::View* view, | 494 views::View* view, |
482 ui::AXEvent event, | 495 ui::AXEvent event, |
483 Profile* profile) { | 496 Profile* profile) { |
484 ui::AXViewState state; | 497 ui::AXViewState state; |
485 view->GetAccessibleState(&state); | 498 view->GetAccessibleState(&state); |
486 | 499 |
487 std::string name = base::UTF16ToUTF8(state.name); | 500 std::string name = base::UTF16ToUTF8(state.name); |
488 AccessibilityAlertInfo info( | 501 AccessibilityAlertInfo info( |
489 profile, | 502 profile, |
490 name); | 503 name); |
| 504 info.set_bounds(view->GetBoundsInScreen()); |
491 SendControlAccessibilityNotification(event, &info); | 505 SendControlAccessibilityNotification(event, &info); |
492 } | 506 } |
493 | 507 |
494 // static | 508 // static |
495 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { | 509 std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { |
496 ui::AXViewState state; | 510 ui::AXViewState state; |
497 view->GetAccessibleState(&state); | 511 view->GetAccessibleState(&state); |
498 return base::UTF16ToUTF8(state.name); | 512 return base::UTF16ToUTF8(state.name); |
499 } | 513 } |
500 | 514 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // static | 618 // static |
605 views::View* AccessibilityEventRouterViews::FindFirstAccessibleAncestor( | 619 views::View* AccessibilityEventRouterViews::FindFirstAccessibleAncestor( |
606 views::View* view) { | 620 views::View* view) { |
607 views::View* temp_view = view; | 621 views::View* temp_view = view; |
608 while (temp_view->parent() && !temp_view->IsAccessibilityFocusable()) | 622 while (temp_view->parent() && !temp_view->IsAccessibilityFocusable()) |
609 temp_view = temp_view->parent(); | 623 temp_view = temp_view->parent(); |
610 if (temp_view->IsAccessibilityFocusable()) | 624 if (temp_view->IsAccessibilityFocusable()) |
611 return temp_view; | 625 return temp_view; |
612 return view; | 626 return view; |
613 } | 627 } |
OLD | NEW |