diff options
author | arv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 02:38:03 +0000 |
---|---|---|
committer | arv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 02:38:03 +0000 |
commit | 5f9ae6c55bb6cf325bcd85465a370d7fc32bd47a (patch) | |
tree | bb9b9e7c5ef78e47dafb968bea5491ca54d2965b | |
parent | 8f04ff93eba6678ed17b7157f805212d9438507b (diff) | |
download | chromium_src-5f9ae6c55bb6cf325bcd85465a370d7fc32bd47a.zip chromium_src-5f9ae6c55bb6cf325bcd85465a370d7fc32bd47a.tar.gz chromium_src-5f9ae6c55bb6cf325bcd85465a370d7fc32bd47a.tar.bz2 |
Make the cancelling of drag and drop match Safari for Windows. This is
a follow up CL to http://codereview.chromium.org/149038 as well as to
https://bugs.webkit.org/show_bug.cgi?id=26699
With this change we use DragOperationNone (instead of DragOperationCopy)
and NoButton (instead of LeftButton) when the user presses Escape.
BUG=12018
TEST=On the new new tab page drag one of the thumbnails out of the
window and press escape. The thumbnail should move back to its starting
position.
Review URL: http://codereview.chromium.org/149296
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20125 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 13 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 5 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_drag_source.cc | 4 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 5 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 12 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 2 | ||||
-rw-r--r-- | webkit/glue/webview.h | 5 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 12 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 3 |
9 files changed, 49 insertions, 12 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index c06d4fa..cd23770 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -579,13 +579,22 @@ void RenderViewHost::CopyImageAt(int x, int y) { Send(new ViewMsg_CopyImageAt(routing_id(), x, y)); } +void RenderViewHost::DragSourceCancelledAt( + int client_x, int client_y, int screen_x, int screen_y) { + Send(new ViewMsg_DragSourceEndedOrMoved( + routing_id(), + gfx::Point(client_x, client_y), + gfx::Point(screen_x, screen_y), + true, true)); +} + void RenderViewHost::DragSourceEndedAt( int client_x, int client_y, int screen_x, int screen_y) { Send(new ViewMsg_DragSourceEndedOrMoved( routing_id(), gfx::Point(client_x, client_y), gfx::Point(screen_x, screen_y), - true)); + true, false)); } void RenderViewHost::DragSourceMovedTo( @@ -594,7 +603,7 @@ void RenderViewHost::DragSourceMovedTo( routing_id(), gfx::Point(client_x, client_y), gfx::Point(screen_x, screen_y), - false)); + false, false)); } void RenderViewHost::DragSourceSystemDragEnded() { diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index ddae3b1..e7e6a81 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -291,6 +291,11 @@ class RenderViewHost : public RenderWidgetHost, // Copies the image at the specified point. void CopyImageAt(int x, int y); + // Notifies the renderer that a drag and drop was cancelled. This is + // necessary because the render may be the one that started the drag. + void DragSourceCancelledAt( + int client_x, int client_y, int screen_x, int screen_y); + // Notifies the renderer that a drop occurred. This is necessary because the // render may be the one that started the drag. void DragSourceEndedAt( diff --git a/chrome/browser/tab_contents/web_drag_source.cc b/chrome/browser/tab_contents/web_drag_source.cc index 0abf968..d61f3ba2 100644 --- a/chrome/browser/tab_contents/web_drag_source.cc +++ b/chrome/browser/tab_contents/web_drag_source.cc @@ -48,8 +48,8 @@ void WebDragSource::OnDragSourceCancel() { gfx::Point client; gfx::Point screen; GetCursorPositions(source_wnd_, &client, &screen); - render_view_host_->DragSourceEndedAt(client.x(), client.y(), - screen.x(), screen.y()); + render_view_host_->DragSourceCancelledAt(client.x(), client.y(), + screen.x(), screen.y()); } void WebDragSource::OnDragSourceDrop() { diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index d6ff653..0f50867 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -310,10 +310,11 @@ IPC_BEGIN_MESSAGES(View) // Notifies the renderer of updates in mouse position of an in-progress // drag. if |ended| is true, then the user has ended the drag operation. - IPC_MESSAGE_ROUTED3(ViewMsg_DragSourceEndedOrMoved, + IPC_MESSAGE_ROUTED4(ViewMsg_DragSourceEndedOrMoved, gfx::Point /* client_pt */, gfx::Point /* screen_pt */, - bool /* ended */) + bool /* ended */, + bool /* cancelled */) // Notifies the renderer that the system DoDragDrop call has ended. IPC_MESSAGE_ROUTED0(ViewMsg_DragSourceSystemDragEnded) diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 8e6fab8..58328f6 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2442,11 +2442,15 @@ void RenderView::OnReservePageIDRange(int size_of_range) { void RenderView::OnDragSourceEndedOrMoved(const gfx::Point& client_point, const gfx::Point& screen_point, - bool ended) { - if (ended) - webview()->DragSourceEndedAt(client_point, screen_point); - else + bool ended, bool cancelled) { + if (ended) { + if (cancelled) + webview()->DragSourceCancelledAt(client_point, screen_point); + else + webview()->DragSourceEndedAt(client_point, screen_point); + } else { webview()->DragSourceMovedTo(client_point, screen_point); + } } void RenderView::OnDragSourceSystemDragEnded() { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 22d613f..fc01af9 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -524,7 +524,7 @@ class RenderView : public RenderWidget, void OnDragSourceEndedOrMoved(const gfx::Point& client_point, const gfx::Point& screen_point, - bool ended); + bool ended, bool cancelled); void OnDragSourceSystemDragEnded(); void OnInstallMissingPlugin(); void OnFileChooserResponse(const std::vector<FilePath>& file_names); diff --git a/webkit/glue/webview.h b/webkit/glue/webview.h index a2621ab..7468e0a 100644 --- a/webkit/glue/webview.h +++ b/webkit/glue/webview.h @@ -171,6 +171,11 @@ class WebView : public WebWidget { // Show the JavaScript console. virtual void ShowJavaScriptConsole() = 0; + // Notifies the webview that a drag has been cancelled. + virtual void DragSourceCancelledAt( + const WebKit::WebPoint& client_point, + const WebKit::WebPoint& screen_point) = 0; + // Notifies the webview that a drag has terminated. virtual void DragSourceEndedAt( const WebKit::WebPoint& client_point, diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 45ce865..250896e 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1537,13 +1537,23 @@ void WebViewImpl::ShowJavaScriptConsole() { page_->inspectorController()->showPanel(InspectorController::ConsolePanel); } -void WebViewImpl::DragSourceEndedAt( +void WebViewImpl::DragSourceCancelledAt( const WebPoint& client_point, const WebPoint& screen_point) { PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), webkit_glue::WebPointToIntPoint(screen_point), NoButton, MouseEventMoved, 0, false, false, false, false, 0); + page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationNone); +} + +void WebViewImpl::DragSourceEndedAt( + const WebPoint& client_point, + const WebPoint& screen_point) { + PlatformMouseEvent pme(webkit_glue::WebPointToIntPoint(client_point), + webkit_glue::WebPointToIntPoint(screen_point), + LeftButton, MouseEventMoved, 0, false, false, false, + false, 0); page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationCopy); } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index f5908a5..405d654 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -95,6 +95,9 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { virtual void CopyImageAt(int x, int y); virtual void InspectElement(int x, int y); virtual void ShowJavaScriptConsole(); + virtual void DragSourceCancelledAt( + const WebKit::WebPoint& client_point, + const WebKit::WebPoint& screen_point); virtual void DragSourceEndedAt( const WebKit::WebPoint& client_point, const WebKit::WebPoint& screen_point); |