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

Unified Diff: ui/events/event.h

Issue 742103002: Ozone keyboard layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lite-code
Patch Set: rebase 2014/12/08 Created 6 years 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
Index: ui/events/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index 427a731c0a203a44500cdbf1eadb34c60be0feb3..8e39085879395ea90a8c812ee2cc43a742f7eef5 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -27,6 +27,7 @@ class Transform;
namespace ui {
class EventTarget;
enum class DomCode;
+enum class DomKey;
class EVENTS_EXPORT Event {
public:
@@ -584,6 +585,8 @@ class EVENTS_EXPORT ExtendedKeyEventData {
// VKEY_Q for the key beside Tab, while French uses VKEY_A.
// -- code_ is in one-to-one correspondence with a physical keyboard
// location, and does not vary depending on key layout.
+// -- key_, possibly in conjuction with character_, is the meaning
Wez 2014/12/09 07:00:33 Clarify that the character meaning is explained be
kpschoedel 2014/12/09 19:58:43 Done.
+// of the keystroke under the current key layout.
//
// For a character event,
// -- is_char_ is true.
@@ -592,6 +595,7 @@ class EVENTS_EXPORT ExtendedKeyEventData {
// -- key_code_ is conflated with character_ by some code, because both
// arrive in the wParam field of a Windows event.
// -- code_ is DomCode::NONE.
+// -- key_ is DomKey::CHARACTER.
//
class EVENTS_EXPORT KeyEvent : public Event {
public:
@@ -603,6 +607,14 @@ class EVENTS_EXPORT KeyEvent : public Event {
// Create a keystroke event.
KeyEvent(EventType type, KeyboardCode key_code, int flags);
+ // Create a fully defined keystroke event.
+ KeyEvent(EventType type,
+ KeyboardCode key_code,
+ DomCode code,
+ int flags,
+ DomKey key,
+ base::char16 character);
+
// Create a character event.
KeyEvent(base::char16 character, KeyboardCode key_code, int flags);
@@ -686,6 +698,9 @@ class EVENTS_EXPORT KeyEvent : public Event {
DomCode code() const { return code_; };
std::string GetCodeString() const;
+ // Returns the DOM .key (layout meaning) for a keystroke event.
+ DomKey GetDomKey() const;
+
// Normalizes flags_ so that it describes the state after the event.
// (Native X11 event flags describe the state before the event.)
void NormalizeFlags();
@@ -706,6 +721,9 @@ class EVENTS_EXPORT KeyEvent : public Event {
// True if the key press originated from a 'right' key (VKEY_RSHIFT, etc.).
bool IsRightSideKey() const;
+ // Determine key_ and character_ on a keystroke event from code_ and flags().
+ void ApplyLayout() const;
+
KeyboardCode key_code_;
// DOM KeyboardEvent |code| (e.g. DomCode::KEY_A, DomCode::SPACE).
@@ -722,6 +740,21 @@ class EVENTS_EXPORT KeyEvent : public Event {
// For now, this is used for CharacterComposer in ChromeOS.
uint32 platform_keycode_;
+ // TODO(kpschoedel): refactor so that key_ and character_ are not mutable.
+ // This requires defining the KeyEvent completely at construction rather
+ // than lazily under GetCharacter(), which likely also means removing
+ // the two 'incomplete' constructors.
+ //
+ // DOM KeyboardEvent |key|
+ // http://www.w3.org/TR/DOM-Level-3-Events-key/
+ //
+ // This value, together with character_, represents the meaning of a key.
+ // The value is DomKey::CHARACTER when the interpretation is a character.
+ // This, along with character_, may be lazily evaluated, since in some cases
+ // (e.g. native ChromeOS) we are not interested in the values until after
+ // the event has been transformed.
Wez 2014/12/09 07:00:33 What does it mean for it to be "lazily evaluated"?
kpschoedel 2014/12/09 19:58:43 Not set until required by an accessor. Revised the
+ mutable DomKey key_;
+
// String of 'key' defined in DOM KeyboardEvent (e.g. 'a', 'รข')
// http://www.w3.org/TR/uievents/#keyboard-key-codes.
//

Powered by Google App Engine
This is Rietveld 408576698