diff options
author | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 17:51:28 +0000 |
---|---|---|
committer | nona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 17:51:28 +0000 |
commit | 06b61d9b949354608e2c2325da6a086582ac8581 (patch) | |
tree | a24434b510c57557b21e1544618e7894e09b9fe0 | |
parent | 40cb85ee3a816f20b324b8b4e9fc195e4b5a966d (diff) | |
download | chromium_src-06b61d9b949354608e2c2325da6a086582ac8581.zip chromium_src-06b61d9b949354608e2c2325da6a086582ac8581.tar.gz chromium_src-06b61d9b949354608e2c2325da6a086582ac8581.tar.bz2 |
Clean Up: TSF related stuff
This clean up CL contains:
1. Rename TSF acronym from Tsf to TSF based on 11141019.
2. Use STDMETHOD_ instead of STDMETHODIMP suggested on 11235023.
3. Use override comment suggested on 11235023
BUG=None
TBR=mark@chromium.org
TEST=checked on Windows 8 and try bots
Review URL: https://chromiumcodereview.appspot.com/11341036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165700 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 799 insertions, 845 deletions
diff --git a/base/win/metro.cc b/base/win/metro.cc index fffad87..22bc5e8 100644 --- a/base/win/metro.cc +++ b/base/win/metro.cc @@ -70,13 +70,13 @@ bool IsProcessImmersive(HANDLE process) { return false; } -bool IsTsfAwareRequired() { +bool IsTSFAwareRequired() { // Although this function is equal to IsMetroProcess at this moment, // Chrome for Win7 and Vista may support TSF in the future. return g_should_tsf_aware_required || IsMetroProcess(); } -void SetForceToUseTsf() { +void SetForceToUseTSF() { g_should_tsf_aware_required = true; // Since Windows 8 Metro mode disables CUAS (Cicero Unaware Application diff --git a/base/win/metro.h b/base/win/metro.h index 41404a8..a43bbc3 100644 --- a/base/win/metro.h +++ b/base/win/metro.h @@ -56,14 +56,14 @@ BASE_EXPORT bool IsProcessImmersive(HANDLE process); // Returns true if this process is running under Text Services Framework (TSF) // and browser must be TSF-aware. -BASE_EXPORT bool IsTsfAwareRequired(); +BASE_EXPORT bool IsTSFAwareRequired(); -// Sets browser to use Text Service Framework (TSF) regardless of process +// Sets browser to use Text Services Framework (TSF) regardless of process // status. On Windows 8, this function also disables CUAS (Cicero Unaware // Application Support) to emulate Windows Metro mode in terms of IME // functionality. This should be beneficial in QA process because on can test // IME functionality in Windows 8 desktop mode. -BASE_EXPORT void SetForceToUseTsf(); +BASE_EXPORT void SetForceToUseTSF(); // Allocates and returns the destination string via the LocalAlloc API after // copying the src to it. diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 3731ac1..2ce8a25 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -216,7 +216,7 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() { void ChromeBrowserMainPartsWin::PostMainMessageLoopStart() { DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - if (base::win::IsTsfAwareRequired()) { + if (base::win::IsTSFAwareRequired()) { // Create a TSF message filter for the message loop. MessageLoop takes // ownership of the filter. scoped_ptr<base::win::TextServicesMessageFilter> tsf_message_filter( diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 4c273aa..8149e97 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -479,8 +479,8 @@ OmniboxViewWin::OmniboxViewWin(OmniboxEditController* controller, security_level_(ToolbarModel::NONE), text_object_model_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST( - tsf_event_router_(base::win::IsTsfAwareRequired() ? - new ui::TsfEventRouter(this) : NULL)) { + tsf_event_router_(base::win::IsTSFAwareRequired() ? + new ui::TSFEventRouter(this) : NULL)) { if (!loaded_library_module_) loaded_library_module_ = LoadLibrary(kRichEditDLLName); @@ -1394,7 +1394,7 @@ void OmniboxViewWin::OnCopy() { } LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { - if (base::win::IsTsfAwareRequired()) { + if (base::win::IsTSFAwareRequired()) { // Enable TSF support of RichEdit. SetEditStyle(SES_USECTF, SES_USECTF); } @@ -1409,7 +1409,7 @@ LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { // to guarantee we've always called OnBeforePossibleChange() before // OnAfterPossibleChange(), we therefore call that here. Note that multiple // (i.e. unmatched) calls to this function in a row are safe. - if (base::win::IsTsfAwareRequired()) + if (base::win::IsTSFAwareRequired()) OnBeforePossibleChange(); return 0; } @@ -1954,7 +1954,7 @@ void OmniboxViewWin::OnSetFocus(HWND focus_wnd) { // Document manager created by RichEdit can be obtained only after // WM_SETFOCUS event is handled. tsf_event_router_->SetManager( - ui::TsfBridge::GetInstance()->GetThreadManager()); + ui::TSFBridge::GetInstance()->GetThreadManager()); SetMsgHandled(true); } } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.h b/chrome/browser/ui/views/omnibox/omnibox_view_win.h index 2cf0327..7bcb9dc 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.h +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.h @@ -43,7 +43,7 @@ class OmniboxViewWin ES_NOHIDESEL> >, public CRichEditCommands<OmniboxViewWin>, public ui::SimpleMenuModel::Delegate, - public ui::TsfEventRouterObserver, + public ui::TSFEventRouterObserver, public OmniboxView { public: struct State { @@ -329,7 +329,7 @@ class OmniboxViewWin // If a host name is found, it makes it visually stronger. virtual void EmphasizeURLComponents() OVERRIDE; - // TsfEventRouter::Observer: + // TSFEventRouter::Observer: virtual void OnCandidateWindowCountChanged(size_t window_count) OVERRIDE; virtual void OnTextUpdated(const ui::Range& composition_range) OVERRIDE; @@ -516,7 +516,7 @@ class OmniboxViewWin views::NativeViewHost* native_view_host_; // TSF related event router. - scoped_ptr<ui::TsfEventRouter> tsf_event_router_; + scoped_ptr<ui::TSFEventRouter> tsf_event_router_; DISALLOW_COPY_AND_ASSIGN(OmniboxViewWin); }; diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index a58e566..8aeec88 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -59,7 +59,7 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { #if defined(OS_WIN) if (parameters.command_line.HasSwitch( switches::kEnableTextServicesFramework)) { - base::win::SetForceToUseTsf(); + base::win::SetForceToUseTSF(); } #endif // OS_WIN @@ -91,8 +91,8 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { base::allocator::SetupSubprocessAllocator(); #endif ole_initializer_.reset(new ui::ScopedOleInitializer); - if (base::win::IsTsfAwareRequired()) - ui::TsfBridge::Initialize(); + if (base::win::IsTSFAwareRequired()) + ui::TSFBridge::Initialize(); #endif // OS_WIN #if defined(OS_ANDROID) @@ -127,8 +127,8 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { main_loop_->ShutdownThreadsAndCleanUp(); #if defined(OS_WIN) - if (base::win::IsTsfAwareRequired()) - ui::TsfBridge::GetInstance()->Shutdown(); + if (base::win::IsTSFAwareRequired()) + ui::TSFBridge::GetInstance()->Shutdown(); ole_initializer_.reset(NULL); #endif diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index 9feecbf..9e458c1 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -917,7 +917,7 @@ void RenderWidgetHostViewWin::SetScrollOffsetPinning( void RenderWidgetHostViewWin::SetCompositionText( const ui::CompositionText& composition) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -937,7 +937,7 @@ void RenderWidgetHostViewWin::SetCompositionText( } void RenderWidgetHostViewWin::ConfirmCompositionText() { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -946,7 +946,7 @@ void RenderWidgetHostViewWin::ConfirmCompositionText() { } void RenderWidgetHostViewWin::ClearCompositionText() { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -955,7 +955,7 @@ void RenderWidgetHostViewWin::ClearCompositionText() { } void RenderWidgetHostViewWin::InsertText(const string16& text) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -964,7 +964,7 @@ void RenderWidgetHostViewWin::InsertText(const string16& text) { } void RenderWidgetHostViewWin::InsertChar(char16 ch, int flags) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -973,7 +973,7 @@ void RenderWidgetHostViewWin::InsertChar(char16 ch, int flags) { } ui::TextInputType RenderWidgetHostViewWin::GetTextInputType() const { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return ui::TEXT_INPUT_TYPE_NONE; } @@ -981,7 +981,7 @@ ui::TextInputType RenderWidgetHostViewWin::GetTextInputType() const { } bool RenderWidgetHostViewWin::CanComposeInline() const { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -991,7 +991,7 @@ bool RenderWidgetHostViewWin::CanComposeInline() const { } gfx::Rect RenderWidgetHostViewWin::GetCaretBounds() { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return gfx::Rect(0, 0, 0, 0); } @@ -1002,7 +1002,7 @@ gfx::Rect RenderWidgetHostViewWin::GetCaretBounds() { bool RenderWidgetHostViewWin::GetCompositionCharacterBounds( uint32 index, gfx::Rect* rect) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1016,7 +1016,7 @@ bool RenderWidgetHostViewWin::GetCompositionCharacterBounds( } bool RenderWidgetHostViewWin::HasCompositionText() { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1026,7 +1026,7 @@ bool RenderWidgetHostViewWin::HasCompositionText() { } bool RenderWidgetHostViewWin::GetTextRange(ui::Range* range) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1036,7 +1036,7 @@ bool RenderWidgetHostViewWin::GetTextRange(ui::Range* range) { } bool RenderWidgetHostViewWin::GetCompositionTextRange(ui::Range* range) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1046,7 +1046,7 @@ bool RenderWidgetHostViewWin::GetCompositionTextRange(ui::Range* range) { } bool RenderWidgetHostViewWin::GetSelectionRange(ui::Range* range) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1056,7 +1056,7 @@ bool RenderWidgetHostViewWin::GetSelectionRange(ui::Range* range) { } bool RenderWidgetHostViewWin::SetSelectionRange(const ui::Range& range) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1066,7 +1066,7 @@ bool RenderWidgetHostViewWin::SetSelectionRange(const ui::Range& range) { } bool RenderWidgetHostViewWin::DeleteRange(const ui::Range& range) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1077,7 +1077,7 @@ bool RenderWidgetHostViewWin::DeleteRange(const ui::Range& range) { bool RenderWidgetHostViewWin::GetTextFromRange(const ui::Range& range, string16* text) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1098,7 +1098,7 @@ bool RenderWidgetHostViewWin::GetTextFromRange(const ui::Range& range, } void RenderWidgetHostViewWin::OnInputMethodChanged() { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -1108,7 +1108,7 @@ void RenderWidgetHostViewWin::OnInputMethodChanged() { bool RenderWidgetHostViewWin::ChangeTextDirectionAndLayoutAlignment( base::i18n::TextDirection direction) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return false; } @@ -1120,7 +1120,7 @@ bool RenderWidgetHostViewWin::ChangeTextDirectionAndLayoutAlignment( void RenderWidgetHostViewWin::ExtendSelectionAndDelete( size_t before, size_t after) { - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { NOTREACHED(); return; } @@ -1387,8 +1387,8 @@ void RenderWidgetHostViewWin::OnSetFocus(HWND window) { render_widget_host_->GotFocus(); render_widget_host_->SetActive(true); - if (base::win::IsTsfAwareRequired()) - ui::TsfBridge::GetInstance()->SetFocusedClient(m_hWnd, this); + if (base::win::IsTSFAwareRequired()) + ui::TSFBridge::GetInstance()->SetFocusedClient(m_hWnd, this); } void RenderWidgetHostViewWin::OnKillFocus(HWND window) { @@ -1401,8 +1401,8 @@ void RenderWidgetHostViewWin::OnKillFocus(HWND window) { last_touch_location_ = gfx::Point(-1, -1); - if (base::win::IsTsfAwareRequired()) - ui::TsfBridge::GetInstance()->RemoveFocusedClient(this); + if (base::win::IsTSFAwareRequired()) + ui::TSFBridge::GetInstance()->RemoveFocusedClient(this); } void RenderWidgetHostViewWin::OnCaptureChanged(HWND window) { @@ -1709,8 +1709,8 @@ LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam, case WM_RBUTTONDOWN: // Finish the ongoing composition whenever a mouse click happens. // It matches IE's behavior. - if (base::win::IsTsfAwareRequired()) { - ui::TsfBridge::GetInstance()->CancelComposition(); + if (base::win::IsTSFAwareRequired()) { + ui::TSFBridge::GetInstance()->CancelComposition(); } else { ime_input_.CleanupComposition(m_hWnd); } @@ -2102,8 +2102,8 @@ LRESULT RenderWidgetHostViewWin::OnTouchEvent(UINT message, WPARAM wparam, TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnTouchEvent"); // Finish the ongoing composition whenever a touch event happens. // It matches IE's behavior. - if (base::win::IsTsfAwareRequired()) { - ui::TsfBridge::GetInstance()->CancelComposition(); + if (base::win::IsTSFAwareRequired()) { + ui::TSFBridge::GetInstance()->CancelComposition(); } else { ime_input_.CleanupComposition(m_hWnd); } @@ -2976,8 +2976,8 @@ LRESULT RenderWidgetHostViewWin::OnQueryCharPosition( } void RenderWidgetHostViewWin::UpdateIMEState() { - if (base::win::IsTsfAwareRequired()) { - ui::TsfBridge::GetInstance()->OnTextInputTypeChanged(this); + if (base::win::IsTSFAwareRequired()) { + ui::TSFBridge::GetInstance()->OnTextInputTypeChanged(this); return; } if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE && diff --git a/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc index 382a16f..357fedb 100644 --- a/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc +++ b/content/browser/renderer_host/render_widget_host_view_win_browsertest.cc @@ -28,8 +28,8 @@ class RenderWidgetHostViewWinTest : public ContentBrowserTest { // crbug.com/151798 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, DISABLED_SwichToPasswordField) { - ui::MockTsfBridge mock_bridge; - ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); + ui::MockTSFBridge mock_bridge; + ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); NavigateToURL(shell(), test_url); @@ -60,14 +60,14 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, RunAllPendingInMessageLoop(); EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); - ui::TsfBridge::ReplaceForTesting(old_bridge); + ui::TSFBridge::ReplaceForTesting(old_bridge); } // crbug.com/151798 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, DISABLED_SwitchToSameField) { - ui::MockTsfBridge mock_bridge; - ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); + ui::MockTSFBridge mock_bridge; + ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); NavigateToURL(shell(), test_url); @@ -98,14 +98,14 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, RunAllPendingInMessageLoop(); EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, mock_bridge.latest_text_iput_type()); - ui::TsfBridge::ReplaceForTesting(old_bridge); + ui::TSFBridge::ReplaceForTesting(old_bridge); } // crbug.com/151798 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, DISABLED_SwitchToSamePasswordField) { - ui::MockTsfBridge mock_bridge; - ui::TsfBridge* old_bridge = ui::TsfBridge::ReplaceForTesting(&mock_bridge); + ui::MockTSFBridge mock_bridge; + ui::TSFBridge* old_bridge = ui::TSFBridge::ReplaceForTesting(&mock_bridge); GURL test_url = GetTestUrl("textinput", "ime_enable_disable_test.html"); NavigateToURL(shell(), test_url); @@ -136,7 +136,7 @@ IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewWinTest, RunAllPendingInMessageLoop(); EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, mock_bridge.latest_text_iput_type()); - ui::TsfBridge::ReplaceForTesting(old_bridge); + ui::TSFBridge::ReplaceForTesting(old_bridge); } } // namespace content diff --git a/ui/base/ime/win/mock_tsf_bridge.cc b/ui/base/ime/win/mock_tsf_bridge.cc index d242505..bfcd843 100644 --- a/ui/base/ime/win/mock_tsf_bridge.cc +++ b/ui/base/ime/win/mock_tsf_bridge.cc @@ -9,7 +9,7 @@ namespace ui { -MockTsfBridge::MockTsfBridge() +MockTSFBridge::MockTSFBridge() : shutdown_call_count_(0), enable_ime_call_count_(0), disalbe_ime_call_count_(0), @@ -22,41 +22,41 @@ MockTsfBridge::MockTsfBridge() latest_text_input_type_(TEXT_INPUT_TYPE_NONE) { } -MockTsfBridge::~MockTsfBridge() { +MockTSFBridge::~MockTSFBridge() { } -void MockTsfBridge::Shutdown() { +void MockTSFBridge::Shutdown() { shutdown_call_count_++; } -bool MockTsfBridge::CancelComposition() { +bool MockTSFBridge::CancelComposition() { ++cancel_composition_call_count_; return true; } -void MockTsfBridge::OnTextInputTypeChanged(TextInputClient* client) { +void MockTSFBridge::OnTextInputTypeChanged(TextInputClient* client) { latest_text_input_type_ = client->GetTextInputType(); } -void MockTsfBridge::SetFocusedClient(HWND focused_window, +void MockTSFBridge::SetFocusedClient(HWND focused_window, TextInputClient* client) { ++set_focused_client_call_count_; focused_window_ = focused_window; text_input_client_ = client; } -void MockTsfBridge::RemoveFocusedClient(TextInputClient* client) { +void MockTSFBridge::RemoveFocusedClient(TextInputClient* client) { ++remove_focused_client_call_count_; DCHECK_EQ(client, text_input_client_); text_input_client_ = NULL; focused_window_ = NULL; } -base::win::ScopedComPtr<ITfThreadMgr> MockTsfBridge::GetThreadManager() { +base::win::ScopedComPtr<ITfThreadMgr> MockTSFBridge::GetThreadManager() { return thread_manager_; } -void MockTsfBridge::Reset() { +void MockTSFBridge::Reset() { shutdown_call_count_ = 0; enable_ime_call_count_ = 0; disalbe_ime_call_count_ = 0; diff --git a/ui/base/ime/win/mock_tsf_bridge.h b/ui/base/ime/win/mock_tsf_bridge.h index a071988..94e6bd7 100644 --- a/ui/base/ime/win/mock_tsf_bridge.h +++ b/ui/base/ime/win/mock_tsf_bridge.h @@ -14,31 +14,21 @@ namespace ui { -class MockTsfBridge : public TsfBridge { +class MockTSFBridge : public TSFBridge { public: - MockTsfBridge(); - virtual ~MockTsfBridge(); + MockTSFBridge(); + virtual ~MockTSFBridge(); - // TsfBridge override. + // TSFBridge: virtual void Shutdown() OVERRIDE; - - // TsfBridge override. virtual bool CancelComposition() OVERRIDE; - - // TsfBridge override. virtual void OnTextInputTypeChanged(TextInputClient* client) OVERRIDE; - - // TsfBridge override. virtual void SetFocusedClient(HWND focused_window, TextInputClient* client) OVERRIDE; - - // TsfBridge override. virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE; - - // TsfBridge override. virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE; - // Resets MockTsfBridge state including function call counter. + // Resets MockTSFBridge state including function call counter. void Reset(); // Call count of Shutdown(). @@ -92,7 +82,7 @@ class MockTsfBridge : public TsfBridge { TextInputType latest_text_input_type_; base::win::ScopedComPtr<ITfThreadMgr> thread_manager_; - DISALLOW_COPY_AND_ASSIGN(MockTsfBridge); + DISALLOW_COPY_AND_ASSIGN(MockTSFBridge); }; } // namespace ui diff --git a/ui/base/ime/win/tsf_bridge.cc b/ui/base/ime/win/tsf_bridge.cc index 8edb612..162f508 100644 --- a/ui/base/ime/win/tsf_bridge.cc +++ b/ui/base/ime/win/tsf_bridge.cc @@ -20,390 +20,56 @@ namespace ui { namespace { -// A TLS implementation of TsfBridge. -class TsfBridgeDelegate : public TsfBridge { - public: - TsfBridgeDelegate() - : source_cookie_(TF_INVALID_COOKIE), - client_id_(TF_CLIENTID_NULL), - client_(NULL) { - } - - virtual ~TsfBridgeDelegate() { - } - - // TsfBridge override. - bool Initialize() { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - if (client_id_ != TF_CLIENTID_NULL) { - VLOG(1) << "Already initialized."; - return false; - } - - if (FAILED(thread_manager_.CreateInstance(CLSID_TF_ThreadMgr))) { - VLOG(1) << "Failed to create ThreadManager instance."; - return false; - } - - if (FAILED(thread_manager_->Activate(&client_id_))) { - VLOG(1) << "Failed to activate Thread Manager."; - return false; - } - - if (!InitializeForEnabledDocumentManager()) - return false; - - if (!InitializeForPasswordDocumentManager()) - return false; - - if (!InitializeForDisabledDocumentManager()) - return false; - - // Japanese IME expectes the default value of this compartment is - // TF_SENTENCEMODE_PHRASEPREDICT like IMM32 implementation. This value is - // managed per thread, so that it is enough to set this value at once. This - // value does not affect other language's IME behaviors. - base::win::ScopedComPtr<ITfCompartmentMgr> thread_compartment_manager; - if (FAILED(thread_compartment_manager.QueryFrom(thread_manager_))) { - VLOG(1) << "Failed to get ITfCompartmentMgr."; - return false; - } - - base::win::ScopedComPtr<ITfCompartment> sentence_compartment; - if (FAILED(thread_compartment_manager->GetCompartment( - GUID_COMPARTMENT_KEYBOARD_INPUTMODE_SENTENCE, - sentence_compartment.Receive()))) { - VLOG(1) << "Failed to get sentence compartment."; - return false; - } - - base::win::ScopedVariant sentence_variant; - sentence_variant.Set(TF_SENTENCEMODE_PHRASEPREDICT); - if (FAILED(sentence_compartment->SetValue(client_id_, &sentence_variant))) { - VLOG(1) << "Failed to change the sentence mode."; - return false; - } +// We use thread local storage for TSFBridge lifespan management. +base::ThreadLocalStorage::StaticSlot tls_tsf_bridge = TLS_INITIALIZER; - return true; - } - // TsfBridge override. - virtual void Shutdown() OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - if (!IsInitialized()) - return; - base::win::ScopedComPtr<ITfContext> context; - if (FAILED(document_manager_for_editable_->GetTop(context.Receive()))) - return; - base::win::ScopedComPtr<ITfSource> source; - if (FAILED(source.QueryFrom(context))) - return; - if (source_cookie_ == TF_INVALID_COOKIE) - return; - if (FAILED(source->UnadviseSink(source_cookie_))) - return; - - DCHECK(text_store_.get()); - text_store_.reset(); - client_id_ = TF_CLIENTID_NULL; - } +// TsfBridgeDelegate ----------------------------------------------------------- - // TsfBridge override. - virtual void OnTextInputTypeChanged(TextInputClient* client) OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - DCHECK(IsInitialized()); - - if (client != client_) { - // Called from not focusing client. Do nothing. - return; - } - - DCHECK(client_); - const TextInputType type = client_->GetTextInputType(); - switch (type) { - case TEXT_INPUT_TYPE_NONE: - thread_manager_->SetFocus(document_manager_for_non_editable_); - break; - case TEXT_INPUT_TYPE_PASSWORD: - thread_manager_->SetFocus(document_manager_for_password_); - break; - default: - thread_manager_->SetFocus(document_manager_for_editable_); - break; - } - } +// A TLS implementation of TSFBridge. +class TSFBridgeDelegate : public TSFBridge { + public: + TSFBridgeDelegate(); + virtual ~TSFBridgeDelegate(); - // TsfBridge override. - virtual bool CancelComposition() OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - DCHECK(IsInitialized()); - // If the current focused document manager is not - // |document_manager_for_editable_|, do nothing here. - if (!IsFocused(document_manager_for_editable_)) - return false; - - base::win::ScopedComPtr<ITfContext> context; - if (FAILED(document_manager_for_editable_->GetTop(context.Receive()))) { - VLOG(1) << "Failed to get top context."; - return false; - } - - base::win::ScopedComPtr<ITfContextOwnerCompositionServices> owner; - if (FAILED(owner.QueryFrom(context))) { - VLOG(1) << "Failed to get ITfContextOwnerCompositionService."; - return false; - } - // Cancel all composition. - owner->TerminateComposition(NULL); - return true; - } + bool Initialize(); - // TsfBridge override. + // TsfBridge: + virtual void Shutdown() OVERRIDE; + virtual void OnTextInputTypeChanged(TextInputClient* client) OVERRIDE; + virtual bool CancelComposition() OVERRIDE; virtual void SetFocusedClient(HWND focused_window, - TextInputClient* client) OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - DCHECK(client); - DCHECK(IsInitialized()); - client_ = client; - text_store_->get()->SetFocusedTextInputClient(focused_window, client); - password_text_store_->get()->SetFocusedTextInputClient(focused_window, - client); - - // Synchronize text input type state. - OnTextInputTypeChanged(client); - } - - // TsfBridge override. - virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - DCHECK(IsInitialized()); - if (client_ == client) { - client_ = NULL; - text_store_->get()->SetFocusedTextInputClient(NULL, NULL); - password_text_store_->get()->SetFocusedTextInputClient(NULL, NULL); - } - } - - virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE { - DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); - DCHECK(IsInitialized()); - return thread_manager_; - } + TextInputClient* client) OVERRIDE; + virtual void RemoveFocusedClient(TextInputClient* client) OVERRIDE; + virtual base::win::ScopedComPtr<ITfThreadMgr> GetThreadManager() OVERRIDE; private: - friend struct DefaultSingletonTraits<TsfBridgeDelegate>; + friend struct DefaultSingletonTraits<TSFBridgeDelegate>; // Initializes |document_manager_for_editable_|. - bool InitializeForEnabledDocumentManager() { - if (FAILED(thread_manager_->CreateDocumentMgr( - document_manager_for_editable_.Receive()))) { - VLOG(1) << "Failed to create Document Manager."; - return false; - } - - TfEditCookie unused_edit_cookie = TF_INVALID_EDIT_COOKIE; - text_store_.reset(new scoped_refptr<TsfTextStore>(new TsfTextStore())); - - base::win::ScopedComPtr<ITfContext> context; - if (FAILED(document_manager_for_editable_->CreateContext(client_id_, - 0, - static_cast<ITextStoreACP*>( - text_store_->get()), - context.Receive(), - &unused_edit_cookie))) { - VLOG(1) << "Failed to create Context."; - return false; - } - - if (FAILED(document_manager_for_editable_->Push(context))) { - VLOG(1) << "Failed to push context."; - return false; - } - - base::win::ScopedComPtr<ITfSource> source; - if (FAILED(source.QueryFrom(context))) { - VLOG(1) << "Failed to get source."; - return false; - } - - if (FAILED(source->AdviseSink(IID_ITfTextEditSink, - static_cast<ITfTextEditSink*>( - text_store_->get()), - &source_cookie_))) { - VLOG(1) << "AdviseSink failed."; - return false; - } - - if (source_cookie_ == TF_INVALID_COOKIE) { - VLOG(1) << "The result of cookie is invalid."; - return false; - } - - return true; - } + bool InitializeForEnabledDocumentManager(); // Initializes |document_manager_for_password_|. - bool InitializeForPasswordDocumentManager() { - if (FAILED(thread_manager_->CreateDocumentMgr( - document_manager_for_password_.Receive()))) { - VLOG(1) << "Failed to create Document Manager."; - return false; - } - - TfEditCookie unused_edit_cookie = TF_INVALID_EDIT_COOKIE; - password_text_store_.reset( - new scoped_refptr<TsfTextStore>(new TsfTextStore())); - - base::win::ScopedComPtr<ITfContext> context; - if (FAILED(document_manager_for_password_->CreateContext( - client_id_, - 0, - static_cast<ITextStoreACP*>(password_text_store_->get()), - context.Receive(), - &unused_edit_cookie))) { - VLOG(1) << "Failed to create Context."; - return false; - } - - base::win::ScopedComPtr<ITfCompartmentMgr> compartment_mgr; - if (FAILED(compartment_mgr.QueryFrom(context))) { - VLOG(1) << "Failed to get CompartmentMgr."; - return false; - } - - base::win::ScopedComPtr<ITfCompartment> disabled_compartment; - if (FAILED(compartment_mgr->GetCompartment( - GUID_COMPARTMENT_KEYBOARD_DISABLED, - disabled_compartment.Receive()))) { - VLOG(1) << "Failed to get keyboard disabled compartment."; - return false; - } - - base::win::ScopedVariant variant; - variant.Set(static_cast<int32>(1)); - if (FAILED(disabled_compartment->SetValue(client_id_, &variant))) { - VLOG(1) << "Failed to disable the DocumentMgr."; - return false; - } - - base::win::ScopedComPtr<ITfCompartment> empty_context; - if (FAILED(compartment_mgr->GetCompartment(GUID_COMPARTMENT_EMPTYCONTEXT, - empty_context.Receive()))) { - VLOG(1) << "Failed to get empty context compartment."; - return false; - } - base::win::ScopedVariant empty_context_variant; - empty_context_variant.Set(static_cast<int32>(1)); - if (FAILED(empty_context->SetValue(client_id_, &empty_context_variant))) { - VLOG(1) << "Failed to set empty context."; - return false; - } - - if (FAILED(document_manager_for_password_->Push(context))) { - VLOG(1) << "Failed to push context."; - return false; - } - - base::win::ScopedComPtr<ITfSource> source; - if (FAILED(source.QueryFrom(context))) { - VLOG(1) << "Failed to get source."; - return false; - } - - if (FAILED(source->AdviseSink(IID_ITfTextEditSink, - static_cast<ITfTextEditSink*>( - password_text_store_->get()), - &source_cookie_))) { - VLOG(1) << "AdviseSink failed."; - return false; - } - - if (source_cookie_ == TF_INVALID_COOKIE) { - VLOG(1) << "The result of cookie is invalid."; - return false; - } - - return true; - } + bool InitializeForPasswordDocumentManager(); // Initializes |document_manager_for_non_editable_|. - bool InitializeForDisabledDocumentManager() { - if (FAILED(thread_manager_->CreateDocumentMgr( - document_manager_for_non_editable_.Receive()))) { - VLOG(1) << "Failed to create Document Manager."; - return false; - } - - base::win::ScopedComPtr<ITfContext> disabled_context; - DWORD disabled_edit_cookie; - // Passing NULL as ITextStoreACP to disable IMEs completely. - if (document_manager_for_non_editable_->CreateContext( - client_id_, - 0, - NULL, - disabled_context.Receive(), - &disabled_edit_cookie)) { - VLOG(1) << "Failed to create disabled Context"; - return false; - } - - base::win::ScopedComPtr<ITfCompartmentMgr> compartment_mgr; - if (FAILED(compartment_mgr.QueryFrom(disabled_context))) { - VLOG(1) << "Failed to get CompartmentMgr."; - return false; - } - - base::win::ScopedComPtr<ITfCompartment> disabled_compartment; - if (FAILED(compartment_mgr->GetCompartment( - GUID_COMPARTMENT_KEYBOARD_DISABLED, - disabled_compartment.Receive()))) { - VLOG(1) << "Failed to get keyboard disabled compartment."; - return false; - } - - base::win::ScopedVariant variant; - variant.Set(static_cast<int32>(1)); - if (FAILED(disabled_compartment->SetValue(client_id_, &variant))) { - VLOG(1) << "Failed to disable the DocumentMgr."; - return false; - } - - base::win::ScopedComPtr<ITfCompartment> empty_context; - if (FAILED(compartment_mgr->GetCompartment(GUID_COMPARTMENT_EMPTYCONTEXT, - empty_context.Receive()))) { - VLOG(1) << "Failed to get empty context compartment."; - return false; - } - base::win::ScopedVariant empty_context_variant; - empty_context_variant.Set(static_cast<int32>(1)); - if (FAILED(empty_context->SetValue(client_id_, &empty_context_variant))) { - VLOG(1) << "Failed to set empty context."; - return false; - } - - if (FAILED(document_manager_for_non_editable_->Push(disabled_context))) { - VLOG(1) << "Failed to push disabled context."; - return false; - } + bool InitializeForDisabledDocumentManager(); - return true; - } + // Creates |document_manager| with |text_store|. If text store is not + // necessary, pass |text_store| and |source_cookie| as NULL. + bool CreateDocumentManager(TSFTextStore* text_store, + ITfDocumentMgr** document_manager, + ITfContext** context, + DWORD* source_cookie); // 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); - } + bool IsFocused(base::win::ScopedComPtr<ITfDocumentMgr> document_manager); // Returns true if already initialized. - bool IsInitialized() { - return client_id_ != TF_CLIENTID_NULL; - } + bool IsInitialized(); // An ITfContext object to be used in normal text field. This document manager - // contains a TsfTextStore instance and an activated context. + // contains a TSFTextStore instance and an activated context. base::win::ScopedComPtr<ITfDocumentMgr> document_manager_for_editable_; // Altough TSF support IME enable/disable switching without context changing, @@ -426,70 +92,400 @@ class TsfBridgeDelegate : public TsfBridge { base::win::ScopedComPtr<ITfThreadMgr> thread_manager_; // A TextStore object to be used in communicating with IME for normal field. - scoped_ptr<scoped_refptr<TsfTextStore> > text_store_; + scoped_ptr<scoped_refptr<TSFTextStore> > text_store_; // A TextStore object to be used in communicating with IME for password field. - scoped_ptr<scoped_refptr<TsfTextStore> > password_text_store_; + scoped_ptr<scoped_refptr<TSFTextStore> > password_text_store_; DWORD source_cookie_; + DWORD password_source_cookie_; TfClientId client_id_; // Current focused text input client. Do not free |client_|. TextInputClient* client_; - DISALLOW_COPY_AND_ASSIGN(TsfBridgeDelegate); + DISALLOW_COPY_AND_ASSIGN(TSFBridgeDelegate); }; -// We use thread local storage for TsfBridge lifespan management. -base::ThreadLocalStorage::StaticSlot tls_tsf_bridge = TLS_INITIALIZER; +TSFBridgeDelegate::TSFBridgeDelegate() + : source_cookie_(TF_INVALID_COOKIE), + password_source_cookie_(TF_INVALID_COOKIE), + client_id_(TF_CLIENTID_NULL), + client_(NULL) { +} -// Used for releasing TLS object. -void FreeTlsTsfBridgeDelegate(void* data) { - TsfBridgeDelegate* delegate = static_cast<TsfBridgeDelegate*>(data); - delete delegate; +TSFBridgeDelegate::~TSFBridgeDelegate() { +} + +bool TSFBridgeDelegate::Initialize() { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + if (client_id_ != TF_CLIENTID_NULL) { + DVLOG(1) << "Already initialized."; + return false; + } + + if (FAILED(thread_manager_.CreateInstance(CLSID_TF_ThreadMgr))) { + DVLOG(1) << "Failed to create ThreadManager instance."; + return false; + } + + if (FAILED(thread_manager_->Activate(&client_id_))) { + DVLOG(1) << "Failed to activate Thread Manager."; + return false; + } + + if (!InitializeForEnabledDocumentManager() || + !InitializeForPasswordDocumentManager() || + !InitializeForDisabledDocumentManager()) + return false; + + // Japanese IME expects the default value of this compartment is + // TF_SENTENCEMODE_PHRASEPREDICT like IMM32 implementation. This value is + // managed per thread, so that it is enough to set this value at once. This + // value does not affect other language's IME behaviors. + base::win::ScopedComPtr<ITfCompartmentMgr> thread_compartment_manager; + if (FAILED(thread_compartment_manager.QueryFrom(thread_manager_))) { + DVLOG(1) << "Failed to get ITfCompartmentMgr."; + return false; + } + + base::win::ScopedComPtr<ITfCompartment> sentence_compartment; + if (FAILED(thread_compartment_manager->GetCompartment( + GUID_COMPARTMENT_KEYBOARD_INPUTMODE_SENTENCE, + sentence_compartment.Receive()))) { + DVLOG(1) << "Failed to get sentence compartment."; + return false; + } + + base::win::ScopedVariant sentence_variant; + sentence_variant.Set(TF_SENTENCEMODE_PHRASEPREDICT); + if (FAILED(sentence_compartment->SetValue(client_id_, &sentence_variant))) { + DVLOG(1) << "Failed to change the sentence mode."; + return false; + } + + return true; +} + +void TSFBridgeDelegate::Shutdown() { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + if (!IsInitialized()) + return; + base::win::ScopedComPtr<ITfContext> context; + if (FAILED(document_manager_for_editable_->GetBase(context.Receive()))) + return; + base::win::ScopedComPtr<ITfSource> source; + if (FAILED(source.QueryFrom(context)) || + source_cookie_ == TF_INVALID_COOKIE || + FAILED(source->UnadviseSink(source_cookie_))) + return; + + base::win::ScopedComPtr<ITfContext> password_context; + if (FAILED(document_manager_for_password_->GetBase( + password_context.Receive()))) + return; + base::win::ScopedComPtr<ITfSource> password_source; + if (FAILED(password_source.QueryFrom(password_context)) || + password_source_cookie_ == TF_INVALID_COOKIE || + FAILED(password_source->UnadviseSink(password_source_cookie_))) + return; + + DCHECK(text_store_.get()); + text_store_.reset(); + client_id_ = TF_CLIENTID_NULL; +} + +void TSFBridgeDelegate::OnTextInputTypeChanged(TextInputClient* client) { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + DCHECK(IsInitialized()); + + if (client != client_) { + // Called from not focusing client. Do nothing. + return; + } + + DCHECK(client_); + const TextInputType type = client_->GetTextInputType(); + switch (type) { + case TEXT_INPUT_TYPE_NONE: + thread_manager_->SetFocus(document_manager_for_non_editable_); + break; + case TEXT_INPUT_TYPE_PASSWORD: + thread_manager_->SetFocus(document_manager_for_password_); + break; + default: + thread_manager_->SetFocus(document_manager_for_editable_); + break; + } +} + +bool TSFBridgeDelegate::CancelComposition() { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + DCHECK(IsInitialized()); + // If the current focused document manager is not + // |document_manager_for_editable_|, do nothing here. + if (!IsFocused(document_manager_for_editable_)) + return false; + + base::win::ScopedComPtr<ITfContext> context; + if (FAILED(document_manager_for_editable_->GetTop(context.Receive()))) { + DVLOG(1) << "Failed to get top context."; + return false; + } + + base::win::ScopedComPtr<ITfContextOwnerCompositionServices> owner; + if (FAILED(owner.QueryFrom(context))) { + DVLOG(1) << "Failed to get ITfContextOwnerCompositionService."; + return false; + } + // Cancel all composition. + owner->TerminateComposition(NULL); + return true; +} + +void TSFBridgeDelegate::SetFocusedClient(HWND focused_window, + TextInputClient* client) { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + DCHECK(client); + DCHECK(IsInitialized()); + client_ = client; + text_store_->get()->SetFocusedTextInputClient(focused_window, client); + password_text_store_->get()->SetFocusedTextInputClient(focused_window, + client); + + // Synchronize text input type state. + OnTextInputTypeChanged(client); +} + +void TSFBridgeDelegate::RemoveFocusedClient(TextInputClient* client) { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + DCHECK(IsInitialized()); + if (client_ == client) { + client_ = NULL; + text_store_->get()->SetFocusedTextInputClient(NULL, NULL); + password_text_store_->get()->SetFocusedTextInputClient(NULL, NULL); + } +} + +base::win::ScopedComPtr<ITfThreadMgr> TSFBridgeDelegate::GetThreadManager() { + DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); + DCHECK(IsInitialized()); + return thread_manager_; +} + +bool TSFBridgeDelegate::CreateDocumentManager(TSFTextStore* text_store, + ITfDocumentMgr** document_manager, + ITfContext** context, + DWORD* source_cookie) { + if (FAILED(thread_manager_->CreateDocumentMgr(document_manager))) { + DVLOG(1) << "Failed to create Document Manager."; + return false; + } + + DWORD edit_cookie = TF_INVALID_EDIT_COOKIE; + if (FAILED(document_manager_for_editable_->CreateContext( + client_id_, + 0, + static_cast<ITextStoreACP*>(text_store), + context, + &edit_cookie))) { + DVLOG(1) << "Failed to create Context."; + return false; + } + + if (FAILED((*document_manager)->Push(*context))) { + DVLOG(1) << "Failed to push context."; + return false; + } + + if (!text_store || !source_cookie) + return true; + + base::win::ScopedComPtr<ITfSource> source; + if (FAILED(source.QueryFrom(*context))) { + DVLOG(1) << "Failed to get source."; + return false; + } + + if (FAILED(source->AdviseSink(IID_ITfTextEditSink, + static_cast<ITfTextEditSink*>(text_store), + source_cookie))) { + DVLOG(1) << "AdviseSink failed."; + return false; + } + + if (*source_cookie == TF_INVALID_COOKIE) { + DVLOG(1) << "The result of cookie is invalid."; + return false; + } + return true; +} + +bool TSFBridgeDelegate::InitializeForEnabledDocumentManager() { + text_store_.reset(new scoped_refptr<TSFTextStore>(new TSFTextStore())); + + base::win::ScopedComPtr<ITfContext> context; + return CreateDocumentManager(text_store_->get(), + document_manager_for_editable_.Receive(), + context.Receive(), + &source_cookie_); +} + +bool TSFBridgeDelegate::InitializeForPasswordDocumentManager() { + password_text_store_.reset( + new scoped_refptr<TSFTextStore>(new TSFTextStore())); + + base::win::ScopedComPtr<ITfContext> context; + if (!CreateDocumentManager(password_text_store_->get(), + document_manager_for_password_.Receive(), + context.Receive(), + &password_source_cookie_)) + return false; + + base::win::ScopedComPtr<ITfCompartmentMgr> compartment_mgr; + if (FAILED(compartment_mgr.QueryFrom(context))) { + DVLOG(1) << "Failed to get CompartmentMgr."; + return false; + } + + base::win::ScopedComPtr<ITfCompartment> disabled_compartment; + if (FAILED(compartment_mgr->GetCompartment( + GUID_COMPARTMENT_KEYBOARD_DISABLED, + disabled_compartment.Receive()))) { + DVLOG(1) << "Failed to get keyboard disabled compartment."; + return false; + } + + base::win::ScopedVariant variant; + variant.Set(static_cast<int32>(1)); + if (FAILED(disabled_compartment->SetValue(client_id_, &variant))) { + DVLOG(1) << "Failed to disable the DocumentMgr."; + return false; + } + + base::win::ScopedComPtr<ITfCompartment> empty_context; + if (FAILED(compartment_mgr->GetCompartment(GUID_COMPARTMENT_EMPTYCONTEXT, + empty_context.Receive()))) { + DVLOG(1) << "Failed to get empty context compartment."; + return false; + } + base::win::ScopedVariant empty_context_variant; + empty_context_variant.Set(1); + if (FAILED(empty_context->SetValue(client_id_, &empty_context_variant))) { + DVLOG(1) << "Failed to set empty context."; + return false; + } + + return true; +} + +bool TSFBridgeDelegate::InitializeForDisabledDocumentManager() { + base::win::ScopedComPtr<ITfContext> context; + if (!CreateDocumentManager(NULL, + document_manager_for_non_editable_.Receive(), + context.Receive(), + NULL)) + return false; + + base::win::ScopedComPtr<ITfCompartmentMgr> compartment_mgr; + if (FAILED(compartment_mgr.QueryFrom(context))) { + DVLOG(1) << "Failed to get CompartmentMgr."; + return false; + } + + base::win::ScopedComPtr<ITfCompartment> disabled_compartment; + if (FAILED(compartment_mgr->GetCompartment( + GUID_COMPARTMENT_KEYBOARD_DISABLED, + disabled_compartment.Receive()))) { + DVLOG(1) << "Failed to get keyboard disabled compartment."; + return false; + } + + base::win::ScopedVariant variant; + variant.Set(1); + if (FAILED(disabled_compartment->SetValue(client_id_, &variant))) { + DVLOG(1) << "Failed to disable the DocumentMgr."; + return false; + } + + base::win::ScopedComPtr<ITfCompartment> empty_context; + if (FAILED(compartment_mgr->GetCompartment(GUID_COMPARTMENT_EMPTYCONTEXT, + empty_context.Receive()))) { + DVLOG(1) << "Failed to get empty context compartment."; + return false; + } + base::win::ScopedVariant empty_context_variant; + empty_context_variant.Set(static_cast<int32>(1)); + if (FAILED(empty_context->SetValue(client_id_, &empty_context_variant))) { + DVLOG(1) << "Failed to set empty context."; + return false; + } + + return true; +} + +bool TSFBridgeDelegate::IsFocused( + base::win::ScopedComPtr<ITfDocumentMgr> document_manager) { + base::win::ScopedComPtr<ITfDocumentMgr> focused_document_manager; + if (FAILED(thread_manager_->GetFocus(focused_document_manager.Receive()))) + return false; + return focused_document_manager.IsSameObject(document_manager); +} + +bool TSFBridgeDelegate::IsInitialized() { + return client_id_ != TF_CLIENTID_NULL; } } // namespace -TsfBridge::TsfBridge() { + +// TsfBridge ----------------------------------------------------------------- + +TSFBridge::TSFBridge() { } -TsfBridge::~TsfBridge() { +TSFBridge::~TSFBridge() { } // static -bool TsfBridge::Initialize() { +bool TSFBridge::Initialize() { if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { - VLOG(1) << "Do not use TsfBridge without UI thread."; + DVLOG(1) << "Do not use TSFBridge without UI thread."; return false; } - tls_tsf_bridge.Initialize(FreeTlsTsfBridgeDelegate); - TsfBridgeDelegate* delegate = new TsfBridgeDelegate(); + tls_tsf_bridge.Initialize(TSFBridge::Finalize); + TSFBridgeDelegate* delegate = new TSFBridgeDelegate(); tls_tsf_bridge.Set(delegate); return delegate->Initialize(); } // static -TsfBridge* TsfBridge::ReplaceForTesting(TsfBridge* bridge) { +TSFBridge* TSFBridge::ReplaceForTesting(TSFBridge* bridge) { if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { - VLOG(1) << "Do not use TsfBridge without UI thread."; + DVLOG(1) << "Do not use TSFBridge without UI thread."; return NULL; } - TsfBridge* old_bridge = TsfBridge::GetInstance(); + TSFBridge* old_bridge = TSFBridge::GetInstance(); tls_tsf_bridge.Set(bridge); return old_bridge; } // static -TsfBridge* TsfBridge::GetInstance() { +TSFBridge* TSFBridge::GetInstance() { if (MessageLoop::current()->type() != MessageLoop::TYPE_UI) { - VLOG(1) << "Do not use TsfBridge without UI thread."; + DVLOG(1) << "Do not use TSFBridge without UI thread."; return NULL; } - TsfBridgeDelegate* delegate = - static_cast<TsfBridgeDelegate*>(tls_tsf_bridge.Get()); - DCHECK(delegate) << "Do no call GetInstance before TsfBridge::Initialize."; + TSFBridgeDelegate* delegate = + static_cast<TSFBridgeDelegate*>(tls_tsf_bridge.Get()); + DCHECK(delegate) << "Do no call GetInstance before TSFBridge::Initialize."; return delegate; } +// static +void TSFBridge::Finalize(void* data) { + TSFBridgeDelegate* delegate = static_cast<TSFBridgeDelegate*>(data); + delete delegate; +} + } // namespace ui diff --git a/ui/base/ime/win/tsf_bridge.h b/ui/base/ime/win/tsf_bridge.h index 21f37ed..13bb3dd4 100644 --- a/ui/base/ime/win/tsf_bridge.h +++ b/ui/base/ime/win/tsf_bridge.h @@ -15,33 +15,33 @@ namespace ui { class TextInputClient; -// TsfBridge provides high level IME related operations on top of Text Services -// Framework (TSF). TsfBridge is managed by TLS because TSF related stuff is +// TSFBridge provides high level IME related operations on top of Text Services +// Framework (TSF). TSFBridge is managed by TLS because TSF related stuff is // associated with each thread and not allowed to access across thread boundary. -// To be consistent with IMM32 behavior, TsfBridge is shared in the same thread. -// TsfBridge is used by the web content text inputting field, for example +// To be consistent with IMM32 behavior, TSFBridge is shared in the same thread. +// TSFBridge is used by the web content text inputting field, for example // DisableIME() should be called if a password field is focused. // -// TsfBridge also manages connectivity between TsfTextStore which is the backend +// TSFBridge also manages connectivity between TSFTextStore which is the backend // of text inputting and current focused TextInputClient. // // All methods in this class must be used in UI thread. -class UI_EXPORT TsfBridge { +class UI_EXPORT TSFBridge { public: - virtual ~TsfBridge(); + virtual ~TSFBridge(); - // Returns the thread local TsfBridge instance. Initialize() must be called - // first. Do not cache this pointer and use it after TsfBridge Shutdown(). - static TsfBridge* GetInstance(); + // Returns the thread local TSFBridge instance. Initialize() must be called + // first. Do not cache this pointer and use it after TSFBridge Shutdown(). + static TSFBridge* GetInstance(); // Sets the thread local instance. Must be called before any calls to // GetInstance(). static bool Initialize(); - // Injects an alternative TsfBridge such as MockTsfBridge for testing. The + // Injects an alternative TSFBridge such as MockTSFBridge for testing. The // injected object should be released by the caller. This function returns - // previous TsfBridge pointer with ownership. - static TsfBridge* ReplaceForTesting(TsfBridge* bridge); + // previous TSFBridge pointer with ownership. + static TSFBridge* ReplaceForTesting(TSFBridge* bridge); // Destroys the thread local instance. virtual void Shutdown() = 0; @@ -69,10 +69,13 @@ class UI_EXPORT TsfBridge { protected: // Uses GetInstance() instead. - TsfBridge(); + TSFBridge(); private: - DISALLOW_COPY_AND_ASSIGN(TsfBridge); + // Releases TLS instance. + static void Finalize(void* data); + + DISALLOW_COPY_AND_ASSIGN(TSFBridge); }; } // namespace ui diff --git a/ui/base/ime/win/tsf_event_router.cc b/ui/base/ime/win/tsf_event_router.cc index 4cf625e..0a41ca1 100644 --- a/ui/base/ime/win/tsf_event_router.cc +++ b/ui/base/ime/win/tsf_event_router.cc @@ -17,35 +17,34 @@ namespace ui { -// TsfEventRouter::TsfEventRouterDelegate ------------------------------------ +// TSFEventRouter::Delegate ------------------------------------ // The implementation class of ITfUIElementSink, whose member functions will be // called back by TSF when the UI element status is changed, for example when // the candidate window is opened or closed. This class also implements // ITfTextEditSink, whose member function is called back by TSF when the text // editting session is finished. -class ATL_NO_VTABLE TsfEventRouter::TsfEventRouterDelegate +class ATL_NO_VTABLE TSFEventRouter::Delegate : public ATL::CComObjectRootEx<CComSingleThreadModel>, public ITfUIElementSink, public ITfTextEditSink { public: - BEGIN_COM_MAP(TsfEventRouterDelegate) + BEGIN_COM_MAP(Delegate) COM_INTERFACE_ENTRY(ITfUIElementSink) COM_INTERFACE_ENTRY(ITfTextEditSink) END_COM_MAP() - TsfEventRouterDelegate(); - ~TsfEventRouterDelegate(); + Delegate(); + ~Delegate(); // ITfTextEditSink: - STDMETHOD_(HRESULT, OnEndEdit)(ITfContext* context, - TfEditCookie read_only_cookie, - ITfEditRecord* edit_record) OVERRIDE; + STDMETHOD(OnEndEdit)(ITfContext* context, TfEditCookie read_only_cookie, + ITfEditRecord* edit_record) OVERRIDE; // ITfUiElementSink: - STDMETHOD_(HRESULT, BeginUIElement)(DWORD element_id, BOOL* is_show) OVERRIDE; - STDMETHOD_(HRESULT, UpdateUIElement)(DWORD element_id) OVERRIDE; - STDMETHOD_(HRESULT, EndUIElement)(DWORD element_id) OVERRIDE; + STDMETHOD(BeginUIElement)(DWORD element_id, BOOL* is_show) OVERRIDE; + STDMETHOD(UpdateUIElement)(DWORD element_id) OVERRIDE; + STDMETHOD(EndUIElement)(DWORD element_id) OVERRIDE; // Sets |thread_manager| to be monitored. |thread_manager| can be NULL. void SetManager(ITfThreadMgr* thread_manager); @@ -54,7 +53,7 @@ class ATL_NO_VTABLE TsfEventRouter::TsfEventRouterDelegate bool IsImeComposing(); // Sets |router| to be forwarded TSF-related events. - void SetRouter(TsfEventRouter* router); + void SetRouter(TSFEventRouter* router); private: // Returns current composition range. Returns ui::Range::InvalidRange if there @@ -85,29 +84,28 @@ class ATL_NO_VTABLE TsfEventRouter::TsfEventRouterDelegate // The cookie for |ui_source_|. DWORD ui_source_cookie_; - TsfEventRouter* router_; + TSFEventRouter* router_; ui::Range previous_composition_range_; - DISALLOW_COPY_AND_ASSIGN(TsfEventRouterDelegate); + DISALLOW_COPY_AND_ASSIGN(Delegate); }; -TsfEventRouter::TsfEventRouterDelegate::TsfEventRouterDelegate() +TSFEventRouter::Delegate::Delegate() : context_source_cookie_(TF_INVALID_COOKIE), ui_source_cookie_(TF_INVALID_COOKIE), router_(NULL), previous_composition_range_(ui::Range::InvalidRange()) { } -TsfEventRouter::TsfEventRouterDelegate::~TsfEventRouterDelegate() {} +TSFEventRouter::Delegate::~Delegate() {} -void TsfEventRouter::TsfEventRouterDelegate::SetRouter(TsfEventRouter* router) { +void TSFEventRouter::Delegate::SetRouter(TSFEventRouter* router) { router_ = router; } -STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::OnEndEdit( - ITfContext* context, - TfEditCookie read_only_cookie, - ITfEditRecord* edit_record) { +STDMETHODIMP TSFEventRouter::Delegate::OnEndEdit(ITfContext* context, + TfEditCookie read_only_cookie, + ITfEditRecord* edit_record) { if (!edit_record || !context) return E_INVALIDARG; if (!router_) @@ -130,7 +128,7 @@ STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::OnEndEdit( const ui::Range composition_range = GetCompositionRange(context); if (!previous_composition_range_.IsValid() && composition_range.IsValid()) - router_->OnTsfStartComposition(); + router_->OnTSFStartComposition(); // |fetched_count| != 0 means there is at least one range that contains // updated text. @@ -138,15 +136,14 @@ STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::OnEndEdit( router_->OnTextUpdated(composition_range); if (previous_composition_range_.IsValid() && !composition_range.IsValid()) - router_->OnTsfEndComposition(); + router_->OnTSFEndComposition(); previous_composition_range_ = composition_range; return S_OK; } -STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::BeginUIElement( - DWORD element_id, - BOOL* is_show) { +STDMETHODIMP TSFEventRouter::Delegate::BeginUIElement(DWORD element_id, + BOOL* is_show) { if (is_show) *is_show = TRUE; // Without this the UI element will not be shown. @@ -162,19 +159,19 @@ STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::BeginUIElement( return S_OK; } -STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::UpdateUIElement( +STDMETHODIMP TSFEventRouter::Delegate::UpdateUIElement( DWORD element_id) { return S_OK; } -STDMETHODIMP TsfEventRouter::TsfEventRouterDelegate::EndUIElement( +STDMETHODIMP TSFEventRouter::Delegate::EndUIElement( DWORD element_id) { if ((open_candidate_window_ids_.erase(element_id) != 0) && router_) router_->OnCandidateWindowCountChanged(open_candidate_window_ids_.size()); return S_OK; } -void TsfEventRouter::TsfEventRouterDelegate::SetManager( +void TSFEventRouter::Delegate::SetManager( ITfThreadMgr* thread_manager) { context_.Release(); @@ -211,12 +208,12 @@ void TsfEventRouter::TsfEventRouterDelegate::SetManager( &ui_source_cookie_); } -bool TsfEventRouter::TsfEventRouterDelegate::IsImeComposing() { +bool TSFEventRouter::Delegate::IsImeComposing() { return context_ && GetCompositionRange(context_).IsValid(); } // static -ui::Range TsfEventRouter::TsfEventRouterDelegate::GetCompositionRange( +ui::Range TSFEventRouter::Delegate::GetCompositionRange( ITfContext* context) { DCHECK(context); base::win::ScopedComPtr<ITfContextComposition> context_composition; @@ -247,8 +244,7 @@ ui::Range TsfEventRouter::TsfEventRouterDelegate::GetCompositionRange( return ui::Range(start, start + length); } -bool TsfEventRouter::TsfEventRouterDelegate::IsCandidateWindowInternal( - DWORD element_id) { +bool TSFEventRouter::Delegate::IsCandidateWindowInternal(DWORD element_id) { DCHECK(ui_element_manager_.get()); base::win::ScopedComPtr<ITfUIElement> ui_element; if (FAILED(ui_element_manager_->GetUIElement(element_id, @@ -259,52 +255,51 @@ bool TsfEventRouter::TsfEventRouterDelegate::IsCandidateWindowInternal( } -// TsfEventRouter ------------------------------------------------------------ +// TSFEventRouter ------------------------------------------------------------ -TsfEventRouter::TsfEventRouter(TsfEventRouterObserver* observer) +TSFEventRouter::TSFEventRouter(TSFEventRouterObserver* observer) : observer_(observer), delegate_(NULL) { - DCHECK(base::win::IsTsfAwareRequired()) - << "Do not use TsfEventRouter without TSF environment."; + DCHECK(base::win::IsTSFAwareRequired()) + << "Do not use TSFEventRouter without TSF environment."; DCHECK(observer_); - CComObject<TsfEventRouterDelegate>* delegate; + CComObject<Delegate>* delegate; ui::win::CreateATLModuleIfNeeded(); - if (SUCCEEDED(CComObject<TsfEventRouterDelegate>::CreateInstance( - &delegate))) { + if (SUCCEEDED(CComObject<Delegate>::CreateInstance(&delegate))) { delegate->AddRef(); delegate_.Attach(delegate); delegate_->SetRouter(this); } } -TsfEventRouter::~TsfEventRouter() { +TSFEventRouter::~TSFEventRouter() { if (delegate_) { delegate_->SetManager(NULL); delegate_->SetRouter(NULL); } } -bool TsfEventRouter::IsImeComposing() { +bool TSFEventRouter::IsImeComposing() { return delegate_->IsImeComposing(); } -void TsfEventRouter::OnCandidateWindowCountChanged(size_t window_count) { +void TSFEventRouter::OnCandidateWindowCountChanged(size_t window_count) { observer_->OnCandidateWindowCountChanged(window_count); } -void TsfEventRouter::OnTsfStartComposition() { - observer_->OnTsfStartComposition(); +void TSFEventRouter::OnTSFStartComposition() { + observer_->OnTSFStartComposition(); } -void TsfEventRouter::OnTextUpdated(const ui::Range& composition_range) { +void TSFEventRouter::OnTextUpdated(const ui::Range& composition_range) { observer_->OnTextUpdated(composition_range); } -void TsfEventRouter::OnTsfEndComposition() { - observer_->OnTsfEndComposition(); +void TSFEventRouter::OnTSFEndComposition() { + observer_->OnTSFEndComposition(); } -void TsfEventRouter::SetManager(ITfThreadMgr* thread_manager) { +void TSFEventRouter::SetManager(ITfThreadMgr* thread_manager) { delegate_->SetManager(thread_manager); } diff --git a/ui/base/ime/win/tsf_event_router.h b/ui/base/ime/win/tsf_event_router.h index 4d9128d..be2311c 100644 --- a/ui/base/ime/win/tsf_event_router.h +++ b/ui/base/ime/win/tsf_event_router.h @@ -22,58 +22,58 @@ struct ITfDocumentMgr; namespace ui { -class TsfEventRouterObserver { +class TSFEventRouterObserver { public: - TsfEventRouterObserver() {} + TSFEventRouterObserver() {} // Called when the number of currently opened candidate windows changes. virtual void OnCandidateWindowCountChanged(size_t window_count) {} // Called when a composition is started. - virtual void OnTsfStartComposition() {} + virtual void OnTSFStartComposition() {} // Called when the text contents are updated. If there is no composition, // ui::Range::InvalidRange is passed to |composition_range|. virtual void OnTextUpdated(const ui::Range& composition_range) {} // Called when a composition is terminated. - virtual void OnTsfEndComposition() {} + virtual void OnTSFEndComposition() {} protected: - virtual ~TsfEventRouterObserver() {} + virtual ~TSFEventRouterObserver() {} private: - DISALLOW_COPY_AND_ASSIGN(TsfEventRouterObserver); + DISALLOW_COPY_AND_ASSIGN(TSFEventRouterObserver); }; // This class monitores TSF related events and forwards them to given // |observer|. -class UI_EXPORT TsfEventRouter { +class UI_EXPORT TSFEventRouter { public: // Do not pass NULL to |observer|. - explicit TsfEventRouter(TsfEventRouterObserver* observer); - virtual ~TsfEventRouter(); + explicit TSFEventRouter(TSFEventRouterObserver* observer); + virtual ~TSFEventRouter(); // Returns true if the IME is composing text. bool IsImeComposing(); - // Callbacks from the TsfEventRouterDelegate: + // Callbacks from the TSFEventRouterDelegate: void OnCandidateWindowCountChanged(size_t window_count); - void OnTsfStartComposition(); + void OnTSFStartComposition(); void OnTextUpdated(const ui::Range& composition_range); - void OnTsfEndComposition(); + void OnTSFEndComposition(); // Sets |thread_manager| to be monitored. |thread_manager| can be NULL. void SetManager(ITfThreadMgr* thread_manager); private: - class TsfEventRouterDelegate; + class Delegate; - CComPtr<TsfEventRouterDelegate> delegate_; + CComPtr<Delegate> delegate_; - TsfEventRouterObserver* observer_; + TSFEventRouterObserver* observer_; - DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); + DISALLOW_COPY_AND_ASSIGN(TSFEventRouter); }; } // namespace ui diff --git a/ui/base/ime/win/tsf_input_scope.cc b/ui/base/ime/win/tsf_input_scope.cc index cc1d302..6ed6858 100644 --- a/ui/base/ime/win/tsf_input_scope.cc +++ b/ui/base/ime/win/tsf_input_scope.cc @@ -8,19 +8,19 @@ namespace ui { -TsfInputScope::TsfInputScope(TextInputType text_input_type) +TSFInputScope::TSFInputScope(TextInputType text_input_type) : text_input_type_(text_input_type), ref_count_(0) { } -TsfInputScope::~TsfInputScope() { +TSFInputScope::~TSFInputScope() { } -ULONG STDMETHODCALLTYPE TsfInputScope::AddRef() { +ULONG STDMETHODCALLTYPE TSFInputScope::AddRef() { return InterlockedIncrement(&ref_count_); } -ULONG STDMETHODCALLTYPE TsfInputScope::Release() { +ULONG STDMETHODCALLTYPE TSFInputScope::Release() { const LONG count = InterlockedDecrement(&ref_count_); if (!count) { delete this; @@ -29,7 +29,7 @@ ULONG STDMETHODCALLTYPE TsfInputScope::Release() { return static_cast<ULONG>(count); } -STDMETHODIMP TsfInputScope::QueryInterface(REFIID iid, void** result) { +STDMETHODIMP TSFInputScope::QueryInterface(REFIID iid, void** result) { if (!result) return E_INVALIDARG; if (iid == IID_IUnknown || iid == IID_ITfInputScope) { @@ -42,7 +42,7 @@ STDMETHODIMP TsfInputScope::QueryInterface(REFIID iid, void** result) { return S_OK; } -STDMETHODIMP TsfInputScope::GetInputScopes(InputScope** input_scopes, +STDMETHODIMP TSFInputScope::GetInputScopes(InputScope** input_scopes, UINT* count) { DCHECK_NE(text_input_type_, TEXT_INPUT_TYPE_NONE); if (!count || !input_scopes) @@ -58,19 +58,19 @@ STDMETHODIMP TsfInputScope::GetInputScopes(InputScope** input_scopes, return S_OK; } -STDMETHODIMP TsfInputScope::GetPhrase(BSTR** phrases, UINT* count) { +STDMETHODIMP TSFInputScope::GetPhrase(BSTR** phrases, UINT* count) { return E_NOTIMPL; } -STDMETHODIMP TsfInputScope::GetRegularExpression(BSTR* regexp) { +STDMETHODIMP TSFInputScope::GetRegularExpression(BSTR* regexp) { return E_NOTIMPL; } -STDMETHODIMP TsfInputScope::GetSRGS(BSTR* srgs) { +STDMETHODIMP TSFInputScope::GetSRGS(BSTR* srgs) { return E_NOTIMPL; } -STDMETHODIMP TsfInputScope::GetXML(BSTR* xml) { +STDMETHODIMP TSFInputScope::GetXML(BSTR* xml) { return E_NOTIMPL; } diff --git a/ui/base/ime/win/tsf_input_scope.h b/ui/base/ime/win/tsf_input_scope.h index 489a307..ce7e0fa 100644 --- a/ui/base/ime/win/tsf_input_scope.h +++ b/ui/base/ime/win/tsf_input_scope.h @@ -17,35 +17,20 @@ namespace ui { // The implementation class of ITfInputScope, which is the Windows-specific // category representation corresponding to ui::TextInputType that we are using // to specify the expected text type in the target field. -class TsfInputScope : public ITfInputScope { +class TSFInputScope : public ITfInputScope { public: - explicit TsfInputScope(TextInputType text_input_type); - virtual ~TsfInputScope(); - - // ITfInputScope override. - virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; - - // ITfInputScope override. - virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP QueryInterface(REFIID iid, void** result) OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP GetInputScopes(InputScope** input_scopes, - UINT* count) OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP GetPhrase(BSTR** phrases, UINT* count) OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP GetRegularExpression(BSTR* regexp) OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP GetSRGS(BSTR* srgs) OVERRIDE; - - // ITfInputScope override. - virtual STDMETHODIMP GetXML(BSTR* xml) OVERRIDE; + explicit TSFInputScope(TextInputType text_input_type); + virtual ~TSFInputScope(); + + // ITfInputScope: + STDMETHOD_(ULONG, AddRef)() OVERRIDE; + STDMETHOD_(ULONG, Release)() OVERRIDE; + STDMETHOD(QueryInterface)(REFIID iid, void** result) OVERRIDE; + STDMETHOD(GetInputScopes)(InputScope** input_scopes, UINT* count) OVERRIDE; + STDMETHOD(GetPhrase)(BSTR** phrases, UINT* count) OVERRIDE; + STDMETHOD(GetRegularExpression)(BSTR* regexp) OVERRIDE; + STDMETHOD(GetSRGS)(BSTR* srgs) OVERRIDE; + STDMETHOD(GetXML)(BSTR* xml) OVERRIDE; private: // The corresponding text input type. @@ -54,7 +39,7 @@ class TsfInputScope : public ITfInputScope { // The refrence count of this instance. volatile LONG ref_count_; - DISALLOW_COPY_AND_ASSIGN(TsfInputScope); + DISALLOW_COPY_AND_ASSIGN(TSFInputScope); }; } // namespace ui diff --git a/ui/base/ime/win/tsf_text_store.cc b/ui/base/ime/win/tsf_text_store.cc index 2c4080a..70c0254 100644 --- a/ui/base/ime/win/tsf_text_store.cc +++ b/ui/base/ime/win/tsf_text_store.cc @@ -20,7 +20,7 @@ const TsViewCookie kViewCookie = 1; } // namespace -TsfTextStore::TsfTextStore() +TSFTextStore::TSFTextStore() : ref_count_(0), text_store_acp_sink_mask_(0), window_handle_(NULL), @@ -39,14 +39,14 @@ TsfTextStore::TsfTextStore() } } -TsfTextStore::~TsfTextStore() { +TSFTextStore::~TSFTextStore() { } -ULONG STDMETHODCALLTYPE TsfTextStore::AddRef() { +ULONG STDMETHODCALLTYPE TSFTextStore::AddRef() { return InterlockedIncrement(&ref_count_); } -ULONG STDMETHODCALLTYPE TsfTextStore::Release() { +ULONG STDMETHODCALLTYPE TSFTextStore::Release() { const LONG count = InterlockedDecrement(&ref_count_); if (!count) { delete this; @@ -55,7 +55,7 @@ ULONG STDMETHODCALLTYPE TsfTextStore::Release() { return static_cast<ULONG>(count); } -STDMETHODIMP TsfTextStore::QueryInterface(REFIID iid, void** result) { +STDMETHODIMP TSFTextStore::QueryInterface(REFIID iid, void** result) { if (iid == IID_IUnknown || iid == IID_ITextStoreACP) { *result = static_cast<ITextStoreACP*>(this); } else if (iid == IID_ITfContextOwnerCompositionSink) { @@ -70,7 +70,8 @@ STDMETHODIMP TsfTextStore::QueryInterface(REFIID iid, void** result) { return S_OK; } -STDMETHODIMP TsfTextStore::AdviseSink(REFIID iid, IUnknown* unknown, +STDMETHODIMP TSFTextStore::AdviseSink(REFIID iid, + IUnknown* unknown, DWORD mask) { if (!IsEqualGUID(iid, IID_ITextStoreACPSink)) return E_INVALIDARG; @@ -89,7 +90,7 @@ STDMETHODIMP TsfTextStore::AdviseSink(REFIID iid, IUnknown* unknown, return S_OK; } -STDMETHODIMP TsfTextStore::FindNextAttrTransition( +STDMETHODIMP TSFTextStore::FindNextAttrTransition( LONG acp_start, LONG acp_halt, ULONG num_filter_attributes, @@ -108,18 +109,17 @@ STDMETHODIMP TsfTextStore::FindNextAttrTransition( return S_OK; } -STDMETHODIMP TsfTextStore::GetACPFromPoint( - TsViewCookie view_cookie, - const POINT* point, - DWORD flags, - LONG* acp) { +STDMETHODIMP TSFTextStore::GetACPFromPoint(TsViewCookie view_cookie, + const POINT* point, + DWORD flags, + LONG* acp) { NOTIMPLEMENTED(); if (view_cookie != kViewCookie) return E_INVALIDARG; return E_NOTIMPL; } -STDMETHODIMP TsfTextStore::GetActiveView(TsViewCookie* view_cookie) { +STDMETHODIMP TSFTextStore::GetActiveView(TsViewCookie* view_cookie) { if (!view_cookie) return E_INVALIDARG; // We support only one view. @@ -127,7 +127,7 @@ STDMETHODIMP TsfTextStore::GetActiveView(TsViewCookie* view_cookie) { return S_OK; } -STDMETHODIMP TsfTextStore::GetEmbedded(LONG acp_pos, +STDMETHODIMP TSFTextStore::GetEmbedded(LONG acp_pos, REFGUID service, REFIID iid, IUnknown** unknown) { @@ -139,7 +139,7 @@ STDMETHODIMP TsfTextStore::GetEmbedded(LONG acp_pos, return E_NOTIMPL; } -STDMETHODIMP TsfTextStore::GetEndACP(LONG* acp) { +STDMETHODIMP TSFTextStore::GetEndACP(LONG* acp) { if (!acp) return E_INVALIDARG; if (!HasReadLock()) @@ -148,13 +148,13 @@ STDMETHODIMP TsfTextStore::GetEndACP(LONG* acp) { return S_OK; } -STDMETHODIMP TsfTextStore::GetFormattedText(LONG acp_start, LONG acp_end, +STDMETHODIMP TSFTextStore::GetFormattedText(LONG acp_start, LONG acp_end, IDataObject** data_object) { NOTIMPLEMENTED(); return E_NOTIMPL; } -STDMETHODIMP TsfTextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { +STDMETHODIMP TSFTextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { if (view_cookie != kViewCookie) return E_INVALIDARG; if (!rect) @@ -187,7 +187,7 @@ STDMETHODIMP TsfTextStore::GetScreenExt(TsViewCookie view_cookie, RECT* rect) { return S_OK; } -STDMETHODIMP TsfTextStore::GetSelection(ULONG selection_index, +STDMETHODIMP TSFTextStore::GetSelection(ULONG selection_index, ULONG selection_buffer_size, TS_SELECTION_ACP* selection_buffer, ULONG* fetched_count) { @@ -209,7 +209,7 @@ STDMETHODIMP TsfTextStore::GetSelection(ULONG selection_index, return S_OK; } -STDMETHODIMP TsfTextStore::GetStatus(TS_STATUS* status) { +STDMETHODIMP TSFTextStore::GetStatus(TS_STATUS* status) { if (!status) return E_INVALIDARG; @@ -220,7 +220,7 @@ STDMETHODIMP TsfTextStore::GetStatus(TS_STATUS* status) { return S_OK; } -STDMETHODIMP TsfTextStore::GetText(LONG acp_start, +STDMETHODIMP TSFTextStore::GetText(LONG acp_start, LONG acp_end, wchar_t* text_buffer, ULONG text_buffer_size, @@ -266,7 +266,7 @@ STDMETHODIMP TsfTextStore::GetText(LONG acp_start, return S_OK; } -STDMETHODIMP TsfTextStore::GetTextExt(TsViewCookie view_cookie, +STDMETHODIMP TSFTextStore::GetTextExt(TsViewCookie view_cookie, LONG acp_start, LONG acp_end, RECT* rect, @@ -351,7 +351,7 @@ STDMETHODIMP TsfTextStore::GetTextExt(TsViewCookie view_cookie, return S_OK; } -STDMETHODIMP TsfTextStore::GetWnd(TsViewCookie view_cookie, +STDMETHODIMP TSFTextStore::GetWnd(TsViewCookie view_cookie, HWND* window_handle) { if (!window_handle) return E_INVALIDARG; @@ -361,7 +361,7 @@ STDMETHODIMP TsfTextStore::GetWnd(TsViewCookie view_cookie, return S_OK; } -STDMETHODIMP TsfTextStore::InsertEmbedded(DWORD flags, +STDMETHODIMP TSFTextStore::InsertEmbedded(DWORD flags, LONG acp_start, LONG acp_end, IDataObject* data_object, @@ -371,7 +371,7 @@ STDMETHODIMP TsfTextStore::InsertEmbedded(DWORD flags, return E_NOTIMPL; } -STDMETHODIMP TsfTextStore::InsertEmbeddedAtSelection(DWORD flags, +STDMETHODIMP TSFTextStore::InsertEmbeddedAtSelection(DWORD flags, IDataObject* data_object, LONG* acp_start, LONG* acp_end, @@ -381,7 +381,7 @@ STDMETHODIMP TsfTextStore::InsertEmbeddedAtSelection(DWORD flags, return E_NOTIMPL; } -STDMETHODIMP TsfTextStore::InsertTextAtSelection(DWORD flags, +STDMETHODIMP TSFTextStore::InsertTextAtSelection(DWORD flags, const wchar_t* text_buffer, ULONG text_buffer_size, LONG* acp_start, @@ -425,7 +425,7 @@ STDMETHODIMP TsfTextStore::InsertTextAtSelection(DWORD flags, return S_OK; } -STDMETHODIMP TsfTextStore::QueryInsert( +STDMETHODIMP TSFTextStore::QueryInsert( LONG acp_test_start, LONG acp_test_end, ULONG text_size, @@ -443,7 +443,7 @@ STDMETHODIMP TsfTextStore::QueryInsert( return S_OK; } -STDMETHODIMP TsfTextStore::QueryInsertEmbedded(const GUID* service, +STDMETHODIMP TSFTextStore::QueryInsertEmbedded(const GUID* service, const FORMATETC* format, BOOL* insertable) { if (!format) @@ -454,7 +454,7 @@ STDMETHODIMP TsfTextStore::QueryInsertEmbedded(const GUID* service, return S_OK; } -STDMETHODIMP TsfTextStore::RequestAttrsAtPosition( +STDMETHODIMP TSFTextStore::RequestAttrsAtPosition( LONG acp_pos, ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer, @@ -465,7 +465,7 @@ STDMETHODIMP TsfTextStore::RequestAttrsAtPosition( return S_OK; } -STDMETHODIMP TsfTextStore::RequestAttrsTransitioningAtPosition( +STDMETHODIMP TSFTextStore::RequestAttrsTransitioningAtPosition( LONG acp_pos, ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer, @@ -476,7 +476,7 @@ STDMETHODIMP TsfTextStore::RequestAttrsTransitioningAtPosition( return S_OK; } -STDMETHODIMP TsfTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { +STDMETHODIMP TSFTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { if (!text_store_acp_sink_.get()) return E_FAIL; if (!result) @@ -578,7 +578,7 @@ STDMETHODIMP TsfTextStore::RequestLock(DWORD lock_flags, HRESULT* result) { return S_OK; } -STDMETHODIMP TsfTextStore::RequestSupportedAttrs( +STDMETHODIMP TSFTextStore::RequestSupportedAttrs( DWORD /* flags */, // Seems that we should ignore this. ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer) { @@ -592,7 +592,7 @@ STDMETHODIMP TsfTextStore::RequestSupportedAttrs( return E_FAIL; } -STDMETHODIMP TsfTextStore::RetrieveRequestedAttrs( +STDMETHODIMP TSFTextStore::RetrieveRequestedAttrs( ULONG attribute_buffer_size, TS_ATTRVAL* attribute_buffer, ULONG* attribute_buffer_copied) { @@ -608,14 +608,14 @@ STDMETHODIMP TsfTextStore::RetrieveRequestedAttrs( attribute_buffer[0].dwOverlapId = 0; attribute_buffer[0].idAttr = GUID_PROP_INPUTSCOPE; attribute_buffer[0].varValue.vt = VT_UNKNOWN; - attribute_buffer[0].varValue.punkVal = new TsfInputScope( + attribute_buffer[0].varValue.punkVal = new TSFInputScope( text_input_client_->GetTextInputType()); attribute_buffer[0].varValue.punkVal->AddRef(); *attribute_buffer_copied = 1; return S_OK; } -STDMETHODIMP TsfTextStore::SetSelection( +STDMETHODIMP TSFTextStore::SetSelection( ULONG selection_buffer_size, const TS_SELECTION_ACP* selection_buffer) { if (!HasReadWriteLock()) @@ -634,7 +634,7 @@ STDMETHODIMP TsfTextStore::SetSelection( return S_OK; } -STDMETHODIMP TsfTextStore::SetText(DWORD flags, +STDMETHODIMP TSFTextStore::SetText(DWORD flags, LONG acp_start, LONG acp_end, const wchar_t* text_buffer, @@ -671,7 +671,7 @@ STDMETHODIMP TsfTextStore::SetText(DWORD flags, return S_OK; } -STDMETHODIMP TsfTextStore::UnadviseSink(IUnknown* unknown) { +STDMETHODIMP TSFTextStore::UnadviseSink(IUnknown* unknown) { if (!text_store_acp_sink_.IsSameObject(unknown)) return CONNECT_E_NOCONNECTION; text_store_acp_sink_.Release(); @@ -679,7 +679,7 @@ STDMETHODIMP TsfTextStore::UnadviseSink(IUnknown* unknown) { return S_OK; } -STDMETHODIMP TsfTextStore::OnStartComposition( +STDMETHODIMP TSFTextStore::OnStartComposition( ITfCompositionView* composition_view, BOOL* ok) { if (ok) @@ -687,18 +687,18 @@ STDMETHODIMP TsfTextStore::OnStartComposition( return S_OK; } -STDMETHODIMP TsfTextStore::OnUpdateComposition( +STDMETHODIMP TSFTextStore::OnUpdateComposition( ITfCompositionView* composition_view, ITfRange* range) { return S_OK; } -STDMETHODIMP TsfTextStore::OnEndComposition( +STDMETHODIMP TSFTextStore::OnEndComposition( ITfCompositionView* composition_view) { return S_OK; } -STDMETHODIMP TsfTextStore::OnEndEdit(ITfContext* context, +STDMETHODIMP TSFTextStore::OnEndEdit(ITfContext* context, TfEditCookie read_only_edit_cookie, ITfEditRecord* edit_record) { if (!context || !edit_record) @@ -716,7 +716,7 @@ STDMETHODIMP TsfTextStore::OnEndEdit(ITfContext* context, return S_OK; } -bool TsfTextStore::GetDisplayAttribute(TfGuidAtom guid_atom, +bool TSFTextStore::GetDisplayAttribute(TfGuidAtom guid_atom, TF_DISPLAYATTRIBUTE* attribute) { GUID guid; if (FAILED(category_manager_->GetGUID(guid_atom, &guid))) @@ -730,7 +730,7 @@ bool TsfTextStore::GetDisplayAttribute(TfGuidAtom guid_atom, return SUCCEEDED(display_attribute_info->GetAttributeInfo(attribute)); } -bool TsfTextStore::GetCompositionStatus( +bool TSFTextStore::GetCompositionStatus( ITfContext* context, const TfEditCookie read_only_edit_cookie, size_t* committed_size, @@ -815,14 +815,14 @@ bool TsfTextStore::GetCompositionStatus( return true; } -void TsfTextStore::SetFocusedTextInputClient( +void TSFTextStore::SetFocusedTextInputClient( HWND focused_window, TextInputClient* text_input_client) { window_handle_ = focused_window; text_input_client_ = text_input_client; } -void TsfTextStore::RemoveFocusedTextInputClient( +void TSFTextStore::RemoveFocusedTextInputClient( TextInputClient* text_input_client) { if (text_input_client_ == text_input_client) { window_handle_ = NULL; @@ -830,16 +830,16 @@ void TsfTextStore::RemoveFocusedTextInputClient( } } -void TsfTextStore::SendOnLayoutChange() { +void TSFTextStore::SendOnLayoutChange() { if (text_store_acp_sink_ && (text_store_acp_sink_mask_ & TS_AS_LAYOUT_CHANGE)) text_store_acp_sink_->OnLayoutChange(TS_LC_CHANGE, 0); } -bool TsfTextStore::HasReadLock() const { +bool TSFTextStore::HasReadLock() const { return (current_lock_type_ & TS_LF_READ) == TS_LF_READ; } -bool TsfTextStore::HasReadWriteLock() const { +bool TSFTextStore::HasReadWriteLock() const { return (current_lock_type_ & TS_LF_READWRITE) == TS_LF_READWRITE; } diff --git a/ui/base/ime/win/tsf_text_store.h b/ui/base/ime/win/tsf_text_store.h index d248ad7..3ea0be7 100644 --- a/ui/base/ime/win/tsf_text_store.h +++ b/ui/base/ime/win/tsf_text_store.h @@ -19,61 +19,61 @@ namespace ui { class TextInputClient; -// TsfTextStore is used to interact with the input method via TSF manager. -// TsfTextStore have a string buffer which is manipulated by TSF manager through +// TSFTextStore is used to interact with the input method via TSF manager. +// TSFTextStore have a string buffer which is manipulated by TSF manager through // ITextStoreACP interface methods such as SetText(). -// When the input method updates the composition, TsfTextStore calls +// When the input method updates the composition, TSFTextStore calls // TextInputClient::SetCompositionText(). And when the input method finishes the -// composition, TsfTextStore calls TextInputClient::InsertText() and clears the +// composition, TSFTextStore calls TextInputClient::InsertText() and clears the // buffer. // -// How TsfTextStore works: +// How TSFTextStore works: // - The user enters "a". // - The input method set composition as "a". -// - TSF manager calls TsfTextStore::RequestLock(). -// - TsfTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TSFTextStore::RequestLock(). +// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TsfTextStore::OnStartComposition() -// - TsfTextStore::SetText() +// - TSFTextStore::OnStartComposition() +// - TSFTextStore::SetText() // The string buffer is set as "a". -// - TsfTextStore::OnUpdateComposition() -// - TsfTextStore::OnEndEdit() -// TsfTextStore can get the composition information such as underlines. -// - TsfTextStore calls TextInputClient::SetCompositionText(). +// - TSFTextStore::OnUpdateComposition() +// - TSFTextStore::OnEndEdit() +// TSFTextStore can get the composition information such as underlines. +// - TSFTextStore calls TextInputClient::SetCompositionText(). // "a" is shown with an underline as composition string. // - The user enters <space>. // - The input method set composition as "A". -// - TSF manager calls TsfTextStore::RequestLock(). -// - TsfTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TSFTextStore::RequestLock(). +// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TsfTextStore::SetText() +// - TSFTextStore::SetText() // The string buffer is set as "A". -// - TsfTextStore::OnUpdateComposition() -// - TsfTextStore::OnEndEdit() -// - TsfTextStore calls TextInputClient::SetCompositionText(). +// - TSFTextStore::OnUpdateComposition() +// - TSFTextStore::OnEndEdit() +// - TSFTextStore calls TextInputClient::SetCompositionText(). // "A" is shown with an underline as composition string. // - The user enters <enter>. // - The input method commits "A". -// - TSF manager calls TsfTextStore::RequestLock(). -// - TsfTextStore callbacks ITextStoreACPSink::OnLockGranted(). +// - TSF manager calls TSFTextStore::RequestLock(). +// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). // - In OnLockGranted(), TSF manager calls -// - TsfTextStore::OnEndComposition() -// - TsfTextStore::OnEndEdit() -// TsfTextStore knows "A" is committed. -// - TsfTextStore calls TextInputClient::InsertText(). +// - TSFTextStore::OnEndComposition() +// - TSFTextStore::OnEndEdit() +// TSFTextStore knows "A" is committed. +// - TSFTextStore calls TextInputClient::InsertText(). // "A" is shown as committed string. -// - TsfTextStore clears the string buffer. -// - TsfTextStore calls OnSelectionChange(), OnLayoutChange() and +// - TSFTextStore clears the string buffer. +// - TSFTextStore calls OnSelectionChange(), OnLayoutChange() and // OnTextChange() of ITextStoreACPSink to let TSF manager know that the // string buffer has been changed. // // About the locking scheme: // When TSF manager manipulates the string buffer it calls RequestLock() to get -// the lock of the document. If TsfTextStore can grant the lock request, it +// the lock of the document. If TSFTextStore can grant the lock request, it // callbacks ITextStoreACPSink::OnLockGranted(). // RequestLock() is called from only one thread, but called recursively in // OnLockGranted() or OnSelectionChange() or OnLayoutChange() or OnTextChange(). -// If the document is locked and the lock request is asynchronous, TsfTextStore +// If the document is locked and the lock request is asynchronous, TSFTextStore // queues the request. The queued requests will be handled after the current // lock is removed. // More information about document locks can be found here: @@ -81,135 +81,120 @@ class TextInputClient; // // More information about TSF can be found here: // http://msdn.microsoft.com/en-us/library/ms629032 -class UI_EXPORT TsfTextStore : public ITextStoreACP, +class UI_EXPORT TSFTextStore : public ITextStoreACP, public ITfContextOwnerCompositionSink, public ITfTextEditSink { public: - TsfTextStore(); - virtual ~TsfTextStore(); - - virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; - virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE; - - // Subclasses should extend this to return any interfaces they provide. - virtual STDMETHODIMP QueryInterface(REFIID iid, void** ppv) OVERRIDE; - - // ITextStoreACP overrides. - virtual STDMETHODIMP AdviseSink(REFIID iid, IUnknown* unknown, - DWORD mask) OVERRIDE; - virtual STDMETHODIMP FindNextAttrTransition( - LONG acp_start, - LONG acp_halt, - ULONG num_filter_attributes, - const TS_ATTRID* filter_attributes, - DWORD flags, - LONG* acp_next, - BOOL* found, - LONG* found_offset) OVERRIDE; - virtual STDMETHODIMP GetACPFromPoint(TsViewCookie view_cookie, - const POINT* point, - DWORD flags, - LONG* acp) OVERRIDE; - virtual STDMETHODIMP GetActiveView(TsViewCookie* view_cookie) OVERRIDE; - virtual STDMETHODIMP GetEmbedded(LONG acp_pos, - REFGUID service, - REFIID iid, - IUnknown** unknown) OVERRIDE; - virtual STDMETHODIMP GetEndACP(LONG* acp) OVERRIDE; - virtual STDMETHODIMP GetFormattedText(LONG acp_start, - LONG acp_end, - IDataObject** data_object) OVERRIDE; - virtual STDMETHODIMP GetScreenExt(TsViewCookie view_cookie, - RECT* rect) OVERRIDE; - virtual STDMETHODIMP GetSelection(ULONG selection_index, - ULONG selection_buffer_size, - TS_SELECTION_ACP* selection_buffer, - ULONG* fetched_count) OVERRIDE; - virtual STDMETHODIMP GetStatus(TS_STATUS* pdcs) OVERRIDE; - virtual STDMETHODIMP GetText(LONG acp_start, - LONG acp_end, - wchar_t* text_buffer, - ULONG text_buffer_size, - ULONG* text_buffer_copied, - TS_RUNINFO* run_info_buffer, - ULONG run_info_buffer_size, - ULONG* run_info_buffer_copied, - LONG* next_acp) OVERRIDE; - virtual STDMETHODIMP GetTextExt(TsViewCookie view_cookie, - LONG acp_start, - LONG acp_end, - RECT* rect, - BOOL* clipped) OVERRIDE; - virtual STDMETHODIMP GetWnd(TsViewCookie view_cookie, - HWND* window_handle) OVERRIDE; - virtual STDMETHODIMP InsertEmbedded(DWORD flags, - LONG acp_start, - LONG acp_end, - IDataObject* data_object, - TS_TEXTCHANGE* change) OVERRIDE; - virtual STDMETHODIMP InsertEmbeddedAtSelection( - DWORD flags, - IDataObject* data_object, - LONG* acp_start, - LONG* acp_end, - TS_TEXTCHANGE* change) OVERRIDE; - virtual STDMETHODIMP InsertTextAtSelection( - DWORD flags, - const wchar_t* text_buffer, - ULONG text_buffer_size, - LONG* acp_start, - LONG* acp_end, - TS_TEXTCHANGE* text_change) OVERRIDE; - virtual STDMETHODIMP QueryInsert(LONG acp_test_start, - LONG acp_test_end, - ULONG text_size, - LONG* acp_result_start, - LONG* acp_result_end) OVERRIDE; - virtual STDMETHODIMP QueryInsertEmbedded(const GUID* service, - const FORMATETC* format, - BOOL* insertable) OVERRIDE; - virtual STDMETHODIMP RequestAttrsAtPosition( + TSFTextStore(); + virtual ~TSFTextStore(); + + // ITextStoreACP: + STDMETHOD_(ULONG, AddRef)() OVERRIDE; + STDMETHOD_(ULONG, Release)() OVERRIDE; + STDMETHOD(QueryInterface)(REFIID iid, void** ppv) OVERRIDE; + STDMETHOD(AdviseSink)(REFIID iid, IUnknown* unknown, DWORD mask) OVERRIDE; + STDMETHOD(FindNextAttrTransition)(LONG acp_start, + LONG acp_halt, + ULONG num_filter_attributes, + const TS_ATTRID* filter_attributes, + DWORD flags, + LONG* acp_next, + BOOL* found, + LONG* found_offset) OVERRIDE; + STDMETHOD(GetACPFromPoint)(TsViewCookie view_cookie, + const POINT* point, + DWORD flags, + LONG* acp) OVERRIDE; + STDMETHOD(GetActiveView)(TsViewCookie* view_cookie) OVERRIDE; + STDMETHOD(GetEmbedded)(LONG acp_pos, + REFGUID service, + REFIID iid, + IUnknown** unknown) OVERRIDE; + STDMETHOD(GetEndACP)(LONG* acp) OVERRIDE; + STDMETHOD(GetFormattedText)(LONG acp_start, + LONG acp_end, + IDataObject** data_object) OVERRIDE; + STDMETHOD(GetScreenExt)(TsViewCookie view_cookie, RECT* rect) OVERRIDE; + STDMETHOD(GetSelection)(ULONG selection_index, + ULONG selection_buffer_size, + TS_SELECTION_ACP* selection_buffer, + ULONG* fetched_count) OVERRIDE; + STDMETHOD(GetStatus)(TS_STATUS* pdcs) OVERRIDE; + STDMETHOD(GetText)(LONG acp_start, + LONG acp_end, + wchar_t* text_buffer, + ULONG text_buffer_size, + ULONG* text_buffer_copied, + TS_RUNINFO* run_info_buffer, + ULONG run_info_buffer_size, + ULONG* run_info_buffer_copied, + LONG* next_acp) OVERRIDE; + STDMETHOD(GetTextExt)(TsViewCookie view_cookie, + LONG acp_start, + LONG acp_end, + RECT* rect, + BOOL* clipped) OVERRIDE; + STDMETHOD(GetWnd)(TsViewCookie view_cookie, HWND* window_handle) OVERRIDE; + STDMETHOD(InsertEmbedded)(DWORD flags, + LONG acp_start, + LONG acp_end, + IDataObject* data_object, + TS_TEXTCHANGE* change) OVERRIDE; + STDMETHOD(InsertEmbeddedAtSelection)(DWORD flags, + IDataObject* data_object, + LONG* acp_start, + LONG* acp_end, + TS_TEXTCHANGE* change) OVERRIDE; + STDMETHOD(InsertTextAtSelection)(DWORD flags, + const wchar_t* text_buffer, + ULONG text_buffer_size, + LONG* acp_start, + LONG* acp_end, + TS_TEXTCHANGE* text_change) OVERRIDE; + STDMETHOD(QueryInsert)(LONG acp_test_start, + LONG acp_test_end, + ULONG text_size, + LONG* acp_result_start, + LONG* acp_result_end) OVERRIDE; + STDMETHOD(QueryInsertEmbedded)(const GUID* service, + const FORMATETC* format, + BOOL* insertable) OVERRIDE; + STDMETHOD(RequestAttrsAtPosition)(LONG acp_pos, + ULONG attribute_buffer_size, + const TS_ATTRID* attribute_buffer, + DWORD flags) OVERRIDE; + STDMETHOD(RequestAttrsTransitioningAtPosition)( LONG acp_pos, ULONG attribute_buffer_size, const TS_ATTRID* attribute_buffer, DWORD flags) OVERRIDE; - virtual STDMETHODIMP RequestAttrsTransitioningAtPosition( - LONG acp_pos, - ULONG attribute_buffer_size, - const TS_ATTRID* attribute_buffer, - DWORD flags) OVERRIDE; - virtual STDMETHODIMP RequestLock(DWORD lock_flags, HRESULT* result) OVERRIDE; - virtual STDMETHODIMP RequestSupportedAttrs( - DWORD flags, - ULONG attribute_buffer_size, - const TS_ATTRID* attribute_buffer) OVERRIDE; - virtual STDMETHODIMP RetrieveRequestedAttrs( - ULONG attribute_buffer_size, - TS_ATTRVAL* attribute_buffer, - ULONG* attribute_buffer_copied) OVERRIDE; - virtual STDMETHODIMP SetSelection( - ULONG selection_buffer_size, - const TS_SELECTION_ACP* selection_buffer) OVERRIDE; - virtual STDMETHODIMP SetText(DWORD flags, - LONG acp_start, - LONG acp_end, - const wchar_t* text_buffer, - ULONG text_buffer_size, - TS_TEXTCHANGE* text_change) OVERRIDE; - virtual STDMETHODIMP UnadviseSink(IUnknown* unknown) OVERRIDE; - - // ITfContextOwnerCompositionSink overrides. - virtual STDMETHODIMP OnStartComposition(ITfCompositionView* composition_view, - BOOL* ok) OVERRIDE; - virtual STDMETHODIMP OnUpdateComposition(ITfCompositionView* composition_view, - ITfRange* range) OVERRIDE; - virtual STDMETHODIMP OnEndComposition( - ITfCompositionView* composition_view) OVERRIDE; - - // ITfTextEditSink overrides. - virtual STDMETHODIMP OnEndEdit(ITfContext* context, - TfEditCookie read_only_edit_cookie, - ITfEditRecord* edit_record) OVERRIDE; + STDMETHOD(RequestLock)(DWORD lock_flags, HRESULT* result) OVERRIDE; + STDMETHOD(RequestSupportedAttrs)(DWORD flags, + ULONG attribute_buffer_size, + const TS_ATTRID* attribute_buffer) OVERRIDE; + STDMETHOD(RetrieveRequestedAttrs)(ULONG attribute_buffer_size, + TS_ATTRVAL* attribute_buffer, + ULONG* attribute_buffer_copied) OVERRIDE; + STDMETHOD(SetSelection)(ULONG selection_buffer_size, + const TS_SELECTION_ACP* selection_buffer) OVERRIDE; + STDMETHOD(SetText)(DWORD flags, + LONG acp_start, + LONG acp_end, + const wchar_t* text_buffer, + ULONG text_buffer_size, + TS_TEXTCHANGE* text_change) OVERRIDE; + STDMETHOD(UnadviseSink)(IUnknown* unknown) OVERRIDE; + + // ITfContextOwnerCompositionSink: + STDMETHOD(OnStartComposition)(ITfCompositionView* composition_view, + BOOL* ok) OVERRIDE; + STDMETHOD(OnUpdateComposition)(ITfCompositionView* composition_view, + ITfRange* range) OVERRIDE; + STDMETHOD(OnEndComposition)(ITfCompositionView* composition_view) OVERRIDE; + + // ITfTextEditSink: + STDMETHOD(OnEndEdit)(ITfContext* context, TfEditCookie read_only_edit_cookie, + ITfEditRecord* edit_record) OVERRIDE; // Sets currently focused TextInputClient. void SetFocusedTextInputClient(HWND focused_window, @@ -221,8 +206,8 @@ class UI_EXPORT TsfTextStore : public ITextStoreACP, void SendOnLayoutChange(); private: - friend class TsfTextStoreTest; - friend class TsfTextStoreTestCallback; + friend class TSFTextStoreTest; + friend class TSFTextStoreTestCallback; // Checks if the document has a read-only lock. bool HasReadLock() const; @@ -298,7 +283,7 @@ class UI_EXPORT TsfTextStore : public ITextStoreACP, base::win::ScopedComPtr<ITfCategoryMgr> category_manager_; base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_; - DISALLOW_COPY_AND_ASSIGN(TsfTextStore); + DISALLOW_COPY_AND_ASSIGN(TSFTextStore); }; } // namespace ui diff --git a/ui/base/ime/win/tsf_text_store_unittest.cc b/ui/base/ime/win/tsf_text_store_unittest.cc index 255cc73..5eb2800 100644 --- a/ui/base/ime/win/tsf_text_store_unittest.cc +++ b/ui/base/ime/win/tsf_text_store_unittest.cc @@ -99,10 +99,10 @@ class MockStoreACPSink : public ITextStoreACPSink { } // namespace -class TsfTextStoreTest : public testing::Test { +class TSFTextStoreTest : public testing::Test { protected: virtual void SetUp() OVERRIDE { - text_store_ = new TsfTextStore(); + text_store_ = new TSFTextStore(); text_store_->AddRef(); sink_ = new MockStoreACPSink(); sink_->AddRef(); @@ -119,20 +119,20 @@ class TsfTextStoreTest : public testing::Test { base::win::ScopedCOMInitializer com_initializer_; MockTextInputClient text_input_client_; - TsfTextStore* text_store_; + TSFTextStore* text_store_; MockStoreACPSink* sink_; }; -class TsfTextStoreTestCallback { +class TSFTextStoreTestCallback { public: - explicit TsfTextStoreTestCallback(TsfTextStore* text_store) + explicit TSFTextStoreTestCallback(TSFTextStore* text_store) : text_store_(text_store) { CHECK(text_store_); } - virtual ~TsfTextStoreTestCallback() {} + virtual ~TSFTextStoreTestCallback() {} protected: - // Accessors to the internal state of TsfTextStore. + // Accessors to the internal state of TSFTextStore. bool* edit_flag() { return &text_store_->edit_flag_; } string16* string_buffer() { return &text_store_->string_buffer_; } size_t* committed_size() { return &text_store_->committed_size_; } @@ -278,10 +278,10 @@ class TsfTextStoreTestCallback { &rect, &clipped)); } - TsfTextStore* text_store_; + TSFTextStore* text_store_; }; -TEST_F(TsfTextStoreTest, GetStatusTest) { +TEST_F(TSFTextStoreTest, GetStatusTest) { TS_STATUS status; EXPECT_EQ(S_OK, text_store_->GetStatus(&status)); EXPECT_EQ(0, status.dwDynamicFlags); @@ -289,10 +289,10 @@ TEST_F(TsfTextStoreTest, GetStatusTest) { } -class SyncRequestLockTestCallback : public TsfTextStoreTestCallback { +class SyncRequestLockTestCallback : public TSFTextStoreTestCallback { public: - explicit SyncRequestLockTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store) { + explicit SyncRequestLockTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store) { } HRESULT LockGranted1(DWORD flags) { @@ -346,7 +346,7 @@ class SyncRequestLockTestCallback : public TsfTextStoreTestCallback { } }; -TEST_F(TsfTextStoreTest, SynchronousRequestLockTest) { +TEST_F(TSFTextStoreTest, SynchronousRequestLockTest) { SyncRequestLockTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, &SyncRequestLockTestCallback::LockGranted1)) @@ -376,10 +376,10 @@ TEST_F(TsfTextStoreTest, SynchronousRequestLockTest) { EXPECT_EQ(S_OK, result); } -class AsyncRequestLockTestCallback : public TsfTextStoreTestCallback { +class AsyncRequestLockTestCallback : public TSFTextStoreTestCallback { public: - explicit AsyncRequestLockTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store), + explicit AsyncRequestLockTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store), state_(0) { } @@ -444,7 +444,7 @@ class AsyncRequestLockTestCallback : public TsfTextStoreTestCallback { int state_; }; -TEST_F(TsfTextStoreTest, AsynchronousRequestLockTest) { +TEST_F(TSFTextStoreTest, AsynchronousRequestLockTest) { AsyncRequestLockTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, &AsyncRequestLockTestCallback::LockGranted1)) @@ -458,10 +458,10 @@ TEST_F(TsfTextStoreTest, AsynchronousRequestLockTest) { EXPECT_EQ(S_OK, result); } -class RequestLockTextChangeTestCallback : public TsfTextStoreTestCallback { +class RequestLockTextChangeTestCallback : public TSFTextStoreTestCallback { public: - explicit RequestLockTextChangeTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store), + explicit RequestLockTextChangeTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store), state_(0) { } @@ -517,7 +517,7 @@ class RequestLockTextChangeTestCallback : public TsfTextStoreTestCallback { int state_; }; -TEST_F(TsfTextStoreTest, RequestLockOnTextChangeTest) { +TEST_F(TSFTextStoreTest, RequestLockOnTextChangeTest) { RequestLockTextChangeTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, @@ -544,10 +544,10 @@ TEST_F(TsfTextStoreTest, RequestLockOnTextChangeTest) { EXPECT_EQ(S_OK, result); } -class SelectionTestCallback : public TsfTextStoreTestCallback { +class SelectionTestCallback : public TSFTextStoreTestCallback { public: - explicit SelectionTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store) { + explicit SelectionTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store) { } HRESULT ReadLockGranted(DWORD flags) { @@ -621,7 +621,7 @@ class SelectionTestCallback : public TsfTextStoreTestCallback { } }; -TEST_F(TsfTextStoreTest, SetGetSelectionTest) { +TEST_F(TSFTextStoreTest, SetGetSelectionTest) { SelectionTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, &SelectionTestCallback::ReadLockGranted)) @@ -640,10 +640,10 @@ TEST_F(TsfTextStoreTest, SetGetSelectionTest) { } -class SetGetTextTestCallback : public TsfTextStoreTestCallback { +class SetGetTextTestCallback : public TSFTextStoreTestCallback { public: - explicit SetGetTextTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store) { + explicit SetGetTextTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store) { } HRESULT ReadLockGranted(DWORD flags) { @@ -819,7 +819,7 @@ class SetGetTextTestCallback : public TsfTextStoreTestCallback { } }; -TEST_F(TsfTextStoreTest, SetGetTextTest) { +TEST_F(TSFTextStoreTest, SetGetTextTest) { SetGetTextTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, &SetGetTextTestCallback::ReadLockGranted)) @@ -843,10 +843,10 @@ TEST_F(TsfTextStoreTest, SetGetTextTest) { EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); } -class InsertTextAtSelectionTestCallback : public TsfTextStoreTestCallback { +class InsertTextAtSelectionTestCallback : public TSFTextStoreTestCallback { public: - explicit InsertTextAtSelectionTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store) { + explicit InsertTextAtSelectionTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store) { } HRESULT ReadLockGranted(DWORD flags) { @@ -907,7 +907,7 @@ class InsertTextAtSelectionTestCallback : public TsfTextStoreTestCallback { } }; -TEST_F(TsfTextStoreTest, InsertTextAtSelectionTest) { +TEST_F(TSFTextStoreTest, InsertTextAtSelectionTest) { InsertTextAtSelectionTestCallback callback(text_store_); EXPECT_CALL(*sink_, OnLockGranted(_)) .WillOnce(Invoke(&callback, @@ -921,10 +921,10 @@ TEST_F(TsfTextStoreTest, InsertTextAtSelectionTest) { EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); } -class ScenarioTestCallback : public TsfTextStoreTestCallback { +class ScenarioTestCallback : public TSFTextStoreTestCallback { public: - explicit ScenarioTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store) { + explicit ScenarioTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store) { } HRESULT LockGranted1(DWORD flags) { @@ -1022,7 +1022,7 @@ class ScenarioTestCallback : public TsfTextStoreTestCallback { } }; -TEST_F(TsfTextStoreTest, ScenarioTest) { +TEST_F(TSFTextStoreTest, ScenarioTest) { ScenarioTestCallback callback(text_store_); EXPECT_CALL(text_input_client_, SetCompositionText(_)) .WillOnce(Invoke(&callback, &ScenarioTestCallback::SetCompositionText1)) @@ -1056,10 +1056,10 @@ TEST_F(TsfTextStoreTest, ScenarioTest) { EXPECT_EQ(S_OK, text_store_->RequestLock(TS_LF_READWRITE, &result)); } -class GetTextExtTestCallback : public TsfTextStoreTestCallback { +class GetTextExtTestCallback : public TSFTextStoreTestCallback { public: - explicit GetTextExtTestCallback(TsfTextStore* text_store) - : TsfTextStoreTestCallback(text_store), + explicit GetTextExtTestCallback(TSFTextStore* text_store) + : TSFTextStoreTestCallback(text_store), layout_prepared_character_num_(0) { } @@ -1124,7 +1124,7 @@ class GetTextExtTestCallback : public TsfTextStoreTestCallback { uint32 layout_prepared_character_num_; }; -TEST_F(TsfTextStoreTest, GetTextExtTest) { +TEST_F(TSFTextStoreTest, GetTextExtTest) { GetTextExtTestCallback callback(text_store_); EXPECT_CALL(text_input_client_, GetCaretBounds()) .WillRepeatedly(Invoke(&callback, diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc index ab3749e..d2ca187 100644 --- a/ui/views/controls/textfield/native_textfield_win.cc +++ b/ui/views/controls/textfield/native_textfield_win.cc @@ -98,8 +98,8 @@ NativeTextfieldWin::NativeTextfieldWin(Textfield* textfield) container_view_(new NativeViewHost), bg_color_(0), ALLOW_THIS_IN_INITIALIZER_LIST( - tsf_event_router_(base::win::IsTsfAwareRequired() ? - new ui::TsfEventRouter(this) : NULL)) { + tsf_event_router_(base::win::IsTSFAwareRequired() ? + new ui::TSFEventRouter(this) : NULL)) { if (!loaded_libarary_module_) { // msftedit.dll is RichEdit ver 4.1. // This version is available from WinXP SP1 and has TSF support. @@ -348,7 +348,7 @@ bool NativeTextfieldWin::IsIMEComposing() const { // Retrieve the length of the composition string to check if an IME is // composing text. (If this length is > 0 then an IME is being used to compose // text.) - if (base::win::IsTsfAwareRequired()) + if (base::win::IsTSFAwareRequired()) return tsf_event_router_->IsImeComposing(); HIMC imm_context = ImmGetContext(m_hWnd); @@ -507,11 +507,11 @@ void NativeTextfieldWin::OnImeEndCompositionInternal() { textfield_->SyncText(); } -void NativeTextfieldWin::OnTsfStartComposition() { +void NativeTextfieldWin::OnTSFStartComposition() { OnImeStartCompositionInternal(); } -void NativeTextfieldWin::OnTsfEndComposition() { +void NativeTextfieldWin::OnTSFEndComposition() { OnImeEndCompositionInternal(); } @@ -620,7 +620,7 @@ void NativeTextfieldWin::OnCopy() { } LRESULT NativeTextfieldWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { - if (base::win::IsTsfAwareRequired()) { + if (base::win::IsTSFAwareRequired()) { // Enable TSF support of RichEdit. SetEditStyle(SES_USECTF, SES_USECTF); @@ -1053,7 +1053,7 @@ void NativeTextfieldWin::OnSetFocus(HWND hwnd) { } focus_manager->SetFocusedView(textfield_); - if (!base::win::IsTsfAwareRequired()) { + if (!base::win::IsTSFAwareRequired()) { return; } @@ -1062,7 +1062,7 @@ void NativeTextfieldWin::OnSetFocus(HWND hwnd) { // Document manager created by RichEdit can be obtained only after // WM_SET_FOCUS event is handled. tsf_event_router_->SetManager( - ui::TsfBridge::GetInstance()->GetThreadManager()); + ui::TSFBridge::GetInstance()->GetThreadManager()); SetMsgHandled(TRUE); } diff --git a/ui/views/controls/textfield/native_textfield_win.h b/ui/views/controls/textfield/native_textfield_win.h index 08aba4c..e759f76 100644 --- a/ui/views/controls/textfield/native_textfield_win.h +++ b/ui/views/controls/textfield/native_textfield_win.h @@ -44,7 +44,7 @@ class NativeTextfieldWin public CRichEditCommands<NativeTextfieldWin>, public NativeTextfieldWrapper, public ui::SimpleMenuModel::Delegate, - public ui::TsfEventRouterObserver { + public ui::TSFEventRouterObserver { public: DECLARE_WND_SUPERCLASS(L"ViewsTextfieldEdit", MSFTEDIT_CLASS); @@ -66,7 +66,7 @@ class NativeTextfieldWin // See the code in textfield.cc that calls this for why this is here. void AttachHack(); - // Overridden from NativeTextfieldWrapper: + // NativeTextfieldWrapper: virtual string16 GetText() const OVERRIDE; virtual void UpdateText() OVERRIDE; virtual void AppendText(const string16& text) OVERRIDE; @@ -104,7 +104,7 @@ class NativeTextfieldWin virtual void ClearEditHistory() OVERRIDE; virtual int GetFontHeight() OVERRIDE; - // Overridden from ui::SimpleMenuModel::Delegate: + // ui::SimpleMenuModel::Delegate: virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; virtual bool GetAcceleratorForCommandId( @@ -112,10 +112,10 @@ class NativeTextfieldWin ui::Accelerator* accelerator) OVERRIDE; virtual void ExecuteCommand(int command_id) OVERRIDE; - // Overridden from ui::TsfEventRouterObserver: + // ui::TSFEventRouterObserver: virtual void OnTextUpdated(const ui::Range& composition_range) OVERRIDE; - virtual void OnTsfStartComposition() OVERRIDE; - virtual void OnTsfEndComposition() OVERRIDE; + virtual void OnTSFStartComposition() OVERRIDE; + virtual void OnTSFEndComposition() OVERRIDE; // Update accessibility information. void InitializeAccessibilityInfo(); @@ -189,7 +189,7 @@ class NativeTextfieldWin DISALLOW_COPY_AND_ASSIGN(ScopedSuspendUndo); }; - // message handlers + // Message handlers. void OnChar(TCHAR key, UINT repeat_count, UINT flags); void OnContextMenu(HWND window, const POINT& point); void OnCopy(); @@ -315,7 +315,7 @@ class NativeTextfieldWin // The accessibility state of this object. int accessibility_state_; - scoped_ptr<ui::TsfEventRouter> tsf_event_router_; + scoped_ptr<ui::TSFEventRouter> tsf_event_router_; DISALLOW_COPY_AND_ASSIGN(NativeTextfieldWin); }; |