| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/tools/test_shell/drag_delegate.h" | 5 #include "webkit/tools/test_shell/drag_delegate.h" |
| 6 | 6 |
| 7 #include <atltypes.h> | |
| 8 | |
| 9 #include "webkit/api/public/WebPoint.h" | 7 #include "webkit/api/public/WebPoint.h" |
| 10 #include "webkit/glue/webview.h" | 8 #include "webkit/glue/webview.h" |
| 11 | 9 |
| 12 using WebKit::WebPoint; | 10 using WebKit::WebPoint; |
| 13 | 11 |
| 14 namespace { | 12 namespace { |
| 15 | 13 |
| 16 void GetCursorPositions(HWND hwnd, CPoint* client, CPoint* screen) { | 14 void GetCursorPositions(HWND hwnd, gfx::Point* client, gfx::Point* screen) { |
| 17 // GetCursorPos will fail if the input desktop isn't the current desktop. | 15 // GetCursorPos will fail if the input desktop isn't the current desktop. |
| 18 // See http://b/1173534. (0,0) is wrong, but better than uninitialized. | 16 // See http://b/1173534. (0,0) is wrong, but better than uninitialized. |
| 19 if (!GetCursorPos(screen)) | 17 POINT pos; |
| 20 screen->SetPoint(0, 0); | 18 if (!GetCursorPos(&pos)) { |
| 19 pos.x = 0; |
| 20 pos.y = 0; |
| 21 } |
| 21 | 22 |
| 22 *client = *screen; | 23 *screen = gfx::Point(pos); |
| 23 ScreenToClient(hwnd, client); | 24 ScreenToClient(hwnd, &pos); |
| 25 *client = gfx::Point(pos); |
| 24 } | 26 } |
| 25 | 27 |
| 26 } // anonymous namespace | 28 } // anonymous namespace |
| 27 | 29 |
| 28 void TestDragDelegate::OnDragSourceCancel() { | 30 void TestDragDelegate::OnDragSourceCancel() { |
| 29 OnDragSourceDrop(); | 31 OnDragSourceDrop(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void TestDragDelegate::OnDragSourceDrop() { | 34 void TestDragDelegate::OnDragSourceDrop() { |
| 33 CPoint client; | 35 gfx::Point client; |
| 34 CPoint screen; | 36 gfx::Point screen; |
| 35 GetCursorPositions(source_hwnd_, &client, &screen); | 37 GetCursorPositions(source_hwnd_, &client, &screen); |
| 36 webview_->DragSourceEndedAt(WebPoint(client.x, client.y), | 38 webview_->DragSourceEndedAt(client, screen); |
| 37 WebPoint(screen.x, screen.y)); | |
| 38 } | 39 } |
| 39 | 40 |
| 40 void TestDragDelegate::OnDragSourceMove() { | 41 void TestDragDelegate::OnDragSourceMove() { |
| 41 CPoint client; | 42 gfx::Point client; |
| 42 CPoint screen; | 43 gfx::Point screen; |
| 43 GetCursorPositions(source_hwnd_, &client, &screen); | 44 GetCursorPositions(source_hwnd_, &client, &screen); |
| 44 webview_->DragSourceMovedTo(WebPoint(client.x, client.y), | 45 webview_->DragSourceMovedTo(client, screen); |
| 45 WebPoint(screen.x, screen.y)); | |
| 46 } | 46 } |
| OLD | NEW |