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

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

Issue 2485693003: Drag-and-drop: DragEnter, DragOver, DragLeave, DragDrop (Closed)
Patch Set: Rebased. More fixes. Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 20 matching lines...) Expand all
31 #include "content/common/drag_messages.h" 31 #include "content/common/drag_messages.h"
32 #include "content/common/input/synthetic_gesture_packet.h" 32 #include "content/common/input/synthetic_gesture_packet.h"
33 #include "content/common/input_messages.h" 33 #include "content/common/input_messages.h"
34 #include "content/common/render_message_filter.mojom.h" 34 #include "content/common/render_message_filter.mojom.h"
35 #include "content/common/swapped_out_messages.h" 35 #include "content/common/swapped_out_messages.h"
36 #include "content/common/text_input_state.h" 36 #include "content/common/text_input_state.h"
37 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
38 #include "content/public/common/content_features.h" 38 #include "content/public/common/content_features.h"
39 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
40 #include "content/public/common/context_menu_params.h" 40 #include "content/public/common/context_menu_params.h"
41 #include "content/public/common/drop_data.h"
41 #include "content/renderer/cursor_utils.h" 42 #include "content/renderer/cursor_utils.h"
42 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" 43 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h"
43 #include "content/renderer/drop_data_builder.h" 44 #include "content/renderer/drop_data_builder.h"
44 #include "content/renderer/external_popup_menu.h" 45 #include "content/renderer/external_popup_menu.h"
45 #include "content/renderer/gpu/frame_swap_message_queue.h" 46 #include "content/renderer/gpu/frame_swap_message_queue.h"
46 #include "content/renderer/gpu/queue_message_swap_promise.h" 47 #include "content/renderer/gpu/queue_message_swap_promise.h"
47 #include "content/renderer/gpu/render_widget_compositor.h" 48 #include "content/renderer/gpu/render_widget_compositor.h"
48 #include "content/renderer/ime_event_guard.h" 49 #include "content/renderer/ime_event_guard.h"
49 #include "content/renderer/input/input_handler_manager.h" 50 #include "content/renderer/input/input_handler_manager.h"
50 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 51 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
51 #include "content/renderer/render_frame_impl.h" 52 #include "content/renderer/render_frame_impl.h"
52 #include "content/renderer/render_frame_proxy.h" 53 #include "content/renderer/render_frame_proxy.h"
53 #include "content/renderer/render_process.h" 54 #include "content/renderer/render_process.h"
54 #include "content/renderer/render_thread_impl.h" 55 #include "content/renderer/render_thread_impl.h"
55 #include "content/renderer/render_view_impl.h" 56 #include "content/renderer/render_view_impl.h"
56 #include "content/renderer/render_widget_owner_delegate.h" 57 #include "content/renderer/render_widget_owner_delegate.h"
57 #include "content/renderer/renderer_blink_platform_impl.h" 58 #include "content/renderer/renderer_blink_platform_impl.h"
58 #include "content/renderer/resizing_mode_selector.h" 59 #include "content/renderer/resizing_mode_selector.h"
59 #include "ipc/ipc_message_start.h" 60 #include "ipc/ipc_message_start.h"
60 #include "ipc/ipc_sync_message.h" 61 #include "ipc/ipc_sync_message.h"
61 #include "skia/ext/platform_canvas.h" 62 #include "skia/ext/platform_canvas.h"
62 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 63 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
64 #include "third_party/WebKit/public/platform/WebDragData.h"
65 #include "third_party/WebKit/public/platform/WebDragOperation.h"
63 #include "third_party/WebKit/public/platform/WebPoint.h" 66 #include "third_party/WebKit/public/platform/WebPoint.h"
64 #include "third_party/WebKit/public/platform/WebRect.h" 67 #include "third_party/WebKit/public/platform/WebRect.h"
65 #include "third_party/WebKit/public/platform/WebSize.h" 68 #include "third_party/WebKit/public/platform/WebSize.h"
66 #include "third_party/WebKit/public/platform/WebString.h" 69 #include "third_party/WebKit/public/platform/WebString.h"
67 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc heduling_state.h" 70 #include "third_party/WebKit/public/platform/scheduler/renderer/render_widget_sc heduling_state.h"
68 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h" 71 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h"
69 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 72 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
70 #include "third_party/WebKit/public/web/WebFrameWidget.h" 73 #include "third_party/WebKit/public/web/WebFrameWidget.h"
71 #include "third_party/WebKit/public/web/WebInputMethodController.h" 74 #include "third_party/WebKit/public/web/WebInputMethodController.h"
72 #include "third_party/WebKit/public/web/WebLocalFrame.h" 75 #include "third_party/WebKit/public/web/WebLocalFrame.h"
73 #include "third_party/WebKit/public/web/WebNode.h" 76 #include "third_party/WebKit/public/web/WebNode.h"
74 #include "third_party/WebKit/public/web/WebPagePopup.h" 77 #include "third_party/WebKit/public/web/WebPagePopup.h"
75 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" 78 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
76 #include "third_party/WebKit/public/web/WebRange.h" 79 #include "third_party/WebKit/public/web/WebRange.h"
77 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 80 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
78 #include "third_party/WebKit/public/web/WebView.h" 81 #include "third_party/WebKit/public/web/WebView.h"
79 #include "third_party/WebKit/public/web/WebWidget.h" 82 #include "third_party/WebKit/public/web/WebWidget.h"
80 #include "third_party/skia/include/core/SkShader.h" 83 #include "third_party/skia/include/core/SkShader.h"
84 #include "ui/base/clipboard/clipboard.h"
81 #include "ui/base/ui_base_switches.h" 85 #include "ui/base/ui_base_switches.h"
82 #include "ui/gfx/geometry/point_conversions.h" 86 #include "ui/gfx/geometry/point_conversions.h"
83 #include "ui/gfx/geometry/rect_conversions.h" 87 #include "ui/gfx/geometry/rect_conversions.h"
84 #include "ui/gfx/geometry/size_conversions.h" 88 #include "ui/gfx/geometry/size_conversions.h"
85 #include "ui/gfx/skia_util.h" 89 #include "ui/gfx/skia_util.h"
86 #include "ui/gl/gl_switches.h" 90 #include "ui/gl/gl_switches.h"
87 #include "ui/surface/transport_dib.h" 91 #include "ui/surface/transport_dib.h"
88 92
89 #if defined(OS_ANDROID) 93 #if defined(OS_ANDROID)
90 #include <android/keycodes.h> 94 #include <android/keycodes.h>
91 #endif 95 #endif
92 96
93 #if defined(OS_POSIX) 97 #if defined(OS_POSIX)
94 #include "third_party/skia/include/core/SkMallocPixelRef.h" 98 #include "third_party/skia/include/core/SkMallocPixelRef.h"
95 #include "third_party/skia/include/core/SkPixelRef.h" 99 #include "third_party/skia/include/core/SkPixelRef.h"
96 #endif // defined(OS_POSIX) 100 #endif // defined(OS_POSIX)
97 101
98 #if defined(USE_AURA) 102 #if defined(USE_AURA)
99 #include "content/public/common/service_manager_connection.h" 103 #include "content/public/common/service_manager_connection.h"
100 #include "content/renderer/mus/render_widget_mus_connection.h" 104 #include "content/renderer/mus/render_widget_mus_connection.h"
101 #endif 105 #endif
102 106
103 #if defined(OS_MACOSX) 107 #if defined(OS_MACOSX)
104 #include "content/renderer/text_input_client_observer.h" 108 #include "content/renderer/text_input_client_observer.h"
105 #endif 109 #endif
106 110
107 using blink::WebCompositionUnderline; 111 using blink::WebCompositionUnderline;
108 using blink::WebCursorInfo; 112 using blink::WebCursorInfo;
109 using blink::WebDeviceEmulationParams; 113 using blink::WebDeviceEmulationParams;
114 using blink::WebDragOperation;
110 using blink::WebDragOperationsMask; 115 using blink::WebDragOperationsMask;
111 using blink::WebDragData; 116 using blink::WebDragData;
117 using blink::WebFrameWidget;
112 using blink::WebGestureEvent; 118 using blink::WebGestureEvent;
113 using blink::WebImage; 119 using blink::WebImage;
114 using blink::WebInputEvent; 120 using blink::WebInputEvent;
115 using blink::WebInputEventResult; 121 using blink::WebInputEventResult;
116 using blink::WebInputMethodController; 122 using blink::WebInputMethodController;
117 using blink::WebKeyboardEvent; 123 using blink::WebKeyboardEvent;
118 using blink::WebLocalFrame; 124 using blink::WebLocalFrame;
119 using blink::WebMouseEvent; 125 using blink::WebMouseEvent;
120 using blink::WebMouseWheelEvent; 126 using blink::WebMouseWheelEvent;
121 using blink::WebNavigationPolicy; 127 using blink::WebNavigationPolicy;
122 using blink::WebNode; 128 using blink::WebNode;
123 using blink::WebPagePopup; 129 using blink::WebPagePopup;
124 using blink::WebPoint; 130 using blink::WebPoint;
125 using blink::WebPopupType; 131 using blink::WebPopupType;
126 using blink::WebRange; 132 using blink::WebRange;
127 using blink::WebRect; 133 using blink::WebRect;
128 using blink::WebSize; 134 using blink::WebSize;
135 using blink::WebString;
129 using blink::WebTextDirection; 136 using blink::WebTextDirection;
130 using blink::WebTouchEvent; 137 using blink::WebTouchEvent;
131 using blink::WebTouchPoint; 138 using blink::WebTouchPoint;
132 using blink::WebVector; 139 using blink::WebVector;
133 using blink::WebWidget; 140 using blink::WebWidget;
134 141
142 namespace content {
143
135 namespace { 144 namespace {
136 145
137 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap; 146 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
138 147
139 class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget { 148 class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget {
140 public: 149 public:
141 explicit WebWidgetLockTarget(blink::WebWidget* webwidget) 150 explicit WebWidgetLockTarget(blink::WebWidget* webwidget)
142 : webwidget_(webwidget) {} 151 : webwidget_(webwidget) {}
143 152
144 void OnLockMouseACK(bool succeeded) override { 153 void OnLockMouseACK(bool succeeded) override {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return content::RenderWidgetMusConnection::GetOrCreate( 185 return content::RenderWidgetMusConnection::GetOrCreate(
177 widget->routing_id()); 186 widget->routing_id());
178 } 187 }
179 #endif 188 #endif
180 // If we don't have a connection to the Service Manager, then we want to route 189 // If we don't have a connection to the Service Manager, then we want to route
181 // IPCs back to the browser process rather than Mus so we use the |widget| as 190 // IPCs back to the browser process rather than Mus so we use the |widget| as
182 // the RenderWidgetInputHandlerDelegate. 191 // the RenderWidgetInputHandlerDelegate.
183 return widget; 192 return widget;
184 } 193 }
185 194
195 WebDragData DropMetaDataToWebDragData(
196 const std::vector<DropData::Metadata>& drop_meta_data) {
197 std::vector<WebDragData::Item> item_list;
198 for (const auto& meta_data_item : drop_meta_data) {
199 if (meta_data_item.kind == DropData::Kind::STRING) {
200 WebDragData::Item item;
201 item.storageType = WebDragData::Item::StorageTypeString;
202 item.stringType = meta_data_item.mime_type;
203 // Have to pass a dummy URL here instead of an empty URL because the
204 // DropData received by browser_plugins goes through a round trip:
205 // DropData::MetaData --> WebDragData-->DropData. In the end, DropData
206 // will contain an empty URL (which means no URL is dragged) if the URL in
207 // WebDragData is empty.
208 if (base::EqualsASCII(meta_data_item.mime_type,
209 ui::Clipboard::kMimeTypeURIList)) {
210 item.stringData = WebString::fromUTF8("about:dragdrop-placeholder");
211 }
212 item_list.push_back(item);
213 continue;
214 }
215
216 // TODO(hush): crbug.com/584789. Blink needs to support creating a file with
217 // just the mimetype. This is needed to drag files to WebView on Android
218 // platform.
219 if ((meta_data_item.kind == DropData::Kind::FILENAME) &&
220 !meta_data_item.filename.empty()) {
221 WebDragData::Item item;
222 item.storageType = WebDragData::Item::StorageTypeFilename;
223 item.filenameData = meta_data_item.filename.AsUTF16Unsafe();
224 item_list.push_back(item);
225 continue;
226 }
227
228 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) {
229 WebDragData::Item item;
230 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
231 item.fileSystemURL = meta_data_item.file_system_url;
232 item_list.push_back(item);
233 continue;
234 }
235 }
236
237 WebDragData result;
238 result.initialize();
239 result.setItems(item_list);
240 return result;
241 }
242
243 WebDragData DropDataToWebDragData(const DropData& drop_data) {
244 std::vector<WebDragData::Item> item_list;
245
246 // These fields are currently unused when dragging into WebKit.
247 DCHECK(drop_data.download_metadata.empty());
248 DCHECK(drop_data.file_contents.empty());
249 DCHECK(drop_data.file_description_filename.empty());
250
251 if (!drop_data.text.is_null()) {
252 WebDragData::Item item;
253 item.storageType = WebDragData::Item::StorageTypeString;
254 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText);
255 item.stringData = drop_data.text.string();
256 item_list.push_back(item);
257 }
258
259 if (!drop_data.url.is_empty()) {
260 WebDragData::Item item;
261 item.storageType = WebDragData::Item::StorageTypeString;
262 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList);
263 item.stringData = WebString::fromUTF8(drop_data.url.spec());
264 item.title = drop_data.url_title;
265 item_list.push_back(item);
266 }
267
268 if (!drop_data.html.is_null()) {
269 WebDragData::Item item;
270 item.storageType = WebDragData::Item::StorageTypeString;
271 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML);
272 item.stringData = drop_data.html.string();
273 item.baseURL = drop_data.html_base_url;
274 item_list.push_back(item);
275 }
276
277 for (std::vector<ui::FileInfo>::const_iterator it =
278 drop_data.filenames.begin();
279 it != drop_data.filenames.end();
280 ++it) {
281 WebDragData::Item item;
282 item.storageType = WebDragData::Item::StorageTypeFilename;
283 item.filenameData = it->path.AsUTF16Unsafe();
284 item.displayNameData = it->display_name.AsUTF16Unsafe();
285 item_list.push_back(item);
286 }
287
288 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it =
289 drop_data.file_system_files.begin();
290 it != drop_data.file_system_files.end();
291 ++it) {
292 WebDragData::Item item;
293 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
294 item.fileSystemURL = it->url;
295 item.fileSystemFileSize = it->size;
296 item_list.push_back(item);
297 }
298
299 for (std::map<base::string16, base::string16>::const_iterator it =
300 drop_data.custom_data.begin();
301 it != drop_data.custom_data.end();
302 ++it) {
303 WebDragData::Item item;
304 item.storageType = WebDragData::Item::StorageTypeString;
305 item.stringType = it->first;
306 item.stringData = it->second;
307 item_list.push_back(item);
308 }
309
310 WebDragData result;
311 result.initialize();
312 result.setItems(item_list);
313 result.setFilesystemId(drop_data.filesystem_id);
314 return result;
315 }
316
186 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget = 317 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget =
187 nullptr; 318 nullptr;
188 319
189 content::RenderWidget::RenderWidgetInitializedCallback 320 content::RenderWidget::RenderWidgetInitializedCallback
190 g_render_widget_initialized = nullptr; 321 g_render_widget_initialized = nullptr;
191 322
192 ui::TextInputType ConvertWebTextInputType(blink::WebTextInputType type) { 323 ui::TextInputType ConvertWebTextInputType(blink::WebTextInputType type) {
193 // Check the type is in the range representable by ui::TextInputType. 324 // Check the type is in the range representable by ui::TextInputType.
194 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) 325 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX))
195 << "blink::WebTextInputType and ui::TextInputType not synchronized"; 326 << "blink::WebTextInputType and ui::TextInputType not synchronized";
196 return static_cast<ui::TextInputType>(type); 327 return static_cast<ui::TextInputType>(type);
197 } 328 }
198 329
199 ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) { 330 ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) {
200 // Check the mode is in the range representable by ui::TextInputMode. 331 // Check the mode is in the range representable by ui::TextInputMode.
201 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) 332 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX))
202 << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; 333 << "blink::WebTextInputMode and ui::TextInputMode not synchronized";
203 return static_cast<ui::TextInputMode>(mode); 334 return static_cast<ui::TextInputMode>(mode);
204 } 335 }
205 336
206 } // namespace 337 } // namespace
207 338
208 namespace content {
209
210 // RenderWidget --------------------------------------------------------------- 339 // RenderWidget ---------------------------------------------------------------
211 340
212 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 341 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
213 blink::WebPopupType popup_type, 342 blink::WebPopupType popup_type,
214 const ScreenInfo& screen_info, 343 const ScreenInfo& screen_info,
215 bool swapped_out, 344 bool swapped_out,
216 bool hidden, 345 bool hidden,
217 bool never_visible) 346 bool never_visible)
218 : routing_id_(MSG_ROUTING_NONE), 347 : routing_id_(MSG_ROUTING_NONE),
219 compositor_deps_(compositor_deps), 348 compositor_deps_(compositor_deps),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 643 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
515 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 644 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
516 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 645 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
517 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 646 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
518 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 647 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
519 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 648 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
520 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, 649 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests,
521 OnWaitNextFrameForTests) 650 OnWaitNextFrameForTests)
522 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate, 651 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate,
523 OnRequestCompositionUpdate) 652 OnRequestCompositionUpdate)
653 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
654 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
655 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
656 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
657 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
524 #if defined(OS_ANDROID) 658 #if defined(OS_ANDROID)
525 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) 659 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
526 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate, 660 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
527 OnRequestTextInputStateUpdate) 661 OnRequestTextInputStateUpdate)
528 #endif 662 #endif
529 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
530 IPC_MESSAGE_UNHANDLED(handled = false) 663 IPC_MESSAGE_UNHANDLED(handled = false)
531 IPC_END_MESSAGE_MAP() 664 IPC_END_MESSAGE_MAP()
532 return handled; 665 return handled;
533 } 666 }
534 667
535 bool RenderWidget::Send(IPC::Message* message) { 668 bool RenderWidget::Send(IPC::Message* message) {
536 // Don't send any messages after the browser has told us to close, and filter 669 // Don't send any messages after the browser has told us to close, and filter
537 // most outgoing messages while swapped out. 670 // most outgoing messages while swapped out.
538 if ((is_swapped_out_ && 671 if ((is_swapped_out_ &&
539 !SwappedOutMessages::CanSendWhileSwappedOut(message)) || 672 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); 1663 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect);
1531 else 1664 else
1532 window_screen_rect_ = window_screen_rect; 1665 window_screen_rect_ = window_screen_rect;
1533 } 1666 }
1534 1667
1535 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { 1668 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) {
1536 if (compositor_) 1669 if (compositor_)
1537 compositor_->OnHandleCompositorProto(proto); 1670 compositor_->OnHandleCompositorProto(proto);
1538 } 1671 }
1539 1672
1673 void RenderWidget::OnDragTargetDragEnter(
1674 const std::vector<DropData::Metadata>& drop_meta_data,
1675 const gfx::Point& client_point,
1676 const gfx::Point& screen_point,
1677 WebDragOperationsMask ops,
1678 int key_modifiers) {
1679 if (!GetWebWidget())
1680 return;
1681
1682 DCHECK(GetWebWidget()->isWebFrameWidget());
1683 WebDragOperation operation = static_cast<WebFrameWidget*>(GetWebWidget())->
1684 dragTargetDragEnter(DropMetaDataToWebDragData(drop_meta_data),
1685 client_point, screen_point, ops, key_modifiers);
1686
1687 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
1688 }
1689
1690 void RenderWidget::OnDragTargetDragOver(const gfx::Point& client_point,
1691 const gfx::Point& screen_point,
1692 WebDragOperationsMask ops,
1693 int key_modifiers) {
1694 if (!GetWebWidget())
1695 return;
1696
1697 DCHECK(GetWebWidget()->isWebFrameWidget());
1698 WebDragOperation operation =
1699 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDragOver(
1700 ConvertWindowPointToViewport(client_point),
1701 screen_point, ops, key_modifiers);
1702
1703 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
1704 }
1705
1706 void RenderWidget::OnDragTargetDragLeave() {
1707 if (!GetWebWidget())
1708 return;
1709 DCHECK(GetWebWidget()->isWebFrameWidget());
1710 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDragLeave();
1711 }
1712
1713 void RenderWidget::OnDragTargetDrop(const DropData& drop_data,
1714 const gfx::Point& client_point,
1715 const gfx::Point& screen_point,
1716 int key_modifiers) {
1717 if (!GetWebWidget())
1718 return;
1719
1720 DCHECK(GetWebWidget()->isWebFrameWidget());
1721 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDrop(
1722 DropDataToWebDragData(drop_data),
1723 ConvertWindowPointToViewport(client_point),
1724 screen_point, key_modifiers);
1725 }
1726
1540 void RenderWidget::showImeIfNeeded() { 1727 void RenderWidget::showImeIfNeeded() {
1541 #if defined(OS_ANDROID) || defined(USE_AURA) 1728 #if defined(OS_ANDROID) || defined(USE_AURA)
1542 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); 1729 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
1543 #endif 1730 #endif
1544 1731
1545 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with 1732 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
1546 // virtual keyboard. 1733 // virtual keyboard.
1547 #if !defined(OS_ANDROID) 1734 #if !defined(OS_ANDROID)
1548 FocusChangeComplete(); 1735 FocusChangeComplete();
1549 #endif 1736 #endif
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 2255 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
2069 } 2256 }
2070 2257
2071 float RenderWidget::GetOriginalDeviceScaleFactor() const { 2258 float RenderWidget::GetOriginalDeviceScaleFactor() const {
2072 return 2259 return
2073 screen_metrics_emulator_ ? 2260 screen_metrics_emulator_ ?
2074 screen_metrics_emulator_->original_screen_info().device_scale_factor : 2261 screen_metrics_emulator_->original_screen_info().device_scale_factor :
2075 device_scale_factor_; 2262 device_scale_factor_;
2076 } 2263 }
2077 2264
2265 gfx::Point RenderWidget::ConvertWindowPointToViewport(
2266 const gfx::Point& point) {
2267 blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0);
2268 convertWindowToViewport(&point_in_viewport);
2269 return gfx::Point(point_in_viewport.x, point_in_viewport.y);
2270 }
2271
2078 bool RenderWidget::requestPointerLock() { 2272 bool RenderWidget::requestPointerLock() {
2079 return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); 2273 return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get());
2080 } 2274 }
2081 2275
2082 void RenderWidget::requestPointerUnlock() { 2276 void RenderWidget::requestPointerUnlock() {
2083 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2277 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2084 } 2278 }
2085 2279
2086 bool RenderWidget::isPointerLocked() { 2280 bool RenderWidget::isPointerLocked() {
2087 return mouse_lock_dispatcher_->IsMouseLockedTo( 2281 return mouse_lock_dispatcher_->IsMouseLockedTo(
2088 webwidget_mouse_lock_target_.get()); 2282 webwidget_mouse_lock_target_.get());
2089 } 2283 }
2090 2284
2091 void RenderWidget::startDragging(blink::WebReferrerPolicy policy, 2285 void RenderWidget::startDragging(blink::WebReferrerPolicy policy,
2092 const WebDragData& data, 2286 const WebDragData& data,
2093 WebDragOperationsMask mask, 2287 WebDragOperationsMask mask,
2094 const WebImage& image, 2288 const WebImage& image,
2095 const WebPoint& webImageOffset) { 2289 const WebPoint& webImageOffset) {
2096 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0); 2290 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0);
2097 convertViewportToWindow(&offset_in_window); 2291 convertViewportToWindow(&offset_in_window);
2098 DropData drop_data(DropDataBuilder::Build(data)); 2292 DropData drop_data(DropDataBuilder::Build(data));
2099 drop_data.referrer_policy = policy; 2293 drop_data.referrer_policy = policy;
2100 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); 2294 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y);
2101 Send(new DragHostMsg_StartDragging(routing_id_, drop_data, mask, 2295 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask,
2102 image.getSkBitmap(), imageOffset, 2296 image.getSkBitmap(), imageOffset,
2103 possible_drag_event_info_)); 2297 possible_drag_event_info_));
2104 } 2298 }
2105 2299
2106 blink::WebWidget* RenderWidget::GetWebWidget() const { 2300 blink::WebWidget* RenderWidget::GetWebWidget() const {
2107 return webwidget_internal_; 2301 return webwidget_internal_;
2108 } 2302 }
2109 2303
2110 blink::WebInputMethodController* RenderWidget::GetInputMethodController() 2304 blink::WebInputMethodController* RenderWidget::GetInputMethodController()
2111 const { 2305 const {
2112 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is 2306 // TODO(ekaramad): Remove this CHECK when GetWebWidget() is
2113 // always a WebFrameWidget. 2307 // always a WebFrameWidget.
2114 CHECK(GetWebWidget()->isWebFrameWidget()); 2308 CHECK(GetWebWidget()->isWebFrameWidget());
2115 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) 2309 return static_cast<blink::WebFrameWidget*>(GetWebWidget())
2116 ->getActiveWebInputMethodController(); 2310 ->getActiveWebInputMethodController();
2117 } 2311 }
2118 2312
2119 } // namespace content 2313 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | third_party/WebKit/Source/core/page/DragController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698