#include "ui/base/accelerators/accelerator.h"
#include <stdint.h>
#include <tuple>
#include "base/check_op.h"
#include "base/i18n/rtl.h"
#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
#include "ui/strings/grit/ui_strings.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#if !BUILDFLAG(IS_WIN) && (defined(USE_AURA) || BUILDFLAG(IS_MAC))
#include "ui/events/keycodes/keyboard_code_conversion.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "ui/base/accelerators/ash/right_alt_event_property.h"
#include "ui/base/ui_base_features.h"
#endif
namespace ui {
namespace {
const int kModifierMask = …;
const int kInterestingFlagsMask = …;
std::u16string ApplyModifierToAcceleratorString(
const std::u16string& accelerator,
int modifier_message_id) { … }
}
Accelerator::Accelerator() : … { … }
Accelerator::Accelerator(KeyboardCode key_code,
int modifiers,
KeyState key_state,
base::TimeTicks time_stamp)
: … { … }
#if BUILDFLAG(IS_CHROMEOS)
Accelerator::Accelerator(KeyboardCode key_code,
DomCode code,
int modifiers,
KeyState key_state,
base::TimeTicks time_stamp)
: key_code_(key_code),
code_(code),
key_state_(key_state),
modifiers_(modifiers & kInterestingFlagsMask),
time_stamp_(time_stamp),
interrupted_by_mouse_event_(false) {}
#endif
Accelerator::Accelerator(const KeyEvent& key_event)
: … { … }
Accelerator::Accelerator(const Accelerator& accelerator) = default;
Accelerator& Accelerator::operator=(const Accelerator& accelerator) = default;
Accelerator::~Accelerator() = default;
int Accelerator::MaskOutKeyEventFlags(int flags) { … }
KeyEvent Accelerator::ToKeyEvent() const { … }
bool Accelerator::operator<(const Accelerator& rhs) const { … }
bool Accelerator::operator==(const Accelerator& rhs) const { … }
bool Accelerator::operator!=(const Accelerator& rhs) const { … }
bool Accelerator::IsShiftDown() const { … }
bool Accelerator::IsCtrlDown() const { … }
bool Accelerator::IsAltDown() const { … }
bool Accelerator::IsAltGrDown() const { … }
bool Accelerator::IsCmdDown() const { … }
bool Accelerator::IsFunctionDown() const { … }
bool Accelerator::IsRepeat() const { … }
std::u16string Accelerator::GetShortcutText() const { … }
#if BUILDFLAG(IS_MAC)
std::u16string Accelerator::KeyCodeToMacSymbol() const {
switch (key_code_) {
case VKEY_CAPITAL:
return u"⇪";
case VKEY_RETURN:
return u"⌤";
case VKEY_BACK:
return u"⌫";
case VKEY_ESCAPE:
return u"⎋";
case VKEY_RIGHT:
return u"→";
case VKEY_LEFT:
return u"←";
case VKEY_UP:
return u"↑";
case VKEY_DOWN:
return u"↓";
case VKEY_PRIOR:
return u"⇞";
case VKEY_NEXT:
return u"⇟";
case VKEY_HOME:
return base::i18n::IsRTL() ? u"↗"
: u"↖";
case VKEY_END:
return base::i18n::IsRTL() ? u"↙"
: u"↘";
case VKEY_TAB:
return u"⇥";
default:
return KeyCodeToName();
}
}
#endif
std::u16string Accelerator::KeyCodeToName() const { … }
std::u16string Accelerator::ApplyLongFormModifiers(
const std::u16string& shortcut) const { … }
std::u16string Accelerator::ApplyShortFormModifiers(
const std::u16string& shortcut) const { … }
}