Index: ui/keyboard/keyboard_controller.cc |
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc |
index 0cb975f7d949ebb54311960524adc2f8317e3918..4f57723a5737f50312a89888cd98271952fcc061 100644 |
--- a/ui/keyboard/keyboard_controller.cc |
+++ b/ui/keyboard/keyboard_controller.cc |
@@ -90,13 +90,25 @@ namespace keyboard { |
// LayoutManager for the virtual keyboard container. Manages a single window |
// (the virtual keyboard) and keeps it positioned at the bottom of the |
// owner window. |
-class KeyboardLayoutManager : public aura::LayoutManager { |
+class KeyboardLayoutManager : public aura::LayoutManager, |
+ public KeyboardResizer { |
public: |
KeyboardLayoutManager(aura::Window* container) |
- : container_(container), keyboard_(NULL) { |
+ : container_(container), keyboard_(NULL), resizing_(false) { |
CHECK(container_); |
} |
+ // Overridden from KeyboardResizer |
+ virtual void SetKeyboardHeight(int height) { |
+ gfx::Rect rect = keyboard_->bounds(); |
+ int old_height = rect.height(); |
+ rect.set_height(height); |
+ rect.set_y(rect.y() + old_height - height); |
+ resizing_ = true; |
+ keyboard_->SetBounds(rect); |
+ resizing_ = false; |
+ } |
+ |
// Overridden from aura::LayoutManager |
virtual void OnWindowResized() OVERRIDE { |
if (!keyboard_) |
@@ -114,12 +126,15 @@ class KeyboardLayoutManager : public aura::LayoutManager { |
bool visible) OVERRIDE {} |
virtual void SetChildBounds(aura::Window* child, |
const gfx::Rect& requested_bounds) OVERRIDE { |
- // Drop these: the size should only be set in OnWindowResized. |
+ if (resizing_) { |
+ SetChildBoundsDirect(child, requested_bounds); |
+ } |
} |
private: |
aura::Window* container_; |
aura::Window* keyboard_; |
+ bool resizing_; |
DISALLOW_COPY_AND_ASSIGN(KeyboardLayoutManager); |
}; |
@@ -148,7 +163,10 @@ aura::Window* KeyboardController::GetContainerWindow() { |
container_->set_owned_by_parent(false); |
container_->Init(ui::LAYER_NOT_DRAWN); |
container_->AddObserver(this); |
- container_->SetLayoutManager(new KeyboardLayoutManager(container_.get())); |
+ KeyboardLayoutManager* layout_manager = new KeyboardLayoutManager( |
+ container_.get()); |
+ proxy_->SetKeyboardResizer(layout_manager); |
+ container_->SetLayoutManager(layout_manager); |
kevers
2013/11/29 20:26:05
It looks a bit odd passing a raw pointer to 2 sepa
Shu Chen
2013/12/02 03:54:40
Done. I've refactored the changes and removed the
|
} |
return container_.get(); |
} |