Index: win8/metro_driver/ime/text_store.h |
diff --git a/ui/base/ime/win/tsf_text_store.h b/win8/metro_driver/ime/text_store.h |
similarity index 74% |
copy from ui/base/ime/win/tsf_text_store.h |
copy to win8/metro_driver/ime/text_store.h |
index 87cd6b42991ed09c07ef272d1781d9d01c37cd76..3ff6011b1ca177a85904c5c12261850f462ab92b 100644 |
--- a/ui/base/ime/win/tsf_text_store.h |
+++ b/win8/metro_driver/ime/text_store.h |
@@ -2,78 +2,80 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef UI_BASE_IME_WIN_TSF_TEXT_STORE_H_ |
-#define UI_BASE_IME_WIN_TSF_TEXT_STORE_H_ |
+#ifndef WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ |
+#define WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ |
+#include <inputscope.h> |
#include <msctf.h> |
+ |
#include <deque> |
+#include <vector> |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
#include "base/strings/string16.h" |
#include "base/win/scoped_comptr.h" |
-#include "ui/base/ime/composition_underline.h" |
-#include "ui/base/ui_export.h" |
-#include "ui/gfx/range/range.h" |
+#include "ui/metro_viewer/ime_types.h" |
+ |
+namespace metro_driver { |
-namespace ui { |
-class TextInputClient; |
+class TextStoreDelegate; |
-// TSFTextStore is used to interact with the input method via TSF manager. |
-// TSFTextStore have a string buffer which is manipulated by TSF manager through |
+// TextStore is used to interact with the input method via TSF manager. |
+// TextStore 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, TextStore calls |
// TextInputClient::SetCompositionText(). And when the input method finishes the |
-// composition, TSFTextStore calls TextInputClient::InsertText() and clears the |
+// composition, TextStore calls TextInputClient::InsertText() and clears the |
// buffer. |
// |
-// How TSFTextStore works: |
+// How TextStore works: |
// - The user enters "a". |
// - The input method set composition as "a". |
-// - TSF manager calls TSFTextStore::RequestLock(). |
-// - TSFTextStore callbacks ITextStoreACPSink::OnLockGranted(). |
+// - TSF manager calls TextStore::RequestLock(). |
+// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). |
// - In OnLockGranted(), TSF manager calls |
-// - TSFTextStore::OnStartComposition() |
-// - TSFTextStore::SetText() |
+// - TextStore::OnStartComposition() |
+// - TextStore::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(). |
+// - TextStore::OnUpdateComposition() |
+// - TextStore::OnEndEdit() |
+// TextStore can get the composition information such as underlines. |
+// - TextStore 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 TextStore::RequestLock(). |
+// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). |
// - In OnLockGranted(), TSF manager calls |
-// - TSFTextStore::SetText() |
+// - TextStore::SetText() |
// The string buffer is set as "A". |
-// - TSFTextStore::OnUpdateComposition() |
-// - TSFTextStore::OnEndEdit() |
-// - TSFTextStore calls TextInputClient::SetCompositionText(). |
+// - TextStore::OnUpdateComposition() |
+// - TextStore::OnEndEdit() |
+// - TextStore 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 TextStore::RequestLock(). |
+// - TextStore callbacks ITextStoreACPSink::OnLockGranted(). |
// - In OnLockGranted(), TSF manager calls |
-// - TSFTextStore::OnEndComposition() |
-// - TSFTextStore::OnEndEdit() |
-// TSFTextStore knows "A" is committed. |
-// - TSFTextStore calls TextInputClient::InsertText(). |
+// - TextStore::OnEndComposition() |
+// - TextStore::OnEndEdit() |
+// TextStore knows "A" is committed. |
+// - TextStore calls TextInputClient::InsertText(). |
// "A" is shown as committed string. |
-// - TSFTextStore clears the string buffer. |
-// - TSFTextStore calls OnSelectionChange(), OnLayoutChange() and |
+// - TextStore clears the string buffer. |
+// - TextStore 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 TextStore 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, TextStore |
// 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,12 +83,14 @@ class TextInputClient; |
// |
// More information about TSF can be found here: |
// http://msdn.microsoft.com/en-us/library/ms629032 |
-class UI_EXPORT TSFTextStore : public ITextStoreACP, |
- public ITfContextOwnerCompositionSink, |
- public ITfTextEditSink { |
+class TextStore : public ITextStoreACP, |
+ public ITfContextOwnerCompositionSink, |
+ public ITfTextEditSink { |
public: |
- TSFTextStore(); |
- virtual ~TSFTextStore(); |
+ TextStore(HWND window_handle, |
+ const std::vector<InputScope>& input_scopes, |
+ TextStoreDelegate* delegate); |
+ virtual ~TextStore(); |
// ITextStoreACP: |
STDMETHOD_(ULONG, AddRef)() OVERRIDE; |
@@ -193,15 +197,10 @@ class UI_EXPORT TSFTextStore : public ITextStoreACP, |
STDMETHOD(OnEndComposition)(ITfCompositionView* composition_view) OVERRIDE; |
// ITfTextEditSink: |
- STDMETHOD(OnEndEdit)(ITfContext* context, TfEditCookie read_only_edit_cookie, |
+ STDMETHOD(OnEndEdit)(ITfContext* context, |
+ 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); |
- |
// Cancels the ongoing composition if exists. |
bool CancelComposition(); |
@@ -212,9 +211,6 @@ class UI_EXPORT TSFTextStore : public ITextStoreACP, |
void SendOnLayoutChange(); |
private: |
- friend class TSFTextStoreTest; |
- friend class TSFTextStoreTestCallback; |
- |
// Checks if the document has a read-only lock. |
bool HasReadLock() const; |
@@ -226,10 +222,11 @@ class UI_EXPORT TSFTextStore : public ITextStoreACP, |
TF_DISPLAYATTRIBUTE* attribute); |
// Gets the committed string size and underline information of the context. |
- bool GetCompositionStatus(ITfContext* context, |
- const TfEditCookie read_only_edit_cookie, |
- size_t* committed_size, |
- CompositionUnderlines* undelines); |
+ bool GetCompositionStatus( |
+ ITfContext* context, |
+ const TfEditCookie read_only_edit_cookie, |
+ size_t* committed_size, |
+ std::vector<metro_viewer::UnderlineInfo>* undelines); |
// The refrence count of this instance. |
volatile LONG ref_count_; |
@@ -240,11 +237,11 @@ class UI_EXPORT 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 SetFocusedTextInputClient. |
+ // HWND of the attached window. |
HWND window_handle_; |
- // Current TextInputClient which is set in SetFocusedTextInputClient. |
- TextInputClient* text_input_client_; |
+ // The delegate attached to this text store. |
+ TextStoreDelegate* delegate_; |
// |string_buffer_| contains committed string and composition string. |
// Example: "aoi" is committed, and "umi" is under composition. |
@@ -256,20 +253,21 @@ class UI_EXPORT TSFTextStore : public ITextStoreACP, |
// |selection_start_| and |selection_end_| indicates the selection range. |
// Example: "iue" is selected |
// |string_buffer_|: "aiueo" |
- // |selection_.start()|: 1 |
- // |selection_.end()|: 4 |
- gfx::Range selection_; |
+ // |selection_start_|: 1 |
+ // |selection_end_|: 4 |
+ size_t selection_start_; |
+ size_t selection_end_; |
// |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" |
// |committed_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_; |
+ // underlines_[0].start_offset: 3 |
+ // underlines_[0].end_offset: 6 |
+ // underlines_[1].start_offset: 6 |
+ // underlines_[1].end_offset: 8 |
+ std::vector<metro_viewer::UnderlineInfo> underlines_; |
// |edit_flag_| indicates that the status is edited during |
// ITextStoreACPSink::OnLockGranted(). |
@@ -288,10 +286,11 @@ class UI_EXPORT TSFTextStore : public ITextStoreACP, |
// attributes of the composition string. |
base::win::ScopedComPtr<ITfCategoryMgr> category_manager_; |
base::win::ScopedComPtr<ITfDisplayAttributeMgr> display_attribute_manager_; |
+ base::win::ScopedComPtr<IUnknown> input_scope_; |
- DISALLOW_COPY_AND_ASSIGN(TSFTextStore); |
+ DISALLOW_COPY_AND_ASSIGN(TextStore); |
}; |
-} // namespace ui |
+} // namespace metro_driver |
-#endif // UI_BASE_IME_WIN_TSF_TEXT_STORE_H_ |
+#endif // WIN8_METRO_DRIVER_IME_TEXT_STORE_H_ |