chromium/chrome/test/chromedriver/key_converter.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/test/chromedriver/key_converter.h"

#include <stddef.h>

#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/ui_events.h"
#include "chrome/test/chromedriver/keycode_text_conversion.h"

namespace {

struct ModifierMaskAndKeyCode {};

const ModifierMaskAndKeyCode kModifiers[] =;

// Ordered list of all the key codes corresponding to special WebDriver keys.
// These keys are "special" in the sense that their code points are defined by
// the W3C spec (https://w3c.github.io/webdriver/#dfn-normalised-key-value),
// and are in the Unicode Private Use Area. All other keys have their code
// points defined by the Unicode standard.
const ui::KeyboardCode kSpecialWebDriverKeys[] =;

const char16_t kWebDriverNullKey =;
const char16_t kWebDriverShiftKey =;
const char16_t kWebDriverControlKey =;
const char16_t kWebDriverAltKey =;
const char16_t kWebDriverCommandKey =;
const char16_t kWebDriverRightShiftKey =;
const char16_t kWebDriverRightControlKey =;
const char16_t kWebDriverRightAltKey =;
const char16_t kWebDriverRightCommandKey =;

// Returns whether the given key code has a corresponding printable char.
// Notice: The given key code should be a special WebDriver key code.
bool IsSpecialKeyPrintable(ui::KeyboardCode key_code) {}

// Returns whether the given key is a WebDriver key modifier.
bool IsModifierKey(char16_t key) {}

// Gets the key code associated with |key|, if it is a special WebDriver key.
// Returns whether |key| is a special WebDriver key. If true, |key_code| will
// be set.
bool KeyCodeFromSpecialWebDriverKey(char16_t key, ui::KeyboardCode* key_code) {}

// Gets the key code associated with |key_utf16|, if it is a special shorthand
// key. Shorthand keys are common text equivalents for keys, such as the newline
// character, which is shorthand for the return key. Returns whether |key| is
// a shorthand key. If true, |key_code| will be set and |client_should_skip|
// will be set to whether the key should be skipped.
bool KeyCodeFromShorthandKey(char16_t key_utf16,
                             ui::KeyboardCode* key_code,
                             bool* client_should_skip) {}

// The "normalised key value" table from W3C spec
// (https://w3c.github.io/webdriver/#dfn-normalised-key-value).
// The code point starts at \uE000 and must increase by 1 with each row,
// with placeholders (empty strings) used for unassigned code points.
const int kNormalisedKeyValueBase =;
const char* const kNormalisedKeyValue[] =;

// The "code for key" table (https://w3c.github.io/webdriver/#dfn-code),
// with the following modifications:
// * Fixed some inconsistencies in the original table.
//   See https://github.com/w3c/webdriver/pull/1384.
// * Replaced "OSLeft" and "OSRight" with "MetaLeft" and "MetaRight", to be
//   compatible with Chrome.
//   TODO([email protected]): Find a better way to handle this.
const struct {} kCodeForKey[] =;

// The "key location for key" table from W3C spec
// (https://w3c.github.io/webdriver/#dfn-key-location). For simplicity, it is
// implemented as a few 'if' statements, instead of as a true table.
int GetKeyLocation(uint32_t code_point) {}

}  // namespace

Status ConvertKeysToKeyEvents(const std::u16string& client_keys,
                              bool release_modifiers,
                              int* modifiers,
                              std::vector<KeyEvent>* client_key_events) {}

Status ConvertKeyActionToKeyEvent(const base::Value::Dict& action_object,
                                  base::Value::Dict& input_state,
                                  bool is_key_down,
                                  std::vector<KeyEvent>* key_events) {}