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

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: Created 8 years, 3 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
164 // Checks if the document has a read-only lock.
165 bool HasReadLock() const;
166
167 // Checks if the document has a read and write lock.
168 bool HasReadWriteLock() const;
169
170 // Gets the display attribute structure.
171 bool GetDisplayAttribute(TfGuidAtom guid_atom,
172 TF_DISPLAYATTRIBUTE* attribute);
173
174 // Gets the committed string size and underline information of the context.
175 bool GetCompositionStatus(ITfContext* context,
176 const TfEditCookie read_only_edit_cookie,
177 size_t* committed_size,
178 CompositionUnderlines* undelines);
179
148 // The refrence count of this instance. 180 // The refrence count of this instance.
149 volatile LONG ref_count_; 181 volatile LONG ref_count_;
150 182
151 // A pointer of ITextStoreACPSink, this instance is given in AdviseSink. 183 // A pointer of ITextStoreACPSink, this instance is given in AdviseSink.
152 base::win::ScopedComPtr<ITextStoreACPSink> text_store_acp_sink_; 184 base::win::ScopedComPtr<ITextStoreACPSink> text_store_acp_sink_;
153 185
154 // The current mask of |text_store_acp_sink_|. 186 // The current mask of |text_store_acp_sink_|.
155 DWORD text_store_acp_sink_mask_; 187 DWORD text_store_acp_sink_mask_;
156 188
189 // HWND of the current view window which is set in SetFocusedTextInputClient.
190 HWND hwnd_;
Yohei Yukawa 2012/08/23 04:10:27 window_handle_ might be better.
horo 2012/08/23 04:39:44 Done.
191
192 // Current TextInputClient which is set in SetFocusedTextInputClient.
193 TextInputClient* text_input_client_;
194
195 // |string_buffer_| contains committed string and composition string.
196 // example: "aoi" is committed, and "umi" is under composition.
197 // |string_buffer_|: "aoiumi"
198 // |committed_size_|: 3
199 string16 string_buffer_;
200 size_t committed_size_;
201
202 // |selection_start_| and |selection_end_| indicates the selection range.
203 // example: "iue" is selected
204 // |string_buffer_|: "aiueo"
205 // |selection_.start()|: 1
206 // |selection_.end()|: 4
207 Range selection_;
208
209 // |start_offset| and |end_offset| of |composition_undelines_| indicates
210 // the offsets in |string_buffer_|.
211 // example: "aoi" is committed. There are two underlines in "umi" and "no".
212 // |string_buffer_|: "aoiumino"
213 // |committed_size_|: 3
214 // composition_undelines_.underlines[0].start_offset: 3
215 // composition_undelines_.underlines[0].end_offset: 6
216 // composition_undelines_.underlines[1].start_offset: 6
217 // composition_undelines_.underlines[1].end_offset: 8
218 CompositionUnderlines composition_undelines_;
219
220 // |edit_flag_| indicates that the status is edited during
221 // ITextStoreACPSink::OnLockGranted().
222 bool edit_flag_;
223
224 // The type of current lock.
225 // 0: No lock.
226 // TS_LF_READ: read-only lock.
227 // TS_LF_READWRITE: read/write lock.
228 DWORD current_lock_type_;
229
230 // Queue of the lock request used in RequestLock().
231 std::deque<DWORD> lock_queue_;
232
233 // Category manager and Display attribute manager are used to obtain the
234 // attributes of the composition string.
235 base::win::ScopedComPtr<ITfCategoryMgr> category_manager_;
236 base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_;
237
157 DISALLOW_COPY_AND_ASSIGN(TsfTextStore); 238 DISALLOW_COPY_AND_ASSIGN(TsfTextStore);
158 }; 239 };
159 240
160 } // namespace ui 241 } // namespace ui
161 242
162 #endif // UI_BASE_WIN_TSF_TEXT_STORE_H_ 243 #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