Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: ui/views/controls/tree/tree_view.cc

Issue 79543010: Added basic accessibility to TreeView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/tree/tree_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/tree/tree_view.cc
diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc
index 78d4693e4a7fafecd0230d8bc0b5fe479580b1ee..4104b1b3e72e1f4fd22995b2265f253025e772e7 100644
--- a/ui/views/controls/tree/tree_view.cc
+++ b/ui/views/controls/tree/tree_view.cc
@@ -42,6 +42,9 @@ static const int kTextHorizontalPadding = 2;
// How much children are indented from their parent.
static const int kIndent = 20;
+// static
+const char TreeView::kViewClassName[] = "TreeView";
+
namespace {
// Returns the color id for the background of selected text. |has_focus|
@@ -238,6 +241,12 @@ void TreeView::SetSelectedNode(TreeModelNode* model_node) {
// remove explicitly resetting selected_node_ before invoking this.
if (controller_ && (changed || was_empty_selection))
controller_->OnTreeViewSelectionChanged(this);
+
+ if (changed) {
+ // TODO(dmazzoni): Decide if EVENT_SELECTION_CHANGED is a better choice for
+ // sub-item selection event.
+ NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true);
+ }
}
TreeModelNode* TreeView::GetSelectedNode() {
@@ -397,6 +406,16 @@ void TreeView::ShowContextMenu(const gfx::Point& p,
void TreeView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_OUTLINE;
state->state = ui::AccessibilityTypes::STATE_READONLY;
+ if (!selected_node_)
+ return;
+
+ // Get selected item info.
+ state->role = ui::AccessibilityTypes::ROLE_OUTLINEITEM;
+ state->name = selected_node_->model_node()->GetTitle();
+}
+
+const char* TreeView::GetClassName() const {
+ return kViewClassName;
}
void TreeView::TreeNodesAdded(TreeModel* model,
« no previous file with comments | « ui/views/controls/tree/tree_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698