diff options
author | snej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 17:29:25 +0000 |
---|---|---|
committer | snej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-08 17:29:25 +0000 |
commit | 1d9f4137eff50f1305e288767bb770151526552d (patch) | |
tree | 4ae1750d34778e7b0ae23dfe315118cf124c3715 /chrome/browser/renderer_host | |
parent | c7f475ed4a9fd8f198468df696c55e1c75d65526 (diff) | |
download | chromium_src-1d9f4137eff50f1305e288767bb770151526552d.zip chromium_src-1d9f4137eff50f1305e288767bb770151526552d.tar.gz chromium_src-1d9f4137eff50f1305e288767bb770151526552d.tar.bz2 |
Plumb the DragOperation through all the layers between the platform Drag-n-drop code and WebCore.
This allows the HTML5 DataTransfer effectAllowed and dropEffect properties to be set correctly in JS handlers, as per the HTML5 spec.
(The drag-dropeffect test isn't in WebKit yet -- it's part of a separate WebKit patch that's been in review for weeks.)
R=darin,pink
BUG=http://code.google.com/p/chromium/issues/detail?id=14654, http://code.google.com/p/chromium/issues/detail?id=20985
TEST=LayoutTests/fast/events/drag-dropeffect.html, LayoutTests/editing/pasteboard/files-during-page-drags.html
Review URL: http://codereview.chromium.org/174364
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 39 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 24 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 8 |
3 files changed, 36 insertions, 35 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index ba82b80..066d1cc 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -49,6 +49,9 @@ using base::TimeDelta; using webkit_glue::PasswordFormDomManager; using WebKit::WebConsoleMessage; +using WebKit::WebDragOperation; +using WebKit::WebDragOperationNone; +using WebKit::WebDragOperationsMask; using WebKit::WebFindOptions; using WebKit::WebInputEvent; using WebKit::WebTextDirection; @@ -460,7 +463,8 @@ void RenderViewHost::FillPasswordForm( void RenderViewHost::DragTargetDragEnter( const WebDropData& drop_data, const gfx::Point& client_pt, - const gfx::Point& screen_pt) { + const gfx::Point& screen_pt, + WebDragOperationsMask operations_allowed) { // Grant the renderer the ability to load the drop_data. ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); @@ -473,12 +477,14 @@ void RenderViewHost::DragTargetDragEnter( policy->GrantUploadFile(process()->id(), path); } Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt, - screen_pt)); + screen_pt, operations_allowed)); } void RenderViewHost::DragTargetDragOver( - const gfx::Point& client_pt, const gfx::Point& screen_pt) { - Send(new ViewMsg_DragTargetDragOver(routing_id(), client_pt, screen_pt)); + const gfx::Point& client_pt, const gfx::Point& screen_pt, + WebDragOperationsMask operations_allowed) { + Send(new ViewMsg_DragTargetDragOver(routing_id(), client_pt, screen_pt, + operations_allowed)); } void RenderViewHost::DragTargetDragLeave() { @@ -608,22 +614,14 @@ 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) { + int client_x, int client_y, int screen_x, int screen_y, + WebDragOperation operation) { Send(new ViewMsg_DragSourceEndedOrMoved( routing_id(), gfx::Point(client_x, client_y), gfx::Point(screen_x, screen_y), - true, false)); + true, operation)); } void RenderViewHost::DragSourceMovedTo( @@ -632,7 +630,7 @@ void RenderViewHost::DragSourceMovedTo( routing_id(), gfx::Point(client_x, client_y), gfx::Point(screen_x, screen_y), - false, false)); + false, WebDragOperationNone)); } void RenderViewHost::DragSourceSystemDragEnded() { @@ -1331,16 +1329,17 @@ void RenderViewHost::OnMsgAutofillFormSubmitted( } void RenderViewHost::OnMsgStartDragging( - const WebDropData& drop_data) { + const WebDropData& drop_data, + WebDragOperationsMask drag_operations_mask) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); if (view) - view->StartDragging(drop_data); + view->StartDragging(drop_data, drag_operations_mask); } -void RenderViewHost::OnUpdateDragCursor(bool is_drop_target) { +void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); if (view) - view->UpdateDragCursor(is_drop_target); + view->UpdateDragCursor(current_op); } void RenderViewHost::OnTakeFocus(bool reverse) { diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index f733f7b..81637aa 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -16,6 +16,7 @@ #include "chrome/common/notification_registrar.h" #include "chrome/common/page_zoom.h" #include "webkit/api/public/WebConsoleMessage.h" +#include "webkit/api/public/WebDragOperation.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/password_form_dom_manager.h" @@ -238,9 +239,11 @@ class RenderViewHost : public RenderWidgetHost, // D&d drop target messages that get sent to WebKit. void DragTargetDragEnter(const WebDropData& drop_data, const gfx::Point& client_pt, - const gfx::Point& screen_pt); + const gfx::Point& screen_pt, + WebKit::WebDragOperationsMask operations_allowed); void DragTargetDragOver(const gfx::Point& client_pt, - const gfx::Point& screen_pt); + const gfx::Point& screen_pt, + WebKit::WebDragOperationsMask operations_allowed); void DragTargetDragLeave(); void DragTargetDrop(const gfx::Point& client_pt, const gfx::Point& screen_pt); @@ -306,15 +309,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. + // Notifies the renderer that a a drag operation that it started has ended, + // either in a drop or by being cancelled. void DragSourceEndedAt( - int client_x, int client_y, int screen_x, int screen_y); + int client_x, int client_y, int screen_x, int screen_y, + WebKit::WebDragOperation operation); // Notifies the renderer that a drag and drop operation is in progress, with // droppable items positioned over the renderer's view. @@ -526,8 +525,9 @@ class RenderViewHost : public RenderWidgetHost, void OnMsgPasswordFormsSeen( const std::vector<webkit_glue::PasswordForm>& forms); void OnMsgAutofillFormSubmitted(const webkit_glue::AutofillForm& forms); - void OnMsgStartDragging(const WebDropData& drop_data); - void OnUpdateDragCursor(bool is_drop_target); + void OnMsgStartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask operations_allowed); + void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation); void OnTakeFocus(bool reverse); void OnMsgPageHasOSDD(int32 page_id, const GURL& doc_url, bool autodetected); void OnDidGetPrintedPagesCount(int cookie, int number_pages); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 6e62289..c1e301c 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -12,6 +12,7 @@ #include "base/string16.h" #include "chrome/common/view_types.h" #include "net/base/load_states.h" +#include "webkit/api/public/WebDragOperation.h" #include "webkit/glue/window_open_disposition.h" class AutofillForm; @@ -111,11 +112,12 @@ class RenderViewHostDelegate { // The user started dragging content of the specified type within the // RenderView. Contextual information about the dragged content is supplied // by WebDropData. - virtual void StartDragging(const WebDropData& drop_data) = 0; + virtual void StartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask allowed_ops) = 0; // The page wants to update the mouse cursor during a drag & drop operation. - // |is_drop_target| is true if the mouse is over a valid drop target. - virtual void UpdateDragCursor(bool is_drop_target) = 0; + // |operation| describes the current operation (none, move, copy, link.) + virtual void UpdateDragCursor(WebKit::WebDragOperation operation) = 0; // Notification that view for this delegate got the focus. virtual void GotFocus() = 0; |