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

Side by Side Diff: win8/metro_driver/ime/text_store.h

Issue 103383004: Rename TSFTextStore to TextStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « win8/metro_driver/ime/text_service.cc ('k') | win8/metro_driver/ime/text_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ 5 #ifndef WIN8_METRO_DRIVER_IME_TEXT_STORE_H_
6 #define WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ 6 #define WIN8_METRO_DRIVER_IME_TEXT_STORE_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 #include <initguid.h> 10 #include <initguid.h>
11 #include <inputscope.h> 11 #include <inputscope.h>
12 #include <msctf.h> 12 #include <msctf.h>
13 13
14 #include <deque> 14 #include <deque>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "base/win/scoped_comptr.h" 21 #include "base/win/scoped_comptr.h"
22 #include "ui/metro_viewer/ime_types.h" 22 #include "ui/metro_viewer/ime_types.h"
23 23
24 namespace metro_driver { 24 namespace metro_driver {
25 25
26 class TextStoreDelegate; 26 class TextStoreDelegate;
27 27
28 // TSFTextStore is used to interact with the input method via TSF manager. 28 // TextStore is used to interact with the input method via TSF manager.
29 // TSFTextStore have a string buffer which is manipulated by TSF manager through 29 // TextStore have a string buffer which is manipulated by TSF manager through
30 // ITextStoreACP interface methods such as SetText(). 30 // ITextStoreACP interface methods such as SetText().
31 // When the input method updates the composition, TSFTextStore calls 31 // When the input method updates the composition, TextStore calls
32 // TextInputClient::SetCompositionText(). And when the input method finishes the 32 // TextInputClient::SetCompositionText(). And when the input method finishes the
33 // composition, TSFTextStore calls TextInputClient::InsertText() and clears the 33 // composition, TextStore calls TextInputClient::InsertText() and clears the
34 // buffer. 34 // buffer.
35 // 35 //
36 // How TSFTextStore works: 36 // How TextStore works:
37 // - The user enters "a". 37 // - The user enters "a".
38 // - The input method set composition as "a". 38 // - The input method set composition as "a".
39 // - TSF manager calls TSFTextStore::RequestLock(). 39 // - TSF manager calls TextStore::RequestLock().
40 // - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). 40 // - TextStore callbacks ITextStoreACPSink::OnLockGranted().
41 // - In OnLockGranted(), TSF manager calls 41 // - In OnLockGranted(), TSF manager calls
42 // - TSFTextStore::OnStartComposition() 42 // - TextStore::OnStartComposition()
43 // - TSFTextStore::SetText() 43 // - TextStore::SetText()
44 // The string buffer is set as "a". 44 // The string buffer is set as "a".
45 // - TSFTextStore::OnUpdateComposition() 45 // - TextStore::OnUpdateComposition()
46 // - TSFTextStore::OnEndEdit() 46 // - TextStore::OnEndEdit()
47 // TSFTextStore can get the composition information such as underlines. 47 // TextStore can get the composition information such as underlines.
48 // - TSFTextStore calls TextInputClient::SetCompositionText(). 48 // - TextStore calls TextInputClient::SetCompositionText().
49 // "a" is shown with an underline as composition string. 49 // "a" is shown with an underline as composition string.
50 // - The user enters <space>. 50 // - The user enters <space>.
51 // - The input method set composition as "A". 51 // - The input method set composition as "A".
52 // - TSF manager calls TSFTextStore::RequestLock(). 52 // - TSF manager calls TextStore::RequestLock().
53 // - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). 53 // - TextStore callbacks ITextStoreACPSink::OnLockGranted().
54 // - In OnLockGranted(), TSF manager calls 54 // - In OnLockGranted(), TSF manager calls
55 // - TSFTextStore::SetText() 55 // - TextStore::SetText()
56 // The string buffer is set as "A". 56 // The string buffer is set as "A".
57 // - TSFTextStore::OnUpdateComposition() 57 // - TextStore::OnUpdateComposition()
58 // - TSFTextStore::OnEndEdit() 58 // - TextStore::OnEndEdit()
59 // - TSFTextStore calls TextInputClient::SetCompositionText(). 59 // - TextStore calls TextInputClient::SetCompositionText().
60 // "A" is shown with an underline as composition string. 60 // "A" is shown with an underline as composition string.
61 // - The user enters <enter>. 61 // - The user enters <enter>.
62 // - The input method commits "A". 62 // - The input method commits "A".
63 // - TSF manager calls TSFTextStore::RequestLock(). 63 // - TSF manager calls TextStore::RequestLock().
64 // - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). 64 // - TextStore callbacks ITextStoreACPSink::OnLockGranted().
65 // - In OnLockGranted(), TSF manager calls 65 // - In OnLockGranted(), TSF manager calls
66 // - TSFTextStore::OnEndComposition() 66 // - TextStore::OnEndComposition()
67 // - TSFTextStore::OnEndEdit() 67 // - TextStore::OnEndEdit()
68 // TSFTextStore knows "A" is committed. 68 // TextStore knows "A" is committed.
69 // - TSFTextStore calls TextInputClient::InsertText(). 69 // - TextStore calls TextInputClient::InsertText().
70 // "A" is shown as committed string. 70 // "A" is shown as committed string.
71 // - TSFTextStore clears the string buffer. 71 // - TextStore clears the string buffer.
72 // - TSFTextStore calls OnSelectionChange(), OnLayoutChange() and 72 // - TextStore calls OnSelectionChange(), OnLayoutChange() and
73 // OnTextChange() of ITextStoreACPSink to let TSF manager know that the 73 // OnTextChange() of ITextStoreACPSink to let TSF manager know that the
74 // string buffer has been changed. 74 // string buffer has been changed.
75 // 75 //
76 // About the locking scheme: 76 // About the locking scheme:
77 // When TSF manager manipulates the string buffer it calls RequestLock() to get 77 // When TSF manager manipulates the string buffer it calls RequestLock() to get
78 // the lock of the document. If TSFTextStore can grant the lock request, it 78 // the lock of the document. If TextStore can grant the lock request, it
79 // callbacks ITextStoreACPSink::OnLockGranted(). 79 // callbacks ITextStoreACPSink::OnLockGranted().
80 // RequestLock() is called from only one thread, but called recursively in 80 // RequestLock() is called from only one thread, but called recursively in
81 // OnLockGranted() or OnSelectionChange() or OnLayoutChange() or OnTextChange(). 81 // OnLockGranted() or OnSelectionChange() or OnLayoutChange() or OnTextChange().
82 // If the document is locked and the lock request is asynchronous, TSFTextStore 82 // If the document is locked and the lock request is asynchronous, TextStore
83 // queues the request. The queued requests will be handled after the current 83 // queues the request. The queued requests will be handled after the current
84 // lock is removed. 84 // lock is removed.
85 // More information about document locks can be found here: 85 // More information about document locks can be found here:
86 // http://msdn.microsoft.com/en-us/library/ms538064 86 // http://msdn.microsoft.com/en-us/library/ms538064
87 // 87 //
88 // More information about TSF can be found here: 88 // More information about TSF can be found here:
89 // http://msdn.microsoft.com/en-us/library/ms629032 89 // http://msdn.microsoft.com/en-us/library/ms629032
90 // TODO(yukawa): Rename TSFTextStore to TextStore. 90 class ATL_NO_VTABLE TextStore
91 class ATL_NO_VTABLE TSFTextStore
92 : public CComObjectRootEx<CComMultiThreadModel>, 91 : public CComObjectRootEx<CComMultiThreadModel>,
93 public ITextStoreACP, 92 public ITextStoreACP,
94 public ITfContextOwnerCompositionSink, 93 public ITfContextOwnerCompositionSink,
95 public ITfTextEditSink { 94 public ITfTextEditSink {
96 public: 95 public:
97 virtual ~TSFTextStore(); 96 virtual ~TextStore();
98 97
99 BEGIN_COM_MAP(TSFTextStore) 98 BEGIN_COM_MAP(TextStore)
100 COM_INTERFACE_ENTRY(ITextStoreACP) 99 COM_INTERFACE_ENTRY(ITextStoreACP)
101 COM_INTERFACE_ENTRY(ITfContextOwnerCompositionSink) 100 COM_INTERFACE_ENTRY(ITfContextOwnerCompositionSink)
102 COM_INTERFACE_ENTRY(ITfTextEditSink) 101 COM_INTERFACE_ENTRY(ITfTextEditSink)
103 END_COM_MAP() 102 END_COM_MAP()
104 103
105 // ITextStoreACP: 104 // ITextStoreACP:
106 STDMETHOD(AdviseSink)(REFIID iid, IUnknown* unknown, DWORD mask) OVERRIDE; 105 STDMETHOD(AdviseSink)(REFIID iid, IUnknown* unknown, DWORD mask) OVERRIDE;
107 STDMETHOD(FindNextAttrTransition)(LONG acp_start, 106 STDMETHOD(FindNextAttrTransition)(LONG acp_start,
108 LONG acp_halt, 107 LONG acp_halt,
109 ULONG num_filter_attributes, 108 ULONG num_filter_attributes,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 208
210 // Cancels the ongoing composition if exists. 209 // Cancels the ongoing composition if exists.
211 bool CancelComposition(); 210 bool CancelComposition();
212 211
213 // Confirms the ongoing composition if exists. 212 // Confirms the ongoing composition if exists.
214 bool ConfirmComposition(); 213 bool ConfirmComposition();
215 214
216 // Sends OnLayoutChange() via |text_store_acp_sink_|. 215 // Sends OnLayoutChange() via |text_store_acp_sink_|.
217 void SendOnLayoutChange(); 216 void SendOnLayoutChange();
218 217
219 // Creates an instance of TSFTextStore. Returns NULL if fails. 218 // Creates an instance of TextStore. Returns NULL if fails.
220 static scoped_refptr<TSFTextStore> Create( 219 static scoped_refptr<TextStore> Create(
221 HWND window_handle, 220 HWND window_handle,
222 const std::vector<InputScope>& input_scopes, 221 const std::vector<InputScope>& input_scopes,
223 TextStoreDelegate* delegate); 222 TextStoreDelegate* delegate);
224 223
225 private: 224 private:
226 friend CComObject<TSFTextStore>; 225 friend CComObject<TextStore>;
227 TSFTextStore(); 226 TextStore();
228 227
229 void Initialize(HWND window_handle, 228 void Initialize(HWND window_handle,
230 ITfCategoryMgr* category_manager, 229 ITfCategoryMgr* category_manager,
231 ITfDisplayAttributeMgr* display_attribute_manager, 230 ITfDisplayAttributeMgr* display_attribute_manager,
232 ITfInputScope* input_scope, 231 ITfInputScope* input_scope,
233 TextStoreDelegate* delegate); 232 TextStoreDelegate* delegate);
234 233
235 // Checks if the document has a read-only lock. 234 // Checks if the document has a read-only lock.
236 bool HasReadLock() const; 235 bool HasReadLock() const;
237 236
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // attributes of the composition string. 300 // attributes of the composition string.
302 base::win::ScopedComPtr<ITfCategoryMgr> category_manager_; 301 base::win::ScopedComPtr<ITfCategoryMgr> category_manager_;
303 base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_; 302 base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_;
304 303
305 // Represents the context information of this text. 304 // Represents the context information of this text.
306 base::win::ScopedComPtr<ITfInputScope> input_scope_; 305 base::win::ScopedComPtr<ITfInputScope> input_scope_;
307 306
308 // The delegate attached to this text store. 307 // The delegate attached to this text store.
309 TextStoreDelegate* delegate_; 308 TextStoreDelegate* delegate_;
310 309
311 DISALLOW_COPY_AND_ASSIGN(TSFTextStore); 310 DISALLOW_COPY_AND_ASSIGN(TextStore);
312 }; 311 };
313 312
314 } // namespace metro_driver 313 } // namespace metro_driver
315 314
316 #endif // WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ 315 #endif // WIN8_METRO_DRIVER_IME_TEXT_STORE_H_
OLDNEW
« no previous file with comments | « win8/metro_driver/ime/text_service.cc ('k') | win8/metro_driver/ime/text_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698