// Copyright 2021 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_BASE_ACCELERATORS_ACCELERATOR_MAP_H_ #define UI_BASE_ACCELERATORS_ACCELERATOR_MAP_H_ #include <map> #include <utility> #include <vector> #include "base/component_export.h" #include "build/build_config.h" #include "ui/base/accelerators/accelerator.h" #if BUILDFLAG(IS_CHROMEOS) #include "ui/events/keycodes/dom/dom_code.h" #include "ui/events/keycodes/dom/keycode_converter.h" #endif namespace ui { // This is a wrapper around an internal std::map of type // |std::map<Accelerator, V>| where |V| is the mapped value. // // Accelerators in Chrome on all platforms are specified with the |key_code|, // aka VKEY, however certain keys (eg. brackets, comma, period, plus, minus), // are in different places based on the keyboard layout. In some cases the // VKEYs don't exist, in some cases they now conflict with other shortcuts. // // Chrome OS uses a positional mapping for this subset of keys. Shortcuts // based on these keys are determined by the position of the key on a US // keyboard. This was already the case for all non-latin alphabet keyboards // (Chinese, Japanese, Arabic, Russian, etc.). // // To achieve this on Chrome OS for the remaining layouts, an additional // remapping may happen to the accelerator used for lookup based on the state // of |use_positional_lookup_|. When false no remapping occurs. When true, // the |code| aka DomCode (which is by definition fixed position), is used to // find the US layout VKEY, and that VKEY is used to lookup in the map. // // Other non-positional keys, eg. alphanumeric, F-keys, and special keys are // all not remapped. Alphanumeric keys always continue to follow the // |code|/VKEY defined by the current layout as is existing behavior. template <typename V> class COMPONENT_EXPORT(UI_BASE) AcceleratorMap { … }; } // namespace ui #endif // UI_BASE_ACCELERATORS_ACCELERATOR_MAP_H_