Commit 9960b831 authored by Huanzhong Huang's avatar Huanzhong Huang Committed by Commit Bot

[iOS] Fix CBD Selection Anomaly after Font Change

Please refer to the bug for details.

-It's unclear how to instruct the table view to recover the selection
states for those previously selected cells after a reload triggered by
a font size change.
-We've previously (1596451) made changes so that
TableViewClearBrowsingDataItem's configureCell:withStyler: is again
solely responsible for a TableViewClearBrowsingDataCell's appearance.
-Therefore we turn back to the usual approach of not maintaining
a cell's selection state: maintaining states in items, reflecting
item states in cell appearances.

Bug: 960756
Change-Id: I987da5e10b0745f035effb12ab493b240ccd407b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601256Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Huanzhong Huang <huanzhong@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661286}
parent b9c2398f
...@@ -140,7 +140,6 @@ ...@@ -140,7 +140,6 @@
// Add a tableFooterView in order to disable separators at the bottom of the // Add a tableFooterView in order to disable separators at the bottom of the
// tableView. // tableView.
self.tableView.tableFooterView = [[UIView alloc] init]; self.tableView.tableFooterView = [[UIView alloc] init];
self.tableView.allowsMultipleSelection = YES;
// Navigation controller configuration. // Navigation controller configuration.
self.title = l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE); self.title = l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
// Adds the "Done" button and hooks it up to |dismiss|. // Adds the "Done" button and hooks it up to |dismiss|.
...@@ -164,21 +163,7 @@ ...@@ -164,21 +163,7 @@
[self.dataManager restartCounters:BrowsingDataRemoveMask::REMOVE_ALL]; [self.dataManager restartCounters:BrowsingDataRemoveMask::REMOVE_ALL];
if (IsNewClearBrowsingDataUIEnabled()) { if (IsNewClearBrowsingDataUIEnabled()) {
// Maintain selection state consistency.
NSArray* dataTypeItems = [self.tableViewModel
itemsInSectionWithIdentifier:SectionIdentifierDataTypes];
for (TableViewClearBrowsingDataItem* dataTypeItem in dataTypeItems) {
DCHECK(
[dataTypeItem isKindOfClass:[TableViewClearBrowsingDataItem class]]);
if (dataTypeItem.checked) {
[self.tableView selectRowAtIndexPath:[self.tableViewModel
indexPathForItem:dataTypeItem]
animated:NO
scrollPosition:UITableViewScrollPositionNone];
}
}
[self updateToolbarButtons]; [self updateToolbarButtons];
// Showing toolbar here because parent class hides toolbar in // Showing toolbar here because parent class hides toolbar in
// viewWillDisappear:. // viewWillDisappear:.
self.navigationController.toolbarHidden = NO; self.navigationController.toolbarHidden = NO;
...@@ -306,7 +291,12 @@ ...@@ -306,7 +291,12 @@
case ItemTypeDataTypeCache: case ItemTypeDataTypeCache:
case ItemTypeDataTypeSavedPasswords: case ItemTypeDataTypeSavedPasswords:
case ItemTypeDataTypeAutofill: { case ItemTypeDataTypeAutofill: {
[self reconfigureCellAndUpdateItem:item toCheckedValue:YES]; DCHECK([item isKindOfClass:[TableViewClearBrowsingDataItem class]]);
TableViewClearBrowsingDataItem* clearBrowsingDataItem =
base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item);
clearBrowsingDataItem.checked = !clearBrowsingDataItem.checked;
[self reconfigureCellsForItems:@[ clearBrowsingDataItem ]];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
break; break;
} }
default: default:
...@@ -340,28 +330,6 @@ ...@@ -340,28 +330,6 @@
} }
} }
- (void)tableView:(UITableView*)tableView
didDeselectRowAtIndexPath:(NSIndexPath*)indexPath {
if (!IsNewClearBrowsingDataUIEnabled()) {
return;
}
TableViewItem* item = [self.tableViewModel itemAtIndexPath:indexPath];
DCHECK(item);
switch (item.type) {
case ItemTypeDataTypeBrowsingHistory:
case ItemTypeDataTypeCookiesSiteData:
case ItemTypeDataTypeCache:
case ItemTypeDataTypeSavedPasswords:
case ItemTypeDataTypeAutofill: {
[self reconfigureCellAndUpdateItem:item toCheckedValue:NO];
break;
}
default:
break;
}
[self updateToolbarButtons];
}
#pragma mark - TableViewTextLinkCellDelegate #pragma mark - TableViewTextLinkCellDelegate
- (void)tableViewTextLinkCell:(TableViewTextLinkCell*)cell - (void)tableViewTextLinkCell:(TableViewTextLinkCell*)cell
...@@ -381,20 +349,6 @@ ...@@ -381,20 +349,6 @@
// thus the cell height needs to adapt accordingly. // thus the cell height needs to adapt accordingly.
[self reloadCellsForItems:@[ item ] [self reloadCellsForItems:@[ item ]
withRowAnimation:UITableViewRowAnimationAutomatic]; withRowAnimation:UITableViewRowAnimationAutomatic];
// Restore a cell's seleted state potentially cleared by the above reload
// method.
if (IsNewClearBrowsingDataUIEnabled() &&
[item isKindOfClass:[TableViewClearBrowsingDataItem class]]) {
TableViewClearBrowsingDataItem* dataTypeItem =
base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item);
if (dataTypeItem.checked) {
[self.tableView selectRowAtIndexPath:[self.tableViewModel
indexPathForItem:dataTypeItem]
animated:NO
scrollPosition:UITableViewScrollPositionNone];
}
}
} }
- (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState - (void)removeBrowsingDataForBrowserState:(ios::ChromeBrowserState*)browserState
...@@ -503,16 +457,6 @@ ...@@ -503,16 +457,6 @@
[self.actionSheetCoordinator start]; [self.actionSheetCoordinator start];
} }
// Sets |item|'s checked to |value|, then invokes cell configuration.
- (void)reconfigureCellAndUpdateItem:(TableViewItem*)item
toCheckedValue:(BOOL)value {
DCHECK([item isKindOfClass:[TableViewClearBrowsingDataItem class]]);
TableViewClearBrowsingDataItem* clearBrowsingDataItem =
base::mac::ObjCCastStrict<TableViewClearBrowsingDataItem>(item);
clearBrowsingDataItem.checked = value;
[self reconfigureCellsForItems:@[ clearBrowsingDataItem ]];
}
- (void)updateToolbarButtons { - (void)updateToolbarButtons {
self.clearBrowsingDataBarButton.enabled = [self hasDataTypeItemsSelected]; self.clearBrowsingDataBarButton.enabled = [self hasDataTypeItemsSelected];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment