summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authorsnej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:29:25 +0000
committersnej@chromium.org <snej@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:29:25 +0000
commit1d9f4137eff50f1305e288767bb770151526552d (patch)
tree4ae1750d34778e7b0ae23dfe315118cf124c3715 /webkit/tools
parentc7f475ed4a9fd8f198468df696c55e1c75d65526 (diff)
downloadchromium_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 'webkit/tools')
-rw-r--r--webkit/tools/layout_tests/test_expectations.txt3
-rw-r--r--webkit/tools/test_shell/drag_delegate.cc3
-rw-r--r--webkit/tools/test_shell/drop_delegate.cc20
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc34
-rw-r--r--webkit/tools/test_shell/event_sending_controller.h6
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc9
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h4
7 files changed, 57 insertions, 22 deletions
diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt
index 5694113..495ff44 100644
--- a/webkit/tools/layout_tests/test_expectations.txt
+++ b/webkit/tools/layout_tests/test_expectations.txt
@@ -2400,9 +2400,6 @@ BUG20376 WIN : LayoutTests/media/video-src-remove.html = TIMEOUT FAIL
BUG20987 : LayoutTests/fast/events/pageshow-pagehide-on-back-uncached.html = FAIL
BUG20987 : LayoutTests/fast/events/pageshow-pagehide.html = FAIL
-// WebKit 47827:47830
-BUG20985 : LayoutTests/editing/pasteboard/files-during-page-drags.html = FAIL
-
// This newly added test times out on Mac:
BUG20438 MAC : chrome/plugins/get-url-with-iframe-target.html = TIMEOUT
BUG20438 MAC : chrome/plugins/get-url-with-iframe-target-no-crash.html = TIMEOUT
diff --git a/webkit/tools/test_shell/drag_delegate.cc b/webkit/tools/test_shell/drag_delegate.cc
index 5f447ef..d9c45cd 100644
--- a/webkit/tools/test_shell/drag_delegate.cc
+++ b/webkit/tools/test_shell/drag_delegate.cc
@@ -35,7 +35,8 @@ void TestDragDelegate::OnDragSourceDrop() {
gfx::Point client;
gfx::Point screen;
GetCursorPositions(source_hwnd_, &client, &screen);
- webview_->DragSourceEndedAt(client, screen);
+ webview_->DragSourceEndedAt(client, screen, WebKit::WebDragOperationCopy);
+ // TODO(snej): Pass the real drag operation instead
}
void TestDragDelegate::OnDragSourceMove() {
diff --git a/webkit/tools/test_shell/drop_delegate.cc b/webkit/tools/test_shell/drop_delegate.cc
index 41b4767..ce0e0dc6 100644
--- a/webkit/tools/test_shell/drop_delegate.cc
+++ b/webkit/tools/test_shell/drop_delegate.cc
@@ -9,6 +9,8 @@
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webview.h"
+using WebKit::WebDragOperation;
+using WebKit::WebDragOperationCopy;
using WebKit::WebPoint;
// BaseDropTarget methods ----------------------------------------------------
@@ -22,11 +24,14 @@ DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object,
POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt);
- bool valid = webview_->DragTargetDragEnter(
+ WebDragOperation op = webview_->DragTargetDragEnter(
drop_data.ToDragData(), drop_data.identity,
WebPoint(client_pt.x, client_pt.y),
- WebPoint(cursor_position.x, cursor_position.y));
- return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ WebPoint(cursor_position.x, cursor_position.y),
+ WebDragOperationCopy);
+ // TODO(snej): Pass the real drag operation instead
+ return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ // TODO(snej): Return the real drop effect constant matching 'op'
}
DWORD TestDropDelegate::OnDragOver(IDataObject* data_object,
@@ -35,10 +40,13 @@ DWORD TestDropDelegate::OnDragOver(IDataObject* data_object,
DWORD effect) {
POINT client_pt = cursor_position;
ScreenToClient(GetHWND(), &client_pt);
- bool valid = webview_->DragTargetDragOver(
+ WebDragOperation op = webview_->DragTargetDragOver(
WebPoint(client_pt.x, client_pt.y),
- WebPoint(cursor_position.x, cursor_position.y));
- return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ WebPoint(cursor_position.x, cursor_position.y),
+ WebDragOperationCopy);
+ // TODO(snej): Pass the real drag operation instead
+ return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
+ // TODO(snej): Return the real drop effect constant matching 'op'
}
void TestDropDelegate::OnDragLeave(IDataObject* data_object) {
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index 42402f0..15d54f6 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -45,7 +45,8 @@ using WebKit::WebInputEventFactory;
using base::Time;
using base::TimeTicks;
-
+using WebKit::WebDragOperation;
+using WebKit::WebDragOperationsMask;
using WebKit::WebDragData;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
@@ -62,6 +63,8 @@ int EventSendingController::last_button_number_ = -1;
namespace {
static WebDragData current_drag_data;
+static WebDragOperation current_drag_effect;
+static WebDragOperationsMask current_drag_effects_allowed;
static bool replaying_saved_events = false;
static std::queue<WebMouseEvent> mouse_event_queue;
@@ -188,6 +191,8 @@ void EventSendingController::Reset() {
// The test should have finished a drag and the mouse button state.
DCHECK(current_drag_data.isNull());
current_drag_data.reset();
+ current_drag_effect = WebKit::WebDragOperationNone;
+ current_drag_effects_allowed = WebKit::WebDragOperationNone;
pressed_button_ = WebMouseEvent::ButtonNone;
dragMode.Set(true);
#if defined(OS_WIN)
@@ -211,9 +216,17 @@ WebView* EventSendingController::webview() {
}
// static
-void EventSendingController::DoDragDrop(const WebDragData& drag_data) {
+void EventSendingController::DoDragDrop(const WebKit::WebPoint &event_pos,
+ const WebDragData& drag_data,
+ WebDragOperationsMask mask) {
+ WebMouseEvent event;
+ InitMouseEvent(WebInputEvent::MouseDown, pressed_button_, event_pos, &event);
+ WebPoint client_point(event.x, event.y);
+ WebPoint screen_point(event.globalX, event.globalY);
current_drag_data = drag_data;
- webview()->DragTargetDragEnter(drag_data, 0, WebPoint(), WebPoint());
+ current_drag_effects_allowed = mask;
+ current_drag_effect = webview()->DragTargetDragEnter(
+ drag_data, 0, client_point, screen_point, current_drag_effects_allowed);
// Finish processing events.
ReplaySavedEvents();
@@ -313,14 +326,17 @@ void EventSendingController::mouseUp(
WebPoint client_point(e.x, e.y);
WebPoint screen_point(e.globalX, e.globalY);
- bool valid = webview()->DragTargetDragOver(client_point, screen_point);
- if (valid) {
- webview()->DragSourceEndedAt(client_point, screen_point);
+ webview()->DragSourceMovedTo(client_point, screen_point);
+ current_drag_effect = webview()->DragTargetDragOver(client_point,
+ screen_point,
+ current_drag_effects_allowed);
+ if (current_drag_effect) {
webview()->DragTargetDrop(client_point, screen_point);
} else {
- webview()->DragSourceEndedAt(client_point, screen_point);
webview()->DragTargetDragLeave();
}
+ webview()->DragSourceEndedAt(client_point, screen_point,
+ current_drag_effect);
current_drag_data.reset();
}
@@ -357,7 +373,9 @@ void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
WebPoint screen_point(e.globalX, e.globalY);
webview()->DragSourceMovedTo(client_point, screen_point);
- webview()->DragTargetDragOver(client_point, screen_point);
+ current_drag_effect = webview()->DragTargetDragOver(
+ client_point, screen_point,
+ current_drag_effects_allowed);
}
}
diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h
index 353c411..5f26083 100644
--- a/webkit/tools/test_shell/event_sending_controller.h
+++ b/webkit/tools/test_shell/event_sending_controller.h
@@ -19,6 +19,7 @@
#include "build/build_config.h"
#include "base/gfx/point.h"
#include "base/task.h"
+#include "webkit/api/public/WebDragOperation.h"
#include "webkit/api/public/WebInputEvent.h"
#include "webkit/glue/cpp_bound_class.h"
@@ -28,6 +29,7 @@ class WebView;
namespace WebKit {
class WebDragData;
class WebMouseEvent;
+struct WebPoint;
}
class EventSendingController : public CppBoundClass {
@@ -40,7 +42,9 @@ class EventSendingController : public CppBoundClass {
void Reset();
// Simulate drag&drop system call.
- static void DoDragDrop(const WebKit::WebDragData& drag_data);
+ static void DoDragDrop(const WebKit::WebPoint &event_pos,
+ const WebKit::WebDragData& drag_data,
+ WebKit::WebDragOperationsMask operations_mask);
// JS callback methods.
void mouseDown(const CppArgumentList& args, CppVariant* result);
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index b8b2a11..63917e9 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -27,6 +27,7 @@
#include "webkit/api/public/WebFrame.h"
#include "webkit/api/public/WebKit.h"
#include "webkit/api/public/WebNode.h"
+#include "webkit/api/public/WebPoint.h"
#include "webkit/api/public/WebRange.h"
#include "webkit/api/public/WebScreenInfo.h"
#include "webkit/api/public/WebString.h"
@@ -61,6 +62,7 @@
using WebKit::WebData;
using WebKit::WebDataSource;
using WebKit::WebDragData;
+using WebKit::WebDragOperationsMask;
using WebKit::WebEditingAction;
using WebKit::WebFrame;
using WebKit::WebHistoryItem;
@@ -69,6 +71,7 @@ using WebKit::WebNavigationPolicy;
using WebKit::WebNode;
using WebKit::WebPlugin;
using WebKit::WebPluginParams;
+using WebKit::WebPoint;
using WebKit::WebRange;
using WebKit::WebRect;
using WebKit::WebScreenInfo;
@@ -675,7 +678,9 @@ void TestWebViewDelegate::SetStatusbarText(WebView* webview,
}
void TestWebViewDelegate::StartDragging(WebView* webview,
- const WebDragData& drag_data) {
+ const WebPoint &mouse_coords,
+ const WebDragData& drag_data,
+ WebDragOperationsMask mask) {
if (WebKit::layoutTestMode()) {
WebDragData mutable_drag_data = drag_data;
if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) {
@@ -685,7 +690,7 @@ void TestWebViewDelegate::StartDragging(WebView* webview,
// When running a test, we need to fake a drag drop operation otherwise
// Windows waits for real mouse events to know when the drag is over.
- EventSendingController::DoDragDrop(mutable_drag_data);
+ EventSendingController::DoDragDrop(mouse_coords, mutable_drag_data, mask);
} else {
// TODO(tc): Drag and drop is disabled in the test shell because we need
// to be able to convert from WebDragData to an IDataObject.
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index d18999e..ad0beee 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -104,7 +104,9 @@ class TestWebViewDelegate : public WebViewDelegate,
unsigned int line_no,
const std::wstring& source_id);
virtual void StartDragging(WebView* webview,
- const WebKit::WebDragData& drag_data);
+ const WebKit::WebPoint &mouseCoords,
+ const WebKit::WebDragData& drag_data,
+ WebKit::WebDragOperationsMask operations_mask);
virtual void ShowContextMenu(WebView* webview,
ContextNodeType node_type,
int x,