blob: 4f577043536efe98ac10487fb77c072d01ba3842 [file] [log] [blame]
[email protected]b3123ce2011-04-08 08:23:171// Copyright (c) 2011 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commitf5b16fe2008-07-27 00:20:514
5#include "webkit/tools/test_shell/drop_delegate.h"
6
[email protected]3034b6812011-12-03 00:00:147#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h"
8#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
[email protected]c1d9cdc2011-01-17 06:50:019#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
initial.commitf5b16fe2008-07-27 00:20:5110#include "webkit/glue/webdropdata.h"
initial.commitf5b16fe2008-07-27 00:20:5111
[email protected]1d9f4132009-09-08 17:29:2512using WebKit::WebDragOperation;
13using WebKit::WebDragOperationCopy;
[email protected]e80c73be2009-04-07 23:24:5814using WebKit::WebPoint;
[email protected]50ae00ef2009-10-19 05:11:0315using WebKit::WebView;
[email protected]e80c73be2009-04-07 23:24:5816
[email protected]79a4c1e2010-10-17 20:44:3817TestDropDelegate::TestDropDelegate(HWND source_hwnd, WebKit::WebView* webview)
[email protected]02bae0f2011-01-19 20:22:0018 : ui::DropTarget(source_hwnd),
[email protected]79a4c1e2010-10-17 20:44:3819 webview_(webview) {
20}
[email protected]e80c73be2009-04-07 23:24:5821
initial.commitf5b16fe2008-07-27 00:20:5122DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object,
23 DWORD key_state,
24 POINT cursor_position,
25 DWORD effect) {
26 WebDropData drop_data;
27 WebDropData::PopulateWebDropData(data_object, &drop_data);
28
29 POINT client_pt = cursor_position;
30 ScreenToClient(GetHWND(), &client_pt);
[email protected]26aa0482009-09-30 16:55:2731 WebDragOperation op = webview_->dragTargetDragEnter(
[email protected]b3123ce2011-04-08 08:23:1732 drop_data.ToDragData(),
[email protected]e80c73be2009-04-07 23:24:5833 WebPoint(client_pt.x, client_pt.y),
[email protected]1d9f4132009-09-08 17:29:2534 WebPoint(cursor_position.x, cursor_position.y),
35 WebDragOperationCopy);
36 // TODO(snej): Pass the real drag operation instead
37 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
38 // TODO(snej): Return the real drop effect constant matching 'op'
initial.commitf5b16fe2008-07-27 00:20:5139}
40
41DWORD TestDropDelegate::OnDragOver(IDataObject* data_object,
42 DWORD key_state,
43 POINT cursor_position,
44 DWORD effect) {
45 POINT client_pt = cursor_position;
46 ScreenToClient(GetHWND(), &client_pt);
[email protected]26aa0482009-09-30 16:55:2747 WebDragOperation op = webview_->dragTargetDragOver(
[email protected]e80c73be2009-04-07 23:24:5848 WebPoint(client_pt.x, client_pt.y),
[email protected]1d9f4132009-09-08 17:29:2549 WebPoint(cursor_position.x, cursor_position.y),
50 WebDragOperationCopy);
51 // TODO(snej): Pass the real drag operation instead
52 return op ? DROPEFFECT_COPY : DROPEFFECT_NONE;
53 // TODO(snej): Return the real drop effect constant matching 'op'
initial.commitf5b16fe2008-07-27 00:20:5154}
55
56void TestDropDelegate::OnDragLeave(IDataObject* data_object) {
[email protected]26aa0482009-09-30 16:55:2757 webview_->dragTargetDragLeave();
initial.commitf5b16fe2008-07-27 00:20:5158}
59
60DWORD TestDropDelegate::OnDrop(IDataObject* data_object,
61 DWORD key_state,
62 POINT cursor_position,
63 DWORD effect) {
64 POINT client_pt = cursor_position;
65 ScreenToClient(GetHWND(), &client_pt);
[email protected]26aa0482009-09-30 16:55:2766 webview_->dragTargetDrop(
[email protected]e80c73be2009-04-07 23:24:5867 WebPoint(client_pt.x, client_pt.y),
68 WebPoint(cursor_position.x, cursor_position.y));
initial.commitf5b16fe2008-07-27 00:20:5169
70 // webkit win port always returns DROPEFFECT_NONE
71 return DROPEFFECT_NONE;
72}