diff options
author | Yukawa@chromium.org <Yukawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-12 18:54:07 +0000 |
---|---|---|
committer | Yukawa@chromium.org <Yukawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-12 18:54:07 +0000 |
commit | 56d0c55f7f6b2070b860fff773038aec57ebb82d (patch) | |
tree | 3e3233039a2b9f1422b81aed3304a0cb7166c2c0 /ui | |
parent | 3458f6b98a79be1ab12f0e18d31449c2e4b6d042 (diff) | |
download | chromium_src-56d0c55f7f6b2070b860fff773038aec57ebb82d.zip chromium_src-56d0c55f7f6b2070b860fff773038aec57ebb82d.tar.gz chromium_src-56d0c55f7f6b2070b860fff773038aec57ebb82d.tar.bz2 |
This patch set introduces a new utility method named "IsFocused" and calls TSF's SetFocus if and only if the current focused document manager is expected ones.
Background:
Despite that TsfBridge is responsible for managing IME on/off state only for content area, TsfBridge::EnableIME and TsfBridge::DisableIME will be called even when other UI components such as OmniBox have input focus. In this case, we should not call TSF's SetFocus because it makes TSF confused.
BUG=141606
TEST=Manually tested on Windows 8 RTM with Metro mode.
Review URL: https://chromiumcodereview.appspot.com/10933042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/win/tsf_bridge.cc | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/ui/base/win/tsf_bridge.cc b/ui/base/win/tsf_bridge.cc index 5878577..8e98b76 100644 --- a/ui/base/win/tsf_bridge.cc +++ b/ui/base/win/tsf_bridge.cc @@ -104,32 +104,39 @@ class TsfBridgeDelegate : public TsfBridge { virtual bool EnableIME() OVERRIDE { DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); DCHECK(IsInitialized()); - if (SUCCEEDED(thread_manager_->SetFocus(document_manager_))) { - return true; - } - return false; + + // Since EnableIME and DisableIME are designed to be a swap operation of + // |document_manager_| and |disabled_document_manager_|, do nothing unless + // the current focused document manager is |disabled_document_manager_|. + // In other words, ITfThreadMgr::SetFocus should be called if and only if + // TsfBridge actually has TSF input focus. Otherwise, TSF input focus will + // be inconsistent with Win32 input focus. + if (!IsFocused(disabled_document_manager_)) + return false; + + return SUCCEEDED(thread_manager_->SetFocus(document_manager_)); } // TsfBridge override. virtual bool DisableIME() OVERRIDE { DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); DCHECK(IsInitialized()); - if (SUCCEEDED(thread_manager_->SetFocus(disabled_document_manager_))) { - return true; - } - return false; + + // Do nothing unless the current focused document manager is + // |document_manager_|. See the comment in EnableIME. + if (!IsFocused(document_manager_)) + return false; + + return SUCCEEDED(thread_manager_->SetFocus(disabled_document_manager_)); } // TsfBridge override. virtual bool CancelComposition() OVERRIDE { DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); DCHECK(IsInitialized()); - // If current focused document manager is not |document_manager_|, do + // If the current focused document manager is not |document_manager_|, do // nothing here. - base::win::ScopedComPtr<ITfDocumentMgr> focused_document_mangaer; - if (FAILED(thread_manager_->GetFocus(focused_document_mangaer.Receive()))) - return false; - if (!focused_document_mangaer.IsSameObject(document_manager_)) + if (!IsFocused(document_manager_)) return false; base::win::ScopedComPtr<ITfContext> context; @@ -293,6 +300,14 @@ class TsfBridgeDelegate : public TsfBridge { return true; } + // Returns true if |document_manager| is the focused document manager. + bool IsFocused(base::win::ScopedComPtr<ITfDocumentMgr> document_manager) { + base::win::ScopedComPtr<ITfDocumentMgr> focused_document_mangaer; + if (FAILED(thread_manager_->GetFocus(focused_document_mangaer.Receive()))) + return false; + return focused_document_mangaer.IsSameObject(document_manager); + } + // Returns true if already initialized. bool IsInitialized() { return client_id_ != TF_CLIENTID_NULL; |