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

Unified Diff: ui/base/ime/input_method_auralinux.cc

Issue 277973002: Fixes the timing to dispatch VKEY_PROCESSKEY. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nona's comments. Created 6 years, 7 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 | « ui/base/ime/input_method_auralinux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/ime/input_method_auralinux.cc
diff --git a/ui/base/ime/input_method_auralinux.cc b/ui/base/ime/input_method_auralinux.cc
index 1bf20174b4ea951c0851d468f7b2fb69b4c279cf..a1c1b74bc1fbcdcb3dcd82c72b9c34b0e727e941 100644
--- a/ui/base/ime/input_method_auralinux.cc
+++ b/ui/base/ime/input_method_auralinux.cc
@@ -12,7 +12,8 @@
namespace ui {
InputMethodAuraLinux::InputMethodAuraLinux(
- internal::InputMethodDelegate* delegate) {
+ internal::InputMethodDelegate* delegate)
+ : allowed_to_fire_vkey_process_key_(false), vkey_processkey_flags_(0) {
SetDelegate(delegate);
}
@@ -54,18 +55,15 @@ bool InputMethodAuraLinux::DispatchKeyEvent(const ui::KeyEvent& event) {
if (!GetTextInputClient())
return DispatchKeyEventPostIME(event);
- // Let an IME handle the key event first.
- if (input_method_context_->DispatchKeyEvent(event)) {
- if (event.type() == ET_KEY_PRESSED &&
- (event.flags() & ui::EF_IME_FABRICATED_KEY) == 0) {
- const ui::KeyEvent fabricated_event(ET_KEY_PRESSED,
- VKEY_PROCESSKEY,
- event.flags(),
- false); // is_char
- DispatchKeyEventPostIME(fabricated_event);
- }
+ // Let an IME handle the key event first, and allow to fire a VKEY_PROCESSKEY
+ // event for keydown events. Note that DOM Level 3 Events Sepc requires that
+ // only keydown events fire keyCode=229 events and not for keyup events.
+ if (event.type() == ET_KEY_PRESSED &&
+ (event.flags() & ui::EF_IME_FABRICATED_KEY) == 0)
+ AllowToFireProcessKey(event);
+ if (input_method_context_->DispatchKeyEvent(event))
return true;
- }
+ StopFiringProcessKey();
// Otherwise, insert the character.
const bool handled = DispatchKeyEventPostIME(event);
@@ -122,24 +120,29 @@ bool InputMethodAuraLinux::IsCandidatePopupOpen() const {
// Overriden from ui::LinuxInputMethodContextDelegate
void InputMethodAuraLinux::OnCommit(const base::string16& text) {
+ MaybeFireProcessKey();
if (!IsTextInputTypeNone())
GetTextInputClient()->InsertText(text);
}
void InputMethodAuraLinux::OnPreeditChanged(
const CompositionText& composition_text) {
+ MaybeFireProcessKey();
TextInputClient* text_input_client = GetTextInputClient();
if (text_input_client)
text_input_client->SetCompositionText(composition_text);
}
void InputMethodAuraLinux::OnPreeditEnd() {
+ MaybeFireProcessKey();
TextInputClient* text_input_client = GetTextInputClient();
if (text_input_client && text_input_client->HasCompositionText())
text_input_client->ClearCompositionText();
}
-void InputMethodAuraLinux::OnPreeditStart() {}
+void InputMethodAuraLinux::OnPreeditStart() {
+ MaybeFireProcessKey();
+}
// Overridden from InputMethodBase.
@@ -153,4 +156,28 @@ void InputMethodAuraLinux::OnDidChangeFocusedClient(
InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
}
+// Helper functions to support VKEY_PROCESSKEY.
+
+void InputMethodAuraLinux::AllowToFireProcessKey(const ui::KeyEvent& event) {
+ allowed_to_fire_vkey_process_key_ = true;
+ vkey_processkey_flags_ = event.flags();
+}
+
+void InputMethodAuraLinux::MaybeFireProcessKey() {
+ if (!allowed_to_fire_vkey_process_key_)
+ return;
+
+ const ui::KeyEvent fabricated_event(ET_KEY_PRESSED,
+ VKEY_PROCESSKEY,
+ vkey_processkey_flags_,
+ false); // is_char
+ DispatchKeyEventPostIME(fabricated_event);
+ StopFiringProcessKey();
+}
+
+void InputMethodAuraLinux::StopFiringProcessKey() {
+ allowed_to_fire_vkey_process_key_ = false;
+ vkey_processkey_flags_ = 0;
+}
+
} // namespace ui
« no previous file with comments | « ui/base/ime/input_method_auralinux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698