diff options
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/drag_delegate.cc | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.cc | 76 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.h | 11 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 38 |
4 files changed, 36 insertions, 91 deletions
diff --git a/webkit/tools/test_shell/drag_delegate.cc b/webkit/tools/test_shell/drag_delegate.cc index 2d558f1..eeb5522 100644 --- a/webkit/tools/test_shell/drag_delegate.cc +++ b/webkit/tools/test_shell/drag_delegate.cc @@ -32,10 +32,10 @@ void TestDragDelegate::OnDragSourceDrop() { GetCursorPositions(source_hwnd_, &client, &screen); webview_->DragSourceEndedAt(client.x, client.y, screen.x, screen.y); } + void TestDragDelegate::OnDragSourceMove() { CPoint client; CPoint screen; GetCursorPositions(source_hwnd_, &client, &screen); webview_->DragSourceMovedTo(client.x, client.y, screen.x, screen.y); } - diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc index ac10803..aea9aed 100644 --- a/webkit/tools/test_shell/event_sending_controller.cc +++ b/webkit/tools/test_shell/event_sending_controller.cc @@ -16,9 +16,6 @@ #include "webkit/tools/test_shell/event_sending_controller.h" -#if defined(OS_WIN) -#include <objidl.h> -#endif #include <queue> #include "base/logging.h" @@ -43,12 +40,7 @@ int EventSendingController::last_button_number_ = -1; namespace { -#if defined(OS_WIN) -static scoped_refptr<IDataObject> drag_data_object; -#elif defined(OS_MACOSX) -// Throughout this file, drag support is #ifdef-ed out. TODO(port): Add it in -// for the Mac. -#endif +static scoped_ptr<WebDropData> drag_data_object; static bool replaying_saved_events = false; static std::queue<WebMouseEvent> mouse_event_queue; @@ -155,10 +147,8 @@ EventSendingController::EventSendingController(TestShell* shell) { void EventSendingController::Reset() { // The test should have finished a drag and the mouse button state. -#if defined(OS_WIN) - DCHECK(!drag_data_object); - drag_data_object = NULL; -#endif + DCHECK(!drag_data_object.get()); + drag_data_object.reset(); pressed_button_ = WebMouseEvent::BUTTON_NONE; dragMode.Set(true); last_click_time_sec = 0; @@ -170,20 +160,16 @@ void EventSendingController::Reset() { return shell_->webView(); } -#if defined(OS_WIN) -/* static */ void EventSendingController::DoDragDrop(IDataObject* data_obj) { - drag_data_object = data_obj; +/* 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); - DWORD effect = 0; - POINTL screen_ptl = {0, 0}; - TestWebViewDelegate* delegate = shell_->delegate(); - delegate->drop_delegate()->DragEnter(drag_data_object, MK_LBUTTON, - screen_ptl, &effect); + webview()->DragTargetDragEnter(data_obj, 0, 0, 0, 0); // Finish processing events. ReplaySavedEvents(); } -#endif WebMouseEvent::Button EventSendingController::GetButtonTypeFromButtonNumber( int button_code) { @@ -271,29 +257,19 @@ int EventSendingController::GetButtonNumberFromSingleArg( webview()->HandleInputEvent(&e); pressed_button_ = WebMouseEvent::BUTTON_NONE; -#if defined(OS_WIN) // If we're in a drag operation, complete it. - if (drag_data_object) { - TestWebViewDelegate* delegate = shell_->delegate(); - // Get screen mouse position. - POINT screen_pt = { static_cast<LONG>(e.x), - static_cast<LONG>(e.y) }; - ClientToScreen(shell_->webViewWnd(), &screen_pt); - POINTL screen_ptl = { screen_pt.x, screen_pt.y }; - - DWORD effect = 0; - delegate->drop_delegate()->DragOver(0, screen_ptl, &effect); - HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, 0); - if (hr == DRAGDROP_S_DROP && effect != DROPEFFECT_NONE) { - DWORD effect = 0; - delegate->drop_delegate()->Drop(drag_data_object.get(), 0, screen_ptl, - &effect); + if (drag_data_object.get()) { + bool valid = webview()->DragTargetDragOver(e.x, e.y, e.global_x, + e.global_y); + if (valid) { + webview()->DragSourceEndedAt(e.x, e.y, e.global_x, e.global_y); + webview()->DragTargetDrop(e.x, e.y, e.global_x, e.global_y); } else { - delegate->drop_delegate()->DragLeave(); + webview()->DragSourceEndedAt(e.x, e.y, e.global_x, e.global_y); + webview()->DragTargetDragLeave(); } - drag_data_object = NULL; + drag_data_object.reset(); } -#endif } void EventSendingController::mouseMoveTo( @@ -320,22 +296,10 @@ int EventSendingController::GetButtonNumberFromSingleArg( /* static */ void EventSendingController::DoMouseMove(const WebMouseEvent& e) { webview()->HandleInputEvent(&e); -#if defined(OS_WIN) - if (pressed_button_ != WebMouseEvent::BUTTON_NONE && drag_data_object) { - TestWebViewDelegate* delegate = shell_->delegate(); - // Get screen mouse position. - POINT screen_pt = { static_cast<LONG>(e.x), - static_cast<LONG>(e.y) }; - ClientToScreen(shell_->webViewWnd(), &screen_pt); - POINTL screen_ptl = { screen_pt.x, screen_pt.y }; - - HRESULT hr = delegate->drag_delegate()->QueryContinueDrag(0, MK_LBUTTON); - DWORD effect = 0; - delegate->drop_delegate()->DragOver(MK_LBUTTON, screen_ptl, &effect); - - delegate->drag_delegate()->GiveFeedback(effect); + if (pressed_button_ != WebMouseEvent::BUTTON_NONE && drag_data_object.get()) { + webview()->DragSourceMovedTo(e.x, e.y, e.global_x, e.global_y); + webview()->DragTargetDragOver(e.x, e.y, e.global_x, e.global_y); } -#endif } void EventSendingController::keyDown( diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h index e544732..004cc82 100644 --- a/webkit/tools/test_shell/event_sending_controller.h +++ b/webkit/tools/test_shell/event_sending_controller.h @@ -19,12 +19,9 @@ #include "build/build_config.h" #include "base/gfx/point.h" #include "webkit/glue/cpp_bound_class.h" +#include "webkit/glue/webdropdata.h" #include "webkit/glue/webinputevent.h" -#if defined(OS_WIN) -struct IDataObject; -struct IDropSource; -#endif class TestShell; class WebView; @@ -37,10 +34,8 @@ class EventSendingController : public CppBoundClass { // Resets some static variable state. void Reset(); -#if defined(OS_WIN) - // Simulate Windows' drag&drop system call. - static void DoDragDrop(IDataObject* drag_data); -#endif + // Simulate drag&drop system call. + static void DoDragDrop(const WebDropData& drag_data); // 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 475289ca..7592f06 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -48,25 +48,8 @@ std::wstring UrlSuitableForTestResult(const std::wstring& url) { // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake // dragging a file. -void AddDRTFakeFileToDataObject(IDataObject* data_object) { - STGMEDIUM medium = {0}; - medium.tymed = TYMED_HGLOBAL; - - const char filename[] = "DRTFakeFile"; - const int filename_len = arraysize(filename); - - // Allocate space for the DROPFILES struct, filename, and 2 null characters. - medium.hGlobal = GlobalAlloc(GPTR, sizeof(DROPFILES) + filename_len + 2); - DCHECK(medium.hGlobal); - DROPFILES* drop_files = static_cast<DROPFILES*>(GlobalLock(medium.hGlobal)); - drop_files->pFiles = sizeof(DROPFILES); - drop_files->fWide = 0; // Filenames are ascii - strcpy_s(reinterpret_cast<char*>(drop_files) + sizeof(DROPFILES), - filename_len, filename); - GlobalUnlock(medium.hGlobal); - - FORMATETC file_desc_fmt = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - data_object->SetData(&file_desc_fmt, &medium, TRUE); +void AddDRTFakeFileToDataObject(WebDropData* drop_data) { + drop_data->filenames.push_back(L"DRTFakeFile"); } } // namespace @@ -466,20 +449,23 @@ void TestWebViewDelegate::StartDragging(WebView* webview, drag_delegate_ = new TestDragDelegate(shell_->webViewWnd(), shell_->webView()); if (webkit_glue::IsLayoutTestMode()) { + WebDropData mutable_drop_data = drop_data; if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { // Add a file called DRTFakeFile to the drag&drop clipboard. - AddDRTFakeFileToDataObject(drop_data.data_object); + AddDRTFakeFileToDataObject(&mutable_drop_data); } // 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(drop_data.data_object); + EventSendingController::DoDragDrop(mutable_drop_data); } else { - const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE; - DWORD effect; - HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), - ok_effect, &effect); - DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); + // TODO(tc): Drag and drop is disabled in the test shell because we need + // to be able to convert from WebDragData to an IDataObject. + //const DWORD ok_effect = DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE; + //DWORD effect; + //HRESULT res = DoDragDrop(drop_data.data_object, drag_delegate_.get(), + // ok_effect, &effect); + //DCHECK(DRAGDROP_S_DROP == res || DRAGDROP_S_CANCEL == res); } webview->DragSourceSystemDragEnded(); } |