Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "app/surface/transport_dib.h" | 7 #include "app/surface/transport_dib.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/render_messages.h" | 15 #include "chrome/common/render_messages.h" |
| 16 #include "chrome/common/render_messages_params.h" | 16 #include "chrome/common/render_messages_params.h" |
| 17 #include "chrome/common/text_input_client_messages.h" | |
| 17 #include "chrome/renderer/render_process.h" | 18 #include "chrome/renderer/render_process.h" |
| 18 #include "chrome/renderer/render_thread.h" | 19 #include "chrome/renderer/render_thread.h" |
| 19 #include "chrome/renderer/renderer_webkitclient_impl.h" | 20 #include "chrome/renderer/renderer_webkitclient_impl.h" |
| 20 #include "ipc/ipc_sync_message.h" | 21 #include "ipc/ipc_sync_message.h" |
| 21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
| 22 #include "third_party/skia/include/core/SkShader.h" | 23 #include "third_party/skia/include/core/SkShader.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 29 #include "ui/gfx/point.h" | 31 #include "ui/gfx/point.h" |
| 30 #include "ui/gfx/size.h" | 32 #include "ui/gfx/size.h" |
| 31 #include "webkit/glue/webkit_glue.h" | 33 #include "webkit/glue/webkit_glue.h" |
| 32 #include "webkit/plugins/npapi/webplugin.h" | 34 #include "webkit/plugins/npapi/webplugin.h" |
| 33 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 35 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 34 | 36 |
| 35 #if defined(OS_POSIX) | 37 #if defined(OS_POSIX) |
| 36 #include "ipc/ipc_channel_posix.h" | 38 #include "ipc/ipc_channel_posix.h" |
| 37 #include "third_party/skia/include/core/SkPixelRef.h" | 39 #include "third_party/skia/include/core/SkPixelRef.h" |
| 38 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 40 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 39 #endif // defined(OS_POSIX) | 41 #endif // defined(OS_POSIX) |
| 40 | 42 |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
| 42 | 44 |
| 43 using WebKit::WebCompositionUnderline; | 45 using WebKit::WebCompositionUnderline; |
| 44 using WebKit::WebCursorInfo; | 46 using WebKit::WebCursorInfo; |
| 45 using WebKit::WebInputEvent; | 47 using WebKit::WebInputEvent; |
| 46 using WebKit::WebMouseEvent; | 48 using WebKit::WebMouseEvent; |
| 47 using WebKit::WebNavigationPolicy; | 49 using WebKit::WebNavigationPolicy; |
| 48 using WebKit::WebPopupMenu; | 50 using WebKit::WebPopupMenu; |
| 49 using WebKit::WebPopupMenuInfo; | 51 using WebKit::WebPopupMenuInfo; |
| 50 using WebKit::WebPopupType; | 52 using WebKit::WebPopupType; |
| 53 using WebKit::WebRange; | |
| 51 using WebKit::WebRect; | 54 using WebKit::WebRect; |
| 52 using WebKit::WebScreenInfo; | 55 using WebKit::WebScreenInfo; |
| 53 using WebKit::WebSize; | 56 using WebKit::WebSize; |
| 54 using WebKit::WebTextDirection; | 57 using WebKit::WebTextDirection; |
| 55 using WebKit::WebTextInputType; | 58 using WebKit::WebTextInputType; |
| 56 using WebKit::WebVector; | 59 using WebKit::WebVector; |
| 57 using WebKit::WebWidget; | 60 using WebKit::WebWidget; |
| 58 | 61 |
| 59 RenderWidget::RenderWidget(RenderThreadBase* render_thread, | 62 RenderWidget::RenderWidget(RenderThreadBase* render_thread, |
| 60 WebKit::WebPopupType popup_type) | 63 WebKit::WebPopupType popup_type) |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 // only during the input method attached to the browser process is active. | 858 // only during the input method attached to the browser process is active. |
| 856 input_method_is_active_ = is_active; | 859 input_method_is_active_ = is_active; |
| 857 } | 860 } |
| 858 | 861 |
| 859 void RenderWidget::OnImeSetComposition( | 862 void RenderWidget::OnImeSetComposition( |
| 860 const string16& text, | 863 const string16& text, |
| 861 const std::vector<WebCompositionUnderline>& underlines, | 864 const std::vector<WebCompositionUnderline>& underlines, |
| 862 int selection_start, int selection_end) { | 865 int selection_start, int selection_end) { |
| 863 if (!webwidget_) | 866 if (!webwidget_) |
| 864 return; | 867 return; |
| 865 if (!webwidget_->setComposition( | 868 if (webwidget_->setComposition( |
| 866 text, WebVector<WebCompositionUnderline>(underlines), | 869 text, WebVector<WebCompositionUnderline>(underlines), |
| 867 selection_start, selection_end)) { | 870 selection_start, selection_end)) { |
| 871 // Setting the IME composition was successful. Send the new composition | |
| 872 // range to the browser. | |
| 873 WebRange range = webwidget_->compositionRange(); | |
| 874 if (range.isNull()) { | |
| 875 // The IME was cancelled via the Esc key, so just send back the caret. | |
| 876 range = webwidget_->caretOrSelectionRange(); | |
| 877 } | |
| 878 Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(), | |
| 879 range.startOffset(), range.endOffset())); | |
| 880 } else { | |
| 868 // If we failed to set the composition text, then we need to let the browser | 881 // If we failed to set the composition text, then we need to let the browser |
| 869 // process to cancel the input method's ongoing composition session, to make | 882 // process to cancel the input method's ongoing composition session, to make |
| 870 // sure we are in a consistent state. | 883 // sure we are in a consistent state. |
| 871 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); | 884 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 885 // Send an updated IME range with just the caret range. | |
| 886 WebRange range = webwidget_->caretOrSelectionRange(); | |
| 887 Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(), | |
| 888 range.startOffset(), range.endOffset())); | |
|
James Su
2011/02/17 02:03:00
We need this code in RenderWidget::resetInputMetho
Robert Sesek
2011/02/17 20:05:04
Done.
| |
| 872 } | 889 } |
| 873 } | 890 } |
| 874 | 891 |
| 875 void RenderWidget::OnImeConfirmComposition(const string16& text) { | 892 void RenderWidget::OnImeConfirmComposition(const string16& text) { |
| 876 if (webwidget_) | 893 if (webwidget_) |
| 877 webwidget_->confirmComposition(text); | 894 webwidget_->confirmComposition(text); |
| 895 // Send an updated IME range with just the caret range. | |
| 896 WebRange range = webwidget_->caretOrSelectionRange(); | |
| 897 Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(), | |
| 898 range.startOffset(), range.endOffset())); | |
| 878 } | 899 } |
| 879 | 900 |
| 880 // This message causes the renderer to render an image of the | 901 // This message causes the renderer to render an image of the |
| 881 // desired_size, regardless of whether the tab is hidden or not. | 902 // desired_size, regardless of whether the tab is hidden or not. |
| 882 void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, | 903 void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, |
| 883 int tag, | 904 int tag, |
| 884 const gfx::Size& page_size, | 905 const gfx::Size& page_size, |
| 885 const gfx::Size& desired_size) { | 906 const gfx::Size& desired_size) { |
| 886 if (!webwidget_ || !TransportDIB::is_valid(dib_handle)) { | 907 if (!webwidget_ || !TransportDIB::is_valid(dib_handle)) { |
| 887 if (TransportDIB::is_valid(dib_handle)) { | 908 if (TransportDIB::is_valid(dib_handle)) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1088 | 1109 |
| 1089 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1110 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
| 1090 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1111 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
| 1091 i != plugin_window_moves_.end(); ++i) { | 1112 i != plugin_window_moves_.end(); ++i) { |
| 1092 if (i->window == window) { | 1113 if (i->window == window) { |
| 1093 plugin_window_moves_.erase(i); | 1114 plugin_window_moves_.erase(i); |
| 1094 break; | 1115 break; |
| 1095 } | 1116 } |
| 1096 } | 1117 } |
| 1097 } | 1118 } |
| OLD | NEW |