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

Side by Side Diff: ui/base/win/tsf_text_store.h

Issue 10831403: TsfTextStore implementation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reflected code review meeting Created 8 years, 4 months 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 | « no previous file | ui/base/win/tsf_text_store.cc » ('j') | ui/base/win/tsf_text_store.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_BASE_WIN_TSF_TEXT_STORE_H_ 5 #ifndef UI_BASE_WIN_TSF_TEXT_STORE_H_
6 #define UI_BASE_WIN_TSF_TEXT_STORE_H_ 6 #define UI_BASE_WIN_TSF_TEXT_STORE_H_
7 7
8 #include <msctf.h> 8 #include <msctf.h>
9 #include <deque>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/string16.h"
12 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
15 #include "ui/base/ime/composition_underline.h"
16 #include "ui/base/range/range.h"
13 17
14 namespace ui { 18 namespace ui {
19 class TextInputClient;
15 20
16 // TsfTextStore is used to interact with the system input method via TSF. 21 // TsfTextStore is used to interact with the system input method via TSF.
17 class TsfTextStore : public ITextStoreACP, 22 class TsfTextStore : public ITextStoreACP,
18 public ITfContextOwnerCompositionSink, 23 public ITfContextOwnerCompositionSink,
19 public ITfTextEditSink { 24 public ITfTextEditSink {
20 public: 25 public:
21 TsfTextStore(); 26 TsfTextStore();
22 ~TsfTextStore(); 27 virtual ~TsfTextStore();
23 28
24 virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; 29 virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE;
25 virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE; 30 virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE;
26 31
27 // Subclasses should extend this to return any interfaces they provide. 32 // Subclasses should extend this to return any interfaces they provide.
28 virtual STDMETHODIMP QueryInterface(REFIID iid, void** ppv) OVERRIDE; 33 virtual STDMETHODIMP QueryInterface(REFIID iid, void** ppv) OVERRIDE;
29 34
30 // ITextStoreACP overrides. 35 // ITextStoreACP overrides.
31 virtual STDMETHODIMP AdviseSink(REFIID iid, IUnknown* unknown, 36 virtual STDMETHODIMP AdviseSink(REFIID iid, IUnknown* unknown,
32 DWORD mask) OVERRIDE; 37 DWORD mask) OVERRIDE;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 virtual STDMETHODIMP OnUpdateComposition(ITfCompositionView* composition_view, 142 virtual STDMETHODIMP OnUpdateComposition(ITfCompositionView* composition_view,
138 ITfRange* range) OVERRIDE; 143 ITfRange* range) OVERRIDE;
139 virtual STDMETHODIMP OnEndComposition( 144 virtual STDMETHODIMP OnEndComposition(
140 ITfCompositionView* composition_view) OVERRIDE; 145 ITfCompositionView* composition_view) OVERRIDE;
141 146
142 // ITfTextEditSink overrides. 147 // ITfTextEditSink overrides.
143 virtual STDMETHODIMP OnEndEdit(ITfContext* context, 148 virtual STDMETHODIMP OnEndEdit(ITfContext* context,
144 TfEditCookie read_only_edit_cookie, 149 TfEditCookie read_only_edit_cookie,
145 ITfEditRecord* edit_record) OVERRIDE; 150 ITfEditRecord* edit_record) OVERRIDE;
146 151
152 // Sets currently focused TextInputClient.
153 void SetFocusedTextInputClient(HWND focused_window,
154 TextInputClient* text_input_client);
155 // Removes currently focused TextInputClient.
156 void RemoveFocusedTextInputClient(TextInputClient* text_input_client);
157
158 // Sends OnLayoutChange() via |text_store_acp_sink_|.
159 void SendOnLayoutChange();
160
147 private: 161 private:
162 friend class TsfTextStoreTest;
163
148 // The refrence count of this instance. 164 // The refrence count of this instance.
149 volatile LONG ref_count_; 165 volatile LONG ref_count_;
150 166
151 // A pointer of ITextStoreACPSink, this instance is given in AdviseSink. 167 // A pointer of ITextStoreACPSink, this instance is given in AdviseSink.
152 base::win::ScopedComPtr<ITextStoreACPSink> text_store_acp_sink_; 168 base::win::ScopedComPtr<ITextStoreACPSink> text_store_acp_sink_;
153 169
154 // The current mask of |text_store_acp_sink_|. 170 // The current mask of |text_store_acp_sink_|.
155 DWORD text_store_acp_sink_mask_; 171 DWORD text_store_acp_sink_mask_;
156 172
173 // HWND of the current view window which is set in SetFocusedTextInputClient.
174 HWND hwnd_;
175
176 // Current TextInputClient which is set in SetFocusedTextInputClient.
177 TextInputClient* text_input_client_;
178
179 // |string_buffer_| contains committed string and composition string.
180 // example: "aoi" is committed, and "umi" is under composition.
181 // |string_buffer_|: "aoiumi"
182 // |committed_size_|: 3
183 string16 string_buffer_;
184 size_t committed_size_;
185
186 // |selection_start_| and |selection_end_| indicates the selection range.
187 // example: "iue" is selected
188 // |string_buffer_|: "aiueo"
189 // |selection_.start()|: 1
190 // |selection_.end()|: 4
191 Range selection_;
192
193 // |start_offset| and |end_offset| of |composition_undelines_| indicates
194 // the offsets in |string_buffer_|.
195 // example: "aoi" is committed. There are two underlines in "umi" and "no".
196 // |string_buffer_|: "aoiumino"
197 // |committed_size_|: 3
198 // composition_undelines_.underlines[0].start_offset: 3
199 // composition_undelines_.underlines[0].end_offset: 6
200 // composition_undelines_.underlines[1].start_offset: 6
201 // composition_undelines_.underlines[1].end_offset: 8
202 CompositionUnderlines composition_undelines_;
203
204 // |edit_flag_| indicates that the status is edited during
205 // ITextStoreACPSink::OnLockGranted().
206 bool edit_flag_;
207
208 // The type of current lock.
209 // 0: No lock.
210 // TS_LF_READ: read-only lock.
211 // TS_LF_READWRITE: read/write lock.
212 DWORD current_lock_type_;
213
214 // Queue of the lock request used in RequestLock().
215 std::deque<DWORD> lock_queue_;
216
217 // Check if the document has a read-only lock.
Seigo Nonaka 2012/08/22 16:44:19 /Check/Checks/ and move to L163
horo 2012/08/23 01:06:51 Done.
218 bool HasReadLock() const;
219
220 // Check if the document has a read and write lock.
221 bool HasReadWriteLock() const;
Seigo Nonaka 2012/08/22 16:44:19 ditto
horo 2012/08/23 01:06:51 Done.
222
223 // Category manager and Display attribute manager are used to obtain the
224 // attributes of the composition string.
225 base::win::ScopedComPtr<ITfCategoryMgr> category_manager_;
226 base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_;
227
228 // Gets the display attribute structure.
229 bool GetDisplayAttribute(TfGuidAtom guid_atom,
230 TF_DISPLAYATTRIBUTE* attribute);
Seigo Nonaka 2012/08/22 16:44:19 move to L163
horo 2012/08/23 01:06:51 Done.
231
232 // Gets the committed string size and underline information of the context.
233 bool GetCompositionStatus(ITfContext* context,
234 const TfEditCookie read_only_edit_cookie,
235 size_t* committed_size,
236 CompositionUnderlines* undelines);
Seigo Nonaka 2012/08/22 16:44:19 ditto
horo 2012/08/23 01:06:51 Done.
157 DISALLOW_COPY_AND_ASSIGN(TsfTextStore); 237 DISALLOW_COPY_AND_ASSIGN(TsfTextStore);
158 }; 238 };
159 239
160 } // namespace ui 240 } // namespace ui
161 241
162 #endif // UI_BASE_WIN_TSF_TEXT_STORE_H_ 242 #endif // UI_BASE_WIN_TSF_TEXT_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/win/tsf_text_store.cc » ('j') | ui/base/win/tsf_text_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698