Fix stale keyboard bounds on login screen

BUG=401667

Review URL: https://codereview.chromium.org/495923002

Cr-Commit-Position: refs/heads/master@{#291281}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291281 0039d316-1c4b-4281-b951-d872f2087c98
parent b20c3222
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/display/display_manager.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/screen_util.h" #include "ash/screen_util.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -187,7 +188,8 @@ TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) { ...@@ -187,7 +188,8 @@ TEST_F(LockLayoutManagerTest, MaximizedFullscreenWindowBoundsAreEqualToScreen) {
} }
TEST_F(LockLayoutManagerTest, KeyboardBounds) { TEST_F(LockLayoutManagerTest, KeyboardBounds) {
gfx::Rect screen_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
gfx::Rect screen_bounds = primary_display.bounds();
views::Widget::InitParams widget_params( views::Widget::InitParams widget_params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
...@@ -203,8 +205,30 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) { ...@@ -203,8 +205,30 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED); keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED);
ShowKeyboard(true); ShowKeyboard(true);
EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString()); EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString());
gfx::Rect keyboard_bounds =
keyboard::KeyboardController::GetInstance()->current_keyboard_bounds();
EXPECT_NE(keyboard_bounds, gfx::Rect());
ShowKeyboard(false); ShowKeyboard(false);
// When keyboard is hidden make sure that rotating the screen gives 100% of
// screen size to window.
// Repro steps for http://crbug.com/401667:
// 1. Set up login screen defaults: VK override disabled
// 2. Show/hide keyboard, make sure that no stale keyboard bounds are cached.
keyboard::SetKeyboardOverscrollOverride(
keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_DISABLED);
ShowKeyboard(true);
ShowKeyboard(false);
ash::DisplayManager* display_manager =
Shell::GetInstance()->display_manager();
display_manager->SetDisplayRotation(primary_display.id(),
gfx::Display::ROTATE_90);
primary_display = Shell::GetScreen()->GetPrimaryDisplay();
screen_bounds = primary_display.bounds();
EXPECT_EQ(screen_bounds.ToString(), window->GetBoundsInScreen().ToString());
display_manager->SetDisplayRotation(primary_display.id(),
gfx::Display::ROTATE_0);
// When virtual keyboard overscroll is disabled keyboard bounds do // When virtual keyboard overscroll is disabled keyboard bounds do
// affect window bounds. // affect window bounds.
keyboard::SetKeyboardOverscrollOverride( keyboard::SetKeyboardOverscrollOverride(
...@@ -212,6 +236,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) { ...@@ -212,6 +236,8 @@ TEST_F(LockLayoutManagerTest, KeyboardBounds) {
ShowKeyboard(true); ShowKeyboard(true);
keyboard::KeyboardController* keyboard = keyboard::KeyboardController* keyboard =
keyboard::KeyboardController::GetInstance(); keyboard::KeyboardController::GetInstance();
primary_display = Shell::GetScreen()->GetPrimaryDisplay();
screen_bounds = primary_display.bounds();
gfx::Rect target_bounds(screen_bounds); gfx::Rect target_bounds(screen_bounds);
target_bounds.set_height(target_bounds.height() - target_bounds.set_height(target_bounds.height() -
keyboard->proxy()->GetKeyboardWindow()->bounds().height()); keyboard->proxy()->GetKeyboardWindow()->bounds().height());
......
...@@ -167,12 +167,17 @@ void LockWindowState::UpdateBounds(wm::WindowState* window_state) { ...@@ -167,12 +167,17 @@ void LockWindowState::UpdateBounds(wm::WindowState* window_state) {
keyboard::KeyboardController::GetInstance(); keyboard::KeyboardController::GetInstance();
gfx::Rect keyboard_bounds; gfx::Rect keyboard_bounds;
if (keyboard_controller && !keyboard::IsKeyboardOverscrollEnabled()) if (keyboard_controller &&
!keyboard::IsKeyboardOverscrollEnabled() &&
keyboard_controller->keyboard_visible()) {
keyboard_bounds = keyboard_controller->current_keyboard_bounds(); keyboard_bounds = keyboard_controller->current_keyboard_bounds();
}
gfx::Rect bounds = gfx::Rect bounds =
ScreenUtil::GetDisplayBoundsInParent(window_state->window()); ScreenUtil::GetDisplayBoundsInParent(window_state->window());
bounds.set_height(bounds.height() - keyboard_bounds.height()); bounds.set_height(bounds.height() - keyboard_bounds.height());
VLOG(1) << "Updating window bounds to: " << bounds.ToString();
window_state->SetBoundsDirect(bounds); window_state->SetBoundsDirect(bounds);
} }
......
...@@ -305,6 +305,8 @@ void KeyboardController::NotifyKeyboardBoundsChanging( ...@@ -305,6 +305,8 @@ void KeyboardController::NotifyKeyboardBoundsChanging(
} else { } else {
ResetWindowInsets(); ResetWindowInsets();
} }
} else {
current_keyboard_bounds_ = gfx::Rect();
} }
} }
......
...@@ -56,7 +56,10 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, ...@@ -56,7 +56,10 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
// case the show keyboard request is called before the height is set. // case the show keyboard request is called before the height is set.
controller_->ShowKeyboard(false); controller_->ShowKeyboard(false);
} else { } else {
controller_->NotifyKeyboardBoundsChanging(requested_bounds); // We need to send out this notification only if keyboard is visible since
// keyboard window is resized even if keyboard is hidden.
if (controller_->keyboard_visible())
controller_->NotifyKeyboardBoundsChanging(requested_bounds);
} }
} }
......
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