28ada6ea8b
* chore: bump chromium in DEPS to 99.0.4819.0
* chore: update patches
* chore: bump chromium in DEPS to 99.0.4824.0
* chore: update patches
* chore: bump chromium in DEPS to 99.0.4827.0
* chore: update patches
* 3352511: PiP: Add inkdrop and pointer cursor to PiP window buttons
https://chromium-review.googlesource.com/c/chromium/src/+/3352511
* 3309164: webhid: Show FIDO devices in the chooser if allowed
https://chromium-review.googlesource.com/c/chromium/src/+/3309164
* 3297868: hid: Add experimental HIDDevice.forget()
https://chromium-review.googlesource.com/c/chromium/src/+/3297868
* 3362491: [Extensions] Move i18n API to //extensions
https://chromium-review.googlesource.com/c/chromium/src/+/3362491
* MCC Refactor step0: Allow embedders to register associated_interface binders with RenderFrameHostImpl::associated_registry_.
https://chromium-review.googlesource.com/c/chromium/src/+/3281481
* 3352616: [Gtk] Remove libgtk from the link-line
https://chromium-review.googlesource.com/c/chromium/src/+/3352616
* 3249211: Clear-Site-Data support for partitioned cookies
https://chromium-review.googlesource.com/c/chromium/src/+/3249211
* [Extensions][COIL] Use [allow|block]list in //extensions/common
https://chromium-review.googlesource.com/c/chromium/src/+/3372668
* Begin ScopedUserPrefUpdate migration to modern base::Value
https://chromium-review.googlesource.com/c/chromium/src/+/3376154
* [Code Health] Refactor PrefService GetDict + GetList to use base::Value
https://chromium-review.googlesource.com/c/chromium/src/+/3343526
* 3354997: [CodeHealth] Remove deprecated SetDictionary method
https://chromium-review.googlesource.com/c/chromium/src/+/3354997
* 3287323: Add LacrosPrefStore for lacros settings
https://chromium-review.googlesource.com/c/chromium/src/+/3287323
* 3365916: [PA] Clean up remaining lazy commit code
https://chromium-review.googlesource.com/c/chromium/src/+/3365916
* [MPArch] Target the external protocol error at the responsible frame.
https://chromium-review.googlesource.com/c/chromium/src/+/3011560
* Pass origin to RegisterNonNetworkSubresourceURLLoaderFactories
https://chromium-review.googlesource.com/c/chromium/src/+/3350608
* Linux: Send OSCrypt raw encryption key to the Network Service
https://chromium-review.googlesource.com/c/chromium/src/+/3320484
* [PlzServiceWorker] Remove remaining references to PlzServiceWorker.
https://chromium-review.googlesource.com/c/chromium/src/+/3359441
* chore: fixup for lint
* 3327621: Fix tablet mode detection for Win 11.
https://chromium-review.googlesource.com/c/chromium/src/+/3327621
* 3342428: ax_mac: move AXTextMarker conversion utils under ui umbrella
https://chromium-review.googlesource.com/c/chromium/src/+/3342428
* 3353974: Mac: Use base::Feature for overlay features
https://chromium-review.googlesource.com/c/chromium/src/+/3353974
* chore: bump chromium in DEPS to 99.0.4828.0
* chore: update patches
* chore: bump chromium in DEPS to 99.0.4837.0
* chore: update patches
* chore: update patches
* 3379142: Drop FALLTHROUGH macro
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3379142
* 3381749: C++17: Allow use of std::map::try_emplace and std::map::insert_or_assign
Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3381749
* chore: bump chromium in DEPS to 99.0.4839.0
* chore: update patches
* chore: bump chromium in DEPS to 99.0.4840.0
* chore: bump chromium in DEPS to 99.0.4844.0
* 3395881: [api] Deprecate Local<v8::Context> v8::Object::CreationContext()
Ref: https://chromium-review.googlesource.com/c/v8/v8/+/3395881
* chore: update patches
* chore: bump chromium in DEPS to 100.0.4845.0
* chore: update patches
* chore: bump chromium in DEPS to 100.0.4847.0
* chore: update patches
* chore: bump chromium in DEPS to 100.0.4849.0
* chore: update patches
* chore: bump chromium in DEPS to 100.0.4851.0
* chore: bump chromium in DEPS to 100.0.4853.0
* update patches
* chore: update patches
* update patches
* 3383599: Fonts Access: Remove prototype that uses a font picker.
https://chromium-review.googlesource.com/c/chromium/src/+/3383599
* 3404768: Remove ALLOW_UNUSED macros
https://chromium-review.googlesource.com/c/chromium/src/+/3404768
* 3374762: Remove ignore_result.h
https://chromium-review.googlesource.com/c/chromium/src/+/3374762
* 3399305: [unseasoned-pdf] Apply proper frame offsets for touch selections
https://chromium-review.googlesource.com/c/chromium/src/+/3399305
* 3402210: [Extensions] Don't trigger unload event for already unloaded extension
https://chromium-review.googlesource.com/c/chromium/src/+/3402210
* 3410912: Combine URLLoaderClient OnReceiveResponse and OnStartLoadingResponseBody.
https://chromium-review.googlesource.com/c/chromium/src/+/3410912
* 3370428: Make the AuthSchemes policy support dynamic refresh
https://chromium-review.googlesource.com/c/chromium/src/+/3370428
* 3407603: Finish ScopedUserPrefUpdate migration to modern base::Value
https://chromium-review.googlesource.com/c/chromium/src/+/3407603
* 3378352: ozone/x11: move code from //ui/p/x11 to //ui/ozone/p/x11
https://chromium-review.googlesource.com/c/chromium/src/+/3378352
* 3370810: Delete chrome/service, AKA the Cloud Print service process.
https://chromium-review.googlesource.com/c/chromium/src/+/3370810
* chore: bump chromium in DEPS to 100.0.4855.0
* chore: update patches
* fixup! 3370810: Delete chrome/service, AKA the Cloud Print service process.
* revert 3348007 to fix windows build
* 3318572: [Code health] Fix gn check errors in //extensions/browser:*
https://chromium-review.googlesource.com/c/chromium/src/+/3318572
* fix printing.patch
* fix iwyu issue
* 3408515: win: Make ShorcutOperation an enum class and modernize names
https://chromium-review.googlesource.com/c/chromium/src/+/3408515
* 3388333: [UIA] Remove dead code accessibility_misc_utils.h/cc
https://chromium-review.googlesource.com/c/chromium/src/+/3388333
* fix windows build? i hope
* patch gn visibility of //ui/ozone/platform/x11
* missing include base/logging.h
* use BUILDFLAG for USE_NSS_CERTS
https://chromium-review.googlesource.com/c/chromium/src/+/3379123
* defined(OS_*) ==> BUILDFLAG(IS_*)
https://bugs.chromium.org/p/chromium/issues/detail?id=1234043
* fixup! 3404768: Remove ALLOW_UNUSED macros
* another attempt to fix windows build
* temporarily disable the custom scheme service worker test
https://github.com/electron/electron/issues/32664
* fix loading mv3 extensions
not sure what cl broke this unfort.
* fixup! 3404768: Remove ALLOW_UNUSED macros
* patch nan
https://chromium-review.googlesource.com/c/v8/v8/+/3395880
* fix node test
* fix nullptr in FindPdfFrame
* patch perfetto to fix build issue on win-ia32
bc44c3c753
* fix build for linux-x64-testing-no-run-as-node
* fix patch
* skip <webview>.capturePage() test
https://github.com/electron/electron/issues/32705
* test: fix failing tests of focus/blur events of WebContents (#32711)
* inherit stdio from app module test child processes
this prevents them from timing out due to full stdout buffers
* test to see if we can get better logs on windows ci
* try again for appveyor log things
* skip contentTracing tests on ia32
* ci: disable gpu compositing
* drop applied patch
* fix merge fail
* Revert "ci: disable gpu compositing"
This reverts commit 0344129fcb19ea3e87e06c1110d751f22eba3fec.
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: VerteDinde <khammond@slack-corp.com>
Co-authored-by: VerteDinde <vertedinde@electronjs.org>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
336 lines
8.1 KiB
C++
336 lines
8.1 KiB
C++
// Copyright (c) 2015 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include <string>
|
|
|
|
#include "base/strings/string_number_conversions.h"
|
|
#include "base/strings/string_util.h"
|
|
#include "shell/common/keyboard_util.h"
|
|
#include "third_party/blink/public/common/input/web_input_event.h"
|
|
#include "ui/events/event_constants.h"
|
|
|
|
namespace electron {
|
|
|
|
namespace {
|
|
|
|
// Return key code represented by |str|.
|
|
ui::KeyboardCode KeyboardCodeFromKeyIdentifier(
|
|
const std::string& s,
|
|
absl::optional<char16_t>* shifted_char) {
|
|
std::string str = base::ToLowerASCII(s);
|
|
if (str == "ctrl" || str == "control") {
|
|
return ui::VKEY_CONTROL;
|
|
} else if (str == "super" || str == "cmd" || str == "command" ||
|
|
str == "meta") {
|
|
return ui::VKEY_COMMAND;
|
|
} else if (str == "commandorcontrol" || str == "cmdorctrl") {
|
|
#if BUILDFLAG(IS_MAC)
|
|
return ui::VKEY_COMMAND;
|
|
#else
|
|
return ui::VKEY_CONTROL;
|
|
#endif
|
|
} else if (str == "alt" || str == "option") {
|
|
return ui::VKEY_MENU;
|
|
} else if (str == "shift") {
|
|
return ui::VKEY_SHIFT;
|
|
} else if (str == "altgr") {
|
|
return ui::VKEY_ALTGR;
|
|
} else if (str == "plus") {
|
|
shifted_char->emplace('+');
|
|
return ui::VKEY_OEM_PLUS;
|
|
} else if (str == "capslock") {
|
|
return ui::VKEY_CAPITAL;
|
|
} else if (str == "numlock") {
|
|
return ui::VKEY_NUMLOCK;
|
|
} else if (str == "scrolllock") {
|
|
return ui::VKEY_SCROLL;
|
|
} else if (str == "tab") {
|
|
return ui::VKEY_TAB;
|
|
} else if (str == "num0") {
|
|
return ui::VKEY_NUMPAD0;
|
|
} else if (str == "num1") {
|
|
return ui::VKEY_NUMPAD1;
|
|
} else if (str == "num2") {
|
|
return ui::VKEY_NUMPAD2;
|
|
} else if (str == "num3") {
|
|
return ui::VKEY_NUMPAD3;
|
|
} else if (str == "num4") {
|
|
return ui::VKEY_NUMPAD4;
|
|
} else if (str == "num5") {
|
|
return ui::VKEY_NUMPAD5;
|
|
} else if (str == "num6") {
|
|
return ui::VKEY_NUMPAD6;
|
|
} else if (str == "num7") {
|
|
return ui::VKEY_NUMPAD7;
|
|
} else if (str == "num8") {
|
|
return ui::VKEY_NUMPAD8;
|
|
} else if (str == "num9") {
|
|
return ui::VKEY_NUMPAD9;
|
|
} else if (str == "numadd") {
|
|
return ui::VKEY_ADD;
|
|
} else if (str == "nummult") {
|
|
return ui::VKEY_MULTIPLY;
|
|
} else if (str == "numdec") {
|
|
return ui::VKEY_DECIMAL;
|
|
} else if (str == "numsub") {
|
|
return ui::VKEY_SUBTRACT;
|
|
} else if (str == "numdiv") {
|
|
return ui::VKEY_DIVIDE;
|
|
} else if (str == "space") {
|
|
return ui::VKEY_SPACE;
|
|
} else if (str == "backspace") {
|
|
return ui::VKEY_BACK;
|
|
} else if (str == "delete") {
|
|
return ui::VKEY_DELETE;
|
|
} else if (str == "insert") {
|
|
return ui::VKEY_INSERT;
|
|
} else if (str == "enter" || str == "return") {
|
|
return ui::VKEY_RETURN;
|
|
} else if (str == "up") {
|
|
return ui::VKEY_UP;
|
|
} else if (str == "down") {
|
|
return ui::VKEY_DOWN;
|
|
} else if (str == "left") {
|
|
return ui::VKEY_LEFT;
|
|
} else if (str == "right") {
|
|
return ui::VKEY_RIGHT;
|
|
} else if (str == "home") {
|
|
return ui::VKEY_HOME;
|
|
} else if (str == "end") {
|
|
return ui::VKEY_END;
|
|
} else if (str == "pageup") {
|
|
return ui::VKEY_PRIOR;
|
|
} else if (str == "pagedown") {
|
|
return ui::VKEY_NEXT;
|
|
} else if (str == "esc" || str == "escape") {
|
|
return ui::VKEY_ESCAPE;
|
|
} else if (str == "volumemute") {
|
|
return ui::VKEY_VOLUME_MUTE;
|
|
} else if (str == "volumeup") {
|
|
return ui::VKEY_VOLUME_UP;
|
|
} else if (str == "volumedown") {
|
|
return ui::VKEY_VOLUME_DOWN;
|
|
} else if (str == "medianexttrack") {
|
|
return ui::VKEY_MEDIA_NEXT_TRACK;
|
|
} else if (str == "mediaprevioustrack") {
|
|
return ui::VKEY_MEDIA_PREV_TRACK;
|
|
} else if (str == "mediastop") {
|
|
return ui::VKEY_MEDIA_STOP;
|
|
} else if (str == "mediaplaypause") {
|
|
return ui::VKEY_MEDIA_PLAY_PAUSE;
|
|
} else if (str == "printscreen") {
|
|
return ui::VKEY_SNAPSHOT;
|
|
} else if (str.size() > 1 && str[0] == 'f') {
|
|
// F1 - F24.
|
|
int n;
|
|
if (base::StringToInt(str.c_str() + 1, &n) && n > 0 && n < 25) {
|
|
return static_cast<ui::KeyboardCode>(ui::VKEY_F1 + n - 1);
|
|
} else {
|
|
LOG(WARNING) << str << "is not available on keyboard";
|
|
return ui::VKEY_UNKNOWN;
|
|
}
|
|
} else {
|
|
if (str.size() > 2)
|
|
LOG(WARNING) << "Invalid accelerator token: " << str;
|
|
return ui::VKEY_UNKNOWN;
|
|
}
|
|
}
|
|
|
|
} // namespace
|
|
|
|
ui::KeyboardCode KeyboardCodeFromCharCode(char16_t c, bool* shifted) {
|
|
c = base::ToLowerASCII(c);
|
|
*shifted = false;
|
|
switch (c) {
|
|
case 0x08:
|
|
return ui::VKEY_BACK;
|
|
case 0x7F:
|
|
return ui::VKEY_DELETE;
|
|
case 0x09:
|
|
return ui::VKEY_TAB;
|
|
case 0x0D:
|
|
return ui::VKEY_RETURN;
|
|
case 0x1B:
|
|
return ui::VKEY_ESCAPE;
|
|
case ' ':
|
|
return ui::VKEY_SPACE;
|
|
case 'a':
|
|
return ui::VKEY_A;
|
|
case 'b':
|
|
return ui::VKEY_B;
|
|
case 'c':
|
|
return ui::VKEY_C;
|
|
case 'd':
|
|
return ui::VKEY_D;
|
|
case 'e':
|
|
return ui::VKEY_E;
|
|
case 'f':
|
|
return ui::VKEY_F;
|
|
case 'g':
|
|
return ui::VKEY_G;
|
|
case 'h':
|
|
return ui::VKEY_H;
|
|
case 'i':
|
|
return ui::VKEY_I;
|
|
case 'j':
|
|
return ui::VKEY_J;
|
|
case 'k':
|
|
return ui::VKEY_K;
|
|
case 'l':
|
|
return ui::VKEY_L;
|
|
case 'm':
|
|
return ui::VKEY_M;
|
|
case 'n':
|
|
return ui::VKEY_N;
|
|
case 'o':
|
|
return ui::VKEY_O;
|
|
case 'p':
|
|
return ui::VKEY_P;
|
|
case 'q':
|
|
return ui::VKEY_Q;
|
|
case 'r':
|
|
return ui::VKEY_R;
|
|
case 's':
|
|
return ui::VKEY_S;
|
|
case 't':
|
|
return ui::VKEY_T;
|
|
case 'u':
|
|
return ui::VKEY_U;
|
|
case 'v':
|
|
return ui::VKEY_V;
|
|
case 'w':
|
|
return ui::VKEY_W;
|
|
case 'x':
|
|
return ui::VKEY_X;
|
|
case 'y':
|
|
return ui::VKEY_Y;
|
|
case 'z':
|
|
return ui::VKEY_Z;
|
|
|
|
case ')':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '0':
|
|
return ui::VKEY_0;
|
|
case '!':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '1':
|
|
return ui::VKEY_1;
|
|
case '@':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '2':
|
|
return ui::VKEY_2;
|
|
case '#':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '3':
|
|
return ui::VKEY_3;
|
|
case '$':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '4':
|
|
return ui::VKEY_4;
|
|
case '%':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '5':
|
|
return ui::VKEY_5;
|
|
case '^':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '6':
|
|
return ui::VKEY_6;
|
|
case '&':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '7':
|
|
return ui::VKEY_7;
|
|
case '*':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '8':
|
|
return ui::VKEY_8;
|
|
case '(':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '9':
|
|
return ui::VKEY_9;
|
|
|
|
case ':':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case ';':
|
|
return ui::VKEY_OEM_1;
|
|
case '+':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '=':
|
|
return ui::VKEY_OEM_PLUS;
|
|
case '<':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case ',':
|
|
return ui::VKEY_OEM_COMMA;
|
|
case '_':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '-':
|
|
return ui::VKEY_OEM_MINUS;
|
|
case '>':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '.':
|
|
return ui::VKEY_OEM_PERIOD;
|
|
case '?':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '/':
|
|
return ui::VKEY_OEM_2;
|
|
case '~':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '`':
|
|
return ui::VKEY_OEM_3;
|
|
case '{':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '[':
|
|
return ui::VKEY_OEM_4;
|
|
case '|':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '\\':
|
|
return ui::VKEY_OEM_5;
|
|
case '}':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case ']':
|
|
return ui::VKEY_OEM_6;
|
|
case '"':
|
|
*shifted = true;
|
|
[[fallthrough]];
|
|
case '\'':
|
|
return ui::VKEY_OEM_7;
|
|
|
|
default:
|
|
return ui::VKEY_UNKNOWN;
|
|
}
|
|
}
|
|
|
|
ui::KeyboardCode KeyboardCodeFromStr(const std::string& str,
|
|
absl::optional<char16_t>* shifted_char) {
|
|
if (str.size() == 1) {
|
|
bool shifted = false;
|
|
auto ret = KeyboardCodeFromCharCode(str[0], &shifted);
|
|
if (shifted)
|
|
shifted_char->emplace(str[0]);
|
|
return ret;
|
|
} else {
|
|
return KeyboardCodeFromKeyIdentifier(str, shifted_char);
|
|
}
|
|
}
|
|
|
|
} // namespace electron
|