// 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. #ifndef UI_EVENTS_EVENT_H_ #define UI_EVENTS_EVENT_H_ #include <cstdint> #include <memory> #include <string> #include <vector> #include "base/containers/flat_map.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/time/time.h" #include "build/build_config.h" #include "ui/events/event_constants.h" #include "ui/events/gesture_event_details.h" #include "ui/events/gestures/gesture_types.h" #include "ui/events/keycodes/dom/dom_key.h" #include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/platform_event.h" #include "ui/events/pointer_details.h" #include "ui/events/types/event_type.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point_conversions.h" #include "ui/latency/latency_info.h" namespace gfx { class Transform; } namespace ui { class CancelModeEvent; class Event; class EventRewriter; class EventTarget; class KeyEvent; class LocatedEvent; class MouseEvent; class MouseWheelEvent; class ScrollEvent; class TouchEvent; enum class DomCode : uint32_t; // Note: In order for Clone() to work properly, every concrete class // transitively inheriting Event must implement Clone() explicitly, even if any // ancestors have provided an implementation. class EVENTS_EXPORT Event { … }; class EVENTS_EXPORT CancelModeEvent : public Event { … }; class EVENTS_EXPORT LocatedEvent : public Event { … }; class EVENTS_EXPORT MouseEvent : public LocatedEvent { … }; class ScrollEvent; class EVENTS_EXPORT MouseWheelEvent : public MouseEvent { … }; // NOTE: Pen (stylus) events use TouchEvent with kPen. They were // originally implemented as MouseEvent but switched to TouchEvent when UX // decided not to show hover effects for pen. class EVENTS_EXPORT TouchEvent : public LocatedEvent { … }; // A KeyEvent is really two distinct classes, melded together due to the // DOM legacy of Windows key events: a keystroke event (is_char_ == false), // or a character event (is_char_ == true). // // For a keystroke event, // -- |bool is_char_| is false. // -- |EventType Event::type()| can be EventType::kKeyPressed or // EventType::kKeyReleased. // -- |DomCode code_| and |int Event::flags()| represent the physical key event. // - code_ is a platform-independent representation of the physical key, // based on DOM UI Events KeyboardEvent |code| values. It does not // vary depending on key layout. // http://www.w3.org/TR/DOM-Level-3-Events-code/ // - Event::flags() provides the active modifiers for the physical key // press. Its value reflects the state after the event; that is, for // a modifier key, a press includes the corresponding flag and a release // does not. // -- |DomKey key_| provides the meaning (character or action) of the key // event, in the context of the active layout and modifiers. It corresponds // to DOM UI Events KeyboardEvent |key| values. // http://www.w3.org/TR/DOM-Level-3-Events-key/ // -- |KeyboardCode key_code_| supports the legacy web event |keyCode| field, // and its VKEY_ values are chosen to match Windows/IE for compatibility. // For printable characters, this may or may not be a layout-mapped value, // imitating MS Windows: if the mapped key generates a character that has // an associated VKEY_ code, then key_code_ is that code; if not, then // key_code_ is the unmapped VKEY_ code. For example, US, Greek, Cyrillic, // Japanese, etc. all use VKEY_Q for the key beside Tab, while French uses // VKEY_A. The stored key_code_ is non-located (e.g. VKEY_SHIFT rather than // VKEY_LSHIFT, VKEY_1 rather than VKEY_NUMPAD1). // -- |uint32_t scan_code_| [IS_OZONE only] supports remapping of the top // function row based on a sysfs attribute provided by the kernel. This // allows devices to have a custom top row layout and still be able to // perform translation back and forth between F-Key and Action-Key. The // value of this scan code is device specific. // // For a character event, // -- |bool is_char_| is true. // -- |EventType Event::type()| is EventType::kKeyPressed. // -- |DomCode code_| is DomCode::NONE. // -- |DomKey key_| is a UTF-16 code point. // -- |KeyboardCode key_code_| is conflated with the character-valued key_ // by some code, because both arrive in the wParam field of a Windows event. // class EVENTS_EXPORT KeyEvent : public Event { … }; class EVENTS_EXPORT ScrollEvent : public MouseEvent { … }; class EVENTS_EXPORT GestureEvent : public LocatedEvent { … }; } // namespace ui #endif // UI_EVENTS_EVENT_H_