| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_controller.h" | 5 #include "ui/keyboard/keyboard_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 if (ui_->HasKeyboardWindow() && ui_->GetKeyboardWindow()->IsVisible()) { | 232 if (ui_->HasKeyboardWindow() && ui_->GetKeyboardWindow()->IsVisible()) { |
| 233 for (KeyboardControllerObserver& observer : observer_list_) | 233 for (KeyboardControllerObserver& observer : observer_list_) |
| 234 observer.OnKeyboardBoundsChanging(new_bounds); | 234 observer.OnKeyboardBoundsChanging(new_bounds); |
| 235 if (keyboard::IsKeyboardOverscrollEnabled()) | 235 if (keyboard::IsKeyboardOverscrollEnabled()) |
| 236 ui_->InitInsets(new_bounds); | 236 ui_->InitInsets(new_bounds); |
| 237 else | 237 else |
| 238 ui_->ResetInsets(); | 238 ui_->ResetInsets(); |
| 239 } else { | 239 } else { |
| 240 current_keyboard_bounds_ = gfx::Rect(); | 240 current_keyboard_bounds_ = gfx::Rect(); |
| 241 } | 241 } |
| 242 ui_->EnsureCaretInWorkArea(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void KeyboardController::HideKeyboard(HideReason reason) { | 245 void KeyboardController::HideKeyboard(HideReason reason) { |
| 245 keyboard_visible_ = false; | 246 keyboard_visible_ = false; |
| 246 ToggleTouchEventLogging(true); | 247 ToggleTouchEventLogging(true); |
| 247 | 248 |
| 248 keyboard::LogKeyboardControlEvent( | 249 keyboard::LogKeyboardControlEvent( |
| 249 reason == HIDE_REASON_AUTOMATIC ? | 250 reason == HIDE_REASON_AUTOMATIC ? |
| 250 keyboard::KEYBOARD_CONTROL_HIDE_AUTO : | 251 keyboard::KEYBOARD_CONTROL_HIDE_AUTO : |
| 251 keyboard::KEYBOARD_CONTROL_HIDE_USER); | 252 keyboard::KEYBOARD_CONTROL_HIDE_USER); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } | 498 } |
| 498 | 499 |
| 499 bool KeyboardController::WillHideKeyboard() const { | 500 bool KeyboardController::WillHideKeyboard() const { |
| 500 return weak_factory_.HasWeakPtrs(); | 501 return weak_factory_.HasWeakPtrs(); |
| 501 } | 502 } |
| 502 | 503 |
| 503 void KeyboardController::ShowAnimationFinished() { | 504 void KeyboardController::ShowAnimationFinished() { |
| 504 // Notify observers after animation finished to prevent reveal desktop | 505 // Notify observers after animation finished to prevent reveal desktop |
| 505 // background during animation. | 506 // background during animation. |
| 506 NotifyKeyboardBoundsChanging(container_->bounds()); | 507 NotifyKeyboardBoundsChanging(container_->bounds()); |
| 507 ui_->EnsureCaretInWorkArea(); | |
| 508 } | 508 } |
| 509 | 509 |
| 510 void KeyboardController::HideAnimationFinished() { | 510 void KeyboardController::HideAnimationFinished() { |
| 511 ui_->HideKeyboardContainer(container_.get()); | 511 ui_->HideKeyboardContainer(container_.get()); |
| 512 for (KeyboardControllerObserver& observer : observer_list_) | 512 for (KeyboardControllerObserver& observer : observer_list_) |
| 513 observer.OnKeyboardHidden(); | 513 observer.OnKeyboardHidden(); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void KeyboardController::AdjustKeyboardBounds() { | 516 void KeyboardController::AdjustKeyboardBounds() { |
| 517 // When keyboard is floating, no resize is necessary. | 517 // When keyboard is floating, no resize is necessary. |
| 518 if (keyboard_mode_ == FLOATING) | 518 if (keyboard_mode_ == FLOATING) |
| 519 return; | 519 return; |
| 520 | 520 |
| 521 if (keyboard_mode_ == FULL_WIDTH) { | 521 if (keyboard_mode_ == FULL_WIDTH) { |
| 522 // TODO(bshe): revisit this logic after we decide to support resize virtual | 522 // TODO(bshe): revisit this logic after we decide to support resize virtual |
| 523 // keyboard. | 523 // keyboard. |
| 524 int keyboard_height = GetContainerWindow()->bounds().height(); | 524 int keyboard_height = GetContainerWindow()->bounds().height(); |
| 525 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds(); | 525 const gfx::Rect& root_bounds = container_->GetRootWindow()->bounds(); |
| 526 gfx::Rect new_bounds = root_bounds; | 526 gfx::Rect new_bounds = root_bounds; |
| 527 new_bounds.set_y(root_bounds.height() - keyboard_height); | 527 new_bounds.set_y(root_bounds.height() - keyboard_height); |
| 528 new_bounds.set_height(keyboard_height); | 528 new_bounds.set_height(keyboard_height); |
| 529 GetContainerWindow()->SetBounds(new_bounds); | 529 GetContainerWindow()->SetBounds(new_bounds); |
| 530 } | 530 } |
| 531 } | 531 } |
| 532 | 532 |
| 533 } // namespace keyboard | 533 } // namespace keyboard |
| OLD | NEW |