diff options
Diffstat (limited to 'views/ime')
-rw-r--r-- | views/ime/input_method.h | 7 | ||||
-rw-r--r-- | views/ime/input_method_base.cc | 9 | ||||
-rw-r--r-- | views/ime/input_method_base.h | 11 | ||||
-rw-r--r-- | views/ime/input_method_gtk.cc | 8 | ||||
-rw-r--r-- | views/ime/input_method_gtk.h | 2 | ||||
-rw-r--r-- | views/ime/input_method_ibus.cc | 10 | ||||
-rw-r--r-- | views/ime/input_method_ibus.h | 2 | ||||
-rw-r--r-- | views/ime/input_method_wayland.cc | 2 | ||||
-rw-r--r-- | views/ime/input_method_win.cc | 6 | ||||
-rw-r--r-- | views/ime/mock_input_method.cc | 5 | ||||
-rw-r--r-- | views/ime/mock_input_method.h | 1 | ||||
-rw-r--r-- | views/ime/text_input_client.h | 125 |
12 files changed, 41 insertions, 147 deletions
diff --git a/views/ime/input_method.h b/views/ime/input_method.h index 1c7df22..4ec9523 100644 --- a/views/ime/input_method.h +++ b/views/ime/input_method.h @@ -13,6 +13,10 @@ #include "ui/base/ime/text_input_type.h" #include "views/views_export.h" +namespace ui { +class TextInputClient; +} // namespace ui + namespace views { namespace internal { @@ -20,7 +24,6 @@ class InputMethodDelegate; } // namespace internal class KeyEvent; -class TextInputClient; class View; class Widget; @@ -96,7 +99,7 @@ class VIEWS_EXPORT InputMethod { // Gets the focused text input client. Returns NULL if the Widget is not // focused, or there is no focused View or the focused View doesn't support // text input. - virtual TextInputClient* GetTextInputClient() const = 0; + virtual ui::TextInputClient* GetTextInputClient() const = 0; // Gets the text input type of the focused text input client. Returns // ui::TEXT_INPUT_TYPE_NONE if there is no focused text input client. diff --git a/views/ime/input_method_base.cc b/views/ime/input_method_base.cc index 6155ccd..1fb0a15 100644 --- a/views/ime/input_method_base.cc +++ b/views/ime/input_method_base.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ui/base/ime/text_input_client.h" #include "views/ime/input_method_base.h" #include "views/ime/text_input_type_tracker.h" #include "views/view.h" @@ -70,13 +71,13 @@ void InputMethodBase::OnTextInputTypeChanged(View* view) { } } -TextInputClient* InputMethodBase::GetTextInputClient() const { +ui::TextInputClient* InputMethodBase::GetTextInputClient() const { return (widget_focused_ && GetFocusedView()) ? GetFocusedView()->GetTextInputClient() : NULL; } ui::TextInputType InputMethodBase::GetTextInputType() const { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); return client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; } @@ -103,7 +104,7 @@ bool InputMethodBase::IsTextInputTypeNone() const { } void InputMethodBase::OnInputMethodChanged() const { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) client->OnInputMethodChanged(); } @@ -115,7 +116,7 @@ void InputMethodBase::DispatchKeyEventPostIME(const KeyEvent& key) const { bool InputMethodBase::GetCaretBoundsInWidget(gfx::Rect* rect) const { DCHECK(rect); - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (!client || client->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) return false; diff --git a/views/ime/input_method_base.h b/views/ime/input_method_base.h index e657e22..751757a 100644 --- a/views/ime/input_method_base.h +++ b/views/ime/input_method_base.h @@ -11,7 +11,14 @@ #include "views/focus/focus_manager.h" #include "views/ime/input_method.h" #include "views/ime/input_method_delegate.h" -#include "views/ime/text_input_client.h" + +namespace gfx { +class Rect; +} // namespace gfx + +namespace ui { +class TextInputClient; +} // namespace ui namespace views { @@ -46,7 +53,7 @@ class VIEWS_EXPORT InputMethodBase : public InputMethod, // implementation. virtual void OnTextInputTypeChanged(View* view) OVERRIDE; - virtual TextInputClient* GetTextInputClient() const OVERRIDE; + virtual ui::TextInputClient* GetTextInputClient() const OVERRIDE; virtual ui::TextInputType GetTextInputType() const OVERRIDE; virtual bool IsMock() const OVERRIDE; diff --git a/views/ime/input_method_gtk.cc b/views/ime/input_method_gtk.cc index ee1dabb..50fd37e 100644 --- a/views/ime/input_method_gtk.cc +++ b/views/ime/input_method_gtk.cc @@ -209,7 +209,7 @@ void InputMethodGtk::OnDidChangeFocus(View* focused_before, View* focused) { } void InputMethodGtk::ConfirmCompositionText() { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->HasCompositionText()) client->ConfirmCompositionText(); @@ -297,14 +297,14 @@ void InputMethodGtk::ProcessUnfilteredKeyPressEvent(const KeyEvent& key) { // event (ctrl-a, return, tab, etc.). We need to send the character to the // focused text input client by calling TextInputClient::InsertChar(). char16 ch = key.GetCharacter(); - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (ch && client) client->InsertChar(ch, key.flags()); } void InputMethodGtk::ProcessInputMethodResult(const KeyEvent& key, bool filtered) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); DCHECK(client); if (result_text_.length()) { @@ -427,7 +427,7 @@ void InputMethodGtk::OnPreeditEnd(GtkIMContext* context) { composition_.Clear(); if (!handling_key_event_) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->HasCompositionText()) client->ClearCompositionText(); } diff --git a/views/ime/input_method_gtk.h b/views/ime/input_method_gtk.h index fe323ea..4e40409 100644 --- a/views/ime/input_method_gtk.h +++ b/views/ime/input_method_gtk.h @@ -11,6 +11,8 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "ui/base/gtk/gtk_signal.h" +#include "ui/base/ime/composition_text.h" +#include "ui/base/ime/text_input_client.h" #include "views/ime/input_method_base.h" #include "views/view.h" diff --git a/views/ime/input_method_ibus.cc b/views/ime/input_method_ibus.cc index a9fa1c3..c9090ff 100644 --- a/views/ime/input_method_ibus.cc +++ b/views/ime/input_method_ibus.cc @@ -596,7 +596,7 @@ void InputMethodIBus::DestroyContext() { } void InputMethodIBus::ConfirmCompositionText() { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->HasCompositionText()) client->ConfirmCompositionText(); @@ -744,7 +744,7 @@ void InputMethodIBus::ProcessUnfilteredKeyPressEvent(const KeyEvent& key, if (character_composer_.FilterKeyPress(ibus_keyval)) { string16 composed = character_composer_.composed_character(); if (!composed.empty()) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client) client->InsertText(composed); } @@ -754,7 +754,7 @@ void InputMethodIBus::ProcessUnfilteredKeyPressEvent(const KeyEvent& key, // then it means the key event didn't generate any result text. So we need // to send corresponding character to the focused text input client. - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); char16 ch = key.GetCharacter(); if (ch && client) client->InsertChar(ch, key.flags()); @@ -762,7 +762,7 @@ void InputMethodIBus::ProcessUnfilteredKeyPressEvent(const KeyEvent& key, void InputMethodIBus::ProcessInputMethodResult(const KeyEvent& key, bool filtered) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); DCHECK(client); if (result_text_.length()) { @@ -939,7 +939,7 @@ void InputMethodIBus::OnHidePreeditText(IBusInputContext* context) { composition_.Clear(); if (pending_key_events_.empty()) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->HasCompositionText()) client->ClearCompositionText(); composition_changed_ = false; diff --git a/views/ime/input_method_ibus.h b/views/ime/input_method_ibus.h index d07a457..c9fd102 100644 --- a/views/ime/input_method_ibus.h +++ b/views/ime/input_method_ibus.h @@ -15,6 +15,8 @@ #include "ui/base/glib/glib_integers.h" #include "ui/base/glib/glib_signal.h" #include "ui/base/ime/character_composer.h" +#include "ui/base/ime/composition_text.h" +#include "ui/base/ime/text_input_client.h" #include "views/events/event.h" #include "views/ime/input_method_base.h" #include "views/view.h" diff --git a/views/ime/input_method_wayland.cc b/views/ime/input_method_wayland.cc index 20d3ff2..4b90b2b 100644 --- a/views/ime/input_method_wayland.cc +++ b/views/ime/input_method_wayland.cc @@ -68,7 +68,7 @@ void InputMethodWayland::ProcessKeyPressEvent(const KeyEvent& key) { // event (ctrl-a, return, tab, etc.). We need to send the character to the // focused text input client by calling TextInputClient::InsertChar(). char16 ch = key.GetCharacter(); - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (ch && client) client->InsertChar(ch, key.flags()); } diff --git a/views/ime/input_method_win.cc b/views/ime/input_method_win.cc index 12ae2f4..748df76 100644 --- a/views/ime/input_method_win.cc +++ b/views/ime/input_method_win.cc @@ -7,6 +7,8 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/string_util.h" +#include "ui/base/ime/composition_text.h" +#include "ui/base/ime/text_input_client.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/events/event.h" @@ -285,7 +287,7 @@ LRESULT InputMethodWin::OnDeadChar( } LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING* reconv) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (!client) return 0; @@ -348,7 +350,7 @@ LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING* reconv) { } LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING* reconv) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (!client) return 0; diff --git a/views/ime/mock_input_method.cc b/views/ime/mock_input_method.cc index 07dca3ac..5a227b7 100644 --- a/views/ime/mock_input_method.cc +++ b/views/ime/mock_input_method.cc @@ -6,6 +6,7 @@ #include "base/basictypes.h" #include "base/logging.h" +#include "ui/base/ime/text_input_client.h" #include "ui/base/keycodes/keyboard_codes.h" #include "views/events/event.h" #include "views/widget/widget.h" @@ -57,7 +58,7 @@ void MockInputMethod::DispatchKeyEvent(const KeyEvent& key) { if (focus_changed_) return; - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client) { if (handled) { if (result_text_.length()) @@ -112,7 +113,7 @@ bool MockInputMethod::IsMock() const { } void MockInputMethod::OnWillChangeFocus(View* focused_before, View* focused) { - TextInputClient* client = GetTextInputClient(); + ui::TextInputClient* client = GetTextInputClient(); if (client && client->HasCompositionText()) client->ConfirmCompositionText(); focus_changed_ = true; diff --git a/views/ime/mock_input_method.h b/views/ime/mock_input_method.h index 01373eb..b3392c1 100644 --- a/views/ime/mock_input_method.h +++ b/views/ime/mock_input_method.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "ui/base/ime/composition_text.h" #include "views/ime/input_method_base.h" #include "views/view.h" diff --git a/views/ime/text_input_client.h b/views/ime/text_input_client.h deleted file mode 100644 index a0dd86a3..0000000 --- a/views/ime/text_input_client.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef VIEWS_IME_TEXT_INPUT_CLIENT_H_ -#define VIEWS_IME_TEXT_INPUT_CLIENT_H_ -#pragma once - -#include <vector> - -#include "base/basictypes.h" -#include "base/string16.h" -#include "ui/base/ime/composition_text.h" -#include "ui/base/ime/text_input_type.h" -#include "ui/base/range/range.h" -#include "views/views_export.h" - -namespace gfx { -class Rect; -} - -namespace views { - -class View; - -// An interface implemented by a View that needs text input support. -class VIEWS_EXPORT TextInputClient { - public: - virtual ~TextInputClient() {} - - // Input method result ------------------------------------------------------- - - // Sets composition text and attributes. If there is composition text already, - // it’ll be replaced by the new one. Otherwise, current selection will be - // replaced. If there is no selection, the composition text will be inserted - // at the insertion point. - virtual void SetCompositionText(const ui::CompositionText& composition) = 0; - - // Converts current composition text into final content. - virtual void ConfirmCompositionText() = 0; - - // Removes current composition text. - virtual void ClearCompositionText() = 0; - - // Inserts a given text at the insertion point. Current composition text or - // selection will be removed. This method should never be called when the - // current text input type is TEXT_INPUT_TYPE_NONE. - virtual void InsertText(const string16& text) = 0; - - // Inserts a single char at the insertion point. Unlike above InsertText() - // method, this method has an extra |flags| parameter indicating the modifier - // key states when the character is generated. This method should only be - // called when a key press is not handled by the input method but still - // generates a character (eg. by the keyboard driver). In another word, the - // preceding key press event should not be a VKEY_PROCESSKEY. - // This method will be called whenever a char is generated by the keyboard, - // even if the current text input type is TEXT_INPUT_TYPE_NONE. - virtual void InsertChar(char16 ch, int flags) = 0; - - // Input context information ------------------------------------------------- - - // Returns current text input type. It could be changed and even becomes - // TEXT_INPUT_TYPE_NONE at runtime. - virtual ui::TextInputType GetTextInputType() const = 0; - - // Returns current caret (insertion point) bounds relative to the View’s - // coordinates. If there is selection, then the selection bounds will be - // returned. - virtual gfx::Rect GetCaretBounds() = 0; - - // Returns true if there is composition text. - virtual bool HasCompositionText() = 0; - - // Document content operations ---------------------------------------------- - - // Retrieves the UTF-16 based character range containing accessibled text in - // the View. It must cover the composition and selection range. - // Returns false if the information cannot be retrieved right now. - virtual bool GetTextRange(ui::Range* range) = 0; - - // Retrieves the UTF-16 based character range of current composition text. - // Returns false if the information cannot be retrieved right now. - virtual bool GetCompositionTextRange(ui::Range* range) = 0; - - // Retrieves the UTF-16 based character range of current selection. - // Returns false if the information cannot be retrieved right now. - virtual bool GetSelectionRange(ui::Range* range) = 0; - - // Selects the given UTF-16 based character range. Current composition text - // will be confirmed before selecting the range. - // Returns false if the operation is not supported. - virtual bool SetSelectionRange(const ui::Range& range) = 0; - - // Deletes contents in the given UTF-16 based character range. Current - // composition text will be confirmed before deleting the range. - // The input caret will be moved to the place where the range gets deleted. - // Returns false if the oepration is not supported. - virtual bool DeleteRange(const ui::Range& range) = 0; - - // Retrieves the text content in a given UTF-16 based character range. - // The result will be stored into |*text|. - // Returns false if the operation is not supported or the specified range - // is out of the text range returned by GetTextRange(). - virtual bool GetTextFromRange(const ui::Range& range, string16* text) = 0; - - // Miscellaneous ------------------------------------------------------------ - - // Called whenever current keyboard layout or input method is changed, - // especially the change of input locale and text direction. - virtual void OnInputMethodChanged() = 0; - - // Called whenever the user requests to change the text direction and layout - // alignment of the current text box. It’s for supporting ctrl-shift on - // Windows. - // Returns false if the operation is not supported. - virtual bool ChangeTextDirectionAndLayoutAlignment( - base::i18n::TextDirection direction) = 0; - - // Gets the View object who owns this TextInputClient instance. - virtual View* GetOwnerViewOfTextInputClient() = 0; -}; - -} // namespace views - -#endif // VIEWS_IME_TEXT_INPUT_CLIENT_H_ |