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

Side by Side Diff: chrome/browser/tabs/tab_strip_selection_model.cc

Issue 7140001: Multi-tab: Fixing TabStripSelectionModel::SetSelectedIndex corner case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/tabs/tab_strip_selection_model.h" 5 #include "chrome/browser/tabs/tab_strip_selection_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <valarray> 8 #include <valarray>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 i = selected_indices_.erase(i); 52 i = selected_indices_.erase(i);
53 else 53 else
54 ++i; 54 ++i;
55 } 55 }
56 DecrementFromImpl(index, &anchor_); 56 DecrementFromImpl(index, &anchor_);
57 DecrementFromImpl(index, &active_); 57 DecrementFromImpl(index, &active_);
58 } 58 }
59 59
60 void TabStripSelectionModel::SetSelectedIndex(int index) { 60 void TabStripSelectionModel::SetSelectedIndex(int index) {
61 anchor_ = active_ = index; 61 anchor_ = active_ = index;
62 SetSelectionFromAnchorTo(index); 62 selected_indices_.clear();
63 selected_indices_.push_back(index);
sky 2011/06/08 20:38:49 Only push_back if index != kUnselectedIndex.
dpapad 2011/06/08 21:19:34 Done.
63 } 64 }
64 65
65 bool TabStripSelectionModel::IsSelected(int index) const { 66 bool TabStripSelectionModel::IsSelected(int index) const {
66 return std::find(selected_indices_.begin(), selected_indices_.end(), index) != 67 return std::find(selected_indices_.begin(), selected_indices_.end(), index) !=
67 selected_indices_.end(); 68 selected_indices_.end();
68 } 69 }
69 70
70 void TabStripSelectionModel::AddIndexToSelection(int index) { 71 void TabStripSelectionModel::AddIndexToSelection(int index) {
71 if (!IsSelected(index)) { 72 if (!IsSelected(index)) {
72 selected_indices_.push_back(index); 73 selected_indices_.push_back(index);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 anchor_ = active_ = kUnselectedIndex; 133 anchor_ = active_ = kUnselectedIndex;
133 SelectedIndices empty_selection; 134 SelectedIndices empty_selection;
134 selected_indices_.swap(empty_selection); 135 selected_indices_.swap(empty_selection);
135 } 136 }
136 137
137 void TabStripSelectionModel::Copy(const TabStripSelectionModel& source) { 138 void TabStripSelectionModel::Copy(const TabStripSelectionModel& source) {
138 selected_indices_ = source.selected_indices_; 139 selected_indices_ = source.selected_indices_;
139 active_ = source.active_; 140 active_ = source.active_;
140 anchor_ = source.anchor_; 141 anchor_ = source.anchor_;
141 } 142 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698