| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/drop_delegate.h" | 5 #include "webkit/tools/test_shell/drop_delegate.h" |
| 6 | 6 |
| 7 #include "webkit/api/public/WebDragData.h" | 7 #include "webkit/api/public/WebDragData.h" |
| 8 #include "webkit/api/public/WebPoint.h" | 8 #include "webkit/api/public/WebPoint.h" |
| 9 #include "webkit/glue/webdropdata.h" | 9 #include "webkit/glue/webdropdata.h" |
| 10 #include "webkit/glue/webview.h" | 10 #include "webkit/glue/webview.h" |
| 11 | 11 |
| 12 using WebKit::WebDragOperation; |
| 13 using WebKit::WebDragOperationCopy; |
| 12 using WebKit::WebPoint; | 14 using WebKit::WebPoint; |
| 13 | 15 |
| 14 // BaseDropTarget methods ---------------------------------------------------- | 16 // BaseDropTarget methods ---------------------------------------------------- |
| 15 | 17 |
| 16 DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, | 18 DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, |
| 17 DWORD key_state, | 19 DWORD key_state, |
| 18 POINT cursor_position, | 20 POINT cursor_position, |
| 19 DWORD effect) { | 21 DWORD effect) { |
| 20 WebDropData drop_data; | 22 WebDropData drop_data; |
| 21 WebDropData::PopulateWebDropData(data_object, &drop_data); | 23 WebDropData::PopulateWebDropData(data_object, &drop_data); |
| 22 | 24 |
| 23 POINT client_pt = cursor_position; | 25 POINT client_pt = cursor_position; |
| 24 ScreenToClient(GetHWND(), &client_pt); | 26 ScreenToClient(GetHWND(), &client_pt); |
| 25 bool valid = webview_->DragTargetDragEnter( | 27 WebDragOperation op = webview_->DragTargetDragEnter( |
| 26 drop_data.ToDragData(), drop_data.identity, | 28 drop_data.ToDragData(), drop_data.identity, |
| 27 WebPoint(client_pt.x, client_pt.y), | 29 WebPoint(client_pt.x, client_pt.y), |
| 28 WebPoint(cursor_position.x, cursor_position.y)); | 30 WebPoint(cursor_position.x, cursor_position.y), |
| 29 return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; | 31 WebDragOperationCopy); |
| 32 // TODO(snej): Pass the real drag operation instead |
| 33 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; |
| 34 // TODO(snej): Return the real drop effect constant matching 'op' |
| 30 } | 35 } |
| 31 | 36 |
| 32 DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, | 37 DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, |
| 33 DWORD key_state, | 38 DWORD key_state, |
| 34 POINT cursor_position, | 39 POINT cursor_position, |
| 35 DWORD effect) { | 40 DWORD effect) { |
| 36 POINT client_pt = cursor_position; | 41 POINT client_pt = cursor_position; |
| 37 ScreenToClient(GetHWND(), &client_pt); | 42 ScreenToClient(GetHWND(), &client_pt); |
| 38 bool valid = webview_->DragTargetDragOver( | 43 WebDragOperation op = webview_->DragTargetDragOver( |
| 39 WebPoint(client_pt.x, client_pt.y), | 44 WebPoint(client_pt.x, client_pt.y), |
| 40 WebPoint(cursor_position.x, cursor_position.y)); | 45 WebPoint(cursor_position.x, cursor_position.y), |
| 41 return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; | 46 WebDragOperationCopy); |
| 47 // TODO(snej): Pass the real drag operation instead |
| 48 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE; |
| 49 // TODO(snej): Return the real drop effect constant matching 'op' |
| 42 } | 50 } |
| 43 | 51 |
| 44 void TestDropDelegate::OnDragLeave(IDataObject* data_object) { | 52 void TestDropDelegate::OnDragLeave(IDataObject* data_object) { |
| 45 webview_->DragTargetDragLeave(); | 53 webview_->DragTargetDragLeave(); |
| 46 } | 54 } |
| 47 | 55 |
| 48 DWORD TestDropDelegate::OnDrop(IDataObject* data_object, | 56 DWORD TestDropDelegate::OnDrop(IDataObject* data_object, |
| 49 DWORD key_state, | 57 DWORD key_state, |
| 50 POINT cursor_position, | 58 POINT cursor_position, |
| 51 DWORD effect) { | 59 DWORD effect) { |
| 52 POINT client_pt = cursor_position; | 60 POINT client_pt = cursor_position; |
| 53 ScreenToClient(GetHWND(), &client_pt); | 61 ScreenToClient(GetHWND(), &client_pt); |
| 54 webview_->DragTargetDrop( | 62 webview_->DragTargetDrop( |
| 55 WebPoint(client_pt.x, client_pt.y), | 63 WebPoint(client_pt.x, client_pt.y), |
| 56 WebPoint(cursor_position.x, cursor_position.y)); | 64 WebPoint(cursor_position.x, cursor_position.y)); |
| 57 | 65 |
| 58 // webkit win port always returns DROPEFFECT_NONE | 66 // webkit win port always returns DROPEFFECT_NONE |
| 59 return DROPEFFECT_NONE; | 67 return DROPEFFECT_NONE; |
| 60 } | 68 } |
| OLD | NEW |