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

Unified Diff: ui/views/controls/table/table_view.cc

Issue 2780833004: Improve TableView unit tests and fix bugs that were uncovered. (Closed)
Patch Set: docs 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/table/table_view.h ('k') | ui/views/controls/table/table_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/controls/table/table_view.h ('k') | ui/views/controls/table/table_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698