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

Unified Diff: ui/keyboard/keyboard_controller.cc

Issue 14674004: DRAFT: Add setKeyboardVisibility API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: ui/keyboard/keyboard_controller.cc
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
index 17f4fddd8c8ac95ccdf57e0a0bdd29fcf4174f80..9bb7fb44aa3dde1d9a11b1a24c589b3794a45bdf 100644
--- a/ui/keyboard/keyboard_controller.cc
+++ b/ui/keyboard/keyboard_controller.cc
@@ -142,45 +142,19 @@ aura::Window* KeyboardController::GetContainerWindow() {
return container_;
}
-void KeyboardController::AddObserver(KeyboardControllerObserver* observer) {
- observer_list_.AddObserver(observer);
-}
-
-void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) {
- observer_list_.RemoveObserver(observer);
-}
-
-void KeyboardController::OnWindowParentChanged(aura::Window* window,
- aura::Window* parent) {
- OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient());
-}
-
-void KeyboardController::OnWindowDestroying(aura::Window* window) {
- DCHECK_EQ(container_, window);
- container_ = NULL;
-}
-
-void KeyboardController::OnTextInputStateChanged(
- const ui::TextInputClient* client) {
+void KeyboardController::SetKeyboardVisibility(bool should_show) {
if (!container_)
return;
bool was_showing = container_->IsVisible();
- bool should_show = was_showing;
- if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) {
- should_show = false;
- } else {
- if (container_->children().empty()) {
+ if (was_showing != should_show) {
+ if (should_show && container_->children().empty()) {
aura::Window* keyboard = proxy_->GetKeyboardWindow();
keyboard->Show();
container_->AddChild(keyboard);
container_->layout_manager()->OnWindowResized();
}
- container_->parent()->StackChildAtTop(container_);
- should_show = true;
- }
- if (was_showing != should_show) {
gfx::Rect new_bounds(
should_show ? container_->children()[0]->bounds() : gfx::Rect());
@@ -189,13 +163,39 @@ void KeyboardController::OnTextInputStateChanged(
observer_list_,
OnKeyboardBoundsChanging(new_bounds));
- if (should_show)
+ if (should_show) {
+ container_->parent()->StackChildAtTop(container_);
container_->Show();
- else
+ } else {
container_->Hide();
bryeung 2013/04/30 20:21:03 directly hiding the keyboard from JS seems to caus
sadrul 2013/05/14 06:23:19 Animation in the page itself should not be causing
+ }
proxy_->OnKeyboardBoundsChanged(new_bounds);
}
+}
+
+void KeyboardController::AddObserver(KeyboardControllerObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+void KeyboardController::OnWindowParentChanged(aura::Window* window,
+ aura::Window* parent) {
+ OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient());
+}
+
+void KeyboardController::OnWindowDestroying(aura::Window* window) {
+ DCHECK_EQ(container_, window);
+ container_ = NULL;
+}
+
+void KeyboardController::OnTextInputStateChanged(
+ const ui::TextInputClient* client) {
+ SetKeyboardVisibility(
+ (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE));
// TODO(bryeung): whenever the TextInputClient changes we need to notify the
// keyboard (with the TextInputType) so that it can reset it's state (e.g.

Powered by Google App Engine
This is Rietveld 408576698