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

Unified Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm

Issue 2741883002: [ios] Use WebStateList to back the tab grid. (Closed)
Patch Set: Add constant for invalid index 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 side-by-side diff with in-line comments
Download patch
Index: ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm
diff --git a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm
index 9ee9700b5b41eb6a12677446277f2dbadc36421c..4edb8fcfea36ce0361bdacd6da8d10689dcfac6c 100644
--- a/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm
+++ b/ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm
@@ -105,7 +105,7 @@ const CGFloat kToolbarHeight = 64.0f;
- (NSInteger)collectionView:(UICollectionView*)collectionView
numberOfItemsInSection:(NSInteger)section {
- NSInteger items = [self.dataSource numberOfTabsInTabGrid];
+ int items = [self.dataSource numberOfTabsInTabGrid];
// HACK: Do not make showing noTabsOverlay a side effect of the dataSource
// callback.
if (items) {
@@ -124,7 +124,9 @@ const CGFloat kToolbarHeight = 64.0f;
forIndexPath:indexPath]);
cell.delegate = self;
[cell setSessionType:TabSwitcherSessionType::REGULAR_SESSION];
- [cell setAppearanceForTabTitle:[self.dataSource titleAtIndex:indexPath.item]
+ DCHECK_LE(indexPath.item, INT_MAX);
+ int item = static_cast<int>(indexPath.item);
+ [cell setAppearanceForTabTitle:[self.dataSource titleAtIndex:item]
favicon:nil
cellSize:CGSizeZero];
[cell setSelected:(indexPath.item == [self.dataSource indexOfActiveTab])];
@@ -162,15 +164,13 @@ const CGFloat kToolbarHeight = 64.0f;
}
- (void)createNewTab:(id)sender {
- // PLACEHOLDER: The new WebStateList data structure will have implications
- // on how new tabs are created.
NSInteger index = [self.grid numberOfItemsInSection:0];
NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0];
auto updateBlock = ^{
// Unselect current selected item.
- NSInteger selectedIndex = [self.dataSource indexOfActiveTab];
NSIndexPath* selectedIndexPath =
- [NSIndexPath indexPathForItem:selectedIndex inSection:0];
+ [NSIndexPath indexPathForItem:[self.dataSource indexOfActiveTab]
+ inSection:0];
[self.grid reloadItemsAtIndexPaths:@[ selectedIndexPath ]];
// Create and show new tab.
@@ -189,10 +189,12 @@ const CGFloat kToolbarHeight = 64.0f;
}
- (void)cellPressed:(UICollectionViewCell*)cell {
- NSInteger selectedIndex = [self.dataSource indexOfActiveTab];
+ int selectedIndex = [self.dataSource indexOfActiveTab];
NSIndexPath* newSelectedIndexPath = [self.grid indexPathForCell:cell];
[self.tabCommandHandler showTabAtIndexPath:newSelectedIndexPath];
- if (newSelectedIndexPath.item != selectedIndex) {
+ if (selectedIndex == kTabGridDataSourceInvalidIndex) {
+ [self.grid reloadItemsAtIndexPaths:@[ newSelectedIndexPath ]];
+ } else if (newSelectedIndexPath.item != selectedIndex) {
NSIndexPath* selectedIndexPath =
[NSIndexPath indexPathForItem:selectedIndex inSection:0];
[self.grid
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h ('k') | ios/showcase/tab_grid/sc_tab_grid_coordinator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698