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

Unified Diff: ui/views/ime/input_method.h

Issue 12902029: Fix InputMethod Widget activation checks; cleanup, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views_unittest.cc ('k') | ui/views/ime/input_method_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/ime/input_method.h
diff --git a/ui/views/ime/input_method.h b/ui/views/ime/input_method.h
index 6d14639afdd780cb43889cf97c0a34978d487686..e718741bd235d15b54a3785d3e198c7471e1266b 100644
--- a/ui/views/ime/input_method.h
+++ b/ui/views/ime/input_method.h
@@ -27,55 +27,46 @@ class View;
class Widget;
// An interface implemented by an object that encapsulates a native input method
-// service provided by the underlying operation system.
-// Because on most systems, the system input method service is bound to
-// individual native window. On Windows, its HWND, on Aura, its
-// ui::aura::Window. And in Views control system, only the top-level
-// NativeWidget has a native window that can get keyboard focus. So this API is
-// designed to be bound to the top-level NativeWidget.
+// service provided by the underlying operation system. Input method services
+// are typically bound to individual native windows (HWND, aura::Window, etc.).
+// In Views, only the top-level Widgets get keyboard focus, so this API is
+// designed to be bound to top-level Widgets.
class VIEWS_EXPORT InputMethod {
public:
virtual ~InputMethod() {}
- // Sets the delegate used by this InputMethod instance. It should only be
- // called by the internal NativeWidget or testing code.
- virtual void set_delegate(internal::InputMethodDelegate* delegate) = 0;
+ // Sets the delegate used by this InputMethod instance.
+ // This should only be called by the owner Widget or testing code.
+ virtual void SetDelegate(internal::InputMethodDelegate* delegate) = 0;
// Initialize the InputMethod object and attach it to the given |widget|.
// The |widget| must already be initialized.
virtual void Init(Widget* widget) = 0;
- // Called when the top-level NativeWidget gets keyboard focus. It should only
- // be called by the top-level NativeWidget which owns this InputMethod
- // instance.
+ // Called when the top-level Widget gains or loses keyboard focus.
+ // These should only be called by the Widget that owns this InputMethod.
virtual void OnFocus() = 0;
-
- // Called when the top-level NativeWidget loses keyboard focus. It should only
- // be called by the top-level NativeWidget which owns this InputMethod
- // instance.
virtual void OnBlur() = 0;
// Dispatch a key event to the input method. The key event will be dispatched
// back to the caller via InputMethodDelegate::DispatchKeyEventPostIME(), once
- // it's processed by the input method. It should only be called by the
- // top-level NativeWidget which owns this InputMethod instance, or other
- // related platform dependent code, such as a message dispatcher.
+ // it has been processed by the input method. It should only be called by the
+ // top-level Widget that owns this InputMethod instance, or other related
+ // platform-specific code, such as a message dispatcher.
virtual void DispatchKeyEvent(const ui::KeyEvent& key) = 0;
- // Called by the focused |view| whenever its text input type is changed.
- // Before calling this method, the focused |view| must confirm or clear
+ // Called by the focused |view| whenever its text input type has changed.
+ // Before calling this method, the focused |view| must confirm or clear any
// existing composition text and call InputMethod::CancelComposition() when
- // necessary. Otherwise unexpected behavior may happen. This method has no
- // effect if the |view| is not focused.
+ // necessary. This method has no effect if |view| is not focused.
virtual void OnTextInputTypeChanged(View* view) = 0;
- // Called by the focused |view| whenever its caret bounds is changed.
- // This method has no effect if the |view| is not focused.
+ // Called by the focused |view| whenever its caret bounds have changed.
+ // This method has no effect if |view| is not focused.
virtual void OnCaretBoundsChanged(View* view) = 0;
- // Called by the focused |view| to ask the input method cancel the ongoing
- // composition session. This method has no effect if the |view| is not
- // focused.
+ // Called by the focused |view| to cancel the ongoing composition session.
+ // This method has no effect if |view| is not focused.
virtual void CancelComposition(View* view) = 0;
// Returns the locale of current keyboard layout or input method, as a BCP-47
@@ -86,25 +77,22 @@ class VIEWS_EXPORT InputMethod {
// base::i18n::UNKNOWN_DIRECTION if the input method cannot provide it.
virtual base::i18n::TextDirection GetInputTextDirection() = 0;
- // Checks if the input method is active, i.e. if it's ready for processing
- // keyboard event and generate composition or text result.
- // If the input method is inactive, then it's not necessary to inform it the
- // changes of caret bounds and text input type.
- // Note: character results may still be generated and sent to the text input
- // client by calling TextInputClient::InsertChar(), even if the input method
- // is not active.
+ // Returns true if the input method is ready to process keyboard events and
+ // generate composition or text results. It is not necessary to notify
+ // inactive input methods of caret bounds or text input type changes.
+ // Note: TextInputClient::InsertChar() may be called to send input to the text
+ // input client even if the input method is not active.
virtual bool IsActive() = 0;
- // 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.
+ // Returns the focused text input client, or NULL if the Widget is not active,
+ // has no focused View, or if the focused View does not support text input.
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.
virtual ui::TextInputType GetTextInputType() const = 0;
- // Returns true if the input method is a mock and not real.
+ // Returns true if the input method is a mock instance used for testing.
virtual bool IsMock() const = 0;
// TODO(suzhe): Support mouse/touch event.
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views_unittest.cc ('k') | ui/views/ime/input_method_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698