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

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

Issue 2485693003: Drag-and-drop: DragEnter, DragOver, DragLeave, DragDrop (Closed)
Patch Set: No longer using GetSiteInstance() in RenderWidgetHostImpl. 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"
dcheng 2016/11/09 20:23:17 Can we clean up the corresponding forward declares
paulmeyer 2016/11/09 23:19:11 Done.
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/WebLocalFrame.h" 74 #include "third_party/WebKit/public/web/WebLocalFrame.h"
72 #include "third_party/WebKit/public/web/WebNode.h" 75 #include "third_party/WebKit/public/web/WebNode.h"
73 #include "third_party/WebKit/public/web/WebPagePopup.h" 76 #include "third_party/WebKit/public/web/WebPagePopup.h"
74 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" 77 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
75 #include "third_party/WebKit/public/web/WebRange.h" 78 #include "third_party/WebKit/public/web/WebRange.h"
76 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 79 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
77 #include "third_party/WebKit/public/web/WebView.h" 80 #include "third_party/WebKit/public/web/WebView.h"
78 #include "third_party/WebKit/public/web/WebWidget.h" 81 #include "third_party/WebKit/public/web/WebWidget.h"
79 #include "third_party/skia/include/core/SkShader.h" 82 #include "third_party/skia/include/core/SkShader.h"
83 #include "ui/base/clipboard/clipboard.h"
80 #include "ui/base/ui_base_switches.h" 84 #include "ui/base/ui_base_switches.h"
81 #include "ui/gfx/geometry/point_conversions.h" 85 #include "ui/gfx/geometry/point_conversions.h"
82 #include "ui/gfx/geometry/rect_conversions.h" 86 #include "ui/gfx/geometry/rect_conversions.h"
83 #include "ui/gfx/geometry/size_conversions.h" 87 #include "ui/gfx/geometry/size_conversions.h"
84 #include "ui/gfx/skia_util.h" 88 #include "ui/gfx/skia_util.h"
85 #include "ui/gl/gl_switches.h" 89 #include "ui/gl/gl_switches.h"
86 #include "ui/surface/transport_dib.h" 90 #include "ui/surface/transport_dib.h"
87 91
88 #if defined(OS_ANDROID) 92 #if defined(OS_ANDROID)
89 #include <android/keycodes.h> 93 #include <android/keycodes.h>
(...skipping 10 matching lines...) Expand all
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::WebKeyboardEvent; 122 using blink::WebKeyboardEvent;
117 using blink::WebLocalFrame; 123 using blink::WebLocalFrame;
118 using blink::WebMouseEvent; 124 using blink::WebMouseEvent;
119 using blink::WebMouseWheelEvent; 125 using blink::WebMouseWheelEvent;
120 using blink::WebNavigationPolicy; 126 using blink::WebNavigationPolicy;
121 using blink::WebNode; 127 using blink::WebNode;
122 using blink::WebPagePopup; 128 using blink::WebPagePopup;
123 using blink::WebPoint; 129 using blink::WebPoint;
124 using blink::WebPopupType; 130 using blink::WebPopupType;
125 using blink::WebRange; 131 using blink::WebRange;
126 using blink::WebRect; 132 using blink::WebRect;
127 using blink::WebSize; 133 using blink::WebSize;
134 using blink::WebString;
128 using blink::WebTextDirection; 135 using blink::WebTextDirection;
129 using blink::WebTouchEvent; 136 using blink::WebTouchEvent;
130 using blink::WebTouchPoint; 137 using blink::WebTouchPoint;
131 using blink::WebVector; 138 using blink::WebVector;
132 using blink::WebWidget; 139 using blink::WebWidget;
133 140
141 namespace content {
142
134 namespace { 143 namespace {
135 144
136 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap; 145 typedef std::map<std::string, ui::TextInputMode> TextInputModeMap;
137 146
138 class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget { 147 class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget {
139 public: 148 public:
140 explicit WebWidgetLockTarget(blink::WebWidget* webwidget) 149 explicit WebWidgetLockTarget(blink::WebWidget* webwidget)
141 : webwidget_(webwidget) {} 150 : webwidget_(webwidget) {}
142 151
143 void OnLockMouseACK(bool succeeded) override { 152 void OnLockMouseACK(bool succeeded) override {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return content::RenderWidgetMusConnection::GetOrCreate( 184 return content::RenderWidgetMusConnection::GetOrCreate(
176 widget->routing_id()); 185 widget->routing_id());
177 } 186 }
178 #endif 187 #endif
179 // If we don't have a connection to the Service Manager, then we want to route 188 // If we don't have a connection to the Service Manager, then we want to route
180 // IPCs back to the browser process rather than Mus so we use the |widget| as 189 // IPCs back to the browser process rather than Mus so we use the |widget| as
181 // the RenderWidgetInputHandlerDelegate. 190 // the RenderWidgetInputHandlerDelegate.
182 return widget; 191 return widget;
183 } 192 }
184 193
194 WebDragData DropMetaDataToWebDragData(
195 const std::vector<DropData::Metadata>& drop_meta_data) {
196 std::vector<WebDragData::Item> item_list;
197 for (const auto& meta_data_item : drop_meta_data) {
198 if (meta_data_item.kind == DropData::Kind::STRING) {
199 WebDragData::Item item;
200 item.storageType = WebDragData::Item::StorageTypeString;
201 item.stringType = meta_data_item.mime_type;
202 // Have to pass a dummy URL here instead of an empty URL because the
203 // DropData received by browser_plugins goes through a round trip:
204 // DropData::MetaData --> WebDragData-->DropData. In the end, DropData
205 // will contain an empty URL (which means no URL is dragged) if the URL in
206 // WebDragData is empty.
207 if (base::EqualsASCII(meta_data_item.mime_type,
208 ui::Clipboard::kMimeTypeURIList)) {
209 item.stringData = WebString::fromUTF8("about:dragdrop-placeholder");
210 }
211 item_list.push_back(item);
212 continue;
213 }
214
215 // TODO(hush): crbug.com/584789. Blink needs to support creating a file with
216 // just the mimetype. This is needed to drag files to WebView on Android
217 // platform.
218 if ((meta_data_item.kind == DropData::Kind::FILENAME) &&
219 !meta_data_item.filename.empty()) {
220 WebDragData::Item item;
221 item.storageType = WebDragData::Item::StorageTypeFilename;
222 item.filenameData = meta_data_item.filename.AsUTF16Unsafe();
223 item_list.push_back(item);
224 continue;
225 }
226
227 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) {
228 WebDragData::Item item;
229 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
230 item.fileSystemURL = meta_data_item.file_system_url;
231 item_list.push_back(item);
232 continue;
233 }
234 }
235
236 WebDragData result;
237 result.initialize();
238 result.setItems(item_list);
239 return result;
240 }
241
242 WebDragData DropDataToWebDragData(const DropData& drop_data) {
243 std::vector<WebDragData::Item> item_list;
244
245 // These fields are currently unused when dragging into WebKit.
246 DCHECK(drop_data.download_metadata.empty());
247 DCHECK(drop_data.file_contents.empty());
248 DCHECK(drop_data.file_description_filename.empty());
249
250 if (!drop_data.text.is_null()) {
251 WebDragData::Item item;
252 item.storageType = WebDragData::Item::StorageTypeString;
253 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText);
254 item.stringData = drop_data.text.string();
255 item_list.push_back(item);
256 }
257
258 if (!drop_data.url.is_empty()) {
259 WebDragData::Item item;
260 item.storageType = WebDragData::Item::StorageTypeString;
261 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList);
262 item.stringData = WebString::fromUTF8(drop_data.url.spec());
263 item.title = drop_data.url_title;
264 item_list.push_back(item);
265 }
266
267 if (!drop_data.html.is_null()) {
268 WebDragData::Item item;
269 item.storageType = WebDragData::Item::StorageTypeString;
270 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML);
271 item.stringData = drop_data.html.string();
272 item.baseURL = drop_data.html_base_url;
273 item_list.push_back(item);
274 }
275
276 for (std::vector<ui::FileInfo>::const_iterator it =
277 drop_data.filenames.begin();
278 it != drop_data.filenames.end();
279 ++it) {
280 WebDragData::Item item;
281 item.storageType = WebDragData::Item::StorageTypeFilename;
282 item.filenameData = it->path.AsUTF16Unsafe();
283 item.displayNameData = it->display_name.AsUTF16Unsafe();
284 item_list.push_back(item);
285 }
286
287 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it =
288 drop_data.file_system_files.begin();
289 it != drop_data.file_system_files.end();
290 ++it) {
291 WebDragData::Item item;
292 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
293 item.fileSystemURL = it->url;
294 item.fileSystemFileSize = it->size;
295 item_list.push_back(item);
296 }
297
298 for (std::map<base::string16, base::string16>::const_iterator it =
299 drop_data.custom_data.begin();
300 it != drop_data.custom_data.end();
301 ++it) {
302 WebDragData::Item item;
303 item.storageType = WebDragData::Item::StorageTypeString;
304 item.stringType = it->first;
305 item.stringData = it->second;
306 item_list.push_back(item);
307 }
308
309 WebDragData result;
310 result.initialize();
311 result.setItems(item_list);
312 result.setFilesystemId(drop_data.filesystem_id);
313 return result;
314 }
315
185 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget = 316 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget =
186 nullptr; 317 nullptr;
187 318
188 content::RenderWidget::RenderWidgetInitializedCallback 319 content::RenderWidget::RenderWidgetInitializedCallback
189 g_render_widget_initialized = nullptr; 320 g_render_widget_initialized = nullptr;
190 321
191 ui::TextInputType ConvertWebTextInputType(blink::WebTextInputType type) { 322 ui::TextInputType ConvertWebTextInputType(blink::WebTextInputType type) {
192 // Check the type is in the range representable by ui::TextInputType. 323 // Check the type is in the range representable by ui::TextInputType.
193 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) 324 DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX))
194 << "blink::WebTextInputType and ui::TextInputType not synchronized"; 325 << "blink::WebTextInputType and ui::TextInputType not synchronized";
195 return static_cast<ui::TextInputType>(type); 326 return static_cast<ui::TextInputType>(type);
196 } 327 }
197 328
198 ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) { 329 ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) {
199 // Check the mode is in the range representable by ui::TextInputMode. 330 // Check the mode is in the range representable by ui::TextInputMode.
200 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) 331 DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX))
201 << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; 332 << "blink::WebTextInputMode and ui::TextInputMode not synchronized";
202 return static_cast<ui::TextInputMode>(mode); 333 return static_cast<ui::TextInputMode>(mode);
203 } 334 }
204 335
205 } // namespace 336 } // namespace
206 337
207 namespace content {
208
209 // RenderWidget --------------------------------------------------------------- 338 // RenderWidget ---------------------------------------------------------------
210 339
211 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 340 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
212 blink::WebPopupType popup_type, 341 blink::WebPopupType popup_type,
213 const ScreenInfo& screen_info, 342 const ScreenInfo& screen_info,
214 bool swapped_out, 343 bool swapped_out,
215 bool hidden, 344 bool hidden,
216 bool never_visible) 345 bool never_visible)
217 : routing_id_(MSG_ROUTING_NONE), 346 : routing_id_(MSG_ROUTING_NONE),
218 compositor_deps_(compositor_deps), 347 compositor_deps_(compositor_deps),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) 642 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden)
514 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) 643 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown)
515 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 644 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
516 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 645 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
517 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 646 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
518 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 647 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
519 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests, 648 IPC_MESSAGE_HANDLER(ViewMsg_WaitForNextFrameForTests,
520 OnWaitNextFrameForTests) 649 OnWaitNextFrameForTests)
521 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate, 650 IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate,
522 OnRequestCompositionUpdate) 651 OnRequestCompositionUpdate)
652 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
653 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
654 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
655 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
656 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
523 #if defined(OS_ANDROID) 657 #if defined(OS_ANDROID)
524 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck) 658 IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
525 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate, 659 IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
526 OnRequestTextInputStateUpdate) 660 OnRequestTextInputStateUpdate)
527 #endif 661 #endif
528 IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
529 IPC_MESSAGE_UNHANDLED(handled = false) 662 IPC_MESSAGE_UNHANDLED(handled = false)
530 IPC_END_MESSAGE_MAP() 663 IPC_END_MESSAGE_MAP()
531 return handled; 664 return handled;
532 } 665 }
533 666
534 bool RenderWidget::Send(IPC::Message* message) { 667 bool RenderWidget::Send(IPC::Message* message) {
535 // Don't send any messages after the browser has told us to close, and filter 668 // Don't send any messages after the browser has told us to close, and filter
536 // most outgoing messages while swapped out. 669 // most outgoing messages while swapped out.
537 if ((is_swapped_out_ && 670 if ((is_swapped_out_ &&
538 !SwappedOutMessages::CanSendWhileSwappedOut(message)) || 671 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); 1656 screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect);
1524 else 1657 else
1525 window_screen_rect_ = window_screen_rect; 1658 window_screen_rect_ = window_screen_rect;
1526 } 1659 }
1527 1660
1528 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) { 1661 void RenderWidget::OnHandleCompositorProto(const std::vector<uint8_t>& proto) {
1529 if (compositor_) 1662 if (compositor_)
1530 compositor_->OnHandleCompositorProto(proto); 1663 compositor_->OnHandleCompositorProto(proto);
1531 } 1664 }
1532 1665
1666 void RenderWidget::OnDragTargetDragEnter(
1667 const std::vector<DropData::Metadata>& drop_meta_data,
1668 const gfx::Point& client_point,
1669 const gfx::Point& screen_point,
1670 WebDragOperationsMask ops,
1671 int key_modifiers) {
1672 if (!GetWebWidget())
dcheng 2016/11/09 20:23:17 How come this needs to do null checks, but RenderV
paulmeyer 2016/11/09 23:19:11 It seems to be possible for this message to come d
1673 return;
1674
1675 DCHECK(GetWebWidget()->isWebFrameWidget());
1676 WebDragOperation operation = static_cast<WebFrameWidget*>(GetWebWidget())->
1677 dragTargetDragEnter(DropMetaDataToWebDragData(drop_meta_data),
1678 client_point, screen_point, ops, key_modifiers);
1679
1680 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
1681 }
1682
1683 void RenderWidget::OnDragTargetDragOver(const gfx::Point& client_point,
1684 const gfx::Point& screen_point,
1685 WebDragOperationsMask ops,
1686 int key_modifiers) {
1687 if (!GetWebWidget())
1688 return;
1689
1690 DCHECK(GetWebWidget()->isWebFrameWidget());
1691 WebDragOperation operation =
1692 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDragOver(
1693 ConvertWindowPointToViewport(client_point),
1694 screen_point, ops, key_modifiers);
1695
1696 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
1697 }
1698
1699 void RenderWidget::OnDragTargetDragLeave() {
1700 if (!GetWebWidget())
1701 return;
1702 DCHECK(GetWebWidget()->isWebFrameWidget());
1703 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDragLeave();
1704 }
1705
1706 void RenderWidget::OnDragTargetDrop(const DropData& drop_data,
1707 const gfx::Point& client_point,
1708 const gfx::Point& screen_point,
1709 int key_modifiers) {
1710 if (!GetWebWidget())
1711 return;
1712
1713 DCHECK(GetWebWidget()->isWebFrameWidget());
1714 static_cast<WebFrameWidget*>(GetWebWidget())->dragTargetDrop(
1715 DropDataToWebDragData(drop_data),
1716 ConvertWindowPointToViewport(client_point),
1717 screen_point, key_modifiers);
1718 }
1719
1533 void RenderWidget::showImeIfNeeded() { 1720 void RenderWidget::showImeIfNeeded() {
1534 #if defined(OS_ANDROID) || defined(USE_AURA) 1721 #if defined(OS_ANDROID) || defined(USE_AURA)
1535 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME); 1722 UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_NON_IME);
1536 #endif 1723 #endif
1537 1724
1538 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with 1725 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with
1539 // virtual keyboard. 1726 // virtual keyboard.
1540 #if !defined(OS_ANDROID) 1727 #if !defined(OS_ANDROID)
1541 FocusChangeComplete(); 1728 FocusChangeComplete();
1542 #endif 1729 #endif
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 2247 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
2061 } 2248 }
2062 2249
2063 float RenderWidget::GetOriginalDeviceScaleFactor() const { 2250 float RenderWidget::GetOriginalDeviceScaleFactor() const {
2064 return 2251 return
2065 screen_metrics_emulator_ ? 2252 screen_metrics_emulator_ ?
2066 screen_metrics_emulator_->original_screen_info().device_scale_factor : 2253 screen_metrics_emulator_->original_screen_info().device_scale_factor :
2067 device_scale_factor_; 2254 device_scale_factor_;
2068 } 2255 }
2069 2256
2257 gfx::Point RenderWidget::ConvertWindowPointToViewport(
2258 const gfx::Point& point) {
2259 blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0);
2260 convertWindowToViewport(&point_in_viewport);
2261 return gfx::Point(point_in_viewport.x, point_in_viewport.y);
2262 }
2263
2070 bool RenderWidget::requestPointerLock() { 2264 bool RenderWidget::requestPointerLock() {
2071 return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); 2265 return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get());
2072 } 2266 }
2073 2267
2074 void RenderWidget::requestPointerUnlock() { 2268 void RenderWidget::requestPointerUnlock() {
2075 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2269 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2076 } 2270 }
2077 2271
2078 bool RenderWidget::isPointerLocked() { 2272 bool RenderWidget::isPointerLocked() {
2079 return mouse_lock_dispatcher_->IsMouseLockedTo( 2273 return mouse_lock_dispatcher_->IsMouseLockedTo(
2080 webwidget_mouse_lock_target_.get()); 2274 webwidget_mouse_lock_target_.get());
2081 } 2275 }
2082 2276
2083 void RenderWidget::startDragging(blink::WebReferrerPolicy policy, 2277 void RenderWidget::startDragging(blink::WebReferrerPolicy policy,
2084 const WebDragData& data, 2278 const WebDragData& data,
2085 WebDragOperationsMask mask, 2279 WebDragOperationsMask mask,
2086 const WebImage& image, 2280 const WebImage& image,
2087 const WebPoint& webImageOffset) { 2281 const WebPoint& webImageOffset) {
2088 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0); 2282 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0);
2089 convertViewportToWindow(&offset_in_window); 2283 convertViewportToWindow(&offset_in_window);
2090 DropData drop_data(DropDataBuilder::Build(data)); 2284 DropData drop_data(DropDataBuilder::Build(data));
2091 drop_data.referrer_policy = policy; 2285 drop_data.referrer_policy = policy;
2092 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); 2286 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y);
2093 Send(new DragHostMsg_StartDragging(routing_id_, drop_data, mask, 2287 Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask,
2094 image.getSkBitmap(), imageOffset, 2288 image.getSkBitmap(), imageOffset,
2095 possible_drag_event_info_)); 2289 possible_drag_event_info_));
2096 } 2290 }
2097 2291
2098 blink::WebWidget* RenderWidget::GetWebWidget() const { 2292 blink::WebWidget* RenderWidget::GetWebWidget() const {
2099 return webwidget_internal_; 2293 return webwidget_internal_;
2100 } 2294 }
2101 2295
2102 } // namespace content 2296 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698