Implements InputMethodTSF::IsCandidatePopupOpen().

This CL is almost the same as http://crrev.com/17573006, which was reverted because of a unit test breakage.

BUG=245578
TEST=Test manually.

Review URL: https://chromiumcodereview.appspot.com/22534003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217091 0039d316-1c4b-4281-b951-d872f2087c98
parent 2afa7717
...@@ -6,12 +6,35 @@ ...@@ -6,12 +6,35 @@
#include "ui/base/ime/text_input_client.h" #include "ui/base/ime/text_input_client.h"
#include "ui/base/ime/win/tsf_bridge.h" #include "ui/base/ime/win/tsf_bridge.h"
#include "ui/base/ime/win/tsf_event_router.h"
namespace ui { namespace ui {
class InputMethodTSF::TSFEventObserver : public TSFEventRouterObserver {
public:
TSFEventObserver() : is_candidate_popup_open_(false) {}
// Returns true if we know for sure that a candidate window (or IME suggest,
// etc.) is open.
bool IsCandidatePopupOpen() const { return is_candidate_popup_open_; }
// Overridden from TSFEventRouterObserver:
virtual void OnCandidateWindowCountChanged(size_t window_count) OVERRIDE {
is_candidate_popup_open_ = (window_count != 0);
}
private:
// True if we know for sure that a candidate window is open.
bool is_candidate_popup_open_;
DISALLOW_COPY_AND_ASSIGN(TSFEventObserver);
};
InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate,
HWND toplevel_window_handle) HWND toplevel_window_handle)
: InputMethodWin(delegate, toplevel_window_handle) { : InputMethodWin(delegate, toplevel_window_handle),
tsf_event_observer_(new TSFEventObserver()),
tsf_event_router_(new TSFEventRouter(tsf_event_observer_.get())) {
// In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur() // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur()
// are not implemented yet. To work around this limitation, here we use // are not implemented yet. To work around this limitation, here we use
// "always focused" model. // "always focused" model.
...@@ -20,16 +43,23 @@ InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, ...@@ -20,16 +43,23 @@ InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate,
InputMethodWin::OnFocus(); InputMethodWin::OnFocus();
} }
InputMethodTSF::~InputMethodTSF() {}
void InputMethodTSF::OnFocus() { void InputMethodTSF::OnFocus() {
// Ignore OnFocus event for "always focused" model. See the comment in the // Do not call baseclass' OnFocus() and discard the event being in
// constructor. // "always focused" model. See the comment in the constructor.
// TODO(ime): Implement OnFocus once the callers are fixed. // TODO(ime): Implement OnFocus once the callers are fixed.
tsf_event_router_->SetManager(
ui::TSFBridge::GetInstance()->GetThreadManager());
} }
void InputMethodTSF::OnBlur() { void InputMethodTSF::OnBlur() {
// Ignore OnBlur event for "always focused" model. See the comment in the // Do not call baseclass' OnBlur() and discard the event being in
// constructor. // "always focused" model. See the comment in the constructor.
// TODO(ime): Implement OnFocus once the callers are fixed. // TODO(ime): Implement OnFocus once the callers are fixed.
tsf_event_router_->SetManager(NULL);
} }
bool InputMethodTSF::OnUntranslatedIMEMessage( bool InputMethodTSF::OnUntranslatedIMEMessage(
...@@ -99,8 +129,7 @@ void InputMethodTSF::SetFocusedTextInputClient(TextInputClient* client) { ...@@ -99,8 +129,7 @@ void InputMethodTSF::SetFocusedTextInputClient(TextInputClient* client) {
} }
bool InputMethodTSF::IsCandidatePopupOpen() const { bool InputMethodTSF::IsCandidatePopupOpen() const {
// TODO(yukishiino): Implement this method. return tsf_event_observer_->IsCandidatePopupOpen();
return false;
} }
void InputMethodTSF::OnWillChangeFocusedClient(TextInputClient* focused_before, void InputMethodTSF::OnWillChangeFocusedClient(TextInputClient* focused_before,
......
...@@ -9,15 +9,19 @@ ...@@ -9,15 +9,19 @@
#include <string> #include <string>
#include "base/memory/scoped_ptr.h"
#include "ui/base/ime/input_method_win.h" #include "ui/base/ime/input_method_win.h"
namespace ui { namespace ui {
class TSFEventRouter;
// An InputMethod implementation based on Windows TSF API. // An InputMethod implementation based on Windows TSF API.
class UI_EXPORT InputMethodTSF : public InputMethodWin { class UI_EXPORT InputMethodTSF : public InputMethodWin {
public: public:
InputMethodTSF(internal::InputMethodDelegate* delegate, InputMethodTSF(internal::InputMethodDelegate* delegate,
HWND toplevel_window_handle); HWND toplevel_window_handle);
virtual ~InputMethodTSF();
// Overridden from InputMethod: // Overridden from InputMethod:
virtual void OnFocus() OVERRIDE; virtual void OnFocus() OVERRIDE;
...@@ -37,6 +41,8 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin { ...@@ -37,6 +41,8 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin {
TextInputClient* focused) OVERRIDE; TextInputClient* focused) OVERRIDE;
private: private:
class TSFEventObserver;
// Asks the client to confirm current composition text. // Asks the client to confirm current composition text.
void ConfirmCompositionText(); void ConfirmCompositionText();
...@@ -44,6 +50,10 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin { ...@@ -44,6 +50,10 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin {
// focus. // focus.
bool IsWindowFocused(const TextInputClient* client) const; bool IsWindowFocused(const TextInputClient* client) const;
// TSF event router and observer.
scoped_ptr<TSFEventObserver> tsf_event_observer_;
scoped_ptr<TSFEventRouter> tsf_event_router_;
DISALLOW_COPY_AND_ASSIGN(InputMethodTSF); DISALLOW_COPY_AND_ASSIGN(InputMethodTSF);
}; };
......
...@@ -193,6 +193,7 @@ void TSFEventRouter::Delegate::SetManager( ...@@ -193,6 +193,7 @@ void TSFEventRouter::Delegate::SetManager(
base::win::ScopedComPtr<ITfDocumentMgr> document_manager; base::win::ScopedComPtr<ITfDocumentMgr> document_manager;
if (FAILED(thread_manager->GetFocus(document_manager.Receive())) || if (FAILED(thread_manager->GetFocus(document_manager.Receive())) ||
!document_manager.get() ||
FAILED(document_manager->GetBase(context_.Receive())) || FAILED(document_manager->GetBase(context_.Receive())) ||
FAILED(context_source_.QueryFrom(context_))) FAILED(context_source_.QueryFrom(context_)))
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment