Chromium Code Reviews| Index: ui/base/win/tsf_text_store.h |
| diff --git a/ui/base/win/tsf_text_store.h b/ui/base/win/tsf_text_store.h |
| index 1fb8253740a599b3c88fb46da12093b5ad3bf357..3cdb9a15e06695e526731c2715c4a3766ecb19c2 100644 |
| --- a/ui/base/win/tsf_text_store.h |
| +++ b/ui/base/win/tsf_text_store.h |
| @@ -6,10 +6,15 @@ |
| #define UI_BASE_WIN_TSF_TEXT_STORE_H_ |
| #include <msctf.h> |
| +#include <deque> |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
|
Seigo Nonaka
2012/08/21 12:22:41
We can omit this line.
horo
2012/08/21 13:59:57
Done.
|
| #include "base/win/scoped_comptr.h" |
| +#include "ui/base/ime/composition_underline.h" |
| +#include "ui/base/ime/text_input_client.h" |
|
Seigo Nonaka
2012/08/21 12:22:41
plz use forward declaration instead.
horo
2012/08/21 13:59:57
Done.
|
| +#include "ui/base/ui_export.h" |
|
Seigo Nonaka
2012/08/21 12:22:41
Do you need UI_EXPORT?
horo
2012/08/21 13:59:57
deleted
|
| namespace ui { |
| @@ -19,7 +24,7 @@ class TsfTextStore : public ITextStoreACP, |
| public ITfTextEditSink { |
| public: |
| TsfTextStore(); |
| - ~TsfTextStore(); |
| + virtual ~TsfTextStore(); |
| virtual ULONG STDMETHODCALLTYPE AddRef() OVERRIDE; |
| virtual ULONG STDMETHODCALLTYPE Release() OVERRIDE; |
| @@ -144,7 +149,15 @@ class TsfTextStore : public ITextStoreACP, |
| TfEditCookie read_only_edit_cookie, |
| ITfEditRecord* edit_record) OVERRIDE; |
| + // Sets currently focused TextInputClient. |
| + void SetFocusedTextInputClient(HWND focused_window, |
| + TextInputClient* text_input_client); |
| + // Removes currently focused TextInputClient. |
| + void RemoveFocusedTextInputClient(TextInputClient* text_input_client); |
| + |
| private: |
| + friend class TsfTextStoreTest; |
| + |
| // The refrence count of this instance. |
| volatile LONG ref_count_; |
| @@ -154,9 +167,96 @@ class TsfTextStore : public ITextStoreACP, |
| // The current mask of |text_store_acp_sink_|. |
| DWORD text_store_acp_sink_mask_; |
| + // HWND of the current view window which is set in SetFocus(). |
|
Seigo Nonaka
2012/08/21 12:22:41
nit: SetFocusedTextInputClient
horo
2012/08/21 13:59:57
Done.
|
| + HWND hwnd_; |
| + |
| + // Current TextInputClien which is set in SetFocus(). |
|
Seigo Nonaka
2012/08/21 12:22:41
/TextInputClien/TextInputClient/
/SetFocus/SetFocu
horo
2012/08/21 13:59:57
Done.
|
| + TextInputClient* text_input_client_; |
| + |
| + // Current status of the text store. |
| + struct TextStoreStatus { |
| + public: |
| + TextStoreStatus() : commited_size_(0), selection_start_(0), |
|
Seigo Nonaka
2012/08/21 12:22:41
Plz initialize one line one variable.
http://googl
horo
2012/08/21 13:59:57
Done.
|
| + selection_end_(0), edit_flag_(false) { |
| + } |
| + void InsertText(int nPos, const string16 &buffer){ |
|
Seigo Nonaka
2012/08/21 12:22:41
/string16 &/string16& /
Seigo Nonaka
2012/08/21 12:22:41
nit: /nPos/position/
horo
2012/08/21 13:59:57
Done.
horo
2012/08/21 13:59:57
Done.
|
| + string_buffer_ = string_buffer_.substr(0, nPos) + |
| + buffer + string_buffer_.substr(nPos); |
| + } |
| + void RemoveText(size_t pos, size_t count) { |
| + string_buffer_ = string_buffer_.substr(0, pos) + |
| + string_buffer_.substr(pos + count); |
| + } |
| + void MoveSelection(size_t selection_start, size_t selection_end) { |
| + size_t nTextLength = string_buffer_.length(); |
| + if (selection_start >= nTextLength) |
| + selection_start = nTextLength; |
| + if (selection_end >= nTextLength) |
| + selection_end = nTextLength; |
| + selection_start_ = selection_start; |
| + selection_end_ = selection_end; |
| + } |
| + |
| + // |string_buffer_| contains commited string and composition string. |
| + // example: "aoi" is committed, and "umi" is under composition. |
| + // |string_buffer_|: "aoiumi" |
| + // |commited_size_|: 3 |
| + string16 string_buffer_; |
| + size_t commited_size_; |
| + |
| + // |selection_start_| and |selection_end_| indicates the selection range. |
| + // example: "iue" is selected |
| + // |string_buffer_|: "aiueo" |
| + // |selection_start_|: 1 |
| + // |selection_end_|: 4 |
| + size_t selection_start_; |
| + size_t selection_end_; |
|
Seigo Nonaka
2012/08/21 12:22:41
How about introduce ui::Range object?
horo
2012/08/21 13:59:57
Done.
|
| + |
| + // |start_offset| and |end_offset| of |composition_undelines_| indicates |
| + // the offsets in |string_buffer_|. |
| + // example: "aoi" is committed. There are two underlines in "umi" and "no". |
| + // |string_buffer_|: "aoiumino" |
| + // |commited_size_|: 3 |
| + // composition_undelines_.underlines[0].start_offset: 3 |
| + // composition_undelines_.underlines[0].end_offset: 6 |
| + // composition_undelines_.underlines[1].start_offset: 6 |
| + // composition_undelines_.underlines[1].end_offset: 8 |
| + CompositionUnderlines composition_undelines_; |
| + |
| + // |edit_flag_| indicates that the status is edited during |
| + // ITextStoreACPSink::OnLockGranted(). |
| + bool edit_flag_; |
| + } status_; |
| + |
| + // The type of current lock. |
| + // 0: No lock. |
| + // TS_LF_READ: read-only lock. |
| + // TS_LF_READWRITE: read/write lock. |
| + DWORD current_lock_type_; |
| + // Queue of the lock request used in RequestLock(). |
|
Seigo Nonaka
2012/08/21 12:22:41
Please add one line before line comment.
horo
2012/08/21 13:59:57
Done.
|
| + std::deque<DWORD> lock_queue_; |
| + // Check if the document has a read-only lock. |
| + bool ReaderLocked() const; |
| + // Check if the document has a read and write lock. |
| + bool WriterLocked() const; |
| + |
| + // Category manager and Display attribute manager are used to obtain the |
| + // attributes of the composition string. |
| + base::win::ScopedComPtr<ITfCategoryMgr> category_mgr_; |
|
Seigo Nonaka
2012/08/21 12:22:41
Plz do not abbreviate the variables.
http://google
horo
2012/08/21 13:59:57
Done.
|
| + base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_mgr_; |
| + |
| + // Gets the display attribute structure. |
| + bool GetDisplayAttribute(TfGuidAtom guid_atom, |
| + TF_DISPLAYATTRIBUTE* attribute); |
| + |
| + // Gets the commited string size and underline information of the context. |
| + bool GetCompositionStatus(ITfContext* context, |
| + const TfEditCookie read_only_edit_cookie, |
| + size_t* commited_size, |
| + CompositionUnderlines* undelines); |
| DISALLOW_COPY_AND_ASSIGN(TsfTextStore); |
| }; |
| } // namespace ui |
| -#endif // UI_BASE_WIN_TSF_TEXT_STORE_H_ |
| +#endif // UI_BASE_WIN_TSF_TEXT_STORE_H_ |