Repository navigation
Expand file tree
/
Copy pathissue251.patch
More file actions
353 lines (322 loc) · 10.8 KB
/
Copy pathissue251.patch
File metadata and controls
353 lines (322 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
diff --git include/capi/cef_drag_data_capi.h include/capi/cef_drag_data_capi.h
index e1fcfd8c..084fea20 100644
--- include/capi/cef_drag_data_capi.h
+++ include/capi/cef_drag_data_capi.h
@@ -39,6 +39,7 @@
#pragma once
#include "include/capi/cef_base_capi.h"
+#include "include/capi/cef_image_capi.h"
#include "include/capi/cef_stream_capi.h"
#ifdef __cplusplus
@@ -195,6 +196,21 @@ typedef struct _cef_drag_data_t {
///
void (CEF_CALLBACK *add_file)(struct _cef_drag_data_t* self,
const cef_string_t* path, const cef_string_t* display_name);
+
+ ///
+ // Get image representation of drag data (may be NULL).
+ ///
+ struct _cef_image_t* (CEF_CALLBACK *get_image)(struct _cef_drag_data_t* self);
+
+ ///
+ // Get image hotspot (drag start location relative to image dimensions).
+ ///
+ cef_point_t (CEF_CALLBACK *get_image_hotspot)(struct _cef_drag_data_t* self);
+
+ ///
+ // Whether image representation of drag data is available.
+ ///
+ int (CEF_CALLBACK *has_image)(struct _cef_drag_data_t* self);
} cef_drag_data_t;
diff --git include/cef_drag_data.h include/cef_drag_data.h
index 29b85e84..de37ecc4 100644
--- include/cef_drag_data.h
+++ include/cef_drag_data.h
@@ -39,6 +39,7 @@
#pragma once
#include "include/cef_base.h"
+#include "include/cef_image.h"
#include "include/cef_stream.h"
#include <vector>
@@ -193,6 +194,24 @@ class CefDragData : public virtual CefBaseRefCounted {
///
/*--cef(optional_param=display_name)--*/
virtual void AddFile(const CefString& path, const CefString& display_name) =0;
+
+ ///
+ // Get image representation of drag data (may be NULL).
+ ///
+ /*--cef()--*/
+ virtual CefRefPtr<CefImage> GetImage() =0;
+
+ ///
+ // Get image hotspot (drag start location relative to image dimensions).
+ ///
+ /*--cef()--*/
+ virtual CefPoint GetImageHotspot() =0;
+
+ ///
+ // Whether image representation of drag data is available.
+ ///
+ /*--cef()--*/
+ virtual bool HasImage() =0;
};
#endif // CEF_INCLUDE_CEF_DRAG_DATA_H_
diff --git libcef/browser/osr/browser_platform_delegate_osr.cc libcef/browser/osr/browser_platform_delegate_osr.cc
index 148ef49c..bfec55b7 100644
--- libcef/browser/osr/browser_platform_delegate_osr.cc
+++ libcef/browser/osr/browser_platform_delegate_osr.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "libcef/browser/browser_host_impl.h"
+#include "libcef/browser/image_impl.h"
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "libcef/browser/osr/web_contents_view_osr.h"
#include "libcef/common/drag_data_impl.h"
@@ -432,7 +433,11 @@ void CefBrowserPlatformDelegateOsr::StartDragging(
CefRefPtr<CefRenderHandler> handler =
browser_->GetClient()->GetRenderHandler();
if (handler.get()) {
- CefRefPtr<CefDragDataImpl> drag_data(new CefDragDataImpl(drop_data));
+ CefRefPtr<CefImage> cef_image(new CefImageImpl(image));
+ CefPoint cef_image_pos(CefPoint(image_offset.x(), image_offset.y()));
+ CefRefPtr<CefDragDataImpl> drag_data(new CefDragDataImpl(drop_data,
+ cef_image,
+ cef_image_pos));
drag_data->SetReadOnly(true);
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
diff --git libcef/common/drag_data_impl.cc libcef/common/drag_data_impl.cc
index a8e2c8e1..a5c8940c 100644
--- libcef/common/drag_data_impl.cc
+++ libcef/common/drag_data_impl.cc
@@ -19,6 +19,15 @@ CefDragDataImpl::CefDragDataImpl(const content::DropData& data)
read_only_(false) {
}
+CefDragDataImpl::CefDragDataImpl(const content::DropData& data,
+ CefRefPtr<CefImage> image,
+ const CefPoint& image_hotspot)
+ : data_(data),
+ image_(image),
+ image_hotspot_(image_hotspot),
+ read_only_(false) {
+}
+
CefDragDataImpl::CefDragDataImpl()
: read_only_(false) {
}
@@ -31,7 +40,7 @@ CefRefPtr<CefDragData> CefDragDataImpl::Clone() {
CefDragDataImpl* drag_data = NULL;
{
base::AutoLock lock_scope(lock_);
- drag_data = new CefDragDataImpl(data_);
+ drag_data = new CefDragDataImpl(data_, image_, image_hotspot_);
}
return drag_data;
}
@@ -187,3 +196,31 @@ void CefDragDataImpl::SetReadOnly(bool read_only) {
read_only_ = read_only;
}
+
+void CefDragDataImpl::SetImage(CefRefPtr<CefImage> image) {
+ base::AutoLock lock_scope(lock_);
+ CHECK_READONLY_RETURN_VOID();
+ image_ = image;
+}
+
+void CefDragDataImpl::SetImageHotspot(const CefPoint& point) {
+ base::AutoLock lock_scope(lock_);
+ CHECK_READONLY_RETURN_VOID();
+ image_hotspot_.Set(point.x, point.y);
+}
+
+CefRefPtr<CefImage> CefDragDataImpl::GetImage() {
+ base::AutoLock lock_scope(lock_);
+ return image_;
+}
+
+CefPoint CefDragDataImpl::GetImageHotspot() {
+ base::AutoLock lock_scope(lock_);
+ return image_hotspot_;
+}
+
+bool CefDragDataImpl::HasImage() {
+ base::AutoLock lock_scope(lock_);
+ if (image_) return true;
+ else return false;
+}
diff --git libcef/common/drag_data_impl.h libcef/common/drag_data_impl.h
index 64f29ed3..68cb3875 100644
--- libcef/common/drag_data_impl.h
+++ libcef/common/drag_data_impl.h
@@ -7,6 +7,7 @@
#pragma once
#include "include/cef_drag_data.h"
+#include "include/cef_image.h"
#include <vector>
@@ -18,6 +19,9 @@ class CefDragDataImpl : public CefDragData {
public:
CefDragDataImpl();
explicit CefDragDataImpl(const content::DropData& data);
+ explicit CefDragDataImpl(const content::DropData& data,
+ CefRefPtr<CefImage> image,
+ const CefPoint& image_hotspot);
CefRefPtr<CefDragData> Clone() override;
bool IsReadOnly() override;
@@ -41,6 +45,9 @@ class CefDragDataImpl : public CefDragData {
void SetFragmentBaseURL(const CefString& fragment) override;
void ResetFileContents() override;
void AddFile(const CefString& path, const CefString& display_name) override;
+ CefRefPtr<CefImage> GetImage() override;
+ CefPoint GetImageHotspot() override;
+ bool HasImage() override;
// This method is not safe. Use Lock/Unlock to get mutually exclusive access.
content::DropData* drop_data() {
@@ -49,10 +56,15 @@ class CefDragDataImpl : public CefDragData {
void SetReadOnly(bool read_only);
+ void SetImage(CefRefPtr<CefImage> image);
+ void SetImageHotspot(const CefPoint& point);
+
base::Lock& lock() { return lock_; }
private:
content::DropData data_;
+ CefRefPtr<CefImage> image_;
+ CefPoint image_hotspot_;
// True if this object is read-only.
bool read_only_;
diff --git libcef_dll/cpptoc/drag_data_cpptoc.cc libcef_dll/cpptoc/drag_data_cpptoc.cc
index 381b88b9..01a39793 100644
--- libcef_dll/cpptoc/drag_data_cpptoc.cc
+++ libcef_dll/cpptoc/drag_data_cpptoc.cc
@@ -11,6 +11,7 @@
//
#include "libcef_dll/cpptoc/drag_data_cpptoc.h"
+#include "libcef_dll/cpptoc/image_cpptoc.h"
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
#include "libcef_dll/transfer_util.h"
@@ -367,6 +368,50 @@ void CEF_CALLBACK drag_data_add_file(struct _cef_drag_data_t* self,
CefString(display_name));
}
+struct _cef_image_t* CEF_CALLBACK drag_data_get_image(
+ struct _cef_drag_data_t* self) {
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ DCHECK(self);
+ if (!self)
+ return NULL;
+
+ // Execute
+ CefRefPtr<CefImage> _retval = CefDragDataCppToC::Get(self)->GetImage();
+
+ // Return type: refptr_same
+ return CefImageCppToC::Wrap(_retval);
+}
+
+cef_point_t CEF_CALLBACK drag_data_get_image_hotspot(
+ struct _cef_drag_data_t* self) {
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ DCHECK(self);
+ if (!self)
+ return CefPoint();
+
+ // Execute
+ cef_point_t _retval = CefDragDataCppToC::Get(self)->GetImageHotspot();
+
+ // Return type: simple
+ return _retval;
+}
+
+int CEF_CALLBACK drag_data_has_image(struct _cef_drag_data_t* self) {
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ DCHECK(self);
+ if (!self)
+ return 0;
+
+ // Execute
+ bool _retval = CefDragDataCppToC::Get(self)->HasImage();
+
+ // Return type: bool
+ return _retval;
+}
+
} // namespace
@@ -395,6 +440,9 @@ CefDragDataCppToC::CefDragDataCppToC() {
GetStruct()->set_fragment_base_url = drag_data_set_fragment_base_url;
GetStruct()->reset_file_contents = drag_data_reset_file_contents;
GetStruct()->add_file = drag_data_add_file;
+ GetStruct()->get_image = drag_data_get_image;
+ GetStruct()->get_image_hotspot = drag_data_get_image_hotspot;
+ GetStruct()->has_image = drag_data_has_image;
}
template<> CefRefPtr<CefDragData> CefCppToCRefCounted<CefDragDataCppToC,
diff --git libcef_dll/ctocpp/drag_data_ctocpp.cc libcef_dll/ctocpp/drag_data_ctocpp.cc
index db1a2f71..e6714562 100644
--- libcef_dll/ctocpp/drag_data_ctocpp.cc
+++ libcef_dll/ctocpp/drag_data_ctocpp.cc
@@ -11,6 +11,7 @@
//
#include "libcef_dll/ctocpp/drag_data_ctocpp.h"
+#include "libcef_dll/ctocpp/image_ctocpp.h"
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@@ -372,6 +373,48 @@ void CefDragDataCToCpp::AddFile(const CefString& path,
display_name.GetStruct());
}
+CefRefPtr<CefImage> CefDragDataCToCpp::GetImage() {
+ cef_drag_data_t* _struct = GetStruct();
+ if (CEF_MEMBER_MISSING(_struct, get_image))
+ return NULL;
+
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ // Execute
+ cef_image_t* _retval = _struct->get_image(_struct);
+
+ // Return type: refptr_same
+ return CefImageCToCpp::Wrap(_retval);
+}
+
+CefPoint CefDragDataCToCpp::GetImageHotspot() {
+ cef_drag_data_t* _struct = GetStruct();
+ if (CEF_MEMBER_MISSING(_struct, get_image_hotspot))
+ return CefPoint();
+
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ // Execute
+ cef_point_t _retval = _struct->get_image_hotspot(_struct);
+
+ // Return type: simple
+ return _retval;
+}
+
+bool CefDragDataCToCpp::HasImage() {
+ cef_drag_data_t* _struct = GetStruct();
+ if (CEF_MEMBER_MISSING(_struct, has_image))
+ return false;
+
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ // Execute
+ int _retval = _struct->has_image(_struct);
+
+ // Return type: bool
+ return _retval?true:false;
+}
+
// CONSTRUCTOR - Do not edit by hand.
diff --git libcef_dll/ctocpp/drag_data_ctocpp.h libcef_dll/ctocpp/drag_data_ctocpp.h
index 5b202710..20262388 100644
--- libcef_dll/ctocpp/drag_data_ctocpp.h
+++ libcef_dll/ctocpp/drag_data_ctocpp.h
@@ -54,6 +54,9 @@ class CefDragDataCToCpp
void SetFragmentBaseURL(const CefString& base_url) OVERRIDE;
void ResetFileContents() OVERRIDE;
void AddFile(const CefString& path, const CefString& display_name) OVERRIDE;
+ CefRefPtr<CefImage> GetImage() OVERRIDE;
+ CefPoint GetImageHotspot() OVERRIDE;
+ bool HasImage() OVERRIDE;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_DRAG_DATA_CTOCPP_H_