diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 02:12:46 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-15 02:12:46 +0000 |
commit | 0447bcbc2f764de4ad977a76f1318021c8780f49 (patch) | |
tree | 204f16ffd75a8bb25791aa1e0b48e2b4035b5a45 | |
parent | b1cacb945a4362fe784985d7bb2d1b6d498eac70 (diff) | |
download | chromium_src-0447bcbc2f764de4ad977a76f1318021c8780f49.zip chromium_src-0447bcbc2f764de4ad977a76f1318021c8780f49.tar.gz chromium_src-0447bcbc2f764de4ad977a76f1318021c8780f49.tar.bz2 |
Merge 228079 "Revert 221394 "Remove IBus specific hack from Inpu..."
> Revert 221394 "Remove IBus specific hack from InputMethodIBus."
>
> > Remove IBus specific hack from InputMethodIBus.
> >
> > BUG=None
> > TEST=None, just working fine.
> >
> > Review URL: https://chromiumcodereview.appspot.com/22909048
>
> TBR=nona@chromium.org
>
> Review URL: https://codereview.chromium.org/26262003
TBR=nona@chromium.org
Review URL: https://codereview.chromium.org/27286002
git-svn-id: svn://svn.chromium.org/chrome/branches/1650/src@228593 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/base/ime/input_method_ibus.cc | 26 | ||||
-rw-r--r-- | ui/base/ime/input_method_ibus.h | 4 |
2 files changed, 25 insertions, 5 deletions
diff --git a/ui/base/ime/input_method_ibus.cc b/ui/base/ime/input_method_ibus.cc index 5db106e..8ff645a 100644 --- a/ui/base/ime/input_method_ibus.cc +++ b/ui/base/ime/input_method_ibus.cc @@ -80,6 +80,7 @@ InputMethodIBus::InputMethodIBus( : context_focused_(false), composing_text_(false), composition_changed_(false), + suppress_next_result_(false), current_keyevent_id_(0), previous_textinput_type_(TEXT_INPUT_TYPE_NONE), weak_ptr_factory_(this) { @@ -202,6 +203,10 @@ bool InputMethodIBus::DispatchKeyEvent(const base::NativeEvent& native_event) { ibus_state)); ++current_keyevent_id_; + + // We don't want to suppress the result generated by this key event, but it + // may cause problem. See comment in ResetContext() method. + suppress_next_result_ = false; return true; } @@ -347,6 +352,16 @@ void InputMethodIBus::ResetContext() { DCHECK(system_toplevel_window_focused()); + // Because ibus runs in asynchronous mode, the input method may still send us + // results after sending out the reset request, so we use a flag to discard + // all results generated by previous key events. But because ibus does not + // have a mechanism to identify each key event and corresponding results, this + // approach will not work for some corner cases. For example if the user types + // very fast, then the next key event may come in before the |context_| is + // really reset. Then we actually cannot know whether or not the next + // result should be discard. + suppress_next_result_ = true; + composition_.Clear(); result_text_.clear(); composing_text_ = false; @@ -562,7 +577,7 @@ void InputMethodIBus::AbandonAllPendingKeyEvents() { } void InputMethodIBus::CommitText(const chromeos::IBusText& text) { - if (text.text().empty()) + if (suppress_next_result_ || text.text().empty()) return; // We need to receive input method result even if the text input type is @@ -612,7 +627,7 @@ void InputMethodIBus::ForwardKeyEvent(uint32 keyval, } void InputMethodIBus::ShowPreeditText() { - if (IsTextInputTypeNone()) + if (suppress_next_result_ || IsTextInputTypeNone()) return; composing_text_ = true; @@ -621,6 +636,9 @@ void InputMethodIBus::ShowPreeditText() { void InputMethodIBus::UpdatePreeditText(const chromeos::IBusText& text, uint32 cursor_pos, bool visible) { + if (suppress_next_result_ || IsTextInputTypeNone()) + return; + if (!CanComposeInline()) { chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window = chromeos::IBusBridge::Get()->GetCandidateWindowHandler(); @@ -628,9 +646,6 @@ void InputMethodIBus::UpdatePreeditText(const chromeos::IBusText& text, candidate_window->UpdatePreeditText(text.text(), cursor_pos, visible); } - if (IsTextInputTypeNone()) - return; - // |visible| argument is very confusing. For example, what's the correct // behavior when: // 1. OnUpdatePreeditText() is called with a text and visible == false, then @@ -693,6 +708,7 @@ bool InputMethodIBus::ExecuteCharacterComposer(uint32 ibus_keyval, ibus_keycode, EventFlagsFromXState(ibus_state)); + suppress_next_result_ = false; chromeos::IBusText preedit; preedit.set_text( UTF16ToUTF8(character_composer_.preedit_string())); diff --git a/ui/base/ime/input_method_ibus.h b/ui/base/ime/input_method_ibus.h index 4393225..3be172f 100644 --- a/ui/base/ime/input_method_ibus.h +++ b/ui/base/ime/input_method_ibus.h @@ -166,6 +166,10 @@ class UI_EXPORT InputMethodIBus // Indicates if the composition text is changed or deleted. bool composition_changed_; + // If it's true then all input method result received before the next key + // event will be discarded. + bool suppress_next_result_; + // The latest id of key event. uint32 current_keyevent_id_; |