Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Unified Diff: ui/keyboard/keyboard_layout_manager.cc

Issue 240443006: Remove native VK window height logic and wait for resizeTo to setup VK window height (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/keyboard/keyboard_layout_manager.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/keyboard/keyboard_layout_manager.h ('k') | ui/keyboard/keyboard_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698