diff options
| author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 07:38:06 +0000 |
|---|---|---|
| committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 07:38:06 +0000 |
| commit | f17709bbedbdc5cf3bdc88dc93d264e0191b8f2b (patch) | |
| tree | 04e899a7dc1edaf1152f9419671338505a65ca06 /chrome/browser/renderer_host/render_widget_host_view_mac.h | |
| parent | fb6ec999c0d049c78b16ca6106d5e45624f94ac8 (diff) | |
| download | chromium_src-f17709bbedbdc5cf3bdc88dc93d264e0191b8f2b.zip chromium_src-f17709bbedbdc5cf3bdc88dc93d264e0191b8f2b.tar.gz chromium_src-f17709bbedbdc5cf3bdc88dc93d264e0191b8f2b.tar.bz2 | |
Implement the NSTextInput protocol.
This change implements the NSTextInput protocol to integrate dead-keys and IME support into Mac Chromium.
Same as Linux, to improve compatibility with Windows Chrome, this change emulates IPC messages sent on Windows when we input characters to fix Issue 11952 and Issue 11981.
Even though I notice we need more work for fixing edge cases (e.g. disabling IMEs on a password input) also on Mac, it is the good starting point. (Supporting edge-cases requires complicated code and it makes hard to review.)
BUG=11952 "IME support is not implemented"
BUG=11981 "Deadkeys do not work"
BUG=16393 "Mac: Not able to insert any letter using "Special Characters" pallet"
TEST=Open a web page which contains an <input> form (e.g. <http://www.google.com/>), type a '[{' key and an 'A' key on a Canadian-French keyboard, and see a Latin character "U+00E2" is displayed in the <input> form.
TEST=Open a web page which contains an <input> form (e.g. <http://www.google.com/>), enable an Chinese Pinyin IME, type a 'W' key, type an 'O' key, and see a Chinese character is displayed in the <input> form.
TEST=Open a web page which contains a <textarea> form, type a return key, and see a new line is inserted.
Review URL: http://codereview.chromium.org/150206
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/render_widget_host_view_mac.h')
| -rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_mac.h | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index a693377..7c6ece5 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -29,7 +29,8 @@ class RWHVMEditCommandHelper; // but that means that the view needs to own the delegate and will dispose of it // when it's removed from the view system. -@interface RenderWidgetHostViewCocoa : BaseView <RenderWidgetHostViewMacOwner> { +@interface RenderWidgetHostViewCocoa + : BaseView <RenderWidgetHostViewMacOwner, NSTextInput> { @private RenderWidgetHostViewMac* renderWidgetHostView_; BOOL canBeKeyView_; @@ -130,6 +131,49 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // value returns true for is_null() if we are not recording whiteout times. base::TimeTicks whiteout_start_time_; + // Variables used by our implementaion of the NSTextInput protocol. + // An input method of Mac calls the methods of this protocol not only to + // notify an application of its status, but also to retrieve the status of + // the application. That is, an application cannot control an input method + // directly. + // This object keeps the status of a composition of the renderer and returns + // it when an input method asks for it. + // We need to implement Objective-C methods for the NSTextInput protocol. On + // the other hand, we need to implement a C++ method for an IPC-message + // handler which receives input-method events from the renderer. + // To avoid fragmentation of variables used by our input-method + // implementation, we define all variables as public member variables of + // this C++ class so both the C++ methods and the Objective-C methods can + // access them. + + // Represents the input-method attributes supported by this object. + NSArray* im_attributes_; + + // Represents whether or not an input method is composing a text. + bool im_composing_; + + // Represents the range of the composition string (i.e. a text being + // composed by an input method), and the range of the selected text of the + // composition string. + // TODO(hbono): need to save the composition string itself for the + // attributedSubstringFromRange method? + NSRange im_marked_range_; + NSRange im_selected_range_; + + // Represents the state of modifier keys. + // An input method doesn't notify the state of modifier keys. On the other + // hand, the state of modifier keys are required by Char events because they + // are dispatched to onkeypress() event handlers of JavaScript. + // To create a Char event in NSTextInput methods, we save the latest state + // of modifier keys when we receive it. + int im_modifiers_; + + // Represents the cursor position in this view coordinate. + // The renderer sends the cursor position through an IPC message. + // We save the latest cursor position here and return it when an input + // methods needs it. + NSRect im_caret_rect_; + private: // Updates the display cursor to the current cursor if the cursor is over this // render view. |
