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

Unified Diff: ui/keyboard/keyboard_ui.cc

Issue 2553603002: New accessibility virtual keyboard behavior in non-sticky mode. (Closed)
Patch Set: rebase Created 3 years, 7 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_controller.cc ('k') | ui/views/controls/textfield/textfield.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/keyboard/keyboard_ui.cc
diff --git a/ui/keyboard/keyboard_ui.cc b/ui/keyboard/keyboard_ui.cc
index 896add64cb2fa7fb0d84096e41a51c31141d9c9b..69b1f1e905a400dc1df1ef694e154cca48a71789 100644
--- a/ui/keyboard/keyboard_ui.cc
+++ b/ui/keyboard/keyboard_ui.cc
@@ -4,9 +4,11 @@
#include "ui/keyboard/keyboard_ui.h"
+#include "base/command_line.h"
#include "ui/aura/window.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/keyboard/keyboard_controller.h"
namespace keyboard {
@@ -29,10 +31,26 @@ void KeyboardUI::HideKeyboardContainer(aura::Window* container) {
}
void KeyboardUI::EnsureCaretInWorkArea() {
- if (GetInputMethod()->GetTextInputClient()) {
- aura::Window* keyboard_window = GetKeyboardWindow();
+ if (!GetInputMethod())
+ return;
+
+ const aura::Window* keyboard_window = GetKeyboardWindow();
+ const gfx::Rect keyboard_bounds_in_screen =
+ keyboard_window->IsVisible() ? keyboard_window->GetBoundsInScreen()
+ : gfx::Rect();
+
+ // Use new virtual keyboard behavior only if the flag enabled and in
+ // non-sticky mode.
+ const bool new_vk_behavior =
+ (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ ::switches::kUseNewVirtualKeyboardBehavior) &&
+ !keyboard::KeyboardController::GetInstance()->keyboard_locked());
+
+ if (new_vk_behavior) {
+ GetInputMethod()->SetOnScreenKeyboardBounds(keyboard_bounds_in_screen);
+ } else if (GetInputMethod()->GetTextInputClient()) {
GetInputMethod()->GetTextInputClient()->EnsureCaretNotInRect(
- keyboard_window->GetBoundsInScreen());
+ keyboard_bounds_in_screen);
}
}
« 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