Chromium Code Reviews| Index: ui/events/event.cc |
| diff --git a/ui/events/event.cc b/ui/events/event.cc |
| index 953220d0a634f1de2ae7ec3ca738dfc34a879839..db27545c41c9ae59a32eea223e328b2a18df8670 100644 |
| --- a/ui/events/event.cc |
| +++ b/ui/events/event.cc |
| @@ -671,8 +671,7 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event) |
| code_(CodeFromNative(native_event)), |
| is_char_(IsCharFromNative(native_event)), |
| platform_keycode_(PlatformKeycodeFromNative(native_event)), |
| - key_(DomKey::NONE), |
| - character_(0) { |
| + key_() { |
|
Wez
2015/08/13 22:31:48
No need to initialize |key_| if it takes no ctor p
kpschoedel
2015/08/17 20:16:14
Done.
|
| if (IsRepeated(*this)) |
| set_flags(flags() | ui::EF_IS_REPEAT); |
| @@ -682,7 +681,7 @@ KeyEvent::KeyEvent(const base::NativeEvent& native_event) |
| #if defined(OS_WIN) |
| // Only Windows has native character events. |
| if (is_char_) |
| - character_ = native_event.wParam; |
| + key_ = DomKey(native_event.wParam); |
| #endif |
| } |
| @@ -694,8 +693,7 @@ KeyEvent::KeyEvent(EventType type, |
| code_(UsLayoutKeyboardCodeToDomCode(key_code)), |
| is_char_(false), |
| platform_keycode_(0), |
|
Wez
2015/08/13 22:31:48
Could any of these fields have their initial value
kpschoedel
2015/08/17 20:16:14
Yes, this hasn't been touched since inline initial
Wez
2015/08/18 22:34:32
Acknowledged.
|
| - key_(DomKey::NONE), |
| - character_() { |
| + key_() { |
| } |
| KeyEvent::KeyEvent(EventType type, |
| @@ -707,8 +705,7 @@ KeyEvent::KeyEvent(EventType type, |
| code_(code), |
| is_char_(false), |
| platform_keycode_(0), |
| - key_(DomKey::NONE), |
| - character_(0) { |
| + key_() { |
| } |
| KeyEvent::KeyEvent(EventType type, |
| @@ -716,15 +713,13 @@ KeyEvent::KeyEvent(EventType type, |
| DomCode code, |
| int flags, |
| DomKey key, |
| - base::char16 character, |
| base::TimeDelta time_stamp) |
| : Event(type, time_stamp, flags), |
| key_code_(key_code), |
| code_(code), |
| is_char_(false), |
| platform_keycode_(0), |
| - key_(key), |
| - character_(character) { |
| + key_(key) { |
| } |
| KeyEvent::KeyEvent(base::char16 character, KeyboardCode key_code, int flags) |
| @@ -733,8 +728,7 @@ KeyEvent::KeyEvent(base::char16 character, KeyboardCode key_code, int flags) |
| code_(DomCode::NONE), |
| is_char_(true), |
| platform_keycode_(0), |
| - key_(DomKey::CHARACTER), |
| - character_(character) { |
| + key_(character) { |
| } |
| KeyEvent::KeyEvent(const KeyEvent& rhs) |
| @@ -743,8 +737,7 @@ KeyEvent::KeyEvent(const KeyEvent& rhs) |
| code_(rhs.code_), |
| is_char_(rhs.is_char_), |
| platform_keycode_(rhs.platform_keycode_), |
| - key_(rhs.key_), |
| - character_(rhs.character_) { |
| + key_(rhs.key_) { |
| if (rhs.extended_key_event_data_) |
| extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); |
| } |
| @@ -757,7 +750,6 @@ KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) { |
| key_ = rhs.key_; |
| is_char_ = rhs.is_char_; |
| platform_keycode_ = rhs.platform_keycode_; |
| - character_ = rhs.character_; |
| if (rhs.extended_key_event_data_) |
| extended_key_event_data_.reset(rhs.extended_key_event_data_->Clone()); |
| @@ -772,14 +764,6 @@ void KeyEvent::SetExtendedKeyEventData(scoped_ptr<ExtendedKeyEventData> data) { |
| } |
| void KeyEvent::ApplyLayout() const { |
| - // If the client has set the character (e.g. faked key events from virtual |
| - // keyboard), it's client's responsibility to set the dom key correctly. |
| - // Otherwise, set the dom key as unidentified. |
| - // Please refer to crbug.com/443889. |
| - if (character_ != 0) { |
| - key_ = DomKey::UNIDENTIFIED; |
| - return; |
| - } |
| ui::DomCode code = code_; |
| if (code == DomCode::NONE) { |
| // Catch old code that tries to do layout without a physical key, and try |
| @@ -803,13 +787,12 @@ void KeyEvent::ApplyLayout() const { |
| // returns 'a' for VKEY_A even if the key is actually bound to 'à' in X11. |
| // GetCharacterFromXEvent returns 'à' in that case. |
| if (!IsControlDown() && native_event()) { |
| - GetMeaningFromXEvent(native_event(), &key_, &character_); |
| + key_ = GetDomKeyFromXEvent(native_event()); |
| return; |
| } |
| #elif defined(USE_OZONE) |
| if (KeyboardLayoutEngineManager::GetKeyboardLayoutEngine()->Lookup( |
| - code, flags(), &key_, &character_, &dummy_key_code, |
| - &platform_keycode_)) { |
| + code, flags(), &key_, &dummy_key_code, &platform_keycode_)) { |
| return; |
| } |
| #else |
| @@ -818,33 +801,32 @@ void KeyEvent::ApplyLayout() const { |
| EventTypeFromNative(native_event()) == ET_KEY_RELEASED); |
| } |
| #endif |
| - if (!DomCodeToUsLayoutMeaning(code, flags(), &key_, &character_, |
| - &dummy_key_code)) { |
| + if (!DomCodeToUsLayoutDomKey(code, flags(), &key_, &dummy_key_code)) |
| key_ = DomKey::UNIDENTIFIED; |
| - } |
| } |
| DomKey KeyEvent::GetDomKey() const { |
| - // Determination of character_ and key_ may be done lazily. |
| + // Determination of key_ may be done lazily. |
| if (key_ == DomKey::NONE) |
| ApplyLayout(); |
| return key_; |
| } |
| base::char16 KeyEvent::GetCharacter() const { |
|
kpschoedel
2015/08/07 20:42:12
We still need a separate GetCharacter() for cases
Wez
2015/08/13 22:31:48
Acknowledged.
|
| - // Determination of character_ and key_ may be done lazily. |
| + // Determination of key_ may be done lazily. |
| if (key_ == DomKey::NONE) |
| ApplyLayout(); |
| - return character_; |
| + if (key_.IsUnicode()) |
| + return key_; |
|
dtapuska
2015/08/13 14:47:25
I find this tricky.. In that the code assumes that
kpschoedel
2015/08/13 15:46:06
This proposal is for a DomKey that is explicitly d
Wez
2015/08/13 22:31:48
I'd be fine with something like DomKey::ToChar(key
kpschoedel
2015/08/17 20:16:14
I haven't looked into it, but I assume builds use
Wez
2015/08/26 23:38:33
Acknowledged.
|
| + return 0; |
| } |
| base::char16 KeyEvent::GetText() const { |
| if ((flags() & EF_CONTROL_DOWN) != 0) { |
| - base::char16 character; |
| ui::DomKey key; |
| ui::KeyboardCode key_code; |
| - if (DomCodeToControlCharacter(code_, flags(), &key, &character, &key_code)) |
| - return character; |
| + if (DomCodeToControlCharacter(code_, flags(), &key, &key_code)) |
| + return key; |
| } |
| return GetUnmodifiedText(); |
| } |
| @@ -905,7 +887,7 @@ KeyboardCode KeyEvent::GetLocatedWindowsKeyboardCode() const { |
| uint16 KeyEvent::GetConflatedWindowsKeyCode() const { |
| if (is_char_) |
| - return character_; |
| + return key_; |
| return key_code_; |
| } |