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

Side by Side Diff: ui/views/controls/tree/tree_view.cc

Issue 79273002: Fixed accessibility issues in bookmark bubble dialog. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/views/controls/tree/tree_view.h" 5 #include "ui/views/controls/tree/tree_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 24 matching lines...) Expand all
35 // Padding before/after the image. 35 // Padding before/after the image.
36 static const int kImagePadding = 4; 36 static const int kImagePadding = 4;
37 // Size of the arrow region. 37 // Size of the arrow region.
38 static const int kArrowRegionSize = 12; 38 static const int kArrowRegionSize = 12;
39 // Padding around the text (on each side). 39 // Padding around the text (on each side).
40 static const int kTextVerticalPadding = 3; 40 static const int kTextVerticalPadding = 3;
41 static const int kTextHorizontalPadding = 2; 41 static const int kTextHorizontalPadding = 2;
42 // How much children are indented from their parent. 42 // How much children are indented from their parent.
43 static const int kIndent = 20; 43 static const int kIndent = 20;
44 44
45 // static
46 const char TreeView::kViewClassName[] = "TreeView";
47
45 namespace { 48 namespace {
46 49
47 // Returns the color id for the background of selected text. |has_focus| 50 // Returns the color id for the background of selected text. |has_focus|
48 // indicates if the tree has focus. 51 // indicates if the tree has focus.
49 ui::NativeTheme::ColorId text_background_color_id(bool has_focus) { 52 ui::NativeTheme::ColorId text_background_color_id(bool has_focus) {
50 return has_focus ? 53 return has_focus ?
51 ui::NativeTheme::kColorId_TreeSelectionBackgroundFocused : 54 ui::NativeTheme::kColorId_TreeSelectionBackgroundFocused :
52 ui::NativeTheme::kColorId_TreeSelectionBackgroundUnfocused; 55 ui::NativeTheme::kColorId_TreeSelectionBackgroundUnfocused;
53 } 56 }
54 57
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 bool was_empty_selection = (selected_node_ == NULL); 225 bool was_empty_selection = (selected_node_ == NULL);
223 bool changed = (selected_node_ != node); 226 bool changed = (selected_node_ != node);
224 if (changed) { 227 if (changed) {
225 SchedulePaintForNode(selected_node_); 228 SchedulePaintForNode(selected_node_);
226 selected_node_ = node; 229 selected_node_ = node;
227 if (selected_node_ == &root_ && !root_shown_) 230 if (selected_node_ == &root_ && !root_shown_)
228 selected_node_ = NULL; 231 selected_node_ = NULL;
229 if (selected_node_ && selected_node_ != &root_) 232 if (selected_node_ && selected_node_ != &root_)
230 Expand(model_->GetParent(selected_node_->model_node())); 233 Expand(model_->GetParent(selected_node_->model_node()));
231 SchedulePaintForNode(selected_node_); 234 SchedulePaintForNode(selected_node_);
235
236 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, true);
232 } 237 }
233 238
234 if (selected_node_) 239 if (selected_node_)
235 ScrollRectToVisible(GetBoundsForNode(selected_node_)); 240 ScrollRectToVisible(GetBoundsForNode(selected_node_));
236 241
237 // Notify controller if the old selection was empty to handle the case of 242 // Notify controller if the old selection was empty to handle the case of
238 // remove explicitly resetting selected_node_ before invoking this. 243 // remove explicitly resetting selected_node_ before invoking this.
239 if (controller_ && (changed || was_empty_selection)) 244 if (controller_ && (changed || was_empty_selection))
240 controller_->OnTreeViewSelectionChanged(this); 245 controller_->OnTreeViewSelectionChanged(this);
241 } 246 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth)); 395 gfx::Rect bounds(GetBoundsForNodeImpl(node, row, depth));
391 if (!bounds.Contains(local_point)) 396 if (!bounds.Contains(local_point))
392 return; 397 return;
393 } 398 }
394 View::ShowContextMenu(p, source_type); 399 View::ShowContextMenu(p, source_type);
395 } 400 }
396 401
397 void TreeView::GetAccessibleState(ui::AccessibleViewState* state) { 402 void TreeView::GetAccessibleState(ui::AccessibleViewState* state) {
398 state->role = ui::AccessibilityTypes::ROLE_OUTLINE; 403 state->role = ui::AccessibilityTypes::ROLE_OUTLINE;
399 state->state = ui::AccessibilityTypes::STATE_READONLY; 404 state->state = ui::AccessibilityTypes::STATE_READONLY;
405 if (!selected_node_ || !selected_node_->model_node())
406 return;
407
408 // Get selected item info.
409 state->role = ui::AccessibilityTypes::ROLE_OUTLINEITEM;
dmazzoni 2013/11/21 06:54:07 Oh! I think I understand - the whole tree is repre
zel 2013/11/21 07:02:27 Yep, the whole TreeView is one big fat View.
410 state->name = selected_node_->model_node()->GetTitle();
411 }
412
413 const char* TreeView::GetClassName() const {
414 return kViewClassName;
400 } 415 }
401 416
402 void TreeView::TreeNodesAdded(TreeModel* model, 417 void TreeView::TreeNodesAdded(TreeModel* model,
403 TreeModelNode* parent, 418 TreeModelNode* parent,
404 int start, 419 int start,
405 int count) { 420 int count) {
406 InternalNode* parent_node = 421 InternalNode* parent_node =
407 GetInternalNodeForModelNode(parent, DONT_CREATE_IF_NOT_LOADED); 422 GetInternalNodeForModelNode(parent, DONT_CREATE_IF_NOT_LOADED);
408 if (!parent_node || !parent_node->loaded_children()) 423 if (!parent_node || !parent_node->loaded_children())
409 return; 424 return;
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 if (!is_expanded_) 1029 if (!is_expanded_)
1015 return max_width; 1030 return max_width;
1016 for (int i = 0; i < child_count(); ++i) { 1031 for (int i = 0; i < child_count(); ++i) {
1017 max_width = std::max(max_width, 1032 max_width = std::max(max_width,
1018 GetChild(i)->GetMaxWidth(indent, depth + 1)); 1033 GetChild(i)->GetMaxWidth(indent, depth + 1));
1019 } 1034 }
1020 return max_width; 1035 return max_width;
1021 } 1036 }
1022 1037
1023 } // namespace views 1038 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698