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

Side by Side Diff: content/renderer/render_widget.cc

Issue 6289009: [Mac] Implement the system dictionary popup by implementing NSTextInput methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_view.cc ('k') | content/renderer/render_widget_fullscreen_pepper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.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 "build/build_config.h" 12 #include "build/build_config.h"
13 #include "content/common/content_switches.h" 13 #include "content/common/content_switches.h"
14 #include "content/common/view_messages.h" 14 #include "content/common/view_messages.h"
15 #include "content/renderer/render_process.h" 15 #include "content/renderer/render_process.h"
16 #include "content/renderer/render_thread.h" 16 #include "content/renderer/render_thread.h"
17 #include "content/renderer/renderer_webkitclient_impl.h" 17 #include "content/renderer/renderer_webkitclient_impl.h"
18 #include "gpu/common/gpu_trace_event.h" 18 #include "gpu/common/gpu_trace_event.h"
19 #include "ipc/ipc_sync_message.h" 19 #include "ipc/ipc_sync_message.h"
20 #include "skia/ext/platform_canvas.h" 20 #include "skia/ext/platform_canvas.h"
21 #include "third_party/skia/include/core/SkShader.h" 21 #include "third_party/skia/include/core/SkShader.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
28 #include "ui/gfx/point.h" 29 #include "ui/gfx/point.h"
29 #include "ui/gfx/size.h" 30 #include "ui/gfx/size.h"
30 #include "ui/gfx/surface/transport_dib.h" 31 #include "ui/gfx/surface/transport_dib.h"
31 #include "webkit/glue/webkit_glue.h" 32 #include "webkit/glue/webkit_glue.h"
32 #include "webkit/plugins/npapi/webplugin.h" 33 #include "webkit/plugins/npapi/webplugin.h"
33 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 34 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
34 35
35 #if defined(OS_POSIX) 36 #if defined(OS_POSIX)
36 #include "ipc/ipc_channel_posix.h" 37 #include "ipc/ipc_channel_posix.h"
37 #include "third_party/skia/include/core/SkPixelRef.h" 38 #include "third_party/skia/include/core/SkPixelRef.h"
38 #include "third_party/skia/include/core/SkMallocPixelRef.h" 39 #include "third_party/skia/include/core/SkMallocPixelRef.h"
39 #endif // defined(OS_POSIX) 40 #endif // defined(OS_POSIX)
40 41
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
42 43
43 using WebKit::WebCompositionUnderline; 44 using WebKit::WebCompositionUnderline;
44 using WebKit::WebCursorInfo; 45 using WebKit::WebCursorInfo;
45 using WebKit::WebInputEvent; 46 using WebKit::WebInputEvent;
46 using WebKit::WebMouseEvent; 47 using WebKit::WebMouseEvent;
47 using WebKit::WebNavigationPolicy; 48 using WebKit::WebNavigationPolicy;
48 using WebKit::WebPopupMenu; 49 using WebKit::WebPopupMenu;
49 using WebKit::WebPopupMenuInfo; 50 using WebKit::WebPopupMenuInfo;
50 using WebKit::WebPopupType; 51 using WebKit::WebPopupType;
52 using WebKit::WebRange;
51 using WebKit::WebRect; 53 using WebKit::WebRect;
52 using WebKit::WebScreenInfo; 54 using WebKit::WebScreenInfo;
53 using WebKit::WebSize; 55 using WebKit::WebSize;
54 using WebKit::WebTextDirection; 56 using WebKit::WebTextDirection;
55 using WebKit::WebTextInputType; 57 using WebKit::WebTextInputType;
56 using WebKit::WebVector; 58 using WebKit::WebVector;
57 using WebKit::WebWidget; 59 using WebKit::WebWidget;
58 60
59 RenderWidget::RenderWidget(RenderThreadBase* render_thread, 61 RenderWidget::RenderWidget(RenderThreadBase* render_thread,
60 WebKit::WebPopupType popup_type) 62 WebKit::WebPopupType popup_type)
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // only during the input method attached to the browser process is active. 881 // only during the input method attached to the browser process is active.
880 input_method_is_active_ = is_active; 882 input_method_is_active_ = is_active;
881 } 883 }
882 884
883 void RenderWidget::OnImeSetComposition( 885 void RenderWidget::OnImeSetComposition(
884 const string16& text, 886 const string16& text,
885 const std::vector<WebCompositionUnderline>& underlines, 887 const std::vector<WebCompositionUnderline>& underlines,
886 int selection_start, int selection_end) { 888 int selection_start, int selection_end) {
887 if (!webwidget_) 889 if (!webwidget_)
888 return; 890 return;
889 if (!webwidget_->setComposition( 891 if (webwidget_->setComposition(
890 text, WebVector<WebCompositionUnderline>(underlines), 892 text, WebVector<WebCompositionUnderline>(underlines),
891 selection_start, selection_end)) { 893 selection_start, selection_end)) {
894 // Setting the IME composition was successful. Send the new composition
895 // range to the browser.
896 ui::Range range(ui::Range::InvalidRange());
897 size_t location, length;
898 if (webwidget_->compositionRange(&location, &length)) {
899 range.set_start(location);
900 range.set_end(location + length);
901 }
902 // The IME was cancelled via the Esc key, so just send back the caret.
903 else if (webwidget_->caretOrSelectionRange(&location, &length)) {
904 range.set_start(location);
905 range.set_end(location + length);
906 }
907 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
908 } else {
892 // If we failed to set the composition text, then we need to let the browser 909 // If we failed to set the composition text, then we need to let the browser
893 // process to cancel the input method's ongoing composition session, to make 910 // process to cancel the input method's ongoing composition session, to make
894 // sure we are in a consistent state. 911 // sure we are in a consistent state.
895 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); 912 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
913
914 // Send an updated IME range with just the caret range.
915 ui::Range range(ui::Range::InvalidRange());
916 size_t location, length;
917 if (webwidget_->caretOrSelectionRange(&location, &length)) {
918 range.set_start(location);
919 range.set_end(location + length);
920 }
921 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
896 } 922 }
897 } 923 }
898 924
899 void RenderWidget::OnImeConfirmComposition(const string16& text) { 925 void RenderWidget::OnImeConfirmComposition(const string16& text) {
900 if (webwidget_) 926 if (webwidget_)
901 webwidget_->confirmComposition(text); 927 webwidget_->confirmComposition(text);
928 // Send an updated IME range with just the caret range.
929 ui::Range range(ui::Range::InvalidRange());
930 size_t location, length;
931 if (webwidget_->caretOrSelectionRange(&location, &length)) {
932 range.set_start(location);
933 range.set_end(location + length);
934 }
935 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
902 } 936 }
903 937
904 // This message causes the renderer to render an image of the 938 // This message causes the renderer to render an image of the
905 // desired_size, regardless of whether the tab is hidden or not. 939 // desired_size, regardless of whether the tab is hidden or not.
906 void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle, 940 void RenderWidget::OnMsgPaintAtSize(const TransportDIB::Handle& dib_handle,
907 int tag, 941 int tag,
908 const gfx::Size& page_size, 942 const gfx::Size& page_size,
909 const gfx::Size& desired_size) { 943 const gfx::Size& desired_size) {
910 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) { 944 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
911 if (TransportDIB::is_valid_handle(dib_handle)) { 945 if (TransportDIB::is_valid_handle(dib_handle)) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 return; 1117 return;
1084 1118
1085 // If the last text input type is not None, then we should finish any 1119 // If the last text input type is not None, then we should finish any
1086 // ongoing composition regardless of the new text input type. 1120 // ongoing composition regardless of the new text input type.
1087 if (text_input_type_ != WebKit::WebTextInputTypeNone) { 1121 if (text_input_type_ != WebKit::WebTextInputTypeNone) {
1088 // If a composition text exists, then we need to let the browser process 1122 // If a composition text exists, then we need to let the browser process
1089 // to cancel the input method's ongoing composition session. 1123 // to cancel the input method's ongoing composition session.
1090 if (webwidget_->confirmComposition()) 1124 if (webwidget_->confirmComposition())
1091 Send(new ViewHostMsg_ImeCancelComposition(routing_id())); 1125 Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
1092 } 1126 }
1127
1128 // Send an updated IME range with the current caret rect.
1129 ui::Range range(ui::Range::InvalidRange());
1130 size_t location, length;
1131 if (webwidget_->caretOrSelectionRange(&location, &length)) {
1132 range.set_start(location);
1133 range.set_end(location + length);
1134 }
1135 Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
1093 } 1136 }
1094 1137
1095 void RenderWidget::SchedulePluginMove( 1138 void RenderWidget::SchedulePluginMove(
1096 const webkit::npapi::WebPluginGeometry& move) { 1139 const webkit::npapi::WebPluginGeometry& move) {
1097 size_t i = 0; 1140 size_t i = 0;
1098 for (; i < plugin_window_moves_.size(); ++i) { 1141 for (; i < plugin_window_moves_.size(); ++i) {
1099 if (plugin_window_moves_[i].window == move.window) { 1142 if (plugin_window_moves_[i].window == move.window) {
1100 if (move.rects_valid) { 1143 if (move.rects_valid) {
1101 plugin_window_moves_[i] = move; 1144 plugin_window_moves_[i] = move;
1102 } else { 1145 } else {
1103 plugin_window_moves_[i].visible = move.visible; 1146 plugin_window_moves_[i].visible = move.visible;
1104 } 1147 }
1105 break; 1148 break;
1106 } 1149 }
1107 } 1150 }
1108 1151
1109 if (i == plugin_window_moves_.size()) 1152 if (i == plugin_window_moves_.size())
1110 plugin_window_moves_.push_back(move); 1153 plugin_window_moves_.push_back(move);
1111 } 1154 }
1112 1155
1113 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { 1156 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
1114 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); 1157 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin();
1115 i != plugin_window_moves_.end(); ++i) { 1158 i != plugin_window_moves_.end(); ++i) {
1116 if (i->window == window) { 1159 if (i->window == window) {
1117 plugin_window_moves_.erase(i); 1160 plugin_window_moves_.erase(i);
1118 break; 1161 break;
1119 } 1162 }
1120 } 1163 }
1121 } 1164 }
OLDNEW
« no previous file with comments | « content/renderer/render_view.cc ('k') | content/renderer/render_widget_fullscreen_pepper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698