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

Side by Side Diff: ios/shared/chrome/browser/tabs/web_state_list.mm

Issue 2766063002: Remove the concept of currentItemIndex (Closed)
Patch Set: fix unit tests 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #import "ios/shared/chrome/browser/tabs/web_state_list.h" 5 #import "ios/shared/chrome/browser/tabs/web_state_list.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 int WebStateList::GetIndexOfNthWebStateOpenedBy(const web::WebState* opener, 295 int WebStateList::GetIndexOfNthWebStateOpenedBy(const web::WebState* opener,
296 int start_index, 296 int start_index,
297 bool use_group, 297 bool use_group,
298 int n) const { 298 int n) const {
299 DCHECK_GT(n, 0); 299 DCHECK_GT(n, 0);
300 if (!opener || !ContainsIndex(start_index) || start_index == INT_MAX) 300 if (!opener || !ContainsIndex(start_index) || start_index == INT_MAX)
301 return kInvalidIndex; 301 return kInvalidIndex;
302 302
303 const int opener_navigation_index = 303 const int opener_navigation_index =
304 use_group ? opener->GetNavigationManager()->GetCurrentItemIndex() : -1; 304 use_group ? opener->GetNavigationManager()->GetLastCommittedItemIndex()
305 : -1;
305 306
306 int found_index = kInvalidIndex; 307 int found_index = kInvalidIndex;
307 for (int index = start_index + 1; index < count() && n; ++index) { 308 for (int index = start_index + 1; index < count() && n; ++index) {
308 if (web_state_wrappers_[index]->WasOpenedBy(opener, opener_navigation_index, 309 if (web_state_wrappers_[index]->WasOpenedBy(opener, opener_navigation_index,
309 use_group)) { 310 use_group)) {
310 found_index = index; 311 found_index = index;
311 --n; 312 --n;
312 } else if (found_index != kInvalidIndex) { 313 } else if (found_index != kInvalidIndex) {
313 return found_index; 314 return found_index;
314 } 315 }
315 } 316 }
316 317
317 return found_index; 318 return found_index;
318 } 319 }
319 320
320 // static 321 // static
321 const int WebStateList::kInvalidIndex; 322 const int WebStateList::kInvalidIndex;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698