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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.h

Issue 1908006: [Mac]Refactor input method related code. (Closed)
Patch Set: Update CL according to review feedback. Created 10 years, 7 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 | « no previous file | chrome/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_mac.h
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 5fa2d6829bfde56227ba9ab3f4633d5439de1feb..d79b0f16e80aecbd5149b36cc8c7ce5e75c954c5 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -45,21 +45,62 @@ class RWHVMEditCommandHelper;
NSTrackingRectTag lastToolTipTag_;
scoped_nsobject<NSString> toolTip_;
- // Set to YES if insertText: or insertNewline: get called.
- BOOL textInserted_;
-
// Is YES if there was a mouse-down as yet unbalanced with a mouse-up.
BOOL hasOpenMouseDown_;
- // Keep current key event when keyEvent: gets called. It's used in
- // insertText: and insertNewline: to synthesize the corresponding Char event.
- scoped_nsobject<NSEvent> currentKeyEvent_;
NSWindow* lastWindow_; // weak
// The Core Animation layer, if any, hosting the accelerated plugins' output.
scoped_nsobject<CALayer> acceleratedPluginLayer_;
+
+ // 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.
+
+ // Represents the input-method attributes supported by this object.
+ scoped_nsobject<NSArray> validAttributesForMarkedText_;
+
+ // 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 caretRect_;
+
+ // Indicates if we are currently handling a key down event.
+ BOOL handlingKeyDown_;
+
+ // Indicates if there is any marked text.
+ BOOL hasMarkedText_;
+
+ // The range of current marked text inside the whole content of the DOM node
+ // being edited.
+ // TODO(suzhe): This is currently a fake value, as we do not support accessing
+ // the whole content yet.
+ NSRange markedRange_;
+
+ // The selected range inside current marked text.
+ // TODO(suzhe): Currently it's only valid when there is any marked text.
+ // In the future, we may need to support accessing the whole content of the
+ // DOM node being edited, then this should be the selected range inside the
+ // DOM node.
+ NSRange selectedRange_;
+
+ // Text to be inserted which was generated by handling a key down event.
+ string16 textToBeInserted_;
+
+ // New marked text which was generated by handling a key down event.
+ string16 newMarkedText_;
}
+@property(assign, nonatomic) NSRect caretRect;
+
- (void)setCanBeKeyView:(BOOL)can;
- (void)setCloseOnDeactivate:(BOOL)b;
- (void)setToolTipAtMousePoint:(NSString *)string;
@@ -76,6 +117,8 @@ class RWHVMEditCommandHelper;
// Notify the RenderWidgetHost that the frame was updated so it can resize
// its contents.
- (void)renderWidgetHostWasResized;
+// Cancel ongoing composition (abandon the marked text).
+- (void)cancelComposition;
@end
@@ -169,11 +212,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
void set_parent_view(BaseView* parent_view) { parent_view_ = parent_view; }
- // Cancels the ongoing composition and cleans up all input-method resources.
- // This function dispatches a cancelation request from a renderer to
- // NSInputManager to synchronize the input-method status with it.
- void IMECleanupComposition();
-
// These member variables should be private, but the associated ObjC class
// needs access to them and can't be made a friend.
@@ -203,48 +241,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
// The time it took after this view was selected for it to be fully painted.
base::TimeTicks tab_switch_paint_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 composition string (i.e. a text being composed by an input
- // method), its range, and the range of the selected text in the composition
- // string.
- string16 im_text_;
- 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.
« no previous file with comments | « no previous file | chrome/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698