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

Side by Side Diff: ui/views/controls/table/table_view.cc

Issue 2769243002: Adjust initial activation/focus Task Manager/Views TableView. (Closed)
Patch Set: sky review Created 3 years, 9 months 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
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/table/table_view.h" 5 #include "ui/views/controls/table/table_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 int TableView::ModelToView(int model_index) const { 292 int TableView::ModelToView(int model_index) const {
293 if (!is_sorted()) 293 if (!is_sorted())
294 return model_index; 294 return model_index;
295 DCHECK_GE(model_index, 0) << " negative model_index " << model_index; 295 DCHECK_GE(model_index, 0) << " negative model_index " << model_index;
296 DCHECK_LT(model_index, RowCount()) << " out of bounds model_index " << 296 DCHECK_LT(model_index, RowCount()) << " out of bounds model_index " <<
297 model_index; 297 model_index;
298 return model_to_view_[model_index]; 298 return model_to_view_[model_index];
299 } 299 }
300 300
301 int TableView::ViewToModel(int view_index) const { 301 int TableView::ViewToModel(int view_index) const {
302 if (!is_sorted())
303 return view_index;
304 DCHECK_GE(view_index, 0) << " negative view_index " << view_index; 302 DCHECK_GE(view_index, 0) << " negative view_index " << view_index;
305 DCHECK_LT(view_index, RowCount()) << " out of bounds view_index " << 303 DCHECK_LT(view_index, RowCount()) << " out of bounds view_index " <<
306 view_index; 304 view_index;
307 return view_to_model_[view_index]; 305 return is_sorted() ? view_to_model_[view_index] : view_index;
308 } 306 }
309 307
310 void TableView::Layout() { 308 void TableView::Layout() {
311 // parent()->parent() is the scrollview. When its width changes we force 309 // parent()->parent() is the scrollview. When its width changes we force
312 // recalculating column sizes. 310 // recalculating column sizes.
313 View* scroll_view = parent() ? parent()->parent() : NULL; 311 View* scroll_view = parent() ? parent()->parent() : NULL;
314 if (scroll_view) { 312 if (scroll_view) {
315 const int scroll_view_width = scroll_view->GetContentsBounds().width(); 313 const int scroll_view_width = scroll_view->GetContentsBounds().width();
316 if (scroll_view_width != last_parent_width_) { 314 if (scroll_view_width != last_parent_width_) {
317 last_parent_width_ = scroll_view_width; 315 last_parent_width_ = scroll_view_width;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()), 617 gfx::Point(group_indicator_x, start_cell_bounds.CenterPoint().y()),
620 kGroupingIndicatorSize / 2, grouping_flags); 618 kGroupingIndicatorSize / 2, grouping_flags);
621 i = last + 1; 619 i = last + 1;
622 } 620 }
623 } 621 }
624 622
625 void TableView::OnFocus() { 623 void TableView::OnFocus() {
626 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); 624 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this);
627 if (scroll_view) 625 if (scroll_view)
628 scroll_view->SetHasFocusIndicator(true); 626 scroll_view->SetHasFocusIndicator(true);
627
628 if (selection_model_.active() == -1 && RowCount())
629 SelectByViewIndex(0);
630
629 SchedulePaintForSelection(); 631 SchedulePaintForSelection();
630
631 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); 632 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true);
632 } 633 }
633 634
634 void TableView::OnBlur() { 635 void TableView::OnBlur() {
635 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this); 636 ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this);
636 if (scroll_view) 637 if (scroll_view)
637 scroll_view->SetHasFocusIndicator(false); 638 scroll_view->SetHasFocusIndicator(false);
638 SchedulePaintForSelection(); 639 SchedulePaintForSelection();
639 } 640 }
640 641
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 if (tooltip) 950 if (tooltip)
950 *tooltip = text; 951 *tooltip = text;
951 if (tooltip_origin) { 952 if (tooltip_origin) {
952 tooltip_origin->SetPoint(cell_bounds.x(), 953 tooltip_origin->SetPoint(cell_bounds.x(),
953 cell_bounds.y() + kTextVerticalPadding); 954 cell_bounds.y() + kTextVerticalPadding);
954 } 955 }
955 return true; 956 return true;
956 } 957 }
957 958
958 } // namespace views 959 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698