Chromium Code Reviews| Index: ui/keyboard/keyboard_layout_manager.cc |
| diff --git a/ui/keyboard/keyboard_layout_manager.cc b/ui/keyboard/keyboard_layout_manager.cc |
| index 32085415bfe6ce5252ad502ee08bb75e48288963..27675c016ce2f9308ee356d12ced1cd59efcc7ae 100644 |
| --- a/ui/keyboard/keyboard_layout_manager.cc |
| +++ b/ui/keyboard/keyboard_layout_manager.cc |
| @@ -4,6 +4,7 @@ |
| #include "ui/keyboard/keyboard_layout_manager.h" |
| +#include "ui/compositor/layer_animator.h" |
| #include "ui/keyboard/keyboard_controller.h" |
| #include "ui/keyboard/keyboard_controller_proxy.h" |
| #include "ui/keyboard/keyboard_util.h" |
| @@ -12,14 +13,24 @@ namespace keyboard { |
| // Overridden from aura::LayoutManager |
| void KeyboardLayoutManager::OnWindowResized() { |
| - if (keyboard_ && !controller_->proxy()->resizing_from_contents()) |
| - ResizeKeyboardToDefault(keyboard_); |
| + if (keyboard_) { |
| + gfx::Rect window_bounds = controller_->GetContainerWindow()->bounds(); |
| + // Keep the same height when window resize. It usually get called when |
| + // screen rotate. |
| + int height = keyboard_->bounds().height(); |
| + keyboard_->SetBounds(gfx::Rect( |
| + window_bounds.x(), |
| + window_bounds.y() + window_bounds.height() - height, |
| + window_bounds.width(), |
| + height)); |
| + } |
| } |
| void KeyboardLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| DCHECK(!keyboard_); |
| keyboard_ = child; |
| - ResizeKeyboardToDefault(keyboard_); |
| + keyboard_->SetBounds(DefaultKeyboardBoundsFromWindowBounds( |
| + controller_->GetContainerWindow()->bounds())); |
| } |
| void KeyboardLayoutManager::SetChildBounds(aura::Window* child, |
| @@ -28,16 +39,21 @@ void KeyboardLayoutManager::SetChildBounds(aura::Window* child, |
| // resizing from the contents (through window.resizeTo call in JS). |
| // The flag resizing_from_contents() is used to determine the source of the |
| // resize. |
| - if (controller_->proxy()->resizing_from_contents()) { |
| + DCHECK(child == keyboard_); |
| + |
| + ui::LayerAnimator* animator = |
| + controller_->GetContainerWindow()->layer()->GetAnimator(); |
| + // Stops previous animation if a window resize is requested during animation. |
| + if (animator->is_animating()) |
| + animator->StopAnimating(); |
| + |
| + bool forceShow = child->bounds().height() == 0; |
|
Shu Chen
2014/04/22 17:54:57
The naming "forceShow" causes confusion.
If force
bshe
2014/04/23 01:08:53
I have changed the code to make it more readable.
|
| + SetChildBoundsDirect(child, requested_bounds); |
| + if (forceShow) { |
| + controller_->ShowKeyboard(false); |
| + } else { |
| controller_->NotifyKeyboardBoundsChanging(requested_bounds); |
| - SetChildBoundsDirect(child, requested_bounds); |
| } |
| } |
| -void KeyboardLayoutManager::ResizeKeyboardToDefault(aura::Window* child) { |
| - gfx::Rect keyboard_bounds = DefaultKeyboardBoundsFromWindowBounds( |
| - controller_->GetContainerWindow()->bounds()); |
| - SetChildBoundsDirect(child, keyboard_bounds); |
| -} |
| - |
| } // namespace keyboard |