OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/scoped_nsobject.h" | 10 #include "base/scoped_nsobject.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 @protocol RenderWidgetHostViewMacOwner | 23 @protocol RenderWidgetHostViewMacOwner |
24 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac; | 24 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac; |
25 @end | 25 @end |
26 | 26 |
27 // This is the view that lives in the Cocoa view hierarchy. In Windows-land, | 27 // This is the view that lives in the Cocoa view hierarchy. In Windows-land, |
28 // RenderWidgetHostViewWin is both the view and the delegate. We split the roles | 28 // RenderWidgetHostViewWin is both the view and the delegate. We split the roles |
29 // but that means that the view needs to own the delegate and will dispose of it | 29 // but that means that the view needs to own the delegate and will dispose of it |
30 // when it's removed from the view system. | 30 // when it's removed from the view system. |
31 | 31 |
32 @interface RenderWidgetHostViewCocoa : BaseView <RenderWidgetHostViewMacOwner> { | 32 @interface RenderWidgetHostViewCocoa |
| 33 : BaseView <RenderWidgetHostViewMacOwner, NSTextInput> { |
33 @private | 34 @private |
34 RenderWidgetHostViewMac* renderWidgetHostView_; | 35 RenderWidgetHostViewMac* renderWidgetHostView_; |
35 BOOL canBeKeyView_; | 36 BOOL canBeKeyView_; |
36 BOOL closeOnDeactivate_; | 37 BOOL closeOnDeactivate_; |
37 scoped_ptr<RWHVMEditCommandHelper> editCommand_helper_; | 38 scoped_ptr<RWHVMEditCommandHelper> editCommand_helper_; |
38 | 39 |
39 // These are part of the magic tooltip code from WebKit's WebHTMLView: | 40 // These are part of the magic tooltip code from WebKit's WebHTMLView: |
40 id trackingRectOwner_; // (not retained) | 41 id trackingRectOwner_; // (not retained) |
41 void *trackingRectUserData_; | 42 void *trackingRectUserData_; |
42 NSTrackingRectTag lastToolTipTag_; | 43 NSTrackingRectTag lastToolTipTag_; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 bool about_to_validate_and_paint_; | 124 bool about_to_validate_and_paint_; |
124 | 125 |
125 // This is the rectangle which we'll paint. | 126 // This is the rectangle which we'll paint. |
126 NSRect invalid_rect_; | 127 NSRect invalid_rect_; |
127 | 128 |
128 // The time at which this view started displaying white pixels as a result of | 129 // The time at which this view started displaying white pixels as a result of |
129 // not having anything to paint (empty backing store from renderer). This | 130 // not having anything to paint (empty backing store from renderer). This |
130 // value returns true for is_null() if we are not recording whiteout times. | 131 // value returns true for is_null() if we are not recording whiteout times. |
131 base::TimeTicks whiteout_start_time_; | 132 base::TimeTicks whiteout_start_time_; |
132 | 133 |
| 134 // Variables used by our implementaion of the NSTextInput protocol. |
| 135 // An input method of Mac calls the methods of this protocol not only to |
| 136 // notify an application of its status, but also to retrieve the status of |
| 137 // the application. That is, an application cannot control an input method |
| 138 // directly. |
| 139 // This object keeps the status of a composition of the renderer and returns |
| 140 // it when an input method asks for it. |
| 141 // We need to implement Objective-C methods for the NSTextInput protocol. On |
| 142 // the other hand, we need to implement a C++ method for an IPC-message |
| 143 // handler which receives input-method events from the renderer. |
| 144 // To avoid fragmentation of variables used by our input-method |
| 145 // implementation, we define all variables as public member variables of |
| 146 // this C++ class so both the C++ methods and the Objective-C methods can |
| 147 // access them. |
| 148 |
| 149 // Represents the input-method attributes supported by this object. |
| 150 NSArray* im_attributes_; |
| 151 |
| 152 // Represents whether or not an input method is composing a text. |
| 153 bool im_composing_; |
| 154 |
| 155 // Represents the range of the composition string (i.e. a text being |
| 156 // composed by an input method), and the range of the selected text of the |
| 157 // composition string. |
| 158 // TODO(hbono): need to save the composition string itself for the |
| 159 // attributedSubstringFromRange method? |
| 160 NSRange im_marked_range_; |
| 161 NSRange im_selected_range_; |
| 162 |
| 163 // Represents the state of modifier keys. |
| 164 // An input method doesn't notify the state of modifier keys. On the other |
| 165 // hand, the state of modifier keys are required by Char events because they |
| 166 // are dispatched to onkeypress() event handlers of JavaScript. |
| 167 // To create a Char event in NSTextInput methods, we save the latest state |
| 168 // of modifier keys when we receive it. |
| 169 int im_modifiers_; |
| 170 |
| 171 // Represents the cursor position in this view coordinate. |
| 172 // The renderer sends the cursor position through an IPC message. |
| 173 // We save the latest cursor position here and return it when an input |
| 174 // methods needs it. |
| 175 NSRect im_caret_rect_; |
| 176 |
133 private: | 177 private: |
134 // Updates the display cursor to the current cursor if the cursor is over this | 178 // Updates the display cursor to the current cursor if the cursor is over this |
135 // render view. | 179 // render view. |
136 void UpdateCursorIfOverSelf(); | 180 void UpdateCursorIfOverSelf(); |
137 | 181 |
138 // Shuts down the render_widget_host_. This is a separate function so we can | 182 // Shuts down the render_widget_host_. This is a separate function so we can |
139 // invoke it from the message loop. | 183 // invoke it from the message loop. |
140 void ShutdownHost(); | 184 void ShutdownHost(); |
141 | 185 |
142 // The associated view. | 186 // The associated view. |
(...skipping 14 matching lines...) Expand all Loading... |
157 // Factory used to safely scope delayed calls to ShutdownHost(). | 201 // Factory used to safely scope delayed calls to ShutdownHost(). |
158 ScopedRunnableMethodFactory<RenderWidgetHostViewMac> shutdown_factory_; | 202 ScopedRunnableMethodFactory<RenderWidgetHostViewMac> shutdown_factory_; |
159 | 203 |
160 // Used for positioning a popup menu. | 204 // Used for positioning a popup menu. |
161 BaseView* parent_view_; | 205 BaseView* parent_view_; |
162 | 206 |
163 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); | 207 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); |
164 }; | 208 }; |
165 | 209 |
166 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ | 210 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ |
OLD | NEW |