Commit ea923074 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Make sure IME guard is added for processing Android text.

The code previously added an IME guard but it was removed when moving
this into blink and the showing/hiding of the virtual keyboard was done
on the HandlingInputState object itself. (via change
https://chromium-review.googlesource.com/c/chromium/src/+/2212805).
he IME guard prevents intermediate changes when handling an event.
This was problematic for TinyIME because the text input mode changed
between the processing of the event which caused the virtual keyboard
to be dismissed. This change makes the code behave exactly the same
before the move to blink. It can't be merged into M85 due to that
branch only having part of the changes. So if it needs to go there it
will need to be written separately.

BUG=1121179

Change-Id: Ida425dedd240a3c2e36b458d45f04433c6d31963
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2373363
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Auto-Submit: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801820}
parent 7eac8fd7
......@@ -1604,13 +1604,13 @@ void WebFrameWidgetBase::DidHandleGestureEvent(const WebGestureEvent& event,
#if defined(OS_ANDROID) || defined(USE_AURA)
if (event.GetType() == WebInputEvent::Type::kGestureTap) {
widget_base_->input_handler().ShowVirtualKeyboard();
widget_base_->ShowVirtualKeyboard();
} else if (event.GetType() == WebInputEvent::Type::kGestureLongPress) {
WebInputMethodController* controller = GetActiveWebInputMethodController();
if (!controller || controller->TextInputInfo().value.IsEmpty())
widget_base_->input_handler().UpdateTextInputState();
widget_base_->UpdateTextInputState();
else
widget_base_->input_handler().ShowVirtualKeyboard();
widget_base_->ShowVirtualKeyboard();
}
#endif
}
......
......@@ -25,6 +25,7 @@
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h"
#include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h"
#include "third_party/blink/renderer/platform/widget/input/ime_event_guard.h"
#include "third_party/blink/renderer/platform/widget/widget_base.h"
#include "third_party/blink/renderer/platform/widget/widget_base_client.h"
#include "ui/latency/latency_info.h"
......@@ -216,13 +217,6 @@ class WidgetBaseInputHandler::HandlingState {
input_handler_->handling_input_event_ = previous_was_handling_input_;
DCHECK_EQ(input_handler_->handling_input_state_, this);
input_handler_->handling_input_state_ = previous_state_;
#if defined(OS_ANDROID)
if (show_virtual_keyboard_)
input_handler_->ShowVirtualKeyboard();
else
input_handler_->UpdateTextInputState();
#endif
}
std::unique_ptr<InputHandlerProxy::DidOverscrollParams>& event_overscroll() {
......@@ -242,12 +236,6 @@ class WidgetBaseInputHandler::HandlingState {
bool touch_start_or_move() { return touch_start_or_move_; }
#if defined(OS_ANDROID)
void set_show_virtual_keyboard(bool show_virtual_keyboard) {
show_virtual_keyboard_ = show_virtual_keyboard;
}
#endif // defined(OS_ANDROID)
private:
// Used to intercept overscroll notifications while an event is being
// handled. If the event causes overscroll, the overscroll metadata can be
......@@ -266,11 +254,6 @@ class WidgetBaseInputHandler::HandlingState {
// Whether the event we are handling is a touch start or move.
bool touch_start_or_move_;
#if defined(OS_ANDROID)
// Whether to show the virtual keyboard or not at the end of processing.
bool show_virtual_keyboard_ = false;
#endif
HandlingState* previous_state_;
bool previous_was_handling_input_;
base::WeakPtr<WidgetBaseInputHandler> input_handler_;
......@@ -323,6 +306,10 @@ void WidgetBaseInputHandler::HandleInputEvent(
weak_ptr_factory_.GetWeakPtr();
HandlingState handling_state(weak_self, IsTouchStartOrMove(input_event));
#if defined(OS_ANDROID)
ImeEventGuard guard(widget_->GetWeakPtr());
#endif
base::TimeTicks start_time;
if (base::TimeTicks::IsHighResolution())
start_time = base::TimeTicks::Now();
......@@ -504,7 +491,7 @@ void WidgetBaseInputHandler::HandleInputEvent(
if ((processed != WebInputEventResult::kNotHandled &&
input_event.GetType() == WebInputEvent::Type::kTouchEnd) ||
show_virtual_keyboard_for_mouse) {
ShowVirtualKeyboard();
widget_->ShowVirtualKeyboard();
}
if (!prevent_default &&
......@@ -688,22 +675,4 @@ bool WidgetBaseInputHandler::ProcessTouchAction(WebTouchAction touch_action) {
return true;
}
void WidgetBaseInputHandler::ShowVirtualKeyboard() {
#if defined(OS_ANDROID)
if (handling_input_state_) {
handling_input_state_->set_show_virtual_keyboard(true);
return;
}
#endif
widget_->ShowVirtualKeyboard();
}
void WidgetBaseInputHandler::UpdateTextInputState() {
#if defined(OS_ANDROID)
if (handling_input_state_)
return;
#endif
widget_->UpdateTextInputState();
}
} // namespace blink
......@@ -86,11 +86,6 @@ class PLATFORM_EXPORT WidgetBaseInputHandler {
// cursor.
bool DidChangeCursor(const ui::Cursor& cursor);
// Request virtual keyboard be shown. The message will be debounced during
// handling of input events.
void ShowVirtualKeyboard();
void UpdateTextInputState();
private:
class HandlingState;
struct InjectScrollGestureParams {
......
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