chromium/ui/base/accelerators/accelerator.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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) {}

}  // namespace

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;

// static
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)
// In macOS 10.13, the glyphs used for page up, page down, home, and end were
// changed from the arrows below to new, skinny arrows. The tricky bit is that
// the underlying Unicode characters weren't changed, just the font used. Maybe
// the keyboard font, CTFontCreateUIFontForLanguage, with key
// kCTFontUIFontMenuItemCmdKey, can be used everywhere this symbol is used. (If
// so, then the RTL stuff will need to be removed.)
std::u16string Accelerator::KeyCodeToMacSymbol() const {
  switch (key_code_) {
    case VKEY_CAPITAL:
      return u"⇪";  // U+21EA, UPWARDS WHITE ARROW FROM BAR
    case VKEY_RETURN:
      return u"⌤";  // U+2324, UP ARROWHEAD BETWEEN TWO HORIZONTAL BARS
    case VKEY_BACK:
      return u"⌫";  // U+232B, ERASE TO THE LEFT
    case VKEY_ESCAPE:
      return u"⎋";  // U+238B, BROKEN CIRCLE WITH NORTHWEST ARROW
    case VKEY_RIGHT:
      return u"→";  // U+2192, RIGHTWARDS ARROW
    case VKEY_LEFT:
      return u"←";  // U+2190, LEFTWARDS ARROW
    case VKEY_UP:
      return u"↑";  // U+2191, UPWARDS ARROW
    case VKEY_DOWN:
      return u"↓";  // U+2193, DOWNWARDS ARROW
    case VKEY_PRIOR:
      return u"⇞";  // U+21DE, UPWARDS ARROW WITH DOUBLE STROKE
    case VKEY_NEXT:
      return u"⇟";  // U+21DF, DOWNWARDS ARROW WITH DOUBLE STROKE
    case VKEY_HOME:
      return base::i18n::IsRTL() ? u"↗"   // U+2197, NORTH EAST ARROW
                                 : u"↖";  // U+2196, NORTH WEST ARROW
    case VKEY_END:
      return base::i18n::IsRTL() ? u"↙"   // U+2199, SOUTH WEST ARROW
                                 : u"↘";  // U+2198, SOUTH EAST ARROW
    case VKEY_TAB:
      return u"⇥";  // U+21E5, RIGHTWARDS ARROW TO BAR
    // Mac has a shift-tab icon ("⇤", U+21E4, LEFTWARDS ARROW TO BAR) but we
    // don't use it. "Space" and some other keys are written out; fall back to
    // KeyCodeToName() for those (and any other unhandled keys).
    default:
      return KeyCodeToName();
  }
}
#endif  // BUILDFLAG(IS_MAC)

std::u16string Accelerator::KeyCodeToName() const {}

std::u16string Accelerator::ApplyLongFormModifiers(
    const std::u16string& shortcut) const {}

std::u16string Accelerator::ApplyShortFormModifiers(
    const std::u16string& shortcut) const {}

}  // namespace ui