Commit aebc4178 authored by Ryan Daum's avatar Ryan Daum Committed by Chromium LUCI CQ

[chromecast] Fix backspace & delete in virtual keyboard

  * Backspace, tab, and delete are special in that they are characters,
    but non-printable.
  * This catches them and passes them through as non-printable class
    characters, so they are properly handled by blink.

Bug: internal b/174869138
Test: manual with wayland_webview_client
Change-Id: I2e33c602fbe6c85f0998717541d2f5fca0b48a5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625207Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarShawn Gallea <sagallea@google.com>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Ryan Daum <rdaum@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842678}
parent 7740dc7a
......@@ -338,17 +338,24 @@ void WebContentController::ProcessInputEvent(const webview::InputEvent& ev) {
if (ev.has_key()) {
ui::DomKey dom_key =
ui::KeycodeConverter::KeyStringToDomKey(ev.key().key_string());
bool is_char = dom_key.IsCharacter();
int32_t key_code = is_char ? dom_key.ToCharacter()
: NonPrintableDomKeyToKeyboardCode(dom_key);
// Backspace, delete, and tab have to be treated specially as they are
// characters according to DomKey, but they are non-printable.
bool is_printable_character =
dom_key.IsCharacter() && dom_key != ui::DomKey::TAB &&
dom_key != ui::DomKey::BACKSPACE && dom_key != ui::DomKey::DEL;
ui::KeyboardCode keyboard_code =
static_cast<ui::KeyboardCode>(key_code);
is_printable_character
? static_cast<ui::KeyboardCode>(dom_key.ToCharacter())
: NonPrintableDomKeyToKeyboardCode(dom_key);
ui::KeyEvent evt(type, keyboard_code,
UsLayoutKeyboardCodeToDomCode(keyboard_code),
ev.flags() | ui::EF_IS_SYNTHESIZED, dom_key,
base::TimeTicks() +
base::TimeDelta::FromMicroseconds(ev.timestamp()),
is_char);
is_printable_character);
// Marks the simulated key event is from a Virtual Keyboard.
ui::Event::Properties properties;
properties[ui::kPropertyFromVK] =
......
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