| Index: third_party/WebKit/public/platform/WebKeyboardEvent.h
|
| diff --git a/third_party/WebKit/public/platform/WebKeyboardEvent.h b/third_party/WebKit/public/platform/WebKeyboardEvent.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ec16cad503b95b6383620b55597a2ecfdc8a863a
|
| --- /dev/null
|
| +++ b/third_party/WebKit/public/platform/WebKeyboardEvent.h
|
| @@ -0,0 +1,94 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef WebKeyboardEvent_h
|
| +#define WebKeyboardEvent_h
|
| +
|
| +#include "WebInputEvent.h"
|
| +
|
| +namespace blink {
|
| +
|
| +// See WebInputEvent.h for details why this pack is here.
|
| +#pragma pack(push, 4)
|
| +
|
| +// WebKeyboardEvent -----------------------------------------------------------
|
| +
|
| +class WebKeyboardEvent : public WebInputEvent {
|
| + public:
|
| + // Caps on string lengths so we can make them static arrays and keep
|
| + // them PODs.
|
| + static const size_t textLengthCap = 4;
|
| +
|
| + // |windowsKeyCode| is the Windows key code associated with this key
|
| + // event. Sometimes it's direct from the event (i.e. on Windows),
|
| + // sometimes it's via a mapping function. If you want a list, see
|
| + // WebCore/platform/chromium/KeyboardCodes* . Note that this should
|
| + // ALWAYS store the non-locational version of a keycode as this is
|
| + // what is returned by the Windows API. For example, it should
|
| + // store VK_SHIFT instead of VK_RSHIFT. The location information
|
| + // should be stored in |modifiers|.
|
| + int windowsKeyCode;
|
| +
|
| + // The actual key code genenerated by the platform. The DOM spec runs
|
| + // on Windows-equivalent codes (thus |windowsKeyCode| above) but it
|
| + // doesn't hurt to have this one around.
|
| + int nativeKeyCode;
|
| +
|
| + // The DOM code enum of the key pressed as passed by the embedder. DOM
|
| + // code enum are defined in ui/events/keycodes/dom4/keycode_converter_data.h.
|
| + int domCode;
|
| +
|
| + // The DOM key enum of the key pressed as passed by the embedder. DOM
|
| + // key enum are defined in ui/events/keycodes/dom3/dom_key_data.h
|
| + int domKey;
|
| +
|
| + // This identifies whether this event was tagged by the system as being
|
| + // a "system key" event (see
|
| + // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for
|
| + // details). Other platforms don't have this concept, but it's just
|
| + // easier to leave it always false than ifdef.
|
| + bool isSystemKey;
|
| +
|
| + // Whether the event forms part of a browser-handled keyboard shortcut.
|
| + // This can be used to conditionally suppress Char events after a
|
| + // shortcut-triggering RawKeyDown goes unhandled.
|
| + bool isBrowserShortcut;
|
| +
|
| + // |text| is the text generated by this keystroke. |unmodifiedText| is
|
| + // |text|, but unmodified by an concurrently-held modifiers (except
|
| + // shift). This is useful for working out shortcut keys. Linux and
|
| + // Windows guarantee one character per event. The Mac does not, but in
|
| + // reality that's all it ever gives. We're generous, and cap it a bit
|
| + // longer.
|
| + WebUChar text[textLengthCap];
|
| + WebUChar unmodifiedText[textLengthCap];
|
| +
|
| + WebKeyboardEvent(Type type, int modifiers, double timeStampSeconds)
|
| + : WebInputEvent(sizeof(WebKeyboardEvent),
|
| + type,
|
| + modifiers,
|
| + timeStampSeconds) {}
|
| +
|
| + WebKeyboardEvent() : WebInputEvent(sizeof(WebKeyboardEvent)) {}
|
| +
|
| + // Please refer to bug http://b/issue?id=961192, which talks about Webkit
|
| + // keyboard event handling changes. It also mentions the list of keys
|
| + // which don't have associated character events.
|
| + bool isCharacterKey() const {
|
| + // TODO(dtapuska): Determine if we can remove this method and just
|
| + // not actually generate events for these instead of filtering them out.
|
| + switch (windowsKeyCode) {
|
| + case 0x08: // VK_BACK
|
| + case 0x1b: // VK_ESCAPE
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| +};
|
| +
|
| +#pragma pack(pop)
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // WebKeyboardEvent_h
|
|
|