From 14276743cac1ab9dff9fa73cd4d25213fd8fa963 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Fri, 1 Sep 2023 03:28:57 +0000 Subject: [PATCH] Change StartDragging IPC to be per-frame. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows per-frame info, such as origin, to be attributed to drags. Bug: 1346429 Change-Id: Ia0b947bb0062458071ca07616f8dd741689b5b9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4828259 Reviewed-by: Alex Moshchuk Reviewed-by: Ɓukasz Anforowicz Commit-Queue: Daniel Cheng Cr-Commit-Position: refs/heads/main@{#1191144} --- .../renderer_host/render_frame_host_impl.cc | 12 ++ .../renderer_host/render_frame_host_impl.h | 6 + .../renderer_host/render_widget_host_impl.cc | 182 +++++++++--------- .../renderer_host/render_widget_host_impl.h | 13 +- .../public/test/fake_render_widget_host.cc | 8 - content/public/test/fake_render_widget_host.h | 6 - content/test/test_render_view_host.cc | 2 +- .../blink/public/mojom/frame/frame.mojom | 13 ++ .../blink/public/mojom/page/widget.mojom | 11 -- .../renderer/core/frame/frame_test_helpers.cc | 8 - .../renderer/core/frame/frame_test_helpers.h | 6 - .../core/frame/web_frame_widget_impl.cc | 5 +- .../core/frame/web_frame_widget_impl.h | 3 +- .../core/frame/web_frame_widget_test.cc | 5 +- .../renderer/core/page/chrome_client_impl.cc | 2 +- .../core/testing/fake_local_frame_host.cc | 8 + .../core/testing/fake_local_frame_host.h | 6 + .../web_test_web_frame_widget_impl.cc | 5 +- .../web_test/web_test_web_frame_widget_impl.h | 3 +- 19 files changed, 158 insertions(+), 146 deletions(-) diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 8da967805f8f82..6646263a52601e 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -8885,6 +8885,18 @@ void RenderFrameHostImpl::OnViewTransitionOptInChanged( ->set_same_origin_opt_in(view_transition_opt_in); } +void RenderFrameHostImpl::StartDragging( + blink::mojom::DragDataPtr drag_data, + blink::DragOperationsMask drag_operations_mask, + const SkBitmap& unsafe_bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + blink::mojom::DragEventSourceInfoPtr event_info) { + GetRenderWidgetHost()->StartDragging( + std::move(drag_data), drag_operations_mask, unsafe_bitmap, + cursor_offset_in_dip, drag_obj_rect_in_dip, std::move(event_info)); +} + void RenderFrameHostImpl::CreateNewPopupWidget( mojo::PendingAssociatedReceiver blink_popup_widget_host, diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index e7a0baa59a0c0b..10282bf7372a07 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h @@ -2485,6 +2485,12 @@ class CONTENT_EXPORT RenderFrameHostImpl const base::UnguessableToken& devtools_frame_token) override; void OnViewTransitionOptInChanged(blink::mojom::ViewTransitionSameOriginOptIn view_transition_opt_in) override; + void StartDragging(blink::mojom::DragDataPtr drag_data, + blink::DragOperationsMask drag_operations_mask, + const SkBitmap& unsafe_bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + blink::mojom::DragEventSourceInfoPtr event_info) override; // blink::mojom::BackForwardCacheControllerHost: void EvictFromBackForwardCache(blink::mojom::RendererEvictionReason) override; diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 570695fa56c84b..9e946e02bca276 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -2694,6 +2694,97 @@ void RenderWidgetHostImpl::UpdateBrowserControlsState( animate); } +void RenderWidgetHostImpl::StartDragging( + blink::mojom::DragDataPtr drag_data, + DragOperationsMask drag_operations_mask, + const SkBitmap& bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + blink::mojom::DragEventSourceInfoPtr event_info) { + DropData drop_data = DragDataToDropData(*drag_data); + DropData filtered_data(drop_data); + RenderProcessHost* process = GetProcess(); + ChildProcessSecurityPolicyImpl* policy = + ChildProcessSecurityPolicyImpl::GetInstance(); + + // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar. + if (!filtered_data.url.SchemeIs(url::kJavaScriptScheme)) { + process->FilterURL(true, &filtered_data.url); + } + process->FilterURL(false, &filtered_data.html_base_url); + // Filter out any paths that the renderer didn't have access to. This prevents + // the following attack on a malicious renderer: + // 1. StartDragging IPC sent with renderer-specified filesystem paths that it + // doesn't have read permissions for. + // 2. We initiate a native DnD operation. + // 3. DnD operation immediately ends since mouse is not held down. DnD events + // still fire though, which causes read permissions to be granted to the + // renderer for any file paths in the drop. + filtered_data.filenames.clear(); + for (const auto& file_info : drop_data.filenames) { + if (policy->CanReadFile(GetProcess()->GetID(), file_info.path)) { + filtered_data.filenames.push_back(file_info); + } + } + + storage::FileSystemContext* file_system_context = + GetProcess()->GetStoragePartition()->GetFileSystemContext(); + filtered_data.file_system_files.clear(); + + for (const auto& file_system_file : drop_data.file_system_files) { + storage::FileSystemURL file_system_url = + file_system_context->CrackURLInFirstPartyContext(file_system_file.url); + + // Sandboxed filesystem files should never be handled via this path, so + // skip any that are sent from the renderer. In all other cases, it should + // be safe to use the FileSystemURL returned from calling + // CrackURLInFirstPartyContext as long as CanReadFileSystemFile only + // performs checks on the origin and doesn't use more of the StorageKey. + if (file_system_url.type() == storage::kFileSystemTypePersistent || + file_system_url.type() == storage::kFileSystemTypeTemporary) { + continue; + } + + if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) { + filtered_data.file_system_files.push_back(file_system_file); + } + } + + if (frame_tree_) { + bool intercepted = false; + devtools_instrumentation::WillStartDragging( + frame_tree_->root(), filtered_data, std::move(drag_data), + drag_operations_mask, &intercepted); + if (intercepted) { + return; + } + } + + RenderViewHostDelegateView* view = delegate_->GetDelegateView(); + if (!view || !GetView()) { + // Need to clear drag and drop state in blink. + DragSourceSystemDragEnded(); + return; + } + float scale = GetScaleFactorForView(GetView()); + gfx::ImageSkia image = gfx::ImageSkia::CreateFromBitmap(bitmap, scale); + gfx::Vector2d offset = cursor_offset_in_dip; + gfx::Rect rect = drag_obj_rect_in_dip; +#if BUILDFLAG(IS_WIN) + // Scale the offset by device scale factor, otherwise the drag + // image location doesn't line up with the drop location (drag destination). + // TODO(crbug.com/1354831): this conversion should not be necessary. + gfx::Vector2dF scaled_offset = static_cast(offset); + scaled_offset.Scale(scale); + offset = gfx::ToRoundedVector2d(scaled_offset); + gfx::RectF scaled_rect = static_cast(rect); + scaled_rect.Scale(scale); + rect = gfx::ToRoundedRect(scaled_rect); +#endif + view->StartDragging(filtered_data, drag_operations_mask, image, offset, rect, + *event_info, this); +} + // static bool RenderWidgetHostImpl::DidVisualPropertiesSizeChange( const blink::VisualProperties& old_visual_properties, @@ -2849,97 +2940,6 @@ void RenderWidgetHostImpl::AutoscrollEnd() { cancel_event, ui::LatencyInfo(ui::SourceEventType::OTHER)); } -void RenderWidgetHostImpl::StartDragging( - blink::mojom::DragDataPtr drag_data, - DragOperationsMask drag_operations_mask, - const SkBitmap& bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - blink::mojom::DragEventSourceInfoPtr event_info) { - DropData drop_data = DragDataToDropData(*drag_data); - DropData filtered_data(drop_data); - RenderProcessHost* process = GetProcess(); - ChildProcessSecurityPolicyImpl* policy = - ChildProcessSecurityPolicyImpl::GetInstance(); - - // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar. - if (!filtered_data.url.SchemeIs(url::kJavaScriptScheme)) { - process->FilterURL(true, &filtered_data.url); - } - process->FilterURL(false, &filtered_data.html_base_url); - // Filter out any paths that the renderer didn't have access to. This prevents - // the following attack on a malicious renderer: - // 1. StartDragging IPC sent with renderer-specified filesystem paths that it - // doesn't have read permissions for. - // 2. We initiate a native DnD operation. - // 3. DnD operation immediately ends since mouse is not held down. DnD events - // still fire though, which causes read permissions to be granted to the - // renderer for any file paths in the drop. - filtered_data.filenames.clear(); - for (const auto& file_info : drop_data.filenames) { - if (policy->CanReadFile(GetProcess()->GetID(), file_info.path)) { - filtered_data.filenames.push_back(file_info); - } - } - - storage::FileSystemContext* file_system_context = - GetProcess()->GetStoragePartition()->GetFileSystemContext(); - filtered_data.file_system_files.clear(); - - for (const auto& file_system_file : drop_data.file_system_files) { - storage::FileSystemURL file_system_url = - file_system_context->CrackURLInFirstPartyContext(file_system_file.url); - - // Sandboxed filesystem files should never be handled via this path, so - // skip any that are sent from the renderer. In all other cases, it should - // be safe to use the FileSystemURL returned from calling - // CrackURLInFirstPartyContext as long as CanReadFileSystemFile only - // performs checks on the origin and doesn't use more of the StorageKey. - if (file_system_url.type() == storage::kFileSystemTypePersistent || - file_system_url.type() == storage::kFileSystemTypeTemporary) { - continue; - } - - if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) { - filtered_data.file_system_files.push_back(file_system_file); - } - } - - if (frame_tree_) { - bool intercepted = false; - devtools_instrumentation::WillStartDragging( - frame_tree_->root(), filtered_data, std::move(drag_data), - drag_operations_mask, &intercepted); - if (intercepted) { - return; - } - } - - RenderViewHostDelegateView* view = delegate_->GetDelegateView(); - if (!view || !GetView()) { - // Need to clear drag and drop state in blink. - DragSourceSystemDragEnded(); - return; - } - float scale = GetScaleFactorForView(GetView()); - gfx::ImageSkia image = gfx::ImageSkia::CreateFromBitmap(bitmap, scale); - gfx::Vector2d offset = cursor_offset_in_dip; - gfx::Rect rect = drag_obj_rect_in_dip; -#if BUILDFLAG(IS_WIN) - // Scale the offset by device scale factor, otherwise the drag - // image location doesn't line up with the drop location (drag destination). - // TODO(crbug.com/1354831): this conversion should not be necessary. - gfx::Vector2dF scaled_offset = static_cast(offset); - scaled_offset.Scale(scale); - offset = gfx::ToRoundedVector2d(scaled_offset); - gfx::RectF scaled_rect = static_cast(rect); - scaled_rect.Scale(scale); - rect = gfx::ToRoundedRect(scaled_rect); -#endif - view->StartDragging(filtered_data, drag_operations_mask, image, offset, rect, - *event_info, this); -} - bool RenderWidgetHostImpl::IsAutoscrollInProgress() { return autoscroll_in_progress_; } diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 17d59903f24120..cd75eee211a8ea 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -908,6 +908,13 @@ class CONTENT_EXPORT RenderWidgetHostImpl cc::BrowserControlsState current, bool animate); + void StartDragging(blink::mojom::DragDataPtr drag_data, + blink::DragOperationsMask drag_operations_mask, + const SkBitmap& unsafe_bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + blink::mojom::DragEventSourceInfoPtr event_info); + protected: // |routing_id| must not be MSG_ROUTING_NONE. // If this object outlives |delegate|, DetachDelegate() must be called when @@ -1037,12 +1044,6 @@ class CONTENT_EXPORT RenderWidgetHostImpl void AutoscrollStart(const gfx::PointF& position) override; void AutoscrollFling(const gfx::Vector2dF& velocity) override; void AutoscrollEnd() override; - void StartDragging(blink::mojom::DragDataPtr drag_data, - blink::DragOperationsMask drag_operations_mask, - const SkBitmap& unsafe_bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - blink::mojom::DragEventSourceInfoPtr event_info) override; // When the RenderWidget is destroyed and recreated, this resets states in the // browser to match the clean start for the renderer side. diff --git a/content/public/test/fake_render_widget_host.cc b/content/public/test/fake_render_widget_host.cc index 9a28b06589af4e..84b3b64d5af8f4 100644 --- a/content/public/test/fake_render_widget_host.cc +++ b/content/public/test/fake_render_widget_host.cc @@ -126,14 +126,6 @@ void FakeRenderWidgetHost::AutoscrollFling(const gfx::Vector2dF& position) {} void FakeRenderWidgetHost::AutoscrollEnd() {} -void FakeRenderWidgetHost::StartDragging( - blink::mojom::DragDataPtr drag_data, - blink::DragOperationsMask operations_allowed, - const SkBitmap& bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - blink::mojom::DragEventSourceInfoPtr event_info) {} - blink::mojom::WidgetInputHandler* FakeRenderWidgetHost::GetWidgetInputHandler() { if (!widget_input_handler_) { diff --git a/content/public/test/fake_render_widget_host.h b/content/public/test/fake_render_widget_host.h index 6d9e765e633d8c..a5c73c15765a32 100644 --- a/content/public/test/fake_render_widget_host.h +++ b/content/public/test/fake_render_widget_host.h @@ -50,12 +50,6 @@ class FakeRenderWidgetHost : public blink::mojom::FrameWidgetHost, void AutoscrollStart(const gfx::PointF& position) override; void AutoscrollFling(const gfx::Vector2dF& position) override; void AutoscrollEnd() override; - void StartDragging(blink::mojom::DragDataPtr drag_data, - blink::DragOperationsMask operations_allowed, - const SkBitmap& bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - blink::mojom::DragEventSourceInfoPtr event_info) override; // blink::mojom::WidgetHost overrides. void SetCursor(const ui::Cursor& cursor) override; diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc index a8742873217456..eeb60f374b3f72 100644 --- a/content/test/test_render_view_host.cc +++ b/content/test/test_render_view_host.cc @@ -497,7 +497,7 @@ void TestRenderViewHost::TestStartDragging(const DropData& drop_data, SkBitmap bitmap) { StoragePartitionImpl* storage_partition = static_cast(GetProcess()->GetStoragePartition()); - GetWidget()->StartDragging( + GetMainRenderFrameHost()->StartDragging( DropDataToDragData( drop_data, storage_partition->GetFileSystemAccessManager(), GetProcess()->GetID(), diff --git a/third_party/blink/public/mojom/frame/frame.mojom b/third_party/blink/public/mojom/frame/frame.mojom index 0596a026e4fe0d..e4c811a9ac7416 100644 --- a/third_party/blink/public/mojom/frame/frame.mojom +++ b/third_party/blink/public/mojom/frame/frame.mojom @@ -18,6 +18,7 @@ import "services/network/public/mojom/network_types.mojom"; import "services/network/public/mojom/source_location.mojom"; import "services/network/public/mojom/url_loader_completion_status.mojom"; import "services/network/public/mojom/attribution.mojom"; +import "skia/public/mojom/bitmap.mojom"; import "skia/public/mojom/skcolor.mojom"; import "skia/public/mojom/skcolor4f.mojom"; import "third_party/blink/public/mojom/blob/blob.mojom"; @@ -29,6 +30,7 @@ import "third_party/blink/public/mojom/css/preferred_color_scheme.mojom"; import "third_party/blink/public/mojom/devtools/console_message.mojom"; import "third_party/blink/public/mojom/devtools/devtools_agent.mojom"; import "third_party/blink/public/mojom/devtools/inspector_issue.mojom"; +import "third_party/blink/public/mojom/drag/drag.mojom"; import "third_party/blink/public/mojom/favicon/favicon_url.mojom"; import "third_party/blink/public/mojom/fenced_frame/fenced_frame.mojom"; import "third_party/blink/public/mojom/fenced_frame/fenced_frame_config.mojom"; @@ -759,6 +761,17 @@ interface LocalFrameHost { // See https://github.com/WICG/view-transitions/blob/main/explainer.md#declarative-opt-in-to-transitions. OnViewTransitionOptInChanged( ViewTransitionSameOriginOptIn view_transition_opt_in); + + // Used to tell the browser the user started dragging in the content area. + // |drag_data| contains contextual information about the pieces of the page + // the user dragged. The browser uses this notification to initiate a drag + // session at the OS level. + StartDragging(DragData drag_data, + AllowedDragOperations operations_allowed, + skia.mojom.BitmapN32? image, + gfx.mojom.Vector2d cursor_offset_in_dip, + gfx.mojom.Rect drag_obj_rect_in_dip, + DragEventSourceInfo event_info); }; // Implemented in Browser, this interface defines frame-specific methods diff --git a/third_party/blink/public/mojom/page/widget.mojom b/third_party/blink/public/mojom/page/widget.mojom index 9cf30401cc6210..831f4a9deae188 100644 --- a/third_party/blink/public/mojom/page/widget.mojom +++ b/third_party/blink/public/mojom/page/widget.mojom @@ -184,17 +184,6 @@ interface FrameWidgetHost { // Sent by a widget to the browser to notify the end of the autoscroll. AutoscrollEnd(); - - // Used to tell the browser the user started dragging in the content area. - // |drag_data| contains contextual information about the pieces of the page - // the user dragged. The browser uses this notification to initiate a drag - // session at the OS level. - StartDragging(DragData drag_data, - AllowedDragOperations operations_allowed, - skia.mojom.BitmapN32? image, - gfx.mojom.Vector2d cursor_offset_in_dip, - gfx.mojom.Rect drag_obj_rect_in_dip, - DragEventSourceInfo event_info); }; // Implemented in Browser, this interface defines popup-widget-specific methods diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.cc b/third_party/blink/renderer/core/frame/frame_test_helpers.cc index 097580fa58c2d0..517db8dc0b35e3 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.cc +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.cc @@ -1086,14 +1086,6 @@ void TestWebFrameWidgetHost::AutoscrollFling(const gfx::Vector2dF& position) {} void TestWebFrameWidgetHost::AutoscrollEnd() {} -void TestWebFrameWidgetHost::StartDragging( - const blink::WebDragData& drag_data, - blink::DragOperationsMask operations_allowed, - const SkBitmap& bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - mojom::blink::DragEventSourceInfoPtr event_info) {} - void TestWebFrameWidgetHost::BindWidgetHost( mojo::PendingAssociatedReceiver receiver, mojo::PendingAssociatedReceiver diff --git a/third_party/blink/renderer/core/frame/frame_test_helpers.h b/third_party/blink/renderer/core/frame/frame_test_helpers.h index ee9704cb498b79..2d31d5ad3c260c 100644 --- a/third_party/blink/renderer/core/frame/frame_test_helpers.h +++ b/third_party/blink/renderer/core/frame/frame_test_helpers.h @@ -209,12 +209,6 @@ class TestWebFrameWidgetHost : public mojom::blink::WidgetHost, void AutoscrollStart(const gfx::PointF& position) override; void AutoscrollFling(const gfx::Vector2dF& position) override; void AutoscrollEnd() override; - void StartDragging(const blink::WebDragData& drag_data, - blink::DragOperationsMask operations_allowed, - const SkBitmap& bitmap, - const gfx::Vector2d& cursor_offset_in_dip, - const gfx::Rect& drag_obj_rect_in_dip, - mojom::blink::DragEventSourceInfoPtr event_info) override; void BindWidgetHost( mojo::PendingAssociatedReceiver, diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc index 5a79aafd4c5400..b2540642a5de06 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc @@ -1238,7 +1238,8 @@ void WebFrameWidgetImpl::CancelDrag() { current_drag_data_ = nullptr; } -void WebFrameWidgetImpl::StartDragging(const WebDragData& drag_data, +void WebFrameWidgetImpl::StartDragging(LocalFrame* source_frame, + const WebDragData& drag_data, DragOperationsMask operations_allowed, const SkBitmap& drag_image, const gfx::Vector2d& cursor_offset, @@ -1255,7 +1256,7 @@ void WebFrameWidgetImpl::StartDragging(const WebDragData& drag_data, gfx::Rect drag_obj_rect_in_dips = gfx::Rect(widget_base_->BlinkSpaceToFlooredDIPs(drag_obj_rect.origin()), widget_base_->BlinkSpaceToFlooredDIPs(drag_obj_rect.size())); - GetAssociatedFrameWidgetHost()->StartDragging( + source_frame->GetLocalFrameHostRemote().StartDragging( drag_data, operations_allowed, drag_image, offset_in_dips, drag_obj_rect_in_dips, possible_drag_event_info_.Clone()); } diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h index d9a05d1cf064ca..555ca1a0d30c72 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.h @@ -377,7 +377,8 @@ class CORE_EXPORT WebFrameWidgetImpl void PrepareForFinalLifecyclUpdateForTesting() override; // Called when a drag-n-drop operation should begin. - virtual void StartDragging(const WebDragData&, + virtual void StartDragging(LocalFrame* source_frame, + const WebDragData&, DragOperationsMask, const SkBitmap& drag_image, const gfx::Vector2d& cursor_offset, diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_test.cc b/third_party/blink/renderer/core/frame/web_frame_widget_test.cc index fc1e3c2d7a0cae..2e6162cc1d7dbc 100644 --- a/third_party/blink/renderer/core/frame/web_frame_widget_test.cc +++ b/third_party/blink/renderer/core/frame/web_frame_widget_test.cc @@ -848,8 +848,9 @@ TEST_P(WebFrameWidgetInputEventsSimTest, DispatchBufferedTouchEvents) { // Expect listener does not get called, due to drag. touch.MovePoint(0, 14, 14); - widget->StartDragging(WebDragData(), kDragOperationCopy, SkBitmap(), - gfx::Vector2d(), gfx::Rect()); + widget->StartDragging(MainFrame().GetFrame(), WebDragData(), + kDragOperationCopy, SkBitmap(), gfx::Vector2d(), + gfx::Rect()); widget->ProcessInputEventSynchronouslyForTesting( WebCoalescedInputEvent(touch.Clone(), {}, {}, ui::LatencyInfo()), base::DoNothing()); diff --git a/third_party/blink/renderer/core/page/chrome_client_impl.cc b/third_party/blink/renderer/core/page/chrome_client_impl.cc index b01e6a74ad2c61..04f2127c5ebe1b 100644 --- a/third_party/blink/renderer/core/page/chrome_client_impl.cc +++ b/third_party/blink/renderer/core/page/chrome_client_impl.cc @@ -269,7 +269,7 @@ void ChromeClientImpl::StartDragging(LocalFrame* frame, const gfx::Rect& drag_obj_rect) { WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); web_frame->LocalRootFrameWidget()->StartDragging( - drag_data, mask, drag_image, cursor_offset, drag_obj_rect); + frame, drag_data, mask, drag_image, cursor_offset, drag_obj_rect); } bool ChromeClientImpl::AcceptsLoadDrops() const { diff --git a/third_party/blink/renderer/core/testing/fake_local_frame_host.cc b/third_party/blink/renderer/core/testing/fake_local_frame_host.cc index 906449754d0566..81eb7fb1250763 100644 --- a/third_party/blink/renderer/core/testing/fake_local_frame_host.cc +++ b/third_party/blink/renderer/core/testing/fake_local_frame_host.cc @@ -310,4 +310,12 @@ void FakeLocalFrameHost::CreateFencedFrame( "unit tests, so this path should not be hit"; } +void FakeLocalFrameHost::StartDragging( + const blink::WebDragData& drag_data, + blink::DragOperationsMask operations_allowed, + const SkBitmap& bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + mojom::blink::DragEventSourceInfoPtr event_info) {} + } // namespace blink diff --git a/third_party/blink/renderer/core/testing/fake_local_frame_host.h b/third_party/blink/renderer/core/testing/fake_local_frame_host.h index 3d1713c6a355ce..23224e98a376e3 100644 --- a/third_party/blink/renderer/core/testing/fake_local_frame_host.h +++ b/third_party/blink/renderer/core/testing/fake_local_frame_host.h @@ -216,6 +216,12 @@ class FakeLocalFrameHost : public mojom::blink::LocalFrameHost { const base::UnguessableToken& devtools_frame_token) override; void OnViewTransitionOptInChanged( mojom::blink::ViewTransitionSameOriginOptIn) override {} + void StartDragging(const blink::WebDragData& drag_data, + blink::DragOperationsMask operations_allowed, + const SkBitmap& bitmap, + const gfx::Vector2d& cursor_offset_in_dip, + const gfx::Rect& drag_obj_rect_in_dip, + mojom::blink::DragEventSourceInfoPtr event_info) override; private: void BindFrameHostReceiver(mojo::ScopedInterfaceEndpointHandle handle); diff --git a/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.cc b/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.cc index 40a4118cdfafb0..af66af896b5a52 100644 --- a/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.cc +++ b/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.cc @@ -157,14 +157,15 @@ bool WebTestWebFrameWidgetImpl::RequestedMainFramePending() { } void WebTestWebFrameWidgetImpl::StartDragging( + LocalFrame* source_frame, const WebDragData& data, DragOperationsMask mask, const SkBitmap& drag_image, const gfx::Vector2d& cursor_offset, const gfx::Rect& drag_obj_rect) { if (!GetTestRunner()->AutomaticDragDropEnabled()) { - return WebFrameWidgetImpl::StartDragging(data, mask, drag_image, - cursor_offset, drag_obj_rect); + return WebFrameWidgetImpl::StartDragging( + source_frame, data, mask, drag_image, cursor_offset, drag_obj_rect); } // When running a test, we need to fake a drag drop operation otherwise diff --git a/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.h b/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.h index 35c662ae19f075..5d10b25fcae21c 100644 --- a/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.h +++ b/third_party/blink/renderer/core/web_test/web_test_web_frame_widget_impl.h @@ -65,7 +65,8 @@ class WebTestWebFrameWidgetImpl : public WebFrameWidgetImpl, private: // WebFrameWidgetImpl overrides. void BindLocalRoot(WebLocalFrame&) override; - void StartDragging(const WebDragData& drag_data, + void StartDragging(LocalFrame* source_frame, + const WebDragData& drag_data, DragOperationsMask operations_allowed, const SkBitmap& drag_image, const gfx::Vector2d& cursor_offset,