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

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, 1 month 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
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..35da6b7461e9a27914959eaa1866a86020ba2195 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|
@@ -229,6 +232,10 @@ void TreeView::SetSelectedNode(TreeModelNode* model_node) {
if (selected_node_ && selected_node_ != &root_)
Expand(model_->GetParent(selected_node_->model_node()));
SchedulePaintForNode(selected_node_);
+
+ // TODO(dmazzoni): Decide if EVENT_SELECTION_CHANGED is a better choice for
+ // sub-item selection event.
+ NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true);
sky 2013/11/24 18:58:28 Can you move this to the end of the function. I wo
zel 2013/12/02 05:36:10 Done.
}
if (selected_node_)
@@ -397,6 +404,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_ || !selected_node_->model_node())
sky 2013/11/24 18:58:28 The second null check isn't necessary.
zel 2013/12/02 05:36:10 Done.
+ 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,
« chrome/browser/accessibility/accessibility_events.cc ('K') | « 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