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

Side by Side Diff: ui/keyboard/keyboard_ui.cc

Issue 2240353002: move switch Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Virtual keyboard non-sticky mode changes. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « ui/keyboard/keyboard_controller.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/keyboard/keyboard_ui.h" 5 #include "ui/keyboard/keyboard_ui.h"
6 6
7 #include "base/command_line.h"
7 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
8 #include "ui/base/ime/input_method.h" 9 #include "ui/base/ime/input_method.h"
9 #include "ui/base/ime/text_input_client.h" 10 #include "ui/base/ime/text_input_client.h"
11 #include "ui/base/ui_base_switches.h"
10 #include "ui/keyboard/keyboard_controller.h" 12 #include "ui/keyboard/keyboard_controller.h"
11 13
12 namespace keyboard { 14 namespace keyboard {
13 15
14 KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {} 16 KeyboardUI::KeyboardUI() : keyboard_controller_(nullptr) {}
15 KeyboardUI::~KeyboardUI() {} 17 KeyboardUI::~KeyboardUI() {}
16 18
17 void KeyboardUI::ShowKeyboardContainer(aura::Window* container) { 19 void KeyboardUI::ShowKeyboardContainer(aura::Window* container) {
18 if (HasKeyboardWindow()) { 20 if (HasKeyboardWindow()) {
19 GetKeyboardWindow()->Show(); 21 GetKeyboardWindow()->Show();
20 container->Show(); 22 container->Show();
21 } 23 }
22 } 24 }
23 25
24 void KeyboardUI::HideKeyboardContainer(aura::Window* container) { 26 void KeyboardUI::HideKeyboardContainer(aura::Window* container) {
25 if (HasKeyboardWindow()) { 27 if (HasKeyboardWindow()) {
26 container->Hide(); 28 container->Hide();
27 GetKeyboardWindow()->Hide(); 29 GetKeyboardWindow()->Hide();
28 } 30 }
29 } 31 }
30 32
31 void KeyboardUI::EnsureCaretInWorkArea() { 33 void KeyboardUI::EnsureCaretInWorkArea() {
32 if (GetInputMethod()->GetTextInputClient()) { 34 if (GetInputMethod()) {
33 aura::Window* keyboard_window = GetKeyboardWindow(); 35 aura::Window* keyboard_window = GetKeyboardWindow();
34 aura::Window* root_window = keyboard_window->GetRootWindow(); 36 aura::Window* root_window = keyboard_window->GetRootWindow();
35 gfx::Rect available_bounds = root_window->bounds(); 37 gfx::Rect available_bounds = root_window->bounds();
36 gfx::Rect keyboard_bounds = keyboard_window->bounds(); 38 gfx::Rect keyboard_bounds = keyboard_window->bounds();
37 available_bounds.set_height(available_bounds.height() - 39
38 keyboard_bounds.height()); 40 bool new_vk_behavior =
39 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(available_bounds); 41 (base::CommandLine::ForCurrentProcess()->HasSwitch(
42 ::switches::kUseNewVKWindowBehavior) &&
43 !keyboard::KeyboardController::GetInstance()->get_lock_keyboard());
44 if (new_vk_behavior) {
45 if (keyboard_controller_->keyboard_visible())
46 available_bounds.set_height(available_bounds.height() -
47 keyboard_bounds.height());
48 GetInputMethod()->set_available_bounds(available_bounds);
49 } else if (GetInputMethod()->GetTextInputClient()) {
50 available_bounds.set_height(available_bounds.height() -
51 keyboard_bounds.height());
52 GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(
53 available_bounds);
54 }
40 } 55 }
41 } 56 }
42 57
43 void KeyboardUI::SetController(KeyboardController* controller) { 58 void KeyboardUI::SetController(KeyboardController* controller) {
44 keyboard_controller_ = controller; 59 keyboard_controller_ = controller;
45 } 60 }
46 61
47 } // namespace keyboard 62 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/keyboard_controller.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698