Commit 8362b5dd authored by Darren Shen's avatar Darren Shen Committed by Chromium LUCI CQ

ime: Remove `code` parameter from SendKeyEvent.

SendKeyEvent has an extra code parameter that is used when there is
no keycode. However, we can just implement that logic upstream so that
there is always a keycode and we can remove the `code` parameter.

Bug: b/174612548
Change-Id: I98bb1be1c62fe141ed74f7243b8ac645f9a51963
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566868Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834440}
parent 78c07784
...@@ -513,12 +513,9 @@ void InputMethodEngine::CommitTextToInputContext(int context_id, ...@@ -513,12 +513,9 @@ void InputMethodEngine::CommitTextToInputContext(int context_id,
} }
} }
bool InputMethodEngine::SendKeyEvent(ui::KeyEvent* event, bool InputMethodEngine::SendKeyEvent(const ui::KeyEvent& event,
const std::string& code,
std::string* error) { std::string* error) {
DCHECK(event); ui::KeyEvent event_copy = event;
if (event->key_code() == ui::VKEY_UNKNOWN)
event->set_key_code(ui::DomKeycodeToKeyboardCode(code));
// Marks the simulated key event is from the Virtual Keyboard. // Marks the simulated key event is from the Virtual Keyboard.
ui::Event::Properties properties; ui::Event::Properties properties;
...@@ -526,12 +523,12 @@ bool InputMethodEngine::SendKeyEvent(ui::KeyEvent* event, ...@@ -526,12 +523,12 @@ bool InputMethodEngine::SendKeyEvent(ui::KeyEvent* event,
std::vector<uint8_t>(ui::kPropertyFromVKSize); std::vector<uint8_t>(ui::kPropertyFromVKSize);
properties[ui::kPropertyFromVK][ui::kPropertyFromVKIsMirroringIndex] = properties[ui::kPropertyFromVK][ui::kPropertyFromVKIsMirroringIndex] =
(uint8_t)is_mirroring_; (uint8_t)is_mirroring_;
event->SetProperties(properties); event_copy.SetProperties(properties);
ui::IMEInputContextHandlerInterface* input_context = ui::IMEInputContextHandlerInterface* input_context =
ui::IMEBridge::Get()->GetInputContextHandler(); ui::IMEBridge::Get()->GetInputContextHandler();
if (input_context) { if (input_context) {
input_context->SendKeyEvent(event); input_context->SendKeyEvent(&event_copy);
return true; return true;
} }
......
...@@ -205,9 +205,7 @@ class InputMethodEngine : public InputMethodEngineBase, ...@@ -205,9 +205,7 @@ class InputMethodEngine : public InputMethodEngineBase,
void CommitTextToInputContext(int context_id, void CommitTextToInputContext(int context_id,
const std::string& text) override; const std::string& text) override;
bool SendKeyEvent(ui::KeyEvent* event, bool SendKeyEvent(const ui::KeyEvent& event, std::string* error) override;
const std::string& code,
std::string* error) override;
// Enables overriding input view page to Virtual Keyboard window. // Enables overriding input view page to Virtual Keyboard window.
void EnableInputView(); void EnableInputView();
......
...@@ -423,8 +423,7 @@ bool InputMethodEngineBase::SendKeyEvents( ...@@ -423,8 +423,7 @@ bool InputMethodEngineBase::SendKeyEvents(
} }
for (const auto& event : events) { for (const auto& event : events) {
ui::KeyEvent ui_event = ConvertKeyboardEventToUIKeyEvent(event); if (!SendKeyEvent(ConvertKeyboardEventToUIKeyEvent(event), error))
if (!SendKeyEvent(&ui_event, event.code, error))
return false; return false;
} }
return true; return true;
......
...@@ -310,8 +310,7 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface, ...@@ -310,8 +310,7 @@ class InputMethodEngineBase : virtual public ui::IMEEngineHandlerInterface,
void DeleteSurroundingTextToInputContext(int offset, size_t number_of_chars); void DeleteSurroundingTextToInputContext(int offset, size_t number_of_chars);
// Sends the key event to the window tree host. // Sends the key event to the window tree host.
virtual bool SendKeyEvent(ui::KeyEvent* ui_event, virtual bool SendKeyEvent(const ui::KeyEvent& ui_event,
const std::string& code,
std::string* error) = 0; std::string* error) = 0;
// Used to verify that a key event is valid before precessing it in the // Used to verify that a key event is valid before precessing it in the
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "ui/base/ime/chromeos/ime_bridge.h" #include "ui/base/ime/chromeos/ime_bridge.h"
#include "ui/base/ime/chromeos/ime_keymap.h"
namespace input_ime = extensions::api::input_ime; namespace input_ime = extensions::api::input_ime;
namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled; namespace KeyEventHandled = extensions::api::input_ime::KeyEventHandled;
...@@ -419,7 +420,9 @@ ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() { ...@@ -419,7 +420,9 @@ ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() {
event.type = input_ime::ToString(key_event.type); event.type = input_ime::ToString(key_event.type);
event.key = key_event.key; event.key = key_event.key;
event.code = key_event.code; event.code = key_event.code;
event.key_code = key_event.key_code.get() ? *(key_event.key_code) : 0; event.key_code = key_event.key_code.get()
? *(key_event.key_code)
: ui::DomKeycodeToKeyboardCode(key_event.code);
event.alt_key = key_event.alt_key ? *(key_event.alt_key) : false; event.alt_key = key_event.alt_key ? *(key_event.alt_key) : false;
event.altgr_key = key_event.altgr_key ? *(key_event.altgr_key) : false; event.altgr_key = key_event.altgr_key ? *(key_event.altgr_key) : false;
event.ctrl_key = key_event.ctrl_key ? *(key_event.ctrl_key) : false; event.ctrl_key = key_event.ctrl_key ? *(key_event.ctrl_key) : false;
......
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