Index: ui/events/event.h |
diff --git a/ui/events/event.h b/ui/events/event.h |
index 427a731c0a203a44500cdbf1eadb34c60be0feb3..8e48ec98713c5caa0977b8121f8e5afebe9ed173 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 interpretation |
+// 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 interpretation) for a keystroke event. |
+ DomKey GetDomKey() const; |
Wez
2014/12/02 05:45:08
Indentation looks wrong?
It's a shame that we can
kpschoedel
2014/12/02 16:45:45
Acknowledged.
|
+ |
// 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). |
@@ -715,6 +733,16 @@ class EVENTS_EXPORT KeyEvent : public Event { |
// converted from / to keyboard scan code like XKB. |
DomCode code_; |
+ // DOM KeyboardEvent |key| |
+ // http://www.w3.org/TR/DOM-Level-3-Events-key/ |
+ // |
+ // This value represents the interpretation 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. |
+ mutable DomKey key_; |
Wez
2014/12/02 05:45:07
Why does this need mutable?
kpschoedel
2014/12/02 16:45:45
Same as character_; the existing code mutates char
|
+ |
// True if this is a character event, false if this is a keystroke event. |
bool is_char_; |