Commit 92fdaae5 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Fix the bug that FIP box is misaligned on relaunching in slide over mode.

If the device's size class has changed from RegularXRegular to another or
reversely, the find bar should switch between regular mode and compact mode
accordingly. Hide and then reshow the findbar in BVC.traitCollectionDidChange
if the size class changed.

Bug: 883672
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I38872c3fd0911e0e99ffae87f51f90c0cf9082fb
Reviewed-on: https://chromium-review.googlesource.com/1256690
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595819}
parent 202e04f1
...@@ -1836,6 +1836,15 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1836,6 +1836,15 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
self.currentWebState->GetWebViewProxy().contentInset = contentPadding; self.currentWebState->GetWebViewProxy().contentInset = contentPadding;
} }
// If the device's size class has changed from RegularXRegular to another and
// vice-versa, the find bar should switch between regular mode and compact
// mode accordingly. Hide the findbar here and it will be reshown in [self
// updateToobar];
if (ShouldShowCompactToolbar(previousTraitCollection) !=
ShouldShowCompactToolbar()) {
[self hideFindBarWithAnimation:NO];
}
// Update the toolbar visibility. // Update the toolbar visibility.
[self updateToolbar]; [self updateToolbar];
......
...@@ -205,16 +205,20 @@ bool IsCompactHeight(); ...@@ -205,16 +205,20 @@ bool IsCompactHeight();
// Whether the |environment| has a compact vertical size class. // Whether the |environment| has a compact vertical size class.
bool IsCompactHeight(id<UITraitEnvironment> environment); bool IsCompactHeight(id<UITraitEnvironment> environment);
// Whether the the main application window's rootViewController has a regular
// vertical and regular horizontal size class.
bool IsRegularXRegularSizeClass();
// Whether toolbar should be shown in compact mode. // Whether toolbar should be shown in compact mode.
bool ShouldShowCompactToolbar(); bool ShouldShowCompactToolbar();
// Whether toolbar should be shown in compact mode in |traitCollection|.
bool ShouldShowCompactToolbar(UITraitCollection* traitCollection);
// Whether the the main application window's rootViewController has a regular
// vertical and regular horizontal size class.
bool IsRegularXRegularSizeClass();
// Whether the |environment| has a regular vertical and regular horizontal // Whether the |environment| has a regular vertical and regular horizontal
// size class. the main application window's rootViewController // size class.
bool IsRegularXRegularSizeClass(id<UITraitEnvironment> environment); bool IsRegularXRegularSizeClass(id<UITraitEnvironment> environment);
// Whether the |traitCollection| has a regular vertical and regular horizontal
// size class.
bool IsRegularXRegularSizeClass(UITraitCollection* traitCollection);
// Returns whether the toolbar is split between top and bottom toolbar or if it // Returns whether the toolbar is split between top and bottom toolbar or if it
// is displayed as only one toolbar. // is displayed as only one toolbar.
......
...@@ -560,16 +560,20 @@ bool IsRegularXRegularSizeClass() { ...@@ -560,16 +560,20 @@ bool IsRegularXRegularSizeClass() {
} }
bool IsRegularXRegularSizeClass(id<UITraitEnvironment> environment) { bool IsRegularXRegularSizeClass(id<UITraitEnvironment> environment) {
UITraitCollection* traitCollection = environment.traitCollection; return IsRegularXRegularSizeClass(environment.traitCollection);
}
bool IsRegularXRegularSizeClass(UITraitCollection* traitCollection) {
return traitCollection.verticalSizeClass == UIUserInterfaceSizeClassRegular && return traitCollection.verticalSizeClass == UIUserInterfaceSizeClassRegular &&
traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular; traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular;
} }
bool ShouldShowCompactToolbar(UITraitCollection* traitCollection) {
return !IsRegularXRegularSizeClass(traitCollection);
}
bool ShouldShowCompactToolbar() { bool ShouldShowCompactToolbar() {
if (IsUIRefreshPhase1Enabled()) { return !IsRegularXRegularSizeClass();
return !IsRegularXRegularSizeClass();
}
return !IsIPadIdiom();
} }
bool IsSplitToolbarMode() { bool IsSplitToolbarMode() {
...@@ -577,8 +581,7 @@ bool IsSplitToolbarMode() { ...@@ -577,8 +581,7 @@ bool IsSplitToolbarMode() {
} }
bool IsSplitToolbarMode(id<UITraitEnvironment> environment) { bool IsSplitToolbarMode(id<UITraitEnvironment> environment) {
return IsUIRefreshPhase1Enabled() && IsCompactWidth(environment) && return IsCompactWidth(environment) && !IsCompactHeight(environment);
!IsCompactHeight(environment);
} }
// Returns the first responder in the subviews of |view|, or nil if no view in // Returns the first responder in the subviews of |view|, or nil if no view in
......
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