Commit 07e1c27a authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

Revert "Fix NTP omnibox animation when there are suggestions"

This reverts commit 2aa19d70.

Reason for revert: Breaks QR code scanner. In investigating that, I think I found a better solution.

Original change's description:
> Fix NTP omnibox animation when there are suggestions
> 
> Before, if there were suggestions on the NTP, they would immediately
> appear. The better animation is to scroll the fakebox up to the top
> of the screen and then present the suggestions.
> 
> To do this, when entering the omnibox from NTP, we only focus the
> location bar, which causes the scrolling animation. -fakeboxFocused
> is already called in the animation completion block, which does the
> actual work to make the omnibox text field first responder, causing the
> suggestions to appear.
> 
> To finish off, the -locationBarDidBecomeFirstResponder code now only
> focuses the location bar if we are not on the regular NTP.
> 
> Bug: 1057643
> Change-Id: I472ee1ee5693fa4102717275bf266f4ab97e121a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2082556
> Commit-Queue: Robbie Gibson <rkgibson@google.com>
> Reviewed-by: Gauthier Ambard <gambard@chromium.org>
> Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#746450}

TBR=stkhapugin@chromium.org,gambard@chromium.org,rkgibson@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1057643
Change-Id: Ifda283f7733b9439e3803d1110b0afefeee084f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089782Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#747710}
parent 68d19c76
......@@ -3911,13 +3911,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[[OmniboxGeolocationController sharedInstance]
locationBarDidBecomeFirstResponder:self.browserState];
// On the non-incognito NTP, the primaryToolbarCoordinator focuses the
// location bar itself when focusing the fakebox (while animating the
// fakebox). On all other pages, the fakebox is focused here after the
// location bar becomes first responder.
if (!IsVisibleURLNewTabPage(self.currentWebState) || self.isOffTheRecord) {
[self.primaryToolbarCoordinator transitionToLocationBarFocusedState:YES];
}
[self.primaryToolbarCoordinator transitionToLocationBarFocusedState:YES];
}
- (void)locationBarDidResignFirstResponder {
......
......@@ -450,19 +450,12 @@ using base::UserMetricsAction;
if (self.disableScrollAnimation)
return;
// Focus the location bar if the omnibox is not already focused.
if (!self.omniboxFocused) {
// Only animated the location bar focus if the header is scrolled to the
// top.
BOOL animated = [self.delegate isScrolledToTop];
[self.dispatcher focusLocationBarWithAnimation:animated];
}
void (^animations)() = nil;
if (![self.delegate isScrolledToTop]) {
// Only trigger the fake omnibox animation if the header isn't scrolled to
// the top. Otherwise just rely on the normal animation.
self.disableScrollAnimation = YES;
[self.dispatcher focusOmniboxNoAnimation];
NamedGuide* omniboxGuide = [NamedGuide guideWithName:kOmniboxGuide
view:self.headerView];
// Layout the owning view to make sure that the constrains are applied.
......
......@@ -159,10 +159,16 @@
#pragma mark - FakeboxFocuser
- (void)focusLocationBarWithAnimation:(BOOL)animated {
self.enableAnimationsForOmniboxFocus = animated;
[self transitionToLocationBarFocusedState:YES];
- (void)focusOmniboxNoAnimation {
self.enableAnimationsForOmniboxFocus = NO;
[self fakeboxFocused];
self.enableAnimationsForOmniboxFocus = YES;
// If the pasteboard is containing a URL, the omnibox popup suggestions are
// displayed as soon as the omnibox is focused.
// If the fake omnibox animation is triggered at the same time, it is possible
// to see the NTP going up where the real omnibox should be displayed.
if ([self.locationBarCoordinator omniboxPopupHasAutocompleteResults])
[self onFakeboxAnimationComplete];
}
- (void)fakeboxFocused {
......
......@@ -10,8 +10,8 @@
// This protocol provides callbacks for focusing and blurring the fake omnibox
// on NTP.
@protocol FakeboxFocuser
// Focuses the location bar.
- (void)focusLocationBarWithAnimation:(BOOL)animated;
// Focuses the omnibox without animations.
- (void)focusOmniboxNoAnimation;
// Give focus to the omnibox, but indicate that the focus event was initiated
// from the fakebox on the Google landing page.
- (void)fakeboxFocused;
......
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