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

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

Issue 1129233006: Fixes possible crash in TableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | ui/views/controls/table/table_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map> 7 #include <map>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 for (int i = 0; i < length; ++i) 478 for (int i = 0; i < length; ++i)
479 selection_model_.DecrementFrom(start); 479 selection_model_.DecrementFrom(start);
480 NumRowsChanged(); 480 NumRowsChanged();
481 // If the selection was empty and is no longer empty select the same visual 481 // If the selection was empty and is no longer empty select the same visual
482 // index. 482 // index.
483 if (selection_model_.empty() && previously_selected_view_index != -1 && 483 if (selection_model_.empty() && previously_selected_view_index != -1 &&
484 RowCount()) { 484 RowCount()) {
485 selection_model_.SetSelectedIndex( 485 selection_model_.SetSelectedIndex(
486 ViewToModel(std::min(RowCount() - 1, previously_selected_view_index))); 486 ViewToModel(std::min(RowCount() - 1, previously_selected_view_index)));
487 } 487 }
488 if (!selection_model_.empty() && selection_model_.active() == -1)
489 selection_model_.set_active(FirstSelectedRow());
490 if (!selection_model_.empty() && selection_model_.anchor() == -1)
491 selection_model_.set_anchor(FirstSelectedRow());
488 if (table_view_observer_) 492 if (table_view_observer_)
489 table_view_observer_->OnSelectionChanged(); 493 table_view_observer_->OnSelectionChanged();
490 } 494 }
491 495
492 gfx::Point TableView::GetKeyboardContextMenuLocation() { 496 gfx::Point TableView::GetKeyboardContextMenuLocation() {
493 int first_selected = FirstSelectedRow(); 497 int first_selected = FirstSelectedRow();
494 gfx::Rect vis_bounds(GetVisibleBounds()); 498 gfx::Rect vis_bounds(GetVisibleBounds());
495 int y = vis_bounds.height() / 2; 499 int y = vis_bounds.height() / 2;
496 if (first_selected != -1) { 500 if (first_selected != -1) {
497 gfx::Rect cell_bounds(GetRowBounds(first_selected)); 501 gfx::Rect cell_bounds(GetRowBounds(first_selected));
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 if (tooltip) 943 if (tooltip)
940 *tooltip = text; 944 *tooltip = text;
941 if (tooltip_origin) { 945 if (tooltip_origin) {
942 tooltip_origin->SetPoint(cell_bounds.x(), 946 tooltip_origin->SetPoint(cell_bounds.x(),
943 cell_bounds.y() + kTextVerticalPadding); 947 cell_bounds.y() + kTextVerticalPadding);
944 } 948 }
945 return true; 949 return true;
946 } 950 }
947 951
948 } // namespace views 952 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/table/table_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698