| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/keyboard/keyboard_ui.h" |
| 6 |
| 7 #include "ui/aura/window.h" |
| 8 #include "ui/base/ime/input_method.h" |
| 9 #include "ui/base/ime/text_input_client.h" |
| 10 #include "ui/keyboard/keyboard_controller.h" |
| 11 |
| 12 namespace keyboard { |
| 13 |
| 14 KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {} |
| 15 KeyboardUI::~KeyboardUI() {} |
| 16 |
| 17 void KeyboardUI::ShowKeyboardContainer(aura::Window* container) { |
| 18 if (HasKeyboardWindow()) { |
| 19 GetKeyboardWindow()->Show(); |
| 20 container->Show(); |
| 21 } |
| 22 } |
| 23 |
| 24 void KeyboardUI::HideKeyboardContainer(aura::Window* container) { |
| 25 if (HasKeyboardWindow()) { |
| 26 container->Hide(); |
| 27 GetKeyboardWindow()->Hide(); |
| 28 } |
| 29 } |
| 30 |
| 31 void KeyboardUI::EnsureCaretInWorkArea() { |
| 32 if (GetInputMethod()->GetTextInputClient()) { |
| 33 aura::Window* keyboard_window = GetKeyboardWindow(); |
| 34 aura::Window* root_window = keyboard_window->GetRootWindow(); |
| 35 gfx::Rect available_bounds = root_window->bounds(); |
| 36 gfx::Rect keyboard_bounds = keyboard_window->bounds(); |
| 37 available_bounds.set_height(available_bounds.height() - |
| 38 keyboard_bounds.height()); |
| 39 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(available_bounds); |
| 40 } |
| 41 } |
| 42 |
| 43 void KeyboardUI::SetController(KeyboardController* controller) { |
| 44 keyboard_controller_ = controller; |
| 45 } |
| 46 |
| 47 } // namespace keyboard |
| OLD | NEW |