| OLD | NEW |
| 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 Loading... |
| 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 if (index != kUnselectedIndex) |
| 64 selected_indices_.push_back(index); |
| 63 } | 65 } |
| 64 | 66 |
| 65 bool TabStripSelectionModel::IsSelected(int index) const { | 67 bool TabStripSelectionModel::IsSelected(int index) const { |
| 66 return std::find(selected_indices_.begin(), selected_indices_.end(), index) != | 68 return std::find(selected_indices_.begin(), selected_indices_.end(), index) != |
| 67 selected_indices_.end(); | 69 selected_indices_.end(); |
| 68 } | 70 } |
| 69 | 71 |
| 70 void TabStripSelectionModel::AddIndexToSelection(int index) { | 72 void TabStripSelectionModel::AddIndexToSelection(int index) { |
| 71 if (!IsSelected(index)) { | 73 if (!IsSelected(index)) { |
| 72 selected_indices_.push_back(index); | 74 selected_indices_.push_back(index); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 anchor_ = active_ = kUnselectedIndex; | 134 anchor_ = active_ = kUnselectedIndex; |
| 133 SelectedIndices empty_selection; | 135 SelectedIndices empty_selection; |
| 134 selected_indices_.swap(empty_selection); | 136 selected_indices_.swap(empty_selection); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void TabStripSelectionModel::Copy(const TabStripSelectionModel& source) { | 139 void TabStripSelectionModel::Copy(const TabStripSelectionModel& source) { |
| 138 selected_indices_ = source.selected_indices_; | 140 selected_indices_ = source.selected_indices_; |
| 139 active_ = source.active_; | 141 active_ = source.active_; |
| 140 anchor_ = source.anchor_; | 142 anchor_ = source.anchor_; |
| 141 } | 143 } |
| OLD | NEW |