Index: views/controls/textfield/native_textfield_views.h |
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h |
index a28dc697911ec6c4a29b7bad0b7bb42ba724ef2e..4095f0b22d2251b0f84f9123f81cfdf29b9d5a72 100644 |
--- a/views/controls/textfield/native_textfield_views.h |
+++ b/views/controls/textfield/native_textfield_views.h |
@@ -12,6 +12,8 @@ |
#include "ui/gfx/font.h" |
#include "views/border.h" |
#include "views/controls/textfield/native_textfield_wrapper.h" |
+#include "views/controls/textfield/textfield_views_model.h" |
+#include "views/ime/text_input_client.h" |
#include "views/view.h" |
namespace base { |
@@ -26,7 +28,6 @@ namespace views { |
class KeyEvent; |
class Menu2; |
-class TextfieldViewsModel; |
// A views/skia only implementation of NativeTextfieldWrapper. |
// No platform specific code is used. |
@@ -41,7 +42,9 @@ class TextfieldViewsModel; |
class NativeTextfieldViews : public views::View, |
public views::ContextMenuController, |
public NativeTextfieldWrapper, |
- public ui::SimpleMenuModel::Delegate { |
+ public ui::SimpleMenuModel::Delegate, |
+ public TextInputClient, |
+ public TextfieldViewsModel::Delegate { |
public: |
explicit NativeTextfieldViews(Textfield* parent); |
~NativeTextfieldViews(); |
@@ -92,6 +95,7 @@ class NativeTextfieldViews : public views::View, |
virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE; |
virtual void HandleFocus() OVERRIDE; |
virtual void HandleBlur() OVERRIDE; |
+ virtual TextInputClient* GetTextInputClient() OVERRIDE; |
// ui::SimpleMenuModel::Delegate overrides |
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
@@ -149,6 +153,30 @@ class NativeTextfieldViews : public views::View, |
DISALLOW_COPY_AND_ASSIGN(TextfieldBorder); |
}; |
+ // Overridden from TextInputClient: |
+ virtual void SetComposition(const ui::Composition& composition) OVERRIDE; |
+ virtual void ConfirmComposition() OVERRIDE; |
+ virtual void ClearComposition() OVERRIDE; |
+ virtual void InsertText(const string16& text) OVERRIDE; |
+ virtual void InsertChar(char16 ch, int flags) OVERRIDE; |
+ virtual ui::TextInputType GetTextInputType() OVERRIDE; |
+ virtual gfx::Rect GetCaretBounds() OVERRIDE; |
+ virtual bool HasComposition() OVERRIDE; |
+ virtual bool GetTextRange(ui::Range* range) OVERRIDE; |
+ virtual bool GetCompositionRange(ui::Range* range) OVERRIDE; |
+ virtual bool GetSelectionRange(ui::Range* range) OVERRIDE; |
+ virtual bool SetSelectionRange(const ui::Range& range) OVERRIDE; |
+ virtual bool DeleteRange(const ui::Range& range) OVERRIDE; |
+ virtual bool GetTextFromRange( |
+ const ui::Range& range, |
+ const base::Callback<void(string16)>& callback) OVERRIDE; |
+ virtual void OnInputMethodChanged() OVERRIDE; |
+ virtual bool ChangeTextDirectionAndLayoutAlignment( |
+ base::i18n::TextDirection direction) OVERRIDE; |
+ |
+ // Overridden from TextfieldViewsModel::Delegate: |
+ virtual void OnCompositionConfirmedOrCleared() OVERRIDE; |
+ |
// Returns the Textfield's font. |
const gfx::Font& GetFont() const; |
@@ -190,6 +218,15 @@ class NativeTextfieldViews : public views::View, |
// Utility function to create the context menu if one does not already exist. |
void InitContextMenuIfRequired(); |
+ // Convenience method to call InputMethod::OnTextInputTypeChanged(); |
+ void OnTextInputTypeChanged(); |
+ |
+ // Convenience method to call InputMethod::OnCaretBoundsChanged(); |
+ void OnCaretBoundsChanged(); |
+ |
+ // Convenience method to call InputMethod::CancelComposition(); |
+ void CancelComposition(); |
+ |
// Convenience method to call TextfieldController::OnBeforeUserAction(); |
void OnBeforeUserAction(); |
@@ -220,6 +257,9 @@ class NativeTextfieldViews : public views::View, |
// The drawing state of cursor. True to draw. |
bool is_cursor_visible_; |
+ // True if CancelComposition() should not be called. |
+ bool skip_cancel_composition_; |
+ |
// A runnable method factory for callback to update the cursor. |
ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_; |