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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { | 388 std::string AccessibilityEventRouterViews::GetViewContext(views::View* view) { |
389 for (views::View* parent = view->parent(); | 389 for (views::View* parent = view->parent(); |
390 parent; | 390 parent; |
391 parent = parent->parent()) { | 391 parent = parent->parent()) { |
392 ui::AccessibleViewState state; | 392 ui::AccessibleViewState state; |
393 parent->GetAccessibleState(&state); | 393 parent->GetAccessibleState(&state); |
394 | 394 |
395 // Two cases are handled right now. More could be added in the future | 395 // Two cases are handled right now. More could be added in the future |
396 // depending on how the UI evolves. | 396 // depending on how the UI evolves. |
397 | 397 |
398 // A control in a toolbar should use the toolbar's accessible name | 398 // A control in alert, toolbar or dialog should use the its accessible name |
David Tseng
2013/11/20 22:13:27
s/the its/its.
Perhaps rephrase
// A control
zel
2013/11/21 00:19:23
Done.
| |
399 // as the context. | 399 // as the context. |
400 if (state.role == ui::AccessibilityTypes::ROLE_TOOLBAR && | 400 if ((state.role == ui::AccessibilityTypes::ROLE_ALERT || |
401 state.role == ui::AccessibilityTypes::ROLE_DIALOG || | |
402 state.role == ui::AccessibilityTypes::ROLE_TOOLBAR) && | |
401 !state.name.empty()) { | 403 !state.name.empty()) { |
402 return UTF16ToUTF8(state.name); | 404 return UTF16ToUTF8(state.name); |
403 } | 405 } |
404 | 406 |
405 // A control inside of an alert or dialog (including an infobar) | 407 // A control inside of an alert or dialog (including an infobar) |
406 // should grab the first static text descendant as the context; | 408 // should grab the first static text descendant as the context; |
407 // that's the prompt. | 409 // that's the prompt. |
408 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || | 410 if (state.role == ui::AccessibilityTypes::ROLE_ALERT || |
409 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { | 411 state.role == ui::AccessibilityTypes::ROLE_DIALOG) { |
410 views::View* static_text_child = FindDescendantWithAccessibleRole( | 412 views::View* static_text_child = FindDescendantWithAccessibleRole( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 return UTF16ToUTF8(state.name); | 476 return UTF16ToUTF8(state.name); |
475 | 477 |
476 for (int i = 0; i < view->child_count(); ++i) { | 478 for (int i = 0; i < view->child_count(); ++i) { |
477 views::View* child = view->child_at(i); | 479 views::View* child = view->child_at(i); |
478 std::string result = RecursiveGetStaticText(child); | 480 std::string result = RecursiveGetStaticText(child); |
479 if (!result.empty()) | 481 if (!result.empty()) |
480 return result; | 482 return result; |
481 } | 483 } |
482 return std::string(); | 484 return std::string(); |
483 } | 485 } |
OLD | NEW |