Index: chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc |
diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc |
index 6e40b63f8ee6bb81242d9dcc194babca4c8ca7e2..2a096dfd935f37f640b3e8f208f9a4196ee408a0 100644 |
--- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc |
+++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc |
@@ -41,6 +41,10 @@ const char* kVirtualKeyboardExtensionID = "mppnpdlheglhdfmldimlhpnegondlapf"; |
// The virtual keyboard show/hide animation duration. |
const int kAnimationDurationMs = 200; |
+// The opacity of virtual keyboard container when show animation starts or |
+// hide animation finishes. |
+const float kAnimationStartOrAfterHideOpacity = 0.2f; |
+ |
Context::Type TextInputTypeToGeneratedInputTypeEnum(ui::TextInputType type) { |
switch (type) { |
case ui::TEXT_INPUT_TYPE_NONE: |
@@ -158,17 +162,18 @@ void AshKeyboardControllerProxy::ShowKeyboardContainer( |
gfx::Transform transform; |
transform.Translate(0, GetKeyboardWindow()->bounds().height()); |
container->SetTransform(transform); |
- container->layer()->SetOpacity(0.0); |
+ container->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); |
} |
+ container_animator->set_preemption_strategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ |
{ |
// Scope the following animation settings as we don't want to animate |
// visibility change that triggered by a call to the base class function |
// ShowKeyboardContainer with these settings. The container should become |
// visible immediately. |
ui::ScopedLayerAnimationSettings settings(container_animator); |
- settings.SetPreemptionStrategy( |
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
settings.SetTweenType(gfx::Tween::EASE_IN); |
settings.SetTransitionDuration( |
base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
@@ -197,24 +202,31 @@ void AshKeyboardControllerProxy::HideKeyboardContainer( |
container_animator->AddObserver(this); |
animation_window_ = container; |
ui::ScopedLayerAnimationSettings settings(container_animator); |
- settings.SetPreemptionStrategy( |
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
settings.SetTweenType(gfx::Tween::EASE_OUT); |
settings.SetTransitionDuration( |
base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
gfx::Transform transform; |
transform.Translate(0, GetKeyboardWindow()->bounds().height()); |
container->SetTransform(transform); |
- container->layer()->SetOpacity(0.0); |
+ // Must hide keyboard container here instead of when animation finished or |
+ // aborted. Otherwise, if we regain focus during hide animation, show |
+ // animation wont be triggered because Chrome still thinks the keyboard |
+ // container is visible and ignores show keyboard request. |
+ container->Hide(); |
+ container->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity); |
} |
void AshKeyboardControllerProxy::OnLayerAnimationEnded( |
ui::LayerAnimationSequence* sequence) { |
if (!animation_window_) |
return; |
+ |
ui::LayerAnimator* animator = animation_window_->layer()->GetAnimator(); |
if (animator && !animator->is_animating()) { |
- KeyboardControllerProxy::HideKeyboardContainer(animation_window_); |
+ // Hides keyboard window after keyboard window container's animation |
+ // finished. Otherwise, keyboard window hides immediately and makes it looks |
+ // like no animation at all. |
+ GetKeyboardWindow()->Hide(); |
animator->RemoveObserver(this); |
animation_window_ = NULL; |
} |