| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/process.h" | 11 #include "base/process.h" |
| 12 #include "base/gfx/native_widget_types.h" | 12 #include "base/gfx/native_widget_types.h" |
| 13 #include "base/gfx/size.h" | 13 #include "base/gfx/size.h" |
| 14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "chrome/common/ipc_channel.h" | 16 #include "chrome/common/ipc_channel.h" |
| 17 #include "chrome/common/native_web_keyboard_event.h" | 17 #include "chrome/common/native_web_keyboard_event.h" |
| 18 #include "chrome/common/property_bag.h" | 18 #include "chrome/common/property_bag.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 19 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 #include "webkit/glue/webtextdirection.h" | 20 #include "webkit/api/public/WebTextDirection.h" |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Rect; | 23 class Rect; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace WebKit { | 26 namespace WebKit { |
| 27 class WebInputEvent; | 27 class WebInputEvent; |
| 28 class WebMouseEvent; | 28 class WebMouseEvent; |
| 29 class WebMouseWheelEvent; | 29 class WebMouseWheelEvent; |
| 30 struct WebScreenInfo; | 30 struct WebScreenInfo; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // CancelUpdateTextDirection(); | 273 // CancelUpdateTextDirection(); |
| 274 // } | 274 // } |
| 275 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { | 275 // } else if (key_event.type == WebKeyboardEvent::KEY_UP) { |
| 276 // NotifyTextDirection(); | 276 // NotifyTextDirection(); |
| 277 // } | 277 // } |
| 278 // Once we cancel updating the text direction, we have to ignore all | 278 // Once we cancel updating the text direction, we have to ignore all |
| 279 // succeeding UpdateTextDirection() requests until calling | 279 // succeeding UpdateTextDirection() requests until calling |
| 280 // NotifyTextDirection(). (We may receive keydown events even after we | 280 // NotifyTextDirection(). (We may receive keydown events even after we |
| 281 // canceled updating the text direction because of auto-repeat.) | 281 // canceled updating the text direction because of auto-repeat.) |
| 282 // Note: we cannot undo this change for compatibility with Firefox and IE. | 282 // Note: we cannot undo this change for compatibility with Firefox and IE. |
| 283 void UpdateTextDirection(WebTextDirection direction); | 283 void UpdateTextDirection(WebKit::WebTextDirection direction); |
| 284 void CancelUpdateTextDirection(); | 284 void CancelUpdateTextDirection(); |
| 285 void NotifyTextDirection(); | 285 void NotifyTextDirection(); |
| 286 | 286 |
| 287 // Notifies the renderer whether or not the IME attached to this process is | 287 // Notifies the renderer whether or not the IME attached to this process is |
| 288 // activated. | 288 // activated. |
| 289 // When the IME is activated, a renderer process sends IPC messages to notify | 289 // When the IME is activated, a renderer process sends IPC messages to notify |
| 290 // the status of its composition node. (This message is mainly used for | 290 // the status of its composition node. (This message is mainly used for |
| 291 // notifying the position of the input cursor so that the browser can | 291 // notifying the position of the input cursor so that the browser can |
| 292 // display IME windows under the cursor.) | 292 // display IME windows under the cursor.) |
| 293 void ImeSetInputMode(bool activate); | 293 void ImeSetInputMode(bool activate); |
| 294 | 294 |
| 295 // Update the composition node of the renderer (or WebKit). | 295 // Update the composition node of the renderer (or WebKit). |
| 296 // WebKit has a special node (a composition node) for IMEs to change its text | 296 // WebKit has a special node (a composition node) for IMEs to change its text |
| 297 // without affecting any other DOM nodes. When the IME (attached to the | 297 // without affecting any other DOM nodes. When the IME (attached to the |
| 298 // browser) updates its text, the browser sends IPC messages to update the | 298 // browser) updates its text, the browser sends IPC messages to update the |
| 299 // composition node of the renderer. | 299 // composition node of the renderer. |
| 300 // (Read the comments of each function for its detail.) | 300 // (Read the comments of each function for its detail.) |
| 301 | 301 |
| 302 // Sets the text of the composition node. | 302 // Sets the text of the composition node. |
| 303 // This function can also update the cursor position and mark the specified | 303 // This function can also update the cursor position and mark the specified |
| 304 // range in the composition node. | 304 // range in the composition node. |
| 305 // A browser should call this function: | 305 // A browser should call this function: |
| 306 // * when it receives a WM_IME_COMPOSITION message with a GCS_COMPSTR flag | 306 // * when it receives a WM_IME_COMPOSITION message with a GCS_COMPSTR flag |
| 307 // (on Windows); | 307 // (on Windows); |
| 308 // * when it receives a "preedit_changed" signal of GtkIMContext (on Linux); | 308 // * when it receives a "preedit_changed" signal of GtkIMContext (on Linux); |
| 309 // * when markedText of NSTextInput is called (on Mac). | 309 // * when markedText of NSTextInput is called (on Mac). |
| 310 void ImeSetComposition(const std::wstring& ime_string, | 310 void ImeSetComposition(const string16& ime_string, |
| 311 int cursor_position, | 311 int cursor_position, |
| 312 int target_start, | 312 int target_start, |
| 313 int target_end); | 313 int target_end); |
| 314 | 314 |
| 315 // Finishes an ongoing composition with the specified text. | 315 // Finishes an ongoing composition with the specified text. |
| 316 // A browser should call this function: | 316 // A browser should call this function: |
| 317 // * when it receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR flag | 317 // * when it receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR flag |
| 318 // (on Windows); | 318 // (on Windows); |
| 319 // * when it receives a "commit" signal of GtkIMContext (on Linux); | 319 // * when it receives a "commit" signal of GtkIMContext (on Linux); |
| 320 // * when insertText of NSTextInput is called (on Mac). | 320 // * when insertText of NSTextInput is called (on Mac). |
| 321 void ImeConfirmComposition(const std::wstring& ime_string); | 321 void ImeConfirmComposition(const string16& ime_string); |
| 322 | 322 |
| 323 // Cancels an ongoing composition. | 323 // Cancels an ongoing composition. |
| 324 void ImeCancelComposition(); | 324 void ImeCancelComposition(); |
| 325 | 325 |
| 326 // This is for derived classes to give us access to the resizer rect. | 326 // This is for derived classes to give us access to the resizer rect. |
| 327 // And to also expose it to the RenderWidgetHostView. | 327 // And to also expose it to the RenderWidgetHostView. |
| 328 virtual gfx::Rect GetRootWindowResizerRect() const; | 328 virtual gfx::Rect GetRootWindowResizerRect() const; |
| 329 | 329 |
| 330 protected: | 330 protected: |
| 331 // Internal implementation of the public Forward*Event() methods. | 331 // Internal implementation of the public Forward*Event() methods. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 // Queue of keyboard events that we need to track. | 500 // Queue of keyboard events that we need to track. |
| 501 typedef std::queue<NativeWebKeyboardEvent> KeyQueue; | 501 typedef std::queue<NativeWebKeyboardEvent> KeyQueue; |
| 502 | 502 |
| 503 // A queue of keyboard events. We can't trust data from the renderer so we | 503 // A queue of keyboard events. We can't trust data from the renderer so we |
| 504 // stuff key events into a queue and pop them out on ACK, feeding our copy | 504 // stuff key events into a queue and pop them out on ACK, feeding our copy |
| 505 // back to whatever unhandled handler instead of the returned version. | 505 // back to whatever unhandled handler instead of the returned version. |
| 506 KeyQueue key_queue_; | 506 KeyQueue key_queue_; |
| 507 | 507 |
| 508 // Set when we update the text direction of the selected input element. | 508 // Set when we update the text direction of the selected input element. |
| 509 bool text_direction_updated_; | 509 bool text_direction_updated_; |
| 510 WebTextDirection text_direction_; | 510 WebKit::WebTextDirection text_direction_; |
| 511 | 511 |
| 512 // Set when we cancel updating the text direction. | 512 // Set when we cancel updating the text direction. |
| 513 // This flag also ignores succeeding update requests until we call | 513 // This flag also ignores succeeding update requests until we call |
| 514 // NotifyTextDirection(). | 514 // NotifyTextDirection(). |
| 515 bool text_direction_canceled_; | 515 bool text_direction_canceled_; |
| 516 | 516 |
| 517 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 517 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
| 518 }; | 518 }; |
| 519 | 519 |
| 520 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 520 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| OLD | NEW |