Commit d3bb267e authored by bshe's avatar bshe Committed by Commit bot

Restore virtual keyboard after switch back to FULL_WIDTH mode

After user decided to switch back to FULL_WIDTH mode, Chrome should:
1. immediately position the virtual keyboard to the bottom of screen and use
the screen width as its window width
2. notify web contents about the new virtual keyboard bounds so web contents
can be scrolled correctly to avoid occlussion.

BUG=487343

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

Cr-Commit-Position: refs/heads/master@{#329690}
parent 3549421e
......@@ -343,8 +343,16 @@ void KeyboardController::SetKeyboardMode(KeyboardMode mode) {
if (keyboard_mode_ == FLOATING) {
NotifyKeyboardBoundsChanging(gfx::Rect());
} else if (keyboard_mode_ == FULL_WIDTH) {
// TODO(bshe): handle switch to FULL_WIDTH from FLOATING mode. We need a way
// to know the height of virtual keyboard in FULL_WIDTH mode before here.
// TODO(bshe): revisit this logic after we decide to support resize virtual
// keyboard.
int keyboard_height = GetContainerWindow()->bounds().height();
const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds();
gfx::Rect new_bounds = root_bounds;
new_bounds.set_y(root_bounds.height() - keyboard_height);
new_bounds.set_height(keyboard_height);
GetContainerWindow()->SetBounds(new_bounds);
// No animation added, so call ShowAnimationFinished immediately.
ShowAnimationFinished();
}
}
......
......@@ -463,6 +463,29 @@ TEST_F(KeyboardControllerTest, FloatingKeyboardDontOverscrollOrResize) {
EXPECT_EQ(gfx::Rect(), controller()->current_keyboard_bounds());
}
// Verify switch to FULL_WIDTH mode will move virtual keyboard to the right
// place and sets the correct overscroll.
TEST_F(KeyboardControllerTest, SwitchToFullWidthVirtualKeyboard) {
ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT);
aura::Window* container(controller()->GetContainerWindow());
root_window()->AddChild(container);
gfx::Rect screen_bounds = root_window()->bounds();
keyboard::SetTouchKeyboardEnabled(true);
SetFocus(&input_client);
controller()->SetKeyboardMode(FLOATING);
EXPECT_EQ(gfx::Rect(), notified_bounds());
EXPECT_EQ(gfx::Rect(), controller()->current_keyboard_bounds());
controller()->SetKeyboardMode(FULL_WIDTH);
gfx::Rect expected_bounds(
0, screen_bounds.height() - kDefaultVirtualKeyboardHeight,
screen_bounds.width(), kDefaultVirtualKeyboardHeight);
EXPECT_EQ(expected_bounds, notified_bounds());
EXPECT_EQ(expected_bounds, controller()->current_keyboard_bounds());
}
TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) {
ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT);
ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT);
......
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