Commit acd7b545 authored by Wez's avatar Wez Committed by Commit Bot

[events] Allow null-named DomCodes to be mapped to/from native.

Previously NativeKeycodeToDomCode() would treat codes with a NULL name
for the DomCode (i.e. DomCodes used internally by Chrome to represent
keys with no standardized DOM |code| value.) as unknown.

This has been work-around in the DomCode table by assigning non-NULL
names to non-standard DomCodes, leading to confusion over which are
standardized mappings, and which are Chrome-internal.

Allow native keycodes with no standardized DOM |code| name to be mapped
to their Chrome-internal DomCode value, so that non-standard keys may
be switched to NULL names.

Bug: 952051
Change-Id: I1a08928765e76816410c3b005383b43910be5b51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020928
Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755499}
parent 48a67647
......@@ -93,10 +93,8 @@ int KeycodeConverter::InvalidNativeKeycode() {
// static
DomCode KeycodeConverter::NativeKeycodeToDomCode(int native_keycode) {
for (auto& mapping : kDomCodeMappings) {
if (mapping.native_keycode == native_keycode) {
if (mapping.code != nullptr)
return static_cast<DomCode>(mapping.usb_keycode);
}
if (mapping.native_keycode == native_keycode)
return static_cast<DomCode>(mapping.usb_keycode);
}
return DomCode::NONE;
}
......
......@@ -172,6 +172,10 @@ TEST(KeycodeConverter, DomCode) {
EXPECT_STREQ(entry->code,
ui::KeycodeConverter::DomCodeToCodeString(code));
}
ui::DomCode code =
ui::KeycodeConverter::NativeKeycodeToDomCode(entry->native_keycode);
EXPECT_EQ(entry->native_keycode,
ui::KeycodeConverter::DomCodeToNativeKeycode(code));
}
}
......
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