Skip to content

Commit

Permalink
Update to Chromium 58.0.3029.81 (#354).
Browse files Browse the repository at this point in the history
CEF: 3.3029.1604.g364cd86

Update issue251 patch, expose DragData.GetImageHotspot() (#251).
  • Loading branch information
cztomczak committed Apr 26, 2017
1 parent 7790b85 commit af7005e
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 74 deletions.
148 changes: 83 additions & 65 deletions patches/issue251.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git include/capi/cef_drag_data_capi.h include/capi/cef_drag_data_capi.h
index e1fcfd8c..fc388247 100644
index e1fcfd8c..084fea20 100644
--- include/capi/cef_drag_data_capi.h
+++ include/capi/cef_drag_data_capi.h
@@ -39,6 +39,7 @@
Expand All @@ -10,21 +10,20 @@ index e1fcfd8c..fc388247 100644
#include "include/capi/cef_stream_capi.h"

#ifdef __cplusplus
@@ -195,6 +196,22 @@ typedef struct _cef_drag_data_t {
@@ -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);
+
+ ///
+ // Set image representation of drag data.
+ // Get image representation of drag data (may be NULL).
+ ///
+ void (CEF_CALLBACK *set_image)(struct _cef_drag_data_t* self,
+ struct _cef_image_t* image);
+ struct _cef_image_t* (CEF_CALLBACK *get_image)(struct _cef_drag_data_t* self);
+
+ ///
+ // Get image representation of drag data (may be NULL).
+ // Get image hotspot (drag start location relative to image dimensions).
+ ///
+ struct _cef_image_t* (CEF_CALLBACK *get_image)(struct _cef_drag_data_t* self);
+ cef_point_t (CEF_CALLBACK *get_image_hotspot)(struct _cef_drag_data_t* self);
+
+ ///
+ // Whether image representation of drag data is available.
Expand All @@ -34,7 +33,7 @@ index e1fcfd8c..fc388247 100644


diff --git include/cef_drag_data.h include/cef_drag_data.h
index 29b85e84..e3c9c2df 100644
index 29b85e84..de37ecc4 100644
--- include/cef_drag_data.h
+++ include/cef_drag_data.h
@@ -39,6 +39,7 @@
Expand All @@ -51,16 +50,16 @@ index 29b85e84..e3c9c2df 100644
virtual void AddFile(const CefString& path, const CefString& display_name) =0;
+
+ ///
+ // Set image representation of drag data.
+ // Get image representation of drag data (may be NULL).
+ ///
+ /*--cef()--*/
+ virtual void SetImage(CefRefPtr<CefImage> image) =0;
+ virtual CefRefPtr<CefImage> GetImage() =0;
+
+ ///
+ // Get image representation of drag data (may be NULL).
+ // Get image hotspot (drag start location relative to image dimensions).
+ ///
+ /*--cef()--*/
+ virtual CefRefPtr<CefImage> GetImage() =0;
+ virtual CefPoint GetImageHotspot() =0;
+
+ ///
+ // Whether image representation of drag data is available.
Expand All @@ -71,7 +70,7 @@ index 29b85e84..e3c9c2df 100644

#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..59cfae97 100644
index 148ef49c..bfec55b7 100644
--- libcef/browser/osr/browser_platform_delegate_osr.cc
+++ libcef/browser/osr/browser_platform_delegate_osr.cc
@@ -7,6 +7,7 @@
Expand All @@ -82,45 +81,49 @@ index 148ef49c..59cfae97 100644
#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,9 @@ void CefBrowserPlatformDelegateOsr::StartDragging(
@@ -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,
+ 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..b0c47e8e 100644
index a8e2c8e1..a5c8940c 100644
--- libcef/common/drag_data_impl.cc
+++ libcef/common/drag_data_impl.cc
@@ -19,6 +19,13 @@ CefDragDataImpl::CefDragDataImpl(const content::DropData& data)
@@ -19,6 +19,15 @@ CefDragDataImpl::CefDragDataImpl(const content::DropData& data)
read_only_(false) {
}

+CefDragDataImpl::CefDragDataImpl(const content::DropData& data,
+ CefRefPtr<CefImage> image)
+ 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 +38,7 @@ CefRefPtr<CefDragData> CefDragDataImpl::Clone() {
@@ -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_);
+ drag_data = new CefDragDataImpl(data_, image_, image_hotspot_);
}
return drag_data;
}
@@ -187,3 +194,20 @@ void CefDragDataImpl::SetReadOnly(bool read_only) {
@@ -187,3 +196,31 @@ void CefDragDataImpl::SetReadOnly(bool read_only) {

read_only_ = read_only;
}
Expand All @@ -131,18 +134,29 @@ index a8e2c8e1..b0c47e8e 100644
+ 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..98707262 100644
index 64f29ed3..68cb3875 100644
--- libcef/common/drag_data_impl.h
+++ libcef/common/drag_data_impl.h
@@ -7,6 +7,7 @@
Expand All @@ -153,35 +167,44 @@ index 64f29ed3..98707262 100644

#include <vector>

@@ -18,6 +19,8 @@ class CefDragDataImpl : public CefDragData {
@@ -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);
+ CefRefPtr<CefImage> image,
+ const CefPoint& image_hotspot);

CefRefPtr<CefDragData> Clone() override;
bool IsReadOnly() override;
@@ -41,6 +44,9 @@ class CefDragDataImpl : public CefDragData {
@@ -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;
+ void SetImage(CefRefPtr<CefImage> image) 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() {
@@ -53,6 +59,7 @@ class CefDragDataImpl : public CefDragData {
@@ -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..6f4925a0 100644
index 381b88b9..01a39793 100644
--- libcef_dll/cpptoc/drag_data_cpptoc.cc
+++ libcef_dll/cpptoc/drag_data_cpptoc.cc
@@ -11,6 +11,7 @@
Expand All @@ -192,40 +215,38 @@ index 381b88b9..6f4925a0 100644
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
#include "libcef_dll/transfer_util.h"

@@ -367,6 +368,52 @@ void CEF_CALLBACK drag_data_add_file(struct _cef_drag_data_t* self,
@@ -367,6 +368,50 @@ void CEF_CALLBACK drag_data_add_file(struct _cef_drag_data_t* self,
CefString(display_name));
}

+void CEF_CALLBACK drag_data_set_image(struct _cef_drag_data_t* self,
+ struct _cef_image_t* image) {
+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;
+ // Verify param: image; type: refptr_same
+ DCHECK(image);
+ if (!image)
+ return;
+ return NULL;
+
+ // Execute
+ CefDragDataCppToC::Get(self)->SetImage(
+ CefImageCppToC::Unwrap(image));
+ CefRefPtr<CefImage> _retval = CefDragDataCppToC::Get(self)->GetImage();
+
+ // Return type: refptr_same
+ return CefImageCppToC::Wrap(_retval);
+}
+
+struct _cef_image_t* CEF_CALLBACK drag_data_get_image(
+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 NULL;
+ return CefPoint();
+
+ // Execute
+ CefRefPtr<CefImage> _retval = CefDragDataCppToC::Get(self)->GetImage();
+ cef_point_t _retval = CefDragDataCppToC::Get(self)->GetImageHotspot();
+
+ // Return type: refptr_same
+ return CefImageCppToC::Wrap(_retval);
+ // Return type: simple
+ return _retval;
+}
+
+int CEF_CALLBACK drag_data_has_image(struct _cef_drag_data_t* self) {
Expand All @@ -245,18 +266,18 @@ index 381b88b9..6f4925a0 100644
} // namespace


@@ -395,6 +442,9 @@ CefDragDataCppToC::CefDragDataCppToC() {
@@ -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()->set_image = drag_data_set_image;
+ 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..5e94aff8 100644
index db1a2f71..e6714562 100644
--- libcef_dll/ctocpp/drag_data_ctocpp.cc
+++ libcef_dll/ctocpp/drag_data_ctocpp.cc
@@ -11,6 +11,7 @@
Expand All @@ -267,39 +288,36 @@ index db1a2f71..5e94aff8 100644
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
#include "libcef_dll/transfer_util.h"

@@ -372,6 +373,51 @@ void CefDragDataCToCpp::AddFile(const CefString& path,
@@ -372,6 +373,48 @@ void CefDragDataCToCpp::AddFile(const CefString& path,
display_name.GetStruct());
}

+void CefDragDataCToCpp::SetImage(CefRefPtr<CefImage> image) {
+CefRefPtr<CefImage> CefDragDataCToCpp::GetImage() {
+ cef_drag_data_t* _struct = GetStruct();
+ if (CEF_MEMBER_MISSING(_struct, set_image))
+ return;
+ if (CEF_MEMBER_MISSING(_struct, get_image))
+ return NULL;
+
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ // Verify param: image; type: refptr_same
+ DCHECK(image.get());
+ if (!image.get())
+ return;
+
+ // Execute
+ _struct->set_image(_struct,
+ CefImageCToCpp::Unwrap(image));
+ cef_image_t* _retval = _struct->get_image(_struct);
+
+ // Return type: refptr_same
+ return CefImageCToCpp::Wrap(_retval);
+}
+
+CefRefPtr<CefImage> CefDragDataCToCpp::GetImage() {
+CefPoint CefDragDataCToCpp::GetImageHotspot() {
+ cef_drag_data_t* _struct = GetStruct();
+ if (CEF_MEMBER_MISSING(_struct, get_image))
+ return NULL;
+ if (CEF_MEMBER_MISSING(_struct, get_image_hotspot))
+ return CefPoint();
+
+ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
+
+ // Execute
+ cef_image_t* _retval = _struct->get_image(_struct);
+ cef_point_t _retval = _struct->get_image_hotspot(_struct);
+
+ // Return type: refptr_same
+ return CefImageCToCpp::Wrap(_retval);
+ // Return type: simple
+ return _retval;
+}
+
+bool CefDragDataCToCpp::HasImage() {
Expand All @@ -320,15 +338,15 @@ index db1a2f71..5e94aff8 100644
// CONSTRUCTOR - Do not edit by hand.

diff --git libcef_dll/ctocpp/drag_data_ctocpp.h libcef_dll/ctocpp/drag_data_ctocpp.h
index 5b202710..a2e3774f 100644
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;
+ void SetImage(CefRefPtr<CefImage> image) OVERRIDE;
+ CefRefPtr<CefImage> GetImage() OVERRIDE;
+ CefPoint GetImageHotspot() OVERRIDE;
+ bool HasImage() OVERRIDE;
};

Expand Down
4 changes: 4 additions & 0 deletions src/drag_data.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ cdef class DragData:
raise Exception("Image is not available")
return PyImage_Init(cef_image)

cpdef tuple GetImageHotspot(self):
cdef CefPoint point = self.cef_drag_data.get().GetImageHotspot()
return (point.x, point.y)

cpdef py_bool HasImage(self):
return self.cef_drag_data.get().HasImage()

Expand Down
2 changes: 2 additions & 0 deletions src/extern/cef/cef_drag_data.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from libcpp cimport bool as cpp_bool
from cef_string cimport CefString
from cef_ptr cimport CefRefPtr
from cef_image cimport CefImage
from cef_types cimport CefPoint

cdef extern from "include/cef_drag_data.h":
cdef cppclass CefDragData:
Expand All @@ -20,6 +21,7 @@ cdef extern from "include/cef_drag_data.h":
void SetFragmentBaseURL(const CefString& base_url)
cpp_bool HasImage()
CefRefPtr[CefImage] GetImage()
CefPoint GetImageHotspot()


cdef CefRefPtr[CefDragData] CefDragData_Create "CefDragData::Create"()
3 changes: 2 additions & 1 deletion src/extern/cef/cef_types.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ cdef extern from "include/internal/cef_types.h":
CefSize(int width, int height)

cdef cppclass CefPoint:
pass
int x
int y

ctypedef struct CefRequestContextSettings:
pass
Expand Down
Loading

0 comments on commit af7005e

Please sign in to comment.