diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 19:56:39 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 19:56:39 +0000 |
commit | 0f59c4c1510fc33fbd30310704c10b08b67cda7d (patch) | |
tree | 2eaeb90e1e600274ea86ff5d2496b9d98a964b22 /chrome/browser/tabs | |
parent | 8f4f152c5a9e4a4de7337d3f3c3e2d42d43f7448 (diff) | |
download | chromium_src-0f59c4c1510fc33fbd30310704c10b08b67cda7d.zip chromium_src-0f59c4c1510fc33fbd30310704c10b08b67cda7d.tar.gz chromium_src-0f59c4c1510fc33fbd30310704c10b08b67cda7d.tar.bz2 |
Tab strip model: Fix an off by one error where we do not check the first tab.
BUG=33323
TEST=see bug
Review URL: http://codereview.chromium.org/561066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 39dea18..28b3639 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -305,23 +305,18 @@ int TabStripModel::GetIndexOfNextTabContentsOpenedBy( DCHECK(opener); DCHECK(ContainsIndex(start_index)); - TabContentsDataVector::const_iterator iter = - contents_data_.begin() + start_index; - TabContentsDataVector::const_iterator next; - for (; iter != contents_data_.end(); ++iter) { - next = iter + 1; - if (next == contents_data_.end()) - break; - if (OpenerMatches(*next, opener, use_group) && - !IsPhantomTab(static_cast<int>(next - contents_data_.begin()))) { - return static_cast<int>(next - contents_data_.begin()); + // Check tabs after start_index first. + for (int i = start_index + 1; i < count(); ++i) { + if (OpenerMatches(contents_data_[i], opener, use_group) && + !IsPhantomTab(i)) { + return i; } } - iter = contents_data_.begin() + start_index; - if (iter != contents_data_.begin()) { - for (--iter; iter != contents_data_.begin(); --iter) { - if (OpenerMatches(*iter, opener, use_group)) - return static_cast<int>(iter - contents_data_.begin()); + // Then check tabs before start_index, iterating backwards. + for (int i = start_index - 1; i >= 0; --i) { + if (OpenerMatches(contents_data_[i], opener, use_group) && + !IsPhantomTab(i)) { + return i; } } return kNoTab; |