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..d7faf0fa7ab27cf20608019ccb880abe80b4e215 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.bottom() - 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,25 @@ 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(); |
+ |
+ gfx::Rect old_bounds = child->bounds(); |
+ SetChildBoundsDirect(child, requested_bounds); |
+ if (old_bounds.height() == 0 && child->bounds().height() != 0) { |
+ // The window height is set to 0 initially. If the height of |old_bounds| is |
+ // 0 and the new bounds is not 0, it probably means window.resizeTo is |
+ // called to set the window height. We should try to show keyboard again in |
+ // case the show keyboard request is called before the height is set. |
+ 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 |