diff --git a/.gitignore b/.gitignore index 5a91c2f8..2e303a2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ build/ *.log -__pycache__/ \ No newline at end of file +__pycache__/ +*.pyc diff --git a/api/API-categories.md b/api/API-categories.md index 68f7e8c0..243ffa47 100644 --- a/api/API-categories.md +++ b/api/API-categories.md @@ -24,6 +24,7 @@ * [DpiAware](DpiAware.md) class (Win) * [DragData](DragData.md) object * [Frame](Frame.md) object + * [Image](Image.md) object * [JavascriptBindings](JavascriptBindings.md) class * [JavascriptCallback](JavascriptCallback.md) object * [PaintBuffer](PaintBuffer.md) object diff --git a/api/API-index.md b/api/API-index.md index e078e1f1..13e7546a 100644 --- a/api/API-index.md +++ b/api/API-index.md @@ -45,6 +45,11 @@ * [OnKeyEvent](KeyboardHandler.md#onkeyevent) * [StringVisitor (interface)](StringVisitor.md) * [Visit](StringVisitor.md#visit) +* [Frame (object)](Image.md) + * [GetAsBitmap](Image.md#getasbitmap) + * [GetAsPng](Image.md#getaspng) + * [GetHeight](Image.md#getheight) + * [GetWidth](Image.md#getwidth) * [JavascriptDialogHandler (interface)](JavascriptDialogHandler.md) * [Continue](JavascriptDialogHandler.md#continue) * [OnJavascriptDialog](JavascriptDialogHandler.md#onjavascriptdialog) @@ -116,6 +121,8 @@ * [GetLinkTitle](DragData.md#getlinktitle) * [GetFragmentText](DragData.md#getfragmenttext) * [GetFragmentHtml](DragData.md#getfragmenthtml) + * [GetImage](DragData.md#getimage) + * [HasImage](DragData.md#hasimage) * [LifespanHandler (interface)](LifespanHandler.md) * [OnBeforePopup](LifespanHandler.md#onbeforepopup) * [_OnAfterCreated](LifespanHandler.md#_onaftercreated) @@ -182,8 +189,11 @@ * [Undo](Frame.md#undo) * [ViewSource](Frame.md#viewsource) * [cefpython](cefpython.md) + * [CreateBrowser](cefpython.md#createbrowser) * [CreateBrowserSync](cefpython.md#createbrowsersync) + * [ExceptHook](cefpython.md#excepthook) * [GetAppSetting](cefpython.md#getappsetting) + * [GetAppPath](cefpython.md#getapppath) * [GetBrowserByWindowHandle](cefpython.md#getbrowserbywindowhandle) * [GetCommandLineSwitch](cefpython.md#getcommandlineswitch) * [GetGlobalClientCallback](cefpython.md#getglobalclientcallback) diff --git a/api/DragData.md b/api/DragData.md index 9ca4df62..b0adf586 100644 --- a/api/DragData.md +++ b/api/DragData.md @@ -1,5 +1,6 @@ [API categories](API-categories.md) | [API index](API-index.md) + # DragData (object) @@ -70,3 +71,22 @@ Return the plain text fragment that is being dragged. Return the text/html fragment that is being dragged. + +### GetImage + +| | | +| --- | --- | +| __Return__ | [Image](Image.md) | + +Get image representation of drag data. Check with HasImage() first, +otherwise if there is no image an exception is thrown. + + +### HasImage + +| | | +| --- | --- | +| __Return__ | bool | + +Whether image representation of drag data is available. + diff --git a/api/Image.md b/api/Image.md new file mode 100644 index 00000000..02bfba2a --- /dev/null +++ b/api/Image.md @@ -0,0 +1,71 @@ +[API categories](API-categories.md) | [API index](API-index.md) + + +# Frame (object) + + +Table of contents: +* [Methods](#methods) + * [GetAsBitmap](#getasbitmap) + * [GetAsPng](#getaspng) + * [GetHeight](#getheight) + * [GetWidth](#getwidth) + + +## Methods + + +### GetAsBitmap + +| Parameter | Type | +| --- | --- | +| scale_factor | float | +| color_type | cef_color_type_t | +| alpha_type | cef_alpha_type_t | +| __Return__ | bytes | + +`cef_color_type_t` constants in the cefpython module: +> CEF_COLOR_TYPE_RGBA_8888, +> CEF_COLOR_TYPE_BGRA_8888, + +`enum cef_alpha_type_t` constants in the cefpython module: +> CEF_ALPHA_TYPE_OPAQUE, +> CEF_ALPHA_TYPE_PREMULTIPLIED, +> CEF_ALPHA_TYPE_POSTMULTIPLIED, + + +### GetAsPng + +| Parameter | Type | +| --- | --- | +| scale_factor | float | +| with_transparency | bool | +| __Return__ | bytes | + +Returns image data as bytes. + +Description from upstream CEF: +> Returns the PNG representation that most closely matches |scale_factor|. If +> |with_transparency| is true any alpha transparency in the image will be +> represented in the resulting PNG data. |pixel_width| and |pixel_height| are +> the output representation size in pixel coordinates. Returns a +> CefBinaryValue containing the PNG image data on success or NULL on failure. + + +### GetHeight + +| | | +| --- | --- | +| __Return__ | int | + +Returns the image heifght in density independent pixel (DIP) units. + + +### GetWidth + +| | | +| --- | --- | +| __Return__ | int | + +Returns the image width in density independent pixel (DIP) units. + diff --git a/docs/Build-instructions.md b/docs/Build-instructions.md index c5569b71..d4138893 100644 --- a/docs/Build-instructions.md +++ b/docs/Build-instructions.md @@ -58,7 +58,7 @@ binaries from GH releases. 8) Build cefpython: ``` cd cefpython/src/linux/ -python compile.py 53.0 +python compile.py 53.1 ``` 9) As of writing only "pygtk_.py" and "kivy_.py" examples are working diff --git a/patches/issue251.patch b/patches/issue251.patch new file mode 100644 index 00000000..918e6c85 --- /dev/null +++ b/patches/issue251.patch @@ -0,0 +1,335 @@ +diff --git include/capi/cef_drag_data_capi.h include/capi/cef_drag_data_capi.h +index 5f86225..1684de2 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,22 @@ 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. ++ /// ++ void (CEF_CALLBACK *set_image)(struct _cef_drag_data_t* self, ++ struct _cef_image_t* image); ++ ++ /// ++ // Get image representation of drag data (may be NULL). ++ /// ++ struct _cef_image_t* (CEF_CALLBACK *get_image)(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 8f8094b..8b4602b 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 + +@@ -193,6 +194,24 @@ class CefDragData : public virtual CefBase { + /// + /*--cef(optional_param=display_name)--*/ + virtual void AddFile(const CefString& path, const CefString& display_name) =0; ++ ++ /// ++ // Set image representation of drag data. ++ /// ++ /*--cef()--*/ ++ virtual void SetImage(CefRefPtr image) =0; ++ ++ /// ++ // Get image representation of drag data (may be NULL). ++ /// ++ /*--cef()--*/ ++ virtual CefRefPtr GetImage() =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/web_contents_view_osr.cc libcef/browser/osr/web_contents_view_osr.cc +index 574c22b..5a04fb1 100644 +--- libcef/browser/osr/web_contents_view_osr.cc ++++ libcef/browser/osr/web_contents_view_osr.cc +@@ -6,6 +6,7 @@ + #include "libcef/browser/osr/web_contents_view_osr.h" + + #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/common/drag_data_impl.h" + +@@ -220,7 +221,9 @@ void CefWebContentsViewOSR::StartDragging( + if (browser.get()) + handler = browser->GetClient()->GetRenderHandler(); + if (handler.get()) { +- CefRefPtr drag_data(new CefDragDataImpl(drop_data)); ++ CefRefPtr cef_image(new CefImageImpl(image)); ++ CefRefPtr drag_data(new CefDragDataImpl(drop_data, ++ cef_image)); + 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 6b632ab..2f12b92 100644 +--- libcef/common/drag_data_impl.cc ++++ libcef/common/drag_data_impl.cc +@@ -20,6 +20,13 @@ CefDragDataImpl::CefDragDataImpl(const content::DropData& data) + read_only_(false) { + } + ++CefDragDataImpl::CefDragDataImpl(const content::DropData& data, ++ CefRefPtr image) ++ : data_(data), ++ image_(image), ++ read_only_(false) { ++} ++ + CefDragDataImpl::CefDragDataImpl() + : read_only_(false) { + } +@@ -32,7 +39,7 @@ CefRefPtr CefDragDataImpl::Clone() { + CefDragDataImpl* drag_data = NULL; + { + base::AutoLock lock_scope(lock_); +- drag_data = new CefDragDataImpl(data_); ++ drag_data = new CefDragDataImpl(data_, image_); + } + return drag_data; + } +@@ -191,3 +198,20 @@ void CefDragDataImpl::SetReadOnly(bool read_only) { + + read_only_ = read_only; + } ++ ++void CefDragDataImpl::SetImage(CefRefPtr image) { ++ base::AutoLock lock_scope(lock_); ++ CHECK_READONLY_RETURN_VOID(); ++ image_ = image; ++} ++ ++CefRefPtr CefDragDataImpl::GetImage() { ++ base::AutoLock lock_scope(lock_); ++ return image_; ++} ++ ++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 64f29ed..9870726 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 + +@@ -18,6 +19,8 @@ class CefDragDataImpl : public CefDragData { + public: + CefDragDataImpl(); + explicit CefDragDataImpl(const content::DropData& data); ++ explicit CefDragDataImpl(const content::DropData& data, ++ CefRefPtr image); + + CefRefPtr Clone() override; + bool IsReadOnly() override; +@@ -41,6 +44,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 image) override; ++ CefRefPtr GetImage() 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 { + + private: + content::DropData data_; ++ CefRefPtr image_; + + // 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 c36069e..ddb5729 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,52 @@ 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) { ++ // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING ++ ++ DCHECK(self); ++ if (!self) ++ return; ++ // Verify param: image; type: refptr_same ++ DCHECK(image); ++ if (!image) ++ return; ++ ++ // Execute ++ CefDragDataCppToC::Get(self)->SetImage( ++ CefImageCppToC::Unwrap(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 NULL; ++ ++ // Execute ++ CefRefPtr _retval = CefDragDataCppToC::Get(self)->GetImage(); ++ ++ // Return type: refptr_same ++ return CefImageCppToC::Wrap(_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 +442,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()->has_image = drag_data_has_image; + } + + template<> CefRefPtr CefCppToC image) { ++ cef_drag_data_t* _struct = GetStruct(); ++ if (CEF_MEMBER_MISSING(_struct, set_image)) ++ return; ++ ++ // 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)); ++} ++ ++CefRefPtr 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); ++} ++ ++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 225f57a..2f0b67d 100644 +--- libcef_dll/ctocpp/drag_data_ctocpp.h ++++ libcef_dll/ctocpp/drag_data_ctocpp.h +@@ -53,6 +53,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 image) OVERRIDE; ++ CefRefPtr GetImage() OVERRIDE; ++ bool HasImage() OVERRIDE; + }; + + #endif // USING_CEF_SHARED diff --git a/patches/patch.py b/patches/patch.py index ec805191..71a28274 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -23,6 +23,11 @@ 'name': 'issue231', 'path': './' }, + { + # Adds drag-image representation during drag & drop in OSR mode. + 'name': 'issue251', + 'path': './' + }, ]) # LINUX diff --git a/src/cefpython.pyx b/src/cefpython.pyx index 3d19900c..86514a3e 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -426,6 +426,7 @@ from request_context_handler cimport * from cef_jsdialog_handler cimport * from cef_path_util cimport * from cef_drag_data cimport * +from cef_image cimport * # ----------------------------------------------------------------------------- @@ -506,6 +507,7 @@ include "app.pyx" include "javascript_dialog_handler.pyx" include "drag_data.pyx" include "helpers.pyx" +include "image.pyx" # ----------------------------------------------------------------------------- # Utility functions to provide settings to the C++ browser process code. @@ -618,7 +620,7 @@ def Initialize(applicationSettings=None, commandLineSwitches=None): if "locales_dir_path" not in applicationSettings: if platform.system() != "Darwin": applicationSettings["locales_dir_path"] = os.path.join( - module_dir, "/locales") + module_dir, "locales") if "resources_dir_path" not in applicationSettings: applicationSettings["resources_dir_path"] = module_dir if platform.system() == "Darwin": @@ -847,10 +849,13 @@ def Shutdown(): time.sleep(0.01) browsers_list = [] for browserId in g_pyBrowsers: - browser = g_pyBrowsers[browserId] - browser.TryCloseBrowser() + # Cannot close browser here otherwise error: + # > dictionary changed size during iteration browsers_list.append(browserId) for browserId in browsers_list: + browser = GetPyBrowserById(browserId) + if browser: + browser.TryCloseBrowser() RemovePyBrowser(browserId) for i in range(10): with nogil: diff --git a/src/compile_time_constants.pxi b/src/compile_time_constants.pxi index 47dedaec..35f85002 100644 --- a/src/compile_time_constants.pxi +++ b/src/compile_time_constants.pxi @@ -1,3 +1,3 @@ # This file was generated by setup.py DEF UNAME_SYSNAME = "Linux" -DEF PY_MAJOR_VERSION = 3 +DEF PY_MAJOR_VERSION = 2 diff --git a/src/cython_includes/cef_drag_data.pxd b/src/cython_includes/cef_drag_data.pxd index e48fceb2..9b9a8469 100644 --- a/src/cython_includes/cef_drag_data.pxd +++ b/src/cython_includes/cef_drag_data.pxd @@ -3,6 +3,7 @@ from libcpp cimport bool as cpp_bool from cef_string cimport CefString from cef_ptr cimport CefRefPtr +from cef_image cimport CefImage cdef extern from "include/cef_drag_data.h": cdef cppclass CefDragData: @@ -15,5 +16,8 @@ cdef extern from "include/cef_drag_data.h": void SetFragmentText(const CefString& text) void SetFragmentHtml(const CefString& html) void SetFragmentBaseURL(const CefString& base_url) + cpp_bool HasImage() + CefRefPtr[CefImage] GetImage() + cdef CefRefPtr[CefDragData] CefDragData_Create "CefDragData::Create"() diff --git a/src/cython_includes/cef_image.pxd b/src/cython_includes/cef_image.pxd new file mode 100644 index 00000000..2e59cd93 --- /dev/null +++ b/src/cython_includes/cef_image.pxd @@ -0,0 +1,21 @@ +# Copyright (c) 2016 The CEF Python authors. All rights reserved. + +from cef_ptr cimport CefRefPtr +from libcpp cimport bool as cpp_bool +from cef_values cimport CefBinaryValue +from cef_types cimport cef_color_type_t, cef_alpha_type_t + +cdef extern from "include/cef_image.h": + + cdef cppclass CefImage: + size_t GetWidth() + size_t GetHeight() + CefRefPtr[CefBinaryValue] GetAsBitmap(float scale_factor, + cef_color_type_t color_type, + cef_alpha_type_t alpha_type, + int& pixel_width, + int& pixel_height) + CefRefPtr[CefBinaryValue] GetAsPNG(float scale_factor, + cpp_bool with_transparency, + int& pixel_width, + int& pixel_height) diff --git a/src/cython_includes/cef_types.pxd b/src/cython_includes/cef_types.pxd index 914c7794..4330887a 100644 --- a/src/cython_includes/cef_types.pxd +++ b/src/cython_includes/cef_types.pxd @@ -347,3 +347,12 @@ cdef extern from "include/internal/cef_types.h": DRAG_OPERATION_MOVE = 16 DRAG_OPERATION_DELETE = 32 DRAG_OPERATION_EVERY = UINT_MAX + + ctypedef enum cef_color_type_t: + CEF_COLOR_TYPE_RGBA_8888, + CEF_COLOR_TYPE_BGRA_8888, + + ctypedef enum cef_alpha_type_t: + CEF_ALPHA_TYPE_OPAQUE, + CEF_ALPHA_TYPE_PREMULTIPLIED, + CEF_ALPHA_TYPE_POSTMULTIPLIED, diff --git a/src/drag_data.pyx b/src/drag_data.pyx index e7c59412..bdc7f46c 100644 --- a/src/drag_data.pyx +++ b/src/drag_data.pyx @@ -34,3 +34,12 @@ cdef class DragData: cpdef py_string GetFragmentHtml(self): return CefToPyString(self.cef_drag_data.get().GetFragmentHtml()) + cpdef PyImage GetImage(self): + cdef CefRefPtr[CefImage] cef_image =\ + self.cef_drag_data.get().GetImage() + if not cef_image.get(): + raise Exception("Image is not available") + return PyImage_Init(cef_image) + + cpdef py_bool HasImage(self): + return self.cef_drag_data.get().HasImage() diff --git a/src/image.pyx b/src/image.pyx new file mode 100644 index 00000000..cfdb8f8f --- /dev/null +++ b/src/image.pyx @@ -0,0 +1,69 @@ +# Copyright (c) 2016 The CEF Python authors. All rights reserved. + +include "cefpython.pyx" + +# noinspection PyUnresolvedReferences +cimport cef_types + +# cef_color_type_t +CEF_COLOR_TYPE_RGBA_8888 = cef_types.CEF_COLOR_TYPE_RGBA_8888 +CEF_COLOR_TYPE_BGRA_8888 = cef_types.CEF_COLOR_TYPE_BGRA_8888 + +# cef_alpha_type_t +CEF_ALPHA_TYPE_OPAQUE = cef_types.CEF_ALPHA_TYPE_OPAQUE +CEF_ALPHA_TYPE_PREMULTIPLIED = cef_types.CEF_ALPHA_TYPE_PREMULTIPLIED +CEF_ALPHA_TYPE_POSTMULTIPLIED = cef_types.CEF_ALPHA_TYPE_POSTMULTIPLIED + + +cdef PyImage PyImage_Init(CefRefPtr[CefImage] cef_image): + cdef PyImage image = PyImage() + image.cef_image = cef_image + return image + +cdef class PyImage: + cdef CefRefPtr[CefImage] cef_image + + cpdef bytes GetAsBitmap(self, + float scale_factor, + cef_types.cef_color_type_t color_type, + cef_types.cef_alpha_type_t alpha_type): + cdef int pixel_width = 0 + cdef int pixel_height = 0 + if not self.cef_image.get(): + raise Exception("cef_image is NULL") + cdef CefRefPtr[CefBinaryValue] binary_value =\ + self.cef_image.get().GetAsBitmap(scale_factor, + color_type, alpha_type, + pixel_width, pixel_height) + cdef size_t size = binary_value.get().GetSize() + cdef void* abuffer = malloc(size) + binary_value.get().GetData(abuffer, size, 0) + cdef bytes ret = (abuffer)[:size] + free(abuffer) + return ret + + cpdef bytes GetAsPng(self, float scale_factor, py_bool with_transparency): + cdef int pixel_width = 0 + cdef int pixel_height = 0 + if not self.cef_image.get(): + raise Exception("cef_image is NULL") + cdef CefRefPtr[CefBinaryValue] binary_value =\ + self.cef_image.get().GetAsPNG(scale_factor, with_transparency, + pixel_width, pixel_height) + cdef size_t size = binary_value.get().GetSize() + cdef void* abuffer = malloc(size) + binary_value.get().GetData(abuffer, size, 0) + cdef bytes ret = (abuffer)[:size] + free(abuffer) + return ret + + cpdef size_t GetHeight(self): + if not self.cef_image.get(): + raise Exception("cef_image is NULL") + return self.cef_image.get().GetHeight() + + cpdef size_t GetWidth(self): + if not self.cef_image.get(): + raise Exception("cef_image is NULL") + return self.cef_image.get().GetWidth() + diff --git a/src/include/cef_drag_data.h b/src/include/cef_drag_data.h index 8f8094b4..8b4602b1 100644 --- a/src/include/cef_drag_data.h +++ b/src/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 @@ -193,6 +194,24 @@ class CefDragData : public virtual CefBase { /// /*--cef(optional_param=display_name)--*/ virtual void AddFile(const CefString& path, const CefString& display_name) =0; + + /// + // Set image representation of drag data. + /// + /*--cef()--*/ + virtual void SetImage(CefRefPtr image) =0; + + /// + // Get image representation of drag data (may be NULL). + /// + /*--cef()--*/ + virtual CefRefPtr GetImage() =0; + + /// + // Whether image representation of drag data is available. + /// + /*--cef()--*/ + virtual bool HasImage() =0; }; #endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ diff --git a/src/linux/binaries_64bit/README.txt b/src/linux/binaries_64bit/README.txt index 19c3a6c9..23abd700 100644 --- a/src/linux/binaries_64bit/README.txt +++ b/src/linux/binaries_64bit/README.txt @@ -1,15 +1,15 @@ Chromium Embedded Framework (CEF) Standard Binary Distribution for Linux ------------------------------------------------------------------------------- -Date: September 08, 2016 +Date: September 20, 2016 -CEF Version: 3.2785.1475.gaead085 +CEF Version: 3.2785.1481.gc3a7e2c CEF URL: https://bitbucket.org/chromiumembedded/cef.git - @aead0852b31b5f9acfa5e9c1216f6dd76d73506f + @c3a7e2cdece270fbccfb5e979d6d2c808456d7a5 -Chromium Verison: 53.0.2785.89 +Chromium Verison: 53.0.2785.101 Chromium URL: https://chromium.googlesource.com/chromium/src.git - @49dccdea6645f6759fc6e779e12e81930ede2d4a + @1b15c6e77f9a1154a85327357ea29c1b57d16445 This distribution contains all components necessary to build and distribute an application using CEF on the Linux platform. Please see the LICENSING diff --git a/src/linux/binaries_64bit/kivy-dragdrop.png b/src/linux/binaries_64bit/kivy-dragdrop.png deleted file mode 100644 index 585bd93f..00000000 Binary files a/src/linux/binaries_64bit/kivy-dragdrop.png and /dev/null differ diff --git a/src/linux/binaries_64bit/kivy-dragdrop.txt b/src/linux/binaries_64bit/kivy-dragdrop.txt deleted file mode 100644 index 255d792d..00000000 --- a/src/linux/binaries_64bit/kivy-dragdrop.txt +++ /dev/null @@ -1,5 +0,0 @@ -"kivy-dragdrop.png" downloaded from here: -http://www.softicons.com/toolbar-icons/free-blue-button-icons-by-aha-soft/cursor-drag-arrow-icon - -Author: Aha-Soft ( http://www.aha-soft.com/ ) -License: CC Attribution 3.0 United States diff --git a/src/linux/binaries_64bit/kivy_.py b/src/linux/binaries_64bit/kivy_.py index 03a6af11..6b686c80 100644 --- a/src/linux/binaries_64bit/kivy_.py +++ b/src/linux/binaries_64bit/kivy_.py @@ -36,6 +36,7 @@ import pygtk pygtk.require('2.0') import gtk +import io import kivy from kivy.app import App @@ -46,8 +47,6 @@ from kivy.graphics import Color, Rectangle, GraphicException from kivy.clock import Clock from kivy.graphics.texture import Texture -from kivy.core.window import Window -from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout from kivy.base import EventLoop @@ -56,25 +55,29 @@ class BrowserLayout(BoxLayout): - browser = None def __init__(self, **kwargs): super(BrowserLayout, self).__init__(**kwargs) self.orientation = "vertical" - browser = CefBrowser(id="browser") + self.browser_widget = CefBrowser(id="browser") layout = BoxLayout() layout.size_hint_y = None layout.height = 40 - layout.add_widget(Button(text="Back", on_press=browser.go_back)) - layout.add_widget(Button(text="Forward", on_press=browser.go_forward)) - layout.add_widget(Button(text="Reload", on_press=browser.reload)) - layout.add_widget(Button(text="Print", on_press=browser.print_page)) - layout.add_widget(Button(text="DevTools", on_press=browser.devtools)) + layout.add_widget(Button(text="Back", + on_press=self.browser_widget.go_back)) + layout.add_widget(Button(text="Forward", + on_press=self.browser_widget.go_forward)) + layout.add_widget(Button(text="Reload", + on_press=self.browser_widget.reload)) + layout.add_widget(Button(text="Print", + on_press=self.browser_widget.print_page)) + layout.add_widget(Button(text="DevTools", + on_press=self.browser_widget.devtools)) self.add_widget(layout) - self.add_widget(browser) + self.add_widget(self.browser_widget) class CefBrowser(Widget): @@ -102,6 +105,8 @@ def __init__(self, start_url='https://www.google.com/', **kwargs): #until runtime without core-dump. self.bind(size = self.size_changed) + self.browser = None + starting = True def size_changed(self, *kwargs): @@ -734,15 +739,27 @@ def drag_ended(self): drag_icon = None def update_drag_icon(self, x, y): - if self.drag_icon: + if self.is_drag: + if self.drag_icon: + self.drag_icon.pos = self.flip_pos_vertical(x, y) + else: + image = self.drag_data.GetImage() + width = image.GetWidth() + height = image.GetHeight() + abuffer = image.GetAsBitmap( + 1.0, + cefpython.CEF_COLOR_TYPE_BGRA_8888, + cefpython.CEF_ALPHA_TYPE_PREMULTIPLIED) + texture = Texture.create(size=(width, height)) + texture.blit_buffer(abuffer, colorfmt='bgra', bufferfmt='ubyte') + texture.flip_vertical() + self.drag_icon = Rectangle(texture=texture, + pos=self.flip_pos_vertical(x, y), + size=(width, height)) + self.canvas.add(self.drag_icon) + elif self.drag_icon: self.canvas.remove(self.drag_icon) del self.drag_icon - if self.is_drag: - self.drag_icon = Rectangle(source="kivy-dragdrop.png", - pos=self.flip_pos_vertical(x,y), - size=(40,40)) - self.canvas.add(self.drag_icon) - def flip_pos_vertical(self, x, y): half = self.height / 2 @@ -971,10 +988,18 @@ def UpdateDragCursor(self, browser, operation): self.browserWidget.current_drag_operation = operation -if __name__ == '__main__': +class CefBrowserApp(App): + + def build(self): + self.layout = BrowserLayout() + return self.layout + + def on_stop(self): + # This is required for a clean shutdown of CEF. + self.layout.browser_widget.browser.CloseBrowser(True) + del self.layout.browser_widget.browser - class CefBrowserApp(App): - def build(self): - return BrowserLayout() + +if __name__ == '__main__': CefBrowserApp().run() cefpython.Shutdown() diff --git a/src/linux/compile.py b/src/linux/compile.py index 7ca4c1d1..3f956233 100644 --- a/src/linux/compile.py +++ b/src/linux/compile.py @@ -56,6 +56,12 @@ else: FAST = False +if len(sys.argv) > 1 and "--kivy" in sys.argv: + KIVY = True + print("KIVY mode On") +else: + KIVY = False + if len(sys.argv) > 1 and re.search(r"^\d+\.\d+$", sys.argv[1]): VERSION = sys.argv[1] else: @@ -187,9 +193,12 @@ os.chdir("./binaries_%s" % BITS) subprocess.call("cygdb . --args python-dbg wxpython.py", shell=True) else: - os.system("rm -rf ./installer/cefpython3-%s-*" % (VERSION,)) - subprocess.call("cd ./installer/ && python make-setup.py --version %s" - " && cd cefpython3-%s-* && python setup.py install" - " && cd ../../../../examples/" - " && python hello_world.py && cd ../src/linux/"\ - % (VERSION,VERSION), shell=True) + if KIVY: + os.system("python binaries_64bit/kivy_.py") + else: + os.system("rm -rf ./installer/cefpython3-%s-*" % (VERSION,)) + subprocess.call("cd ./installer/ && python make-setup.py --version %s" + " && cd cefpython3-%s-* && python setup.py install" + " && cd ../../../../examples/" + " && python hello_world.py && cd ../src/linux/"\ + % (VERSION,VERSION), shell=True) diff --git a/src/linux/installer/make-setup.py b/src/linux/installer/make-setup.py index f4cafc0f..cfb12a00 100644 --- a/src/linux/installer/make-setup.py +++ b/src/linux/installer/make-setup.py @@ -26,7 +26,6 @@ README_FILE = os.getcwd()+r"/README.txt" INIT_TEMPLATE = os.getcwd()+r"/__init__.py.template" SETUP_TEMPLATE = os.getcwd()+r"/setup.py.template" -SETUP_CFG_TEMPLATE = os.getcwd()+r"/setup.cfg.template" def str_format(string, dictionary): orig_string = string @@ -67,11 +66,6 @@ def main(): SETUP_CONTENT = str_format(f.read(), vars) f.close() - print("Reading template: %s" % SETUP_CFG_TEMPLATE) - f = open(SETUP_CFG_TEMPLATE) - SETUP_CFG_CONTENT = str_format(f.read(), vars) - f.close() - installer_dir = os.path.dirname(os.path.abspath(__file__)) setup_dir = installer_dir+"/"+PACKAGE_NAME+"-"+vars["APP_VERSION"]+"-"+LINUX_BITS+"-setup" @@ -94,10 +88,6 @@ def main(): with open(setup_dir+"/setup.py", "w") as f: f.write(SETUP_CONTENT) - print("Creating setup.cfg from template") - with open(setup_dir+"/setup.cfg", "w") as f: - f.write(SETUP_CFG_CONTENT) - binaries_dir = os.path.abspath(installer_dir+"/../binaries_"+BITS+"/") print("Copying binaries to package dir") ret = os.system("cp -rf "+binaries_dir+"/* "+package_dir) @@ -116,6 +106,9 @@ def main(): print("Creating examples dir in package dir") os.mkdir(package_dir+"/examples/") + print("Copying Hello World example") + shutil.copy("../../../examples/hello_world.py", package_dir+"/examples/") + print("Moving kivy-select-boxes dir to examples dir") shutil.move(package_dir+"/kivy-select-boxes", package_dir+"/examples/kivy-select-boxes") @@ -136,9 +129,6 @@ def main(): ret = os.system("mv "+package_dir+"/*.html "+package_dir+"/examples/") ret = os.system("mv "+package_dir+"/*.js "+package_dir+"/examples/") ret = os.system("mv "+package_dir+"/*.css "+package_dir+"/examples/") - ret = os.system("mv "+package_dir+"/*.png "+package_dir+"/examples/") - ret = os.system("mv "+package_dir+"/kivy-dragdrop.txt "\ - +package_dir+"/examples/") assert ret == 0 print("Copying wx/ to package dir") diff --git a/src/linux/setup/cefpython.h b/src/linux/setup/cefpython.h index cfe8d189..a33bde25 100644 --- a/src/linux/setup/cefpython.h +++ b/src/linux/setup/cefpython.h @@ -1,10 +1,8 @@ -/* Generated by Cython 0.24.1 */ +#ifndef __PYX_HAVE__cefpython_py27 +#define __PYX_HAVE__cefpython_py27 -#ifndef __PYX_HAVE__cefpython_py35 -#define __PYX_HAVE__cefpython_py35 - -#ifndef __PYX_HAVE_API__cefpython_py35 +#ifndef __PYX_HAVE_API__cefpython_py27 #ifndef __PYX_EXTERN_C #ifdef __cplusplus @@ -14,87 +12,83 @@ #endif #endif -#ifndef DL_IMPORT - #define DL_IMPORT(_T) _T -#endif - -__PYX_EXTERN_C DL_IMPORT(void) PyBrowser_ShowDevTools(CefRefPtr ); +__PYX_EXTERN_C DL_IMPORT(void) PyBrowser_ShowDevTools(CefRefPtr); __PYX_EXTERN_C DL_IMPORT(void) PyTaskRunnable(int); -__PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnContextCreated(CefRefPtr , CefRefPtr ); +__PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnContextCreated(CefRefPtr, CefRefPtr); __PYX_EXTERN_C DL_IMPORT(void) V8ContextHandler_OnContextReleased(int, int64); -__PYX_EXTERN_C DL_IMPORT(void) V8FunctionHandler_Execute(CefRefPtr , CefRefPtr , CefString &, CefRefPtr ); +__PYX_EXTERN_C DL_IMPORT(void) V8FunctionHandler_Execute(CefRefPtr, CefRefPtr, CefString &, CefRefPtr); __PYX_EXTERN_C DL_IMPORT(void) RemovePythonCallbacksForFrame(int); -__PYX_EXTERN_C DL_IMPORT(bool) ExecutePythonCallback(CefRefPtr , int, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) LifespanHandler_OnBeforePopup(CefRefPtr , CefRefPtr , CefString const &, CefString const &, cef_window_open_disposition_t, bool, int const , CefWindowInfo &, CefRefPtr &, CefBrowserSettings &, bool *); -__PYX_EXTERN_C DL_IMPORT(void) LifespanHandler_OnAfterCreated(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) LifespanHandler_DoClose(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) LifespanHandler_OnBeforeClose(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnAddressChange(CefRefPtr , CefRefPtr , CefString const &); -__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnTitleChange(CefRefPtr , CefString const &); -__PYX_EXTERN_C DL_IMPORT(bool) DisplayHandler_OnTooltip(CefRefPtr , CefString &); -__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnStatusMessage(CefRefPtr , CefString const &); -__PYX_EXTERN_C DL_IMPORT(bool) DisplayHandler_OnConsoleMessage(CefRefPtr , CefString const &, CefString const &, int); -__PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnPreKeyEvent(CefRefPtr , CefKeyEvent const &, CefEventHandle, bool *); -__PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnKeyEvent(CefRefPtr , CefKeyEvent const &, CefEventHandle); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforeResourceLoad(CefRefPtr , CefRefPtr , CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforeBrowse(CefRefPtr , CefRefPtr , CefRefPtr , bool); -__PYX_EXTERN_C DL_IMPORT(CefRefPtr ) RequestHandler_GetResourceHandler(CefRefPtr , CefRefPtr , CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnResourceRedirect(CefRefPtr , CefRefPtr , CefString const &, CefString &, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_GetAuthCredentials(CefRefPtr , CefRefPtr , bool, CefString const &, int, CefString const &, CefString const &, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnQuotaRequest(CefRefPtr , CefString const &, int64, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(CefRefPtr ) RequestHandler_GetCookieManager(CefRefPtr , CefString const &); -__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnProtocolExecution(CefRefPtr , CefString const &, bool &); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforePluginLoad(CefRefPtr , CefString const &, CefString const &, CefString const &, CefRefPtr , cef_plugin_policy_t *); -__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnCertificateError(int, CefString const &, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnRendererProcessTerminated(CefRefPtr , cef_termination_status_t); -__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnPluginCrashed(CefRefPtr , CefString const &); +__PYX_EXTERN_C DL_IMPORT(bool) ExecutePythonCallback(CefRefPtr, int, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) LifespanHandler_OnBeforePopup(CefRefPtr, CefRefPtr, CefString const &, CefString const &, cef_window_open_disposition_t, bool, int const , CefWindowInfo &, CefRefPtr &, CefBrowserSettings &, bool *); +__PYX_EXTERN_C DL_IMPORT(void) LifespanHandler_OnAfterCreated(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) LifespanHandler_DoClose(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) LifespanHandler_OnBeforeClose(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnAddressChange(CefRefPtr, CefRefPtr, CefString const &); +__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnTitleChange(CefRefPtr, CefString const &); +__PYX_EXTERN_C DL_IMPORT(bool) DisplayHandler_OnTooltip(CefRefPtr, CefString &); +__PYX_EXTERN_C DL_IMPORT(void) DisplayHandler_OnStatusMessage(CefRefPtr, CefString const &); +__PYX_EXTERN_C DL_IMPORT(bool) DisplayHandler_OnConsoleMessage(CefRefPtr, CefString const &, CefString const &, int); +__PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnPreKeyEvent(CefRefPtr, CefKeyEvent const &, CefEventHandle, bool *); +__PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnKeyEvent(CefRefPtr, CefKeyEvent const &, CefEventHandle); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforeResourceLoad(CefRefPtr, CefRefPtr, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforeBrowse(CefRefPtr, CefRefPtr, CefRefPtr, bool); +__PYX_EXTERN_C DL_IMPORT(CefRefPtr) RequestHandler_GetResourceHandler(CefRefPtr, CefRefPtr, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnResourceRedirect(CefRefPtr, CefRefPtr, CefString const &, CefString &, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_GetAuthCredentials(CefRefPtr, CefRefPtr, bool, CefString const &, int, CefString const &, CefString const &, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnQuotaRequest(CefRefPtr, CefString const &, int64, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(CefRefPtr) RequestHandler_GetCookieManager(CefRefPtr, CefString const &); +__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnProtocolExecution(CefRefPtr, CefString const &, bool &); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforePluginLoad(CefRefPtr, CefString const &, CefString const &, CefString const &, CefRefPtr, cef_plugin_policy_t *); +__PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnCertificateError(int, CefString const &, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnRendererProcessTerminated(CefRefPtr, cef_termination_status_t); +__PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnPluginCrashed(CefRefPtr, CefString const &); __PYX_EXTERN_C DL_IMPORT(bool) CookieVisitor_Visit(int, CefCookie const &, int, int, bool &); __PYX_EXTERN_C DL_IMPORT(void) StringVisitor_Visit(int, CefString const &); -__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadingStateChange(CefRefPtr , bool, bool, bool); -__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadStart(CefRefPtr , CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadEnd(CefRefPtr , CefRefPtr , int); -__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadError(CefRefPtr , CefRefPtr , cef_errorcode_t, CefString const &, CefString const &); -__PYX_EXTERN_C DL_IMPORT(void) BrowserProcessHandler_OnRenderProcessThreadCreated(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) BrowserProcessHandler_OnBeforeChildProcessLaunch(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetRootScreenRect(CefRefPtr , CefRect &); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetViewRect(CefRefPtr , CefRect &); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenRect(CefRefPtr , CefRect &); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenPoint(CefRefPtr , int, int, int &, int &); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenInfo(CefRefPtr , CefScreenInfo &); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupShow(CefRefPtr , bool); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupSize(CefRefPtr , CefRect const &); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPaint(CefRefPtr , cef_paint_element_type_t, std::vector &, void const *, int, int); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnCursorChange(CefRefPtr , CefCursorHandle); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnScrollOffsetChanged(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_StartDragging(CefRefPtr , CefRefPtr , PY_LONG_LONG, int, int); -__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_UpdateDragCursor(CefRefPtr , PY_LONG_LONG); -__PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ProcessRequest(int, CefRefPtr , CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) ResourceHandler_GetResponseHeaders(int, CefRefPtr , int64 &, CefString &); -__PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ReadResponse(int, void *, int, int &, CefRefPtr ); +__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadingStateChange(CefRefPtr, bool, bool, bool); +__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadStart(CefRefPtr, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadEnd(CefRefPtr, CefRefPtr, int); +__PYX_EXTERN_C DL_IMPORT(void) LoadHandler_OnLoadError(CefRefPtr, CefRefPtr, cef_errorcode_t, CefString const &, CefString const &); +__PYX_EXTERN_C DL_IMPORT(void) BrowserProcessHandler_OnRenderProcessThreadCreated(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) BrowserProcessHandler_OnBeforeChildProcessLaunch(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetRootScreenRect(CefRefPtr, CefRect &); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetViewRect(CefRefPtr, CefRect &); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenRect(CefRefPtr, CefRect &); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenPoint(CefRefPtr, int, int, int &, int &); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_GetScreenInfo(CefRefPtr, CefScreenInfo &); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupShow(CefRefPtr, bool); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupSize(CefRefPtr, CefRect const &); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPaint(CefRefPtr, cef_paint_element_type_t, std::vector &, void const *, int, int); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnCursorChange(CefRefPtr, CefCursorHandle); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnScrollOffsetChanged(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) RenderHandler_StartDragging(CefRefPtr, CefRefPtr, PY_LONG_LONG, int, int); +__PYX_EXTERN_C DL_IMPORT(void) RenderHandler_UpdateDragCursor(CefRefPtr, PY_LONG_LONG); +__PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ProcessRequest(int, CefRefPtr, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) ResourceHandler_GetResponseHeaders(int, CefRefPtr, int64 &, CefString &); +__PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ReadResponse(int, void *, int, int &, CefRefPtr); __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_CanGetCookie(int, CefCookie const &); __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_CanSetCookie(int, CefCookie const &); __PYX_EXTERN_C DL_IMPORT(void) ResourceHandler_Cancel(int); -__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnUploadProgress(int, CefRefPtr , int64, int64); -__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnDownloadProgress(int, CefRefPtr , int64, int64); -__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnDownloadData(int, CefRefPtr , void const *, size_t); -__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnRequestComplete(int, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) App_OnBeforeCommandLineProcessing_BrowserProcess(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(bool) JavascriptDialogHandler_OnJavascriptDialog(CefRefPtr , CefString const &, cef_jsdialog_type_t, CefString const &, CefString const &, CefRefPtr , bool &); -__PYX_EXTERN_C DL_IMPORT(bool) JavascriptDialogHandler_OnBeforeUnloadJavascriptDialog(CefRefPtr , CefString const &, bool, CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) JavascriptDialogHandler_OnResetJavascriptDialogState(CefRefPtr ); -__PYX_EXTERN_C DL_IMPORT(void) JavascriptDialogHandler_OnJavascriptDialogClosed(CefRefPtr ); +__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnUploadProgress(int, CefRefPtr, int64, int64); +__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnDownloadProgress(int, CefRefPtr, int64, int64); +__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnDownloadData(int, CefRefPtr, void const *, size_t); +__PYX_EXTERN_C DL_IMPORT(void) WebRequestClient_OnRequestComplete(int, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) App_OnBeforeCommandLineProcessing_BrowserProcess(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(bool) JavascriptDialogHandler_OnJavascriptDialog(CefRefPtr, CefString const &, cef_jsdialog_type_t, CefString const &, CefString const &, CefRefPtr, bool &); +__PYX_EXTERN_C DL_IMPORT(bool) JavascriptDialogHandler_OnBeforeUnloadJavascriptDialog(CefRefPtr, CefString const &, bool, CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) JavascriptDialogHandler_OnResetJavascriptDialogState(CefRefPtr); +__PYX_EXTERN_C DL_IMPORT(void) JavascriptDialogHandler_OnJavascriptDialogClosed(CefRefPtr); __PYX_EXTERN_C DL_IMPORT(void) cefpython_GetDebugOptions(bool *, std::string *); __PYX_EXTERN_C DL_IMPORT(bool) ApplicationSettings_GetBool(char const *); __PYX_EXTERN_C DL_IMPORT(bool) ApplicationSettings_GetBoolFromDict(char const *, char const *); __PYX_EXTERN_C DL_IMPORT(std::string) ApplicationSettings_GetString(char const *); __PYX_EXTERN_C DL_IMPORT(int) CommandLineSwitches_GetInt(char const *); -#endif /* !__PYX_HAVE_API__cefpython_py35 */ +#endif /* !__PYX_HAVE_API__cefpython_py27 */ #if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initcefpython_py35(void); +PyMODINIT_FUNC initcefpython_py27(void); #else -PyMODINIT_FUNC PyInit_cefpython_py35(void); +PyMODINIT_FUNC PyInit_cefpython_py27(void); #endif -#endif /* !__PYX_HAVE__cefpython_py35 */ +#endif /* !__PYX_HAVE__cefpython_py27 */ diff --git a/src/version/cef_version_linux.h b/src/version/cef_version_linux.h index 8b4c0709..15133ab2 100644 --- a/src/version/cef_version_linux.h +++ b/src/version/cef_version_linux.h @@ -35,16 +35,16 @@ #ifndef CEF_INCLUDE_CEF_VERSION_H_ #define CEF_INCLUDE_CEF_VERSION_H_ -#define CEF_VERSION "3.2785.1475.gaead085" +#define CEF_VERSION "3.2785.1481.gc3a7e2c" #define CEF_VERSION_MAJOR 3 -#define CEF_COMMIT_NUMBER 1475 -#define CEF_COMMIT_HASH "aead0852b31b5f9acfa5e9c1216f6dd76d73506f" +#define CEF_COMMIT_NUMBER 1481 +#define CEF_COMMIT_HASH "c3a7e2cdece270fbccfb5e979d6d2c808456d7a5" #define COPYRIGHT_YEAR 2016 #define CHROME_VERSION_MAJOR 53 #define CHROME_VERSION_MINOR 0 #define CHROME_VERSION_BUILD 2785 -#define CHROME_VERSION_PATCH 89 +#define CHROME_VERSION_PATCH 101 #define DO_MAKE_STRING(p) #p #define MAKE_STRING(p) DO_MAKE_STRING(p) diff --git a/tools/automate.py b/tools/automate.py index ae947b19..0dad900a 100644 --- a/tools/automate.py +++ b/tools/automate.py @@ -6,9 +6,10 @@ Usage: automate.py (--prebuilt-cef | --build-cef) - [--force-chromium-update FORCECHROMIUMUPDATE] + [--force-chromium-update FORCE_CHROMIUM_UPDATE] + [--no-cef-update NO_CEF_UPDATE] [--cef-branch BRANCH] [--cef-commit COMMIT] - [--build-dir BUILDDIR] [--cef-build-dir CEFBUILDDIR] + [--build-dir BUILD_DIR] [--cef-build-dir CEF_BUIL_DDIR] [--ninja-jobs JOBS] [--gyp-generators GENERATORS] [--gyp-msvs-version MSVS] automate.py (-h | --help) [type -h to show full description for options] @@ -113,6 +114,12 @@ class Options(object): def main(): """Main entry point.""" + + if not ((2, 7) <= sys.version_info < (2, 8)): + print("ERROR: to run this tool you need Python 2.7, as upstream") + print(" automate-git.py works only with that version.") + sys.exit(1) + setup_options(docopt.docopt(__doc__)) if Options.build_cef: @@ -135,10 +142,13 @@ def setup_options(docopt_args): Options.tools_dir = os.path.dirname(os.path.realpath(__file__)) Options.cefpython_dir = os.path.dirname(Options.tools_dir) - # --cef-branch + # If --cef-branch is specified will use latest CEF commit from that + # branch. Otherwise get cef branch/commit from src/version/. if not Options.cef_branch: - # Use branch from the src/version/cef_version_*.h file + # Use branch/commit from the src/version/cef_version_*.h file Options.cef_branch = get_cefpython_version()["CHROME_VERSION_BUILD"] + Options.cef_commit = get_cefpython_version()["CEF_COMMIT_HASH"] + # --gyp-msvs-version if not Options.gyp_msvs_version: @@ -224,11 +234,14 @@ def create_cef_directories(): run_git("checkout %s" % Options.cef_commit, cef_dir) # Update cef patches update_cef_patches() - # Copy cef/ to chromium/src/ but only if chromium/src/ exists. + # Copy cef/ to chromium/src/ but only if chromium/src/ exists, + # but don't copy it and delete if exists when --force-chromium-update + # flag is passed, chromium throws error about unstaged changes. if os.path.exists(src_dir): if os.path.exists(cef_dir2): rmdir(cef_dir2) - shutil.copytree(cef_dir, cef_dir2) + if not Options.force_chromium_update: + shutil.copytree(cef_dir, cef_dir2) def update_cef_patches(): @@ -577,7 +590,7 @@ def onerror(func, path, _): os.chmod(path, stat.S_IWUSR) func(path) else: - raise + raise Exception("Not a file permission error, dunno what to do") def get_cefpython_version():