Chromium Code Reviews| Index: ui/keyboard/keyboard_controller.cc |
| diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc |
| index 674685b2658514392b3234f1774866e98b647261..d930696fe4ebe04c81b19c018c770d9aff2d461a 100644 |
| --- a/ui/keyboard/keyboard_controller.cc |
| +++ b/ui/keyboard/keyboard_controller.cc |
| @@ -283,14 +283,7 @@ void KeyboardController::SetKeyboardMode(KeyboardMode mode) { |
| if (keyboard_mode_ == FLOATING) { |
| NotifyKeyboardBoundsChanging(gfx::Rect()); |
| } else if (keyboard_mode_ == FULL_WIDTH) { |
| - // 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); |
| + AdjustKeyboardBounds(); |
| // No animation added, so call ShowAnimationFinished immediately. |
| ShowAnimationFinished(); |
| } |
| @@ -319,6 +312,7 @@ void KeyboardController::OnWindowHierarchyChanged( |
| void KeyboardController::OnWindowAddedToRootWindow(aura::Window* window) { |
| if (!window->GetRootWindow()->HasObserver(this)) |
| window->GetRootWindow()->AddObserver(this); |
| + AdjustKeyboardBounds(); |
| } |
| void KeyboardController::OnWindowRemovingFromRootWindow(aura::Window* window, |
| @@ -511,4 +505,19 @@ void KeyboardController::HideAnimationFinished() { |
| observer.OnKeyboardHidden(); |
| } |
| +void KeyboardController::AdjustKeyboardBounds() { |
| + if (keyboard_mode_ == FLOATING) { |
|
bshe
2017/01/11 14:37:35
nit: if (keyboard_mode == FLOATING) return;
yhanada
2017/01/12 14:26:11
Done.
|
| + // When keyboard is floating, no resize is necessary. |
| + } else if (keyboard_mode_ == FULL_WIDTH) { |
| + // 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); |
| + } |
| +} |
| + |
| } // namespace keyboard |