Commit 67a4b368 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

[iOS] Ignore omnibox popup scroll events caused by new cells.

Ignores the scroll events caused by the updated suggestions.

Bug: 813025
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I10bee25484c964ded91afe47e7f51f8146e16f7b
Reviewed-on: https://chromium-review.googlesource.com/1181131Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584460}
parent 7d706632
......@@ -66,6 +66,11 @@ UIColor* BackgroundColorIncognito() {
@property(nonatomic, strong) UITableView* tableView;
// Flag that enables forwarding scroll events to the delegate. Disabled while
// updating the cells to avoid defocusing the omnibox when the omnibox popup
// changes size and table view issues a scroll event.
@property(nonatomic, assign) BOOL forwardsScrollEvents;
@end
@implementation OmniboxPopupViewController
......@@ -74,12 +79,13 @@ UIColor* BackgroundColorIncognito() {
@synthesize imageRetriever = _imageRetriever;
@synthesize highlightedIndexPath = _highlightedIndexPath;
@synthesize tableView = _tableView;
@synthesize forwardsScrollEvents = _forwardsScrollEvents;
#pragma mark -
#pragma mark Initialization
- (instancetype)init {
if (self = [super initWithNibName:nil bundle:nil]) {
_forwardsScrollEvents = YES;
if (IsIPadIdiom()) {
// The iPad keyboard can cover some of the rows of the scroll view. The
// scroll view's content inset may need to be updated when the keyboard is
......@@ -209,6 +215,7 @@ UIColor* BackgroundColorIncognito() {
- (void)updateMatches:(NSArray<id<AutocompleteSuggestion>>*)result
withAnimation:(BOOL)animation {
self.forwardsScrollEvents = NO;
// Reset highlight state.
if (self.highlightedIndexPath) {
[self unhighlightRowAtIndexPath:self.highlightedIndexPath];
......@@ -222,6 +229,7 @@ UIColor* BackgroundColorIncognito() {
if (animation && size > 0) {
[self fadeInRows];
}
self.forwardsScrollEvents = YES;
}
#pragma mark -
......@@ -502,7 +510,8 @@ UIColor* BackgroundColorIncognito() {
return;
}
[self.delegate autocompleteResultConsumerDidScroll:self];
if (self.forwardsScrollEvents)
[self.delegate autocompleteResultConsumerDidScroll:self];
for (OmniboxPopupRow* row in _rows) {
row.highlighted = NO;
}
......
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