Chromium Code Reviews| Index: ui/views/controls/table/table_view.cc |
| diff --git a/ui/views/controls/table/table_view.cc b/ui/views/controls/table/table_view.cc |
| index 6e05566534e2390c329380af58ea0e358c0ccd37..5d288041842940233edd410095d6eaf37b72dece 100644 |
| --- a/ui/views/controls/table/table_view.cc |
| +++ b/ui/views/controls/table/table_view.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/i18n/rtl.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "base/threading/thread_task_runner_handle.h" |
| #include "cc/paint/paint_flags.h" |
| #include "ui/accessibility/ax_node_data.h" |
| #include "ui/events/event.h" |
| @@ -140,7 +141,8 @@ TableView::TableView(ui::TableModel* model, |
| last_parent_width_(0), |
| layout_width_(0), |
| grouper_(NULL), |
| - in_set_visible_column_width_(false) { |
| + in_set_visible_column_width_(false), |
| + weak_factory_(this) { |
| for (size_t i = 0; i < columns.size(); ++i) { |
| VisibleColumn visible_column; |
| visible_column.column = columns[i]; |
| @@ -625,8 +627,9 @@ void TableView::OnFocus() { |
| if (scroll_view) |
| scroll_view->SetHasFocusIndicator(true); |
| - if (selection_model_.active() == -1 && RowCount()) |
| - SelectByViewIndex(0); |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
|
sky
2017/03/30 03:25:49
We shouldn't need to delay this. The press handler
|
| + FROM_HERE, base::Bind(&TableView::SelectFirstRowIfNoneSelected, |
| + weak_factory_.GetWeakPtr())); |
| SchedulePaintForSelection(); |
| NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
| @@ -956,4 +959,9 @@ bool TableView::GetTooltipImpl(const gfx::Point& location, |
| return true; |
| } |
| +void TableView::SelectFirstRowIfNoneSelected() { |
| + if (HasFocus() && selection_model_.active() == -1 && RowCount()) |
| + SelectByViewIndex(0); |
| +} |
| + |
| } // namespace views |