summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/event_sending_controller.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 23:24:58 +0000
commite80c73be12cc2211d5a72a5ff85eb97366b2458f (patch)
tree5c395779776b368ed6cafdbc5c6bc929776c18a4 /webkit/tools/test_shell/event_sending_controller.cc
parent25a3f6b52228bc68ce63c4032ed6b17cecd7b3c5 (diff)
downloadchromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.zip
chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.gz
chromium_src-e80c73be12cc2211d5a72a5ff85eb97366b2458f.tar.bz2
Switch to using WebDragData in WebView and WebViewDelegate.
I also cleaned up some of the WebView and WebViewDelegate methods to pass WebPoint instead of pairs of ints or gfx::Point. With this change, I am keeping webkit/glue/webdropdata.{h,cc}, which is what Chrome uses to pass around the equivalent data. Now, it is possible to construct a WebDropData from a WebKit::WebDragData and to also get a WebKit::WebDragData from a WebDropData. Hence, the conversion between WebDropData and ChromiumDataObject (see clipboard_conversion.{h,cc}) is now removed in favor of conversion between WebDropData and WebKit::WebDragData. Conversion between WebKit::WebDragData and WebCore::ChromiumDataObject is very cheap (just reference counting). Finally, this change also brings in WebData, which is now used by the return value of WebKitClient::loadResource. As a companion to that change, I also changed webkit_glue::GetDataResource to return StringPiece instead of std::string. That also saves on an unnecessary buffer copy. R=dglazkov Review URL: http://codereview.chromium.org/63084 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/event_sending_controller.cc')
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc55
1 files changed, 33 insertions, 22 deletions
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index d0849ba..5808bd3 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -28,7 +28,8 @@
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/time.h"
-#include "webkit/glue/webdropdata.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "webkit/glue/webview.h"
#include "webkit/tools/test_shell/test_shell.h"
@@ -43,9 +44,11 @@ using WebKit::WebInputEventFactory;
using base::Time;
using base::TimeTicks;
+using WebKit::WebDragData;
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
+using WebKit::WebPoint;
TestShell* EventSendingController::shell_ = NULL;
gfx::Point EventSendingController::last_mouse_pos_;
@@ -56,7 +59,7 @@ int EventSendingController::last_button_number_ = -1;
namespace {
-static scoped_ptr<WebDropData> drag_data_object;
+static WebDragData current_drag_data;
static bool replaying_saved_events = false;
static std::queue<WebMouseEvent> mouse_event_queue;
@@ -179,8 +182,8 @@ EventSendingController::EventSendingController(TestShell* shell)
void EventSendingController::Reset() {
// The test should have finished a drag and the mouse button state.
- DCHECK(!drag_data_object.get());
- drag_data_object.reset();
+ DCHECK(current_drag_data.isNull());
+ current_drag_data.reset();
pressed_button_ = WebMouseEvent::ButtonNone;
dragMode.Set(true);
#if defined(OS_WIN)
@@ -198,16 +201,15 @@ void EventSendingController::Reset() {
last_button_number_ = -1;
}
-/* static */ WebView* EventSendingController::webview() {
+// static
+WebView* EventSendingController::webview() {
return shell_->webView();
}
-/* static */ void EventSendingController::DoDragDrop(const WebDropData& data_obj) {
- WebDropData* drop_data_copy = new WebDropData;
- *drop_data_copy = data_obj;
- drag_data_object.reset(drop_data_copy);
-
- webview()->DragTargetDragEnter(data_obj, 0, 0, 0, 0);
+// static
+void EventSendingController::DoDragDrop(const WebDragData& drag_data) {
+ current_drag_data = drag_data;
+ webview()->DragTargetDragEnter(drag_data, 0, WebPoint(), WebPoint());
// Finish processing events.
ReplaySavedEvents();
@@ -234,6 +236,7 @@ int EventSendingController::GetButtonNumberFromSingleArg(
return button_code;
}
+
//
// Implemented javascript methods.
//
@@ -302,17 +305,20 @@ void EventSendingController::mouseUp(
pressed_button_ = WebMouseEvent::ButtonNone;
// If we're in a drag operation, complete it.
- if (drag_data_object.get()) {
- bool valid = webview()->DragTargetDragOver(e.x, e.y, e.globalX,
- e.globalY);
+ if (!current_drag_data.isNull()) {
+ 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(e.x, e.y, e.globalX, e.globalY);
- webview()->DragTargetDrop(e.x, e.y, e.globalX, e.globalY);
+ webview()->DragSourceEndedAt(client_point, screen_point);
+ webview()->DragTargetDrop(client_point, screen_point);
} else {
- webview()->DragSourceEndedAt(e.x, e.y, e.globalX, e.globalY);
+ webview()->DragSourceEndedAt(client_point, screen_point);
webview()->DragTargetDragLeave();
}
- drag_data_object.reset();
+
+ current_drag_data.reset();
}
}
@@ -337,12 +343,17 @@ void EventSendingController::mouseMoveTo(
}
}
-/* static */ void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
+// static
+void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
webview()->HandleInputEvent(&e);
- if (pressed_button_ != WebMouseEvent::ButtonNone && drag_data_object.get()) {
- webview()->DragSourceMovedTo(e.x, e.y, e.globalX, e.globalY);
- webview()->DragTargetDragOver(e.x, e.y, e.globalX, e.globalY);
+ if (pressed_button_ != WebMouseEvent::ButtonNone &&
+ !current_drag_data.isNull()) {
+ WebPoint client_point(e.x, e.y);
+ WebPoint screen_point(e.globalX, e.globalY);
+
+ webview()->DragSourceMovedTo(client_point, screen_point);
+ webview()->DragTargetDragOver(client_point, screen_point);
}
}