Commit abaf9fd9 authored by Robbie Gibson's avatar Robbie Gibson Committed by Chromium LUCI CQ

[iOS][Thumb Strip] Prevent tab strip appearing/breaking on backgrounding

There are actually two issues fixed by this CL. The first is the tab
strip reappearing after backgrounding/switching dark mode. This happens
because the BVC currently just sets the hidden status when revealing the
thumb strip and when the trait collection changes, so unhiding on trait
collection change overrides the hiding from revealing the thumb strip.
This is fixed by tracking these two separately in the tab strip
controller and using both to determine the overall hidden state.

Second is the thumb strip breaking on backgrounding. This happens
because I slightly misunderstood the UIGestureRecognizerDelegate.
-gestureRecognizerShouldBegin: doesn't necessarily mean WILL begin, so
the |currentRecognizer| should only be set once the pan gesture
actually begins.

Fixed: 1166020, 1165984
Change-Id: I177231f8be13fbc372358b2648a5a0d0a15d7f7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2626390Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#843110}
parent 78fdf20b
...@@ -2904,7 +2904,6 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2904,7 +2904,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
adjustTransformForRTL:CGAffineTransformMakeTranslation( adjustTransformForRTL:CGAffineTransformMakeTranslation(
0, self.tabStripView.frame.size 0, self.tabStripView.frame.size
.height)]; .height)];
self.tabStripView.hidden = YES;
[self.contentArea addSubview:self.tabStripSnapshot]; [self.contentArea addSubview:self.tabStripSnapshot];
AddSameConstraints(self.tabStripSnapshot, self.tabStripView); AddSameConstraints(self.tabStripSnapshot, self.tabStripView);
} }
...@@ -2982,7 +2981,6 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2982,7 +2981,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
} }
- (void)didAnimateViewReveal:(ViewRevealState)viewRevealState { - (void)didAnimateViewReveal:(ViewRevealState)viewRevealState {
self.tabStripView.hidden = (viewRevealState != ViewRevealState::Hidden);
[self.tabStripSnapshot removeFromSuperview]; [self.tabStripSnapshot removeFromSuperview];
self.bottomPosition = (viewRevealState == ViewRevealState::Revealed); self.bottomPosition = (viewRevealState == ViewRevealState::Revealed);
......
...@@ -98,6 +98,7 @@ const CGFloat kAnimationDuration = 0.25f; ...@@ -98,6 +98,7 @@ const CGFloat kAnimationDuration = 0.25f;
} }
if (!self.gesturesEnabled) if (!self.gesturesEnabled)
return; return;
self.currentRecognizer = gesture;
CGFloat translationY = [gesture translationInView:gesture.view.superview].y; CGFloat translationY = [gesture translationInView:gesture.view.superview].y;
if (gesture.state == UIGestureRecognizerStateBegan) { if (gesture.state == UIGestureRecognizerStateBegan) {
...@@ -529,7 +530,6 @@ const CGFloat kAnimationDuration = 0.25f; ...@@ -529,7 +530,6 @@ const CGFloat kAnimationDuration = 0.25f;
if (self.currentRecognizer) { if (self.currentRecognizer) {
return NO; return NO;
} }
self.currentRecognizer = gestureRecognizer;
return YES; return YES;
} }
......
...@@ -284,6 +284,13 @@ UIColor* BackgroundColor() { ...@@ -284,6 +284,13 @@ UIColor* BackgroundColor() {
// Pan gesture recognizer for the view revealing pan gesture handler. // Pan gesture recognizer for the view revealing pan gesture handler.
@property(nonatomic, weak) UIPanGestureRecognizer* panGestureRecognizer; @property(nonatomic, weak) UIPanGestureRecognizer* panGestureRecognizer;
// The tab strip view can be hidden for multiple reasons, which should be
// tracked independently.
// Tracks view hiding from external sources.
@property(nonatomic, assign) BOOL viewHidden;
// Tracks view hiding from thumb strip revealing.
@property(nonatomic, assign) BOOL viewHiddenForThumbStrip;
// Initializes the tab array based on the the entries in the |_webStateList|'s. // Initializes the tab array based on the the entries in the |_webStateList|'s.
// Creates one TabView per Tab and adds it to the tabstrip. A later call to // Creates one TabView per Tab and adds it to the tabstrip. A later call to
// |-layoutTabs| is needed to properly place the tabs in the correct positions. // |-layoutTabs| is needed to properly place the tabs in the correct positions.
...@@ -550,7 +557,13 @@ UIColor* BackgroundColor() { ...@@ -550,7 +557,13 @@ UIColor* BackgroundColor() {
} }
- (void)hideTabStrip:(BOOL)hidden { - (void)hideTabStrip:(BOOL)hidden {
self.view.hidden = hidden; self.viewHidden = hidden;
[self updateViewHidden];
}
// Updates the view's hidden property using all sources of visibility.
- (void)updateViewHidden {
self.view.hidden = self.viewHidden || self.viewHiddenForThumbStrip;
} }
- (void)tabStripSizeDidChange { - (void)tabStripSizeDidChange {
...@@ -1789,6 +1802,8 @@ UIColor* BackgroundColor() { ...@@ -1789,6 +1802,8 @@ UIColor* BackgroundColor() {
// should be visible behind the tab strip are visible. See the comment on // should be visible behind the tab strip are visible. See the comment on
// |BackgroundColor()| for more details. // |BackgroundColor()| for more details.
self.view.backgroundColor = UIColor.clearColor; self.view.backgroundColor = UIColor.clearColor;
self.viewHiddenForThumbStrip = YES;
[self updateViewHidden];
} }
- (void)animateViewReveal:(ViewRevealState)nextViewRevealState { - (void)animateViewReveal:(ViewRevealState)nextViewRevealState {
...@@ -1801,6 +1816,8 @@ UIColor* BackgroundColor() { ...@@ -1801,6 +1816,8 @@ UIColor* BackgroundColor() {
// the tab strip. // the tab strip.
self.view.backgroundColor = BackgroundColor(); self.view.backgroundColor = BackgroundColor();
} }
self.viewHiddenForThumbStrip = viewRevealState != ViewRevealState::Hidden;
[self updateViewHidden];
} }
@end @end
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