Commit caa3e40d authored by oshima's avatar oshima Committed by Commit bot

Fire OnKeyboardBoundsChanging event when Display metrics changes

BUG=623648
TEST=KeyboardControllerTest.DisplayChangeShould

Review-Url: https://codereview.chromium.org/2101023002
Cr-Commit-Position: refs/heads/master@{#403364}
parent 0fa42268
......@@ -206,11 +206,8 @@ class KeyboardControllerTest : public testing::Test,
void MockRotateScreen() {
const gfx::Rect root_bounds = root_window()->bounds();
controller_->OnWindowBoundsChanged(root_window(), gfx::Rect(),
gfx::Rect(0,
0,
root_bounds.height(),
root_bounds.width()));
root_window()->SetBounds(
gfx::Rect(0, 0, root_bounds.height(), root_bounds.width()));
}
protected:
......@@ -275,7 +272,6 @@ TEST_F(KeyboardControllerTest, KeyboardSize) {
ASSERT_EQ(gfx::Rect(), initial_bounds);
VerifyKeyboardWindowSize(container, keyboard);
// In FULL_WIDTH mode, attempt to change window width or move window up from
// the bottom are ignored. Changing window height is supported.
gfx::Rect expected_bounds(0,
......@@ -643,4 +639,22 @@ TEST_F(KeyboardControllerTest, FloatingKeyboardShowOnFirstTap) {
EXPECT_TRUE(container->IsVisible());
}
TEST_F(KeyboardControllerTest, DisplayChangeShouldNotifyBoundsChange) {
ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT);
aura::Window* container(controller()->GetContainerWindow());
root_window()->AddChild(container);
keyboard::SetTouchKeyboardEnabled(true);
controller()->SetKeyboardMode(FULL_WIDTH);
SetFocus(&input_client);
gfx::Rect new_bounds(0, 0, 1280, 800);
ASSERT_NE(new_bounds, root_window()->bounds());
EXPECT_EQ(1, number_of_calls());
root_window()->SetBounds(new_bounds);
EXPECT_EQ(2, number_of_calls());
MockRotateScreen();
EXPECT_EQ(3, number_of_calls());
}
} // namespace keyboard
......@@ -19,7 +19,11 @@ void KeyboardLayoutManager::OnWindowResized() {
// desired bounds before changing the bounds of the virtual keyboard window.
gfx::Rect container_bounds = controller_->GetContainerWindow()->bounds();
// Always align container window and keyboard window.
SetChildBoundsDirect(keyboard_, gfx::Rect(container_bounds.size()));
if (controller_->keyboard_mode() == FULL_WIDTH) {
SetChildBounds(keyboard_, gfx::Rect(container_bounds.size()));
} else {
SetChildBoundsDirect(keyboard_, gfx::Rect(container_bounds.size()));
}
}
}
......@@ -42,7 +46,6 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
// window) should change the container window first. Then the child window is
// resized and covers the container window. Note the child's bound is only set
// in OnWindowResized.
gfx::Rect old_bounds = controller_->GetContainerWindow()->bounds();
gfx::Rect new_bounds = requested_bounds;
if (controller_->keyboard_mode() == FULL_WIDTH) {
const gfx::Rect& window_bounds =
......@@ -57,9 +60,12 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child,
// Keyboard bounds should only be reset when it actually changes. Otherwise
// it interrupts the initial animation of showing the keyboard. Described in
// crbug.com/356753.
if (new_bounds == old_bounds) {
gfx::Rect old_bounds = keyboard_->GetTargetBounds();
aura::Window::ConvertRectToTarget(keyboard_,
keyboard_->GetRootWindow(),
&old_bounds);
if (new_bounds == old_bounds)
return;
}
ui::LayerAnimator* animator =
controller_->GetContainerWindow()->layer()->GetAnimator();
......
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