Commit 0781568a authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Hide the virtual keyboard in OnTextInputTypeChanged().

Before this CL, RequestHideIme() was called by Android side just after
the call of OnTextInputTypeChanged().
However, the interval between the call of OnTextInputTypeChanged() and
the call of RequestHideIme() can be larger than the length of the
animation of showing the virtual keyboard.
When it happens, the bounds of the shown virtual keyboard is notified to
Android side by OnKeyboardAppearanceChanged() and it causes confusion.
This CL fixes it by calling HideKeyboardImplicitlyBySystem() in
OnTextInputTypeChanged() and marks RequestHideIme() mojo call as
deprecated because it's not needed anymore.

Bug: b/148483295
Bug: 1023656
Change-Id: I32c46c18949323c0a33a26dd10a18e2e38cc277a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089434Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748518}
parent dfb12a4a
...@@ -42,7 +42,6 @@ class ArcImeBridge { ...@@ -42,7 +42,6 @@ class ArcImeBridge {
const base::string16& text_in_range, const base::string16& text_in_range,
const gfx::Range& selection_range, const gfx::Range& selection_range,
bool is_screen_coordinates) = 0; bool is_screen_coordinates) = 0;
virtual void RequestHideIme() = 0;
}; };
// Serializes and sends IME related requests through IPCs. // Serializes and sends IME related requests through IPCs.
......
...@@ -150,8 +150,8 @@ void ArcImeBridgeImpl::OnCursorRectChangedWithSurroundingText( ...@@ -150,8 +150,8 @@ void ArcImeBridgeImpl::OnCursorRectChangedWithSurroundingText(
is_screen_coordinates); is_screen_coordinates);
} }
void ArcImeBridgeImpl::RequestHideIme() { void ArcImeBridgeImpl::RequestHideImeDeprecated() {
delegate_->RequestHideIme(); DVLOG(1) << "RequestHideIme is deprecated.";
} }
} // namespace arc } // namespace arc
...@@ -51,7 +51,7 @@ class ArcImeBridgeImpl : public ArcImeBridge, public mojom::ImeHost { ...@@ -51,7 +51,7 @@ class ArcImeBridgeImpl : public ArcImeBridge, public mojom::ImeHost {
const std::string& text_in_range, const std::string& text_in_range,
const gfx::Range& selection_range, const gfx::Range& selection_range,
bool screen_coordinates) override; bool screen_coordinates) override;
void RequestHideIme() override; void RequestHideImeDeprecated() override;
private: private:
Delegate* const delegate_; Delegate* const delegate_;
......
...@@ -311,6 +311,16 @@ void ArcImeService::OnTextInputTypeChanged( ...@@ -311,6 +311,16 @@ void ArcImeService::OnTextInputTypeChanged(
ui::InputMethod* const input_method = GetInputMethod(); ui::InputMethod* const input_method = GetInputMethod();
if (input_method) if (input_method)
input_method->OnTextInputTypeChanged(this); input_method->OnTextInputTypeChanged(this);
// Call HideKeyboard() here. On a text field on an ARC++ app, just having
// non-null text input type doesn't mean the virtual keyboard is necessary. If
// the virtual keyboard is really needed, ShowVirtualKeyboardIfEnabled will be
// called later.
if (keyboard::KeyboardUIController::HasInstance()) {
auto* keyboard_controller = keyboard::KeyboardUIController::Get();
if (keyboard_controller->IsEnabled())
keyboard_controller->HideKeyboardImplicitlyBySystem();
}
} }
void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect, void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect,
...@@ -356,18 +366,6 @@ void ArcImeService::OnCursorRectChangedWithSurroundingText( ...@@ -356,18 +366,6 @@ void ArcImeService::OnCursorRectChangedWithSurroundingText(
input_method->OnCaretBoundsChanged(this); input_method->OnCaretBoundsChanged(this);
} }
void ArcImeService::RequestHideIme() {
// Ignore the request when the ARC app is not focused.
if (!focused_arc_window_)
return;
if (keyboard::KeyboardUIController::HasInstance()) {
auto* keyboard_controller = keyboard::KeyboardUIController::Get();
if (keyboard_controller->IsEnabled())
keyboard_controller->HideKeyboardImplicitlyBySystem();
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Overridden from ash::KeyboardControllerObserver // Overridden from ash::KeyboardControllerObserver
void ArcImeService::OnKeyboardAppearanceChanged( void ArcImeService::OnKeyboardAppearanceChanged(
......
...@@ -104,7 +104,6 @@ class ArcImeService : public KeyedService, ...@@ -104,7 +104,6 @@ class ArcImeService : public KeyedService,
const base::string16& text_in_range, const base::string16& text_in_range,
const gfx::Range& selection_range, const gfx::Range& selection_range,
bool is_screen_coordinates) override; bool is_screen_coordinates) override;
void RequestHideIme() override;
// Overridden from ash::KeyboardControllerObserver. // Overridden from ash::KeyboardControllerObserver.
void OnKeyboardAppearanceChanged( void OnKeyboardAppearanceChanged(
......
...@@ -90,10 +90,8 @@ interface ImeHost { ...@@ -90,10 +90,8 @@ interface ImeHost {
); );
// Requests Chrome to hide the virtual keyboard. // Requests Chrome to hide the virtual keyboard.
// Howver, hiding can be canceled if a text field gets focus. // However, hiding can be canceled if a text field gets focus.
// TODO(yhanada): We might be able to remove this method by adding an argument [MinVersion=9] RequestHideImeDeprecated@5();
// to OnTextInputTypeChanged().
[MinVersion=9] RequestHideIme@5();
}; };
// Next method ID: 8 // Next method ID: 8
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment