Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1442)

Unified Diff: ui/events/event.h

Issue 2765773002: Adds KeyEvent::properties (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/mojo/BUILD.gn » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index cfac55ca118f57abcff2dd76918676f0eece173a..c65d8d1507951d87d63908e9f968bfdda22bf7d7 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -8,6 +8,9 @@
#include <stdint.h>
#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
#include "base/compiler_specific.h"
#include "base/event_types.h"
@@ -798,6 +801,8 @@ class EVENTS_EXPORT PointerEvent : public LocatedEvent {
//
class EVENTS_EXPORT KeyEvent : public Event {
public:
+ using Properties = std::unordered_map<std::string, std::vector<uint8_t>>;
+
// Create a KeyEvent from a NativeEvent. For Windows this native event can
// be either a keystroke message (WM_KEYUP/WM_KEYDOWN) or a character message
// (WM_CHAR). Other systems have only keystroke events.
@@ -904,6 +909,14 @@ class EVENTS_EXPORT KeyEvent : public Event {
// (Native X11 event flags describe the state before the event.)
void NormalizeFlags();
+ // Sets the properties associated with this KeyEvent.
+ void SetProperties(const Properties& properties);
+
+ // Returns the properties associated with this event, which may be null.
+ // The properties are meant to provide a way to associate arbitrary key/value
+ // pairs with KeyEvents and not used by KeyEvent.
+ const Properties* properties() const { return properties_.get(); }
+
protected:
friend class KeyEventTestApi;
@@ -914,6 +927,8 @@ class EVENTS_EXPORT KeyEvent : public Event {
// Determine key_ on a keystroke event from code_ and flags().
void ApplyLayout() const;
+ static bool IsRepeated(const KeyEvent& event);
+
KeyboardCode key_code_;
// DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE).
@@ -940,7 +955,7 @@ class EVENTS_EXPORT KeyEvent : public Event {
// it may be set only if and when GetCharacter() or GetDomKey() is called.
mutable DomKey key_ = DomKey::NONE;
- static bool IsRepeated(const KeyEvent& event);
+ std::unique_ptr<Properties> properties_;
sadrul 2017/03/21 17:21:14 Should this be a base::Optional?
sky 2017/03/21 17:25:37 My understanding is that base::Optional's size is
static KeyEvent* last_key_event_;
};
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/mojo/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698