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() { ...@@ -66,6 +66,11 @@ UIColor* BackgroundColorIncognito() {
@property(nonatomic, strong) UITableView* tableView; @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 @end
@implementation OmniboxPopupViewController @implementation OmniboxPopupViewController
...@@ -74,12 +79,13 @@ UIColor* BackgroundColorIncognito() { ...@@ -74,12 +79,13 @@ UIColor* BackgroundColorIncognito() {
@synthesize imageRetriever = _imageRetriever; @synthesize imageRetriever = _imageRetriever;
@synthesize highlightedIndexPath = _highlightedIndexPath; @synthesize highlightedIndexPath = _highlightedIndexPath;
@synthesize tableView = _tableView; @synthesize tableView = _tableView;
@synthesize forwardsScrollEvents = _forwardsScrollEvents;
#pragma mark - #pragma mark -
#pragma mark Initialization #pragma mark Initialization
- (instancetype)init { - (instancetype)init {
if (self = [super initWithNibName:nil bundle:nil]) { if (self = [super initWithNibName:nil bundle:nil]) {
_forwardsScrollEvents = YES;
if (IsIPadIdiom()) { if (IsIPadIdiom()) {
// The iPad keyboard can cover some of the rows of the scroll view. The // 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 // scroll view's content inset may need to be updated when the keyboard is
...@@ -209,6 +215,7 @@ UIColor* BackgroundColorIncognito() { ...@@ -209,6 +215,7 @@ UIColor* BackgroundColorIncognito() {
- (void)updateMatches:(NSArray<id<AutocompleteSuggestion>>*)result - (void)updateMatches:(NSArray<id<AutocompleteSuggestion>>*)result
withAnimation:(BOOL)animation { withAnimation:(BOOL)animation {
self.forwardsScrollEvents = NO;
// Reset highlight state. // Reset highlight state.
if (self.highlightedIndexPath) { if (self.highlightedIndexPath) {
[self unhighlightRowAtIndexPath:self.highlightedIndexPath]; [self unhighlightRowAtIndexPath:self.highlightedIndexPath];
...@@ -222,6 +229,7 @@ UIColor* BackgroundColorIncognito() { ...@@ -222,6 +229,7 @@ UIColor* BackgroundColorIncognito() {
if (animation && size > 0) { if (animation && size > 0) {
[self fadeInRows]; [self fadeInRows];
} }
self.forwardsScrollEvents = YES;
} }
#pragma mark - #pragma mark -
...@@ -502,7 +510,8 @@ UIColor* BackgroundColorIncognito() { ...@@ -502,7 +510,8 @@ UIColor* BackgroundColorIncognito() {
return; return;
} }
[self.delegate autocompleteResultConsumerDidScroll:self]; if (self.forwardsScrollEvents)
[self.delegate autocompleteResultConsumerDidScroll:self];
for (OmniboxPopupRow* row in _rows) { for (OmniboxPopupRow* row in _rows) {
row.highlighted = NO; 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