From 1a118ede8c7e99910ab2b071fe3ac68d1bbca696 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 08:02:48 +0100 Subject: [PATCH 001/238] Fix building on Linux --- src/subprocess/cefpython_app.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/subprocess/cefpython_app.cpp b/src/subprocess/cefpython_app.cpp index e2c2ed64..269da21b 100644 --- a/src/subprocess/cefpython_app.cpp +++ b/src/subprocess/cefpython_app.cpp @@ -177,11 +177,13 @@ void CefPythonApp::OnBeforeChildProcessLaunch( #ifdef BROWSER_PROCESS // This is included only in the Browser process, when building // the libcefpythonapp library. +#if defined(OS_WINDOWS) if (IsProcessDpiAware()) { // It is required to set DPI awareness in subprocesses // as well, see Issue #358. command_line->AppendSwitch("enable-high-dpi-support"); } +#endif // OS_WINDOWS BrowserProcessHandler_OnBeforeChildProcessLaunch(command_line); #endif // BROWSER_PROCESS From 53d0c63b12b838c0f56c5796d9ddaf9f5091b4b8 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 09:08:30 +0100 Subject: [PATCH 002/238] Update unit tests. Property can be a function too. --- unittests/main_test.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/unittests/main_test.py b/unittests/main_test.py index d7a2fbf9..ecc0f9c3 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -41,6 +41,10 @@ print("Chrome: "+version.chrome_version+""); print("CEF: "+version.cef_version+""); + // Test binding function: test_function + test_function(); + print("test_function() ok"); + // Test binding property: test_property1 if (test_property1 == "Test binding property to the 'window' object") { print("test_property_1 ok"); @@ -56,9 +60,9 @@ throw new Error("test_property2 contains invalid value"); } - // Test binding function: test_function - test_function(); - print("test_function() ok"); + // Test binding function: test_property3_function + test_property3_function(); + print("test_property3_function() ok"); // Test binding external object and use of javascript<>python callbacks var start_time = new Date().getTime(); @@ -145,6 +149,11 @@ def test_main(self): bindings.SetFunction("test_function", external.test_function) bindings.SetProperty("test_property1", external.test_property1) bindings.SetProperty("test_property2", external.test_property2) + # Property with a function value can also be bound. CEF Python + # supports passing functions as callbacks when called from + # javascript, and as a side effect any value and in this case + # a property can also be a function. + bindings.SetProperty("test_property3_function", external.test_property3_function) bindings.SetProperty("cefpython_version", cef.GetVersion()) bindings.SetObject("external", external) browser.SetJavascriptBindings(bindings) @@ -310,6 +319,7 @@ def __init__(self, test_case): # Asserts for True/False will be checked just before shutdown self.test_for_True = True # Test whether asserts are working correctly self.test_function_True = False + self.test_property3_function_True = False self.test_callbacks_True = False self.py_callback_True = False @@ -317,6 +327,10 @@ def test_function(self): """Test binding function to the 'window' object.""" self.test_function_True = True + def test_property3_function(self): + """Test binding function to the 'window' object.""" + self.test_property3_function_True = True + def test_callbacks(self, js_callback): """Test both javascript and python callbacks.""" def py_callback(msg_from_js): From 17caa51fcb7cd24477790cdc145a089454042674 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 10:18:02 +0100 Subject: [PATCH 003/238] Update Tutorial - Cython compiler --- docs/Tutorial.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Tutorial.md b/docs/Tutorial.md index 40a1da38..e79815a4 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -683,6 +683,7 @@ official examples are provided for these. See the following issues in the tracker for all available packagers: * cx_Freeze - see [Issue #338](../../../issues/338) +* Cython - see [Issue #407](../../../issues/407) * py2exe - see [Issue #35](../../../issues/35) * py2app - see [Issue #337](../../../issues/337) * Nuitka - see [Issue #396](../../../issues/396) From 02844979f05a8f693f7f84a811402d1ca1a1a7cf Mon Sep 17 00:00:00 2001 From: Jack-2025 Date: Sun, 18 Feb 2018 18:22:13 +0900 Subject: [PATCH 004/238] Avoids issue #360 on qt.py example --- examples/qt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/qt.py b/examples/qt.py index 0dc126be..261f4160 100644 --- a/examples/qt.py +++ b/examples/qt.py @@ -108,6 +108,8 @@ class MainWindow(QMainWindow): def __init__(self): # noinspection PyArgumentList super(MainWindow, self).__init__(None) + # Avoids crash when shutting down CEF (issue #360) + self.setAttribute(Qt.WA_DeleteOnClose, True) self.cef_widget = None self.navigation_bar = None if PYQT4: From f77161adc6cd9c7c65911e13cd150543d961763b Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 12:26:04 +0100 Subject: [PATCH 005/238] Update examples - print Chromium and CEF version numbers --- examples/hello_world.py | 12 ++++++++---- examples/screenshot.py | 8 ++++++-- examples/tutorial.py | 12 ++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/examples/hello_world.py b/examples/hello_world.py index 0157267f..478c7060 100644 --- a/examples/hello_world.py +++ b/examples/hello_world.py @@ -1,5 +1,5 @@ # Hello world example. Doesn't depend on any third party GUI framework. -# Tested with CEF Python v55.3+. +# Tested with CEF Python v57.0+. from cefpython3 import cefpython as cef import platform @@ -17,10 +17,14 @@ def main(): def check_versions(): - print("[hello_world.py] CEF Python {ver}".format(ver=cef.__version__)) + ver = cef.GetVersion() + print("[hello_world.py] CEF Python {ver}".format(ver=ver["version"])) + print("[hello_world.py] Chromium {ver}".format(ver=ver["chrome_version"])) + print("[hello_world.py] CEF {ver}".format(ver=ver["cef_version"])) print("[hello_world.py] Python {ver} {arch}".format( - ver=platform.python_version(), arch=platform.architecture()[0])) - assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this" + ver=platform.python_version(), + arch=platform.architecture()[0])) + assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this" if __name__ == '__main__': diff --git a/examples/screenshot.py b/examples/screenshot.py index 0f23b627..e99c2fe6 100644 --- a/examples/screenshot.py +++ b/examples/screenshot.py @@ -65,9 +65,13 @@ def main(): def check_versions(): - print("[screenshot.py] CEF Python {ver}".format(ver=cef.__version__)) + ver = cef.GetVersion() + print("[screenshot.py] CEF Python {ver}".format(ver=ver["version"])) + print("[screenshot.py] Chromium {ver}".format(ver=ver["chrome_version"])) + print("[screenshot.py] CEF {ver}".format(ver=ver["cef_version"])) print("[screenshot.py] Python {ver} {arch}".format( - ver=platform.python_version(), arch=platform.architecture()[0])) + ver=platform.python_version(), + arch=platform.architecture()[0])) print("[screenshot.py] Pillow {ver}".format(ver=PILLOW_VERSION)) assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this" diff --git a/examples/tutorial.py b/examples/tutorial.py index a4dbf49e..860bbe12 100644 --- a/examples/tutorial.py +++ b/examples/tutorial.py @@ -1,5 +1,5 @@ # Tutorial example. Doesn't depend on any third party GUI framework. -# Tested with CEF Python v56.2+ +# Tested with CEF Python v57.0+ from cefpython3 import cefpython as cef import base64 @@ -78,10 +78,14 @@ def main(): def check_versions(): - print("[tutorial.py] CEF Python {ver}".format(ver=cef.__version__)) + ver = cef.GetVersion() + print("[tutorial.py] CEF Python {ver}".format(ver=ver["version"])) + print("[tutorial.py] Chromium {ver}".format(ver=ver["chrome_version"])) + print("[tutorial.py] CEF {ver}".format(ver=ver["cef_version"])) print("[tutorial.py] Python {ver} {arch}".format( - ver=platform.python_version(), arch=platform.architecture()[0])) - assert cef.__version__ >= "56.2", "CEF Python v56.2+ required to run this" + ver=platform.python_version(), + arch=platform.architecture()[0])) + assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this" def html_to_data_uri(html, js_callback=None): From d6b0bca10d42685ab6a1fb4022fb652a75c9533f Mon Sep 17 00:00:00 2001 From: Jack-2025 Date: Sun, 18 Feb 2018 22:15:24 +0900 Subject: [PATCH 006/238] Adds Pyside guard --- examples/qt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/qt.py b/examples/qt.py index 261f4160..0c40a530 100644 --- a/examples/qt.py +++ b/examples/qt.py @@ -109,7 +109,8 @@ def __init__(self): # noinspection PyArgumentList super(MainWindow, self).__init__(None) # Avoids crash when shutting down CEF (issue #360) - self.setAttribute(Qt.WA_DeleteOnClose, True) + if PYSIDE: + self.setAttribute(Qt.WA_DeleteOnClose, True) self.cef_widget = None self.navigation_bar = None if PYQT4: From 3b5eb708c7814134ac2abc684b93fba58dca73ff Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 15:21:34 +0100 Subject: [PATCH 007/238] Update KB - Debugging using various chrome:// protocol uris --- README.md | 10 ++--- docs/Knowledge-Base.md | 83 +++++++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 5454d4eb..795de4bb 100644 --- a/README.md +++ b/README.md @@ -219,8 +219,8 @@ Additional information for v31.2 release: - [Tutorial](docs/Tutorial.md) -### API categories - +### API categories + #### Modules * [cefpython](api/cefpython.md#cefpython) module @@ -275,9 +275,9 @@ Additional information for v31.2 release: * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface - -### API index - + +### API index + * [Application settings](api/ApplicationSettings.md#application-settings) * [accept_language_list](api/ApplicationSettings.md#accept_language_list) * [app_user_model_id](api/ApplicationSettings.md#app_user_model_id) diff --git a/docs/Knowledge-Base.md b/docs/Knowledge-Base.md index 648523e6..3e7d6eaa 100644 --- a/docs/Knowledge-Base.md +++ b/docs/Knowledge-Base.md @@ -5,6 +5,8 @@ Table of contents: * [Notifications about new releases / commits](#notifications-about-new-releases--commits) * [Changes in API after CEF updates](#changes-in-api-after-cef-updates) * [Differences between Python 2 and Python 3](#differences-between-python-2-and-python-3) +* [How to enable debug information in examples?](#how-to-enable-debug-information-in-examples) +* [Debugging using various chrome:// protocol uris](#debugging-using-various-chrome-protocol-uris) * [A blank window on Mac/Linux](#a-blank-window-on-maclinux) * [Location of CEF framework in Mac apps](#location-of-cef-framework-in-mac-apps) * [Flash support](#flash-support) @@ -12,7 +14,6 @@ Table of contents: * [How to capture Audio and Video in HTML5?](#how-to-capture-audio-and-video-in-html5) * [Touch and multi-touch support](#touch-and-multi-touch-support) * [Black or white browser screen](#black-or-white-browser-screen) -* [How to enable debug information in examples?](#how-to-enable-debug-information-in-examples) * [Python crashes with "Segmentation fault" - how to debug?](#python-crashes-with-segmentation-fault---how-to-debug) * [Windows XP support](#windows-xp-support) * [Mac 32-bit support](#mac-32-bit-support) @@ -89,6 +90,61 @@ they are all unicode strings. Be aware of this when porting cefpython based apps to Python 3, as it may cause issues. +## How to enable debug information in examples? + +You can pass "--debug" command line flag to any of CEF Python +examples and unit tests. It will also work with your app, as +this feature is enabled in CEF Python's core. When this flag is +passed the following settings will be set: +```python +settings = { + "debug": True, + "log_severity": cef.LOGSEVERITY_INFO, + "log_file": "debug.log", +} +cef.Initialize(settings=settings) +``` + +Now you should see debug information displayed in console like this: +``` +[CEF Python] Initialize() called +[CEF Python] CefExecuteProcess(): exitCode = -1 +[CEF Python] CefInitialize() +[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess() +[CEF Python] Command line string for the browser process: ... +``` + + +## Debugging using various chrome:// protocol uris + +The `chrome://` protocol uris give you access to various debugging +tools. For example if you encounter GPU issues then after the issue +occured load the `chrome://gpu` to see a list of errors. + +Here is a list of supported `chrome://` protocol uris as of v55.2: +- chrome://accessibility +- chrome://appcache-internals +- chrome://blob-internals +- chrome://credits +- chrome://gpu +- chrome://histograms +- chrome://indexeddb-internals +- chrome://license +- chrome://media-internals +- chrome://net-export +- chrome://net-internals +- chrome://network-error +- chrome://network-errors +- chrome://resources +- chrome://serviceworker-internals +- chrome://system +- chrome://tracing +- chrome://version +- chrome://view-http-cache +- chrome://webrtc-internals +- chrome://webui-hosts + + ## A blank window on Mac/Linux A blank window might appear when your Python does not support @@ -214,31 +270,6 @@ appear even after disabling GPU hardware acceleration. This is normal because GPU was disabled so WebGL cannot work. -## How to enable debug information in examples? - -You can pass "--debug" command line flag to any of CEF Python -examples and unit tests. It will also work with your app, as -this feature is enabled in CEF Python's core. When this flag is -passed the following settings will be set: -```python -settings = { - "debug": True, - "log_severity": cef.LOGSEVERITY_INFO, - "log_file": "debug.log", -} -cef.Initialize(settings=settings) -``` - -Now you should see debug information displayed in console like this: -``` -[CEF Python] Initialize() called -[CEF Python] CefExecuteProcess(): exitCode = -1 -[CEF Python] CefInitialize() -[CEF Python] App_OnBeforeCommandLineProcessing_BrowserProcess() -[CEF Python] Command line string for the browser process: ... -``` - - ## Python crashes with "Segmentation fault" - how to debug? Install gdb: From b4e4d779ebf83019899a9bae504530a15bc11aa4 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 18 Feb 2018 15:38:11 +0100 Subject: [PATCH 008/238] Update README - support development contact details --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 795de4bb..25f04808 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ a comment about that when making a donation. It will give it a higher priority. If you are interested in sponsorship opportunities please contact Czarek -directly (linkedin profile or email). +directly - contact details are available in his [Resume](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view). ### Thanks @@ -219,8 +219,8 @@ Additional information for v31.2 release: - [Tutorial](docs/Tutorial.md) -### API categories - +### API categories + #### Modules * [cefpython](api/cefpython.md#cefpython) module @@ -275,9 +275,9 @@ Additional information for v31.2 release: * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface - -### API index - + +### API index + * [Application settings](api/ApplicationSettings.md#application-settings) * [accept_language_list](api/ApplicationSettings.md#accept_language_list) * [app_user_model_id](api/ApplicationSettings.md#app_user_model_id) From 61ffdf48194e1b7e74956e75c3552a808a319b72 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Mon, 19 Feb 2018 12:07:10 +0100 Subject: [PATCH 009/238] Update Knowledge-Base.md --- docs/Knowledge-Base.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/Knowledge-Base.md b/docs/Knowledge-Base.md index 3e7d6eaa..cf1deba5 100644 --- a/docs/Knowledge-Base.md +++ b/docs/Knowledge-Base.md @@ -68,19 +68,16 @@ To be notified on new commits subscribe to this [RSS/Atom feed](../../../commits ## Changes in API after CEF updates CEF Python depends on CEF and API breaks are inevitable when updating -to latest CEF. The [Migration Guide](Migration-guide.md) document which -is still under works, will list most notable breaking changes since -v31 release. Until it's done go to go to the [GitHub Releases](../../../releases) -page and check release notes for all the releases -that appeared between your old version and the new version. Look for -lists named "Changes in API that break backward compatibility" or -similar. +to latest CEF. The [Migration Guide](Migration-guide.md) document +lists most notable breaking changes for each release. Other changes +that do not backwards compatibility can be seen on [GitHub Releases](../../../releases) +pages. Due to unavoidable changes in API it is recommended for your setup scripts that use for example PIP to install the cefpython3 package, to hardcode the cefpython version string. If for example using PIP's requirements.txt file then list the cefpython3 package in the -following format: `cefpython3 == 31.2`. +following format if using cefpython v57.0: `cefpython3 == 57.0`. ## Differences between Python 2 and Python 3 From a6f8d3ede779e2e7d67aa2d8932f0826189be39c Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Mon, 19 Feb 2018 15:48:29 +0100 Subject: [PATCH 010/238] Update ApplicationSettings.md - multi_threaded_message_loop --- api/ApplicationSettings.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/ApplicationSettings.md b/api/ApplicationSettings.md index 209e6f79..8bebae68 100644 --- a/api/ApplicationSettings.md +++ b/api/ApplicationSettings.md @@ -319,6 +319,13 @@ thread. If false (0) than the [cefpython](cefpython.md).MessageLoopWork() function must be called from your application message loop. This option is only supported on Windows. +When this option is set to true, you don't call CEF message loop explicitilly +anymore. Also app's main thread is no more CEF's UI thread, thus many of API +calls will require using cef.[cefpython.md#posttask](PostTask) function to run +code on UI thread. You should also pay attention when reading API docs, as many +handlers/callbacks execute on specific threads, so when this option is On then +your app's code can start executing on different threads. + This option is not and cannot be supported on OS-X for architectural reasons. From c7553bc9014d79a7157e9a2a894d25458c66afd3 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Tue, 20 Feb 2018 14:16:50 +0100 Subject: [PATCH 011/238] Update README-Examples.md - pysdl2 example issue #324 --- examples/README-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index 8b50f1f8..e377b39c 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -45,7 +45,7 @@ workarounds. library (GTK 3). Currently broken on Mac ([#310](../../../issues/310)). - [pysdl2.py](pysdl2.py): off-screen rendering example for [PySDL2](https://github.com/marcusva/py-sdl2) library. Currently tested - only on Linux. + only on Linux ([#324](../../../issues/324)). - [pywin32.py](pywin32.py): example for [pywin32](https://github.com/mhammond/pywin32) library - [qt.py](qt.py): example for [PyQt4](https://wiki.python.org/moin/PyQt4), From 5dbd9d6553ccb3bcd2e091c03b1c60b3d6011dca Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 20 Feb 2018 19:59:54 +0100 Subject: [PATCH 012/238] Update pysdl2.py example - support for Windows, performance fixes --- examples/README-examples.md | 3 ++- examples/pysdl2.py | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index e377b39c..adae5ecd 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -45,7 +45,8 @@ workarounds. library (GTK 3). Currently broken on Mac ([#310](../../../issues/310)). - [pysdl2.py](pysdl2.py): off-screen rendering example for [PySDL2](https://github.com/marcusva/py-sdl2) library. Currently tested - only on Linux ([#324](../../../issues/324)). + and works fine on Linux and Windows. For Mac support and performance + tweaking see Issue [#324](../../../issues/324). - [pywin32.py](pywin32.py): example for [pywin32](https://github.com/mhammond/pywin32) library - [qt.py](qt.py): example for [PyQt4](https://wiki.python.org/moin/PyQt4), diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 2b7aa8cb..7753acab 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -7,17 +7,21 @@ Requires PySDL2 and SDL2 libraries. Tested configurations: +- Windows 7: SDL 2.0.7 and PySDL2 0.9.6 - Fedora 25: SDL2 2.0.5 with PySDL2 0.9.3 - Ubuntu 14.04: SDL2 with PySDL2 0.9.6 Install instructions: 1. Install SDL libraries for your OS, e.g: + - Windows: Download SDL2.dll from http://www.libsdl.org/download-2.0.php + and put SDL2.dll in C:\Python27\ (where you've installed Python) - Fedora: sudo dnf install SDL2 SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer - Ubuntu: sudo apt-get install libsdl2-dev 2. Install PySDL2 using pip package manager: pip install PySDL2 Missing functionality: +- Performance is still not perfect, see Issue #379 for further details - Keyboard modifiers that are not yet handled in this example: ctrl, marking text inputs with the shift key. - Mouse dragging @@ -69,10 +73,23 @@ def main(): browserHeight = height - headerHeight browserWidth = width # Mouse wheel fudge to enhance scrolling - scrollEnhance = 20 + scrollEnhance = 40 # Initialise CEF for offscreen rendering sys.excepthook = cef.ExceptHook - cef.Initialize(settings={"windowless_rendering_enabled": True}) + switches = { + # Tweaking OSR performance by setting the same Chromium flags + # as in upstream cefclient (Issue #240). + "disable-surfaces": "", + "disable-gpu": "", + "disable-gpu-compositing": "", + "enable-begin-frame-scheduling": "", + } + browser_settings = { + # Tweaking OSR performance (Issue #240) + "windowless_frame_rate": 100 + } + cef.Initialize(settings={"windowless_rendering_enabled": True}, + switches=switches) window_info = cef.WindowInfo() window_info.SetAsOffscreen(0) # Initialise SDL2 for video (add other init constants if you @@ -96,7 +113,9 @@ def main(): # Set-up the RenderHandler, passing in the SDL2 renderer renderHandler = RenderHandler(renderer, width, height - headerHeight) # Create the browser instance - browser = cef.CreateBrowserSync(window_info, url="https://www.google.com/") + browser = cef.CreateBrowserSync(window_info, + url="https://www.google.com/", + settings=browser_settings) browser.SetClientHandler(LoadHandler()) browser.SetClientHandler(renderHandler) # Must call WasResized at least once to let know CEF that From a68771c5e3cc6ff2cade8168b87dd9b22bacd4cf Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 20 Feb 2018 20:06:33 +0100 Subject: [PATCH 013/238] Fix typo --- examples/pysdl2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 7753acab..ecb060c1 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -21,7 +21,7 @@ pip install PySDL2 Missing functionality: -- Performance is still not perfect, see Issue #379 for further details +- Performance is still not perfect, see Issue #324 for further details - Keyboard modifiers that are not yet handled in this example: ctrl, marking text inputs with the shift key. - Mouse dragging From 3c8d36ed2e53d79c30907e345085b7c04718349d Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Tue, 20 Feb 2018 20:56:41 +0100 Subject: [PATCH 014/238] Update qt.py --- examples/qt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/qt.py b/examples/qt.py index 0c40a530..731ac2e0 100644 --- a/examples/qt.py +++ b/examples/qt.py @@ -11,7 +11,6 @@ # Issues with PySide 1.2: # - Mac: Keyboard focus issues when switching between controls (Issue #284) # - Mac: Mouse cursor never changes when hovering over links (Issue #311) -# - Windows/Mac: Sometimes process hangs when quitting app (Issue #360) from cefpython3 import cefpython as cef import ctypes From bbd70da9c552c44dab6a857663bec018e8d8aaeb Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Tue, 20 Feb 2018 21:44:47 +0000 Subject: [PATCH 015/238] Added frame rate limiting code --- examples/pysdl2.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index ecb060c1..68af6827 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -5,10 +5,10 @@ further down. Pull requests for the missing functionality are welcome. Requires PySDL2 and SDL2 libraries. - + Tested configurations: - Windows 7: SDL 2.0.7 and PySDL2 0.9.6 -- Fedora 25: SDL2 2.0.5 with PySDL2 0.9.3 +- Fedora 26: SDL2 2.0.7 with PySDL2 0.9.6 - Ubuntu 14.04: SDL2 with PySDL2 0.9.6 Install instructions: @@ -19,7 +19,7 @@ - Ubuntu: sudo apt-get install libsdl2-dev 2. Install PySDL2 using pip package manager: pip install PySDL2 - + Missing functionality: - Performance is still not perfect, see Issue #324 for further details - Keyboard modifiers that are not yet handled in this example: @@ -74,6 +74,8 @@ def main(): browserWidth = width # Mouse wheel fudge to enhance scrolling scrollEnhance = 40 + # desired frame rate + frameRate = 60 # Initialise CEF for offscreen rendering sys.excepthook = cef.ExceptHook switches = { @@ -124,7 +126,12 @@ def main(): browser.WasResized() # Begin the main rendering loop running = True + # FPS debug variables + #frames = 0 + #lastFrameTick = sdl2.timer.SDL_GetTicks() while running: + # record when we started drawing this frame + startTime = sdl2.timer.SDL_GetTicks() # Convert SDL2 events into CEF events (where appropriate) events = sdl2.ext.get_events() for event in events: @@ -269,6 +276,17 @@ def main(): sdl2.SDL_Rect(0, headerHeight, browserWidth, browserHeight) ) sdl2.SDL_RenderPresent(renderer) + + # FPS debug code - left here for reference + #frames += 1 + #currentTick = sdl2.timer.SDL_GetTicks() + #if currentTick - lastFrameTick > 1000: + # lastFrameTick = sdl2.timer.SDL_GetTicks() + # print("FPS %d" % (frames / (currentTick / 1000.0))) + + # regulate frame rate + if sdl2.timer.SDL_GetTicks() - startTime < 1000.0 / frameRate: + sdl2.timer.SDL_Delay((1000 / frameRate) - (sdl2.timer.SDL_GetTicks() - startTime)) # User exited exit_app() @@ -298,11 +316,11 @@ def get_key_code(key): class LoadHandler(object): """Simple handler for loading URLs.""" - + def OnLoadingStateChange(self, is_loading, **_): if not is_loading: print("[pysdl2.py] Page loading complete") - + def OnLoadError(self, frame, failed_url, **_): if not frame.IsMain(): return @@ -313,7 +331,7 @@ class RenderHandler(object): """ Handler for rendering web pages to the screen via SDL2. - + The object's texture property is exposed to allow the main rendering loop to access the SDL2 texture. @@ -324,11 +342,11 @@ def __init__(self, renderer, width, height): self.__height = height self.__renderer = renderer self.texture = None - + def GetViewRect(self, rect_out, **_): rect_out.extend([0, 0, self.__width, self.__height]) return True - + def OnPaint(self, element_type, paint_buffer, **_): """ Using the pixel data from CEF's offscreen rendering @@ -380,7 +398,7 @@ def OnPaint(self, element_type, paint_buffer, **_): else: print("[pysdl2.py] ERROR: Unsupported mode: %s" % mode) exit_app() - + pxbuf = image.tobytes() # Create surface surface = sdl2.SDL_CreateRGBSurfaceFrom( From ee9ee709bb1af2dc8eb63853788bde22917abbe9 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Tue, 20 Feb 2018 23:38:48 +0000 Subject: [PATCH 016/238] Tied up SDL and cef frame rates. Also added argparse and logging modules to handle console messages --- examples/pysdl2.py | 67 ++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 68af6827..7e3e7603 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -36,33 +36,43 @@ https://github.com/neilmunday/pes/blob/master/lib/pes/ui.py """ +import argparse +import logging import sys + +def die(msg): + """ + Helper function to exit application on failed imports etc. + """ + sys.stderr.write("%s\n" % msg) + sys.exit(1) + try: # noinspection PyUnresolvedReferences from cefpython3 import cefpython as cef except ImportError: - print("ERROR: cefpython3 package not found") - print("To install type: `pip install cefpython3`") - sys.exit(1) + die("ERROR: cefpython3 package not found\nTo install type: `pip install cefpython3`") try: # noinspection PyUnresolvedReferences import sdl2 # noinspection PyUnresolvedReferences import sdl2.ext except ImportError: - print("ERROR: SDL2 package not found") - print("To install type: `pip install PySDL2`") - sys.exit(1) + die("ERROR: SDL2 package not found\nTo install type: `pip install PySDL2`") try: # noinspection PyUnresolvedReferences from PIL import Image except ImportError: - print("ERROR: PIL package not found") - print("To install type: pip install Pillow") - sys.exit(1) - + die("ERROR: PIL package not found\nTo install type: pip install Pillow") def main(): + parser = argparse.ArgumentParser(description='PySDL2 / cefpython example', add_help=True) + parser.add_argument('-v', '--verbose', help='Turn on debug info', dest='verbose', action='store_true') + args = parser.parse_args() + logLevel = logging.INFO + if args.verbose: + logLevel = logging.DEBUG + logging.basicConfig(format='[%(filename)s %(levelname)s]: %(message)s', level=logLevel) # The following variables control the dimensions of the window # and browser display area width = 800 @@ -75,7 +85,7 @@ def main(): # Mouse wheel fudge to enhance scrolling scrollEnhance = 40 # desired frame rate - frameRate = 60 + frameRate = 100 # Initialise CEF for offscreen rendering sys.excepthook = cef.ExceptHook switches = { @@ -88,16 +98,18 @@ def main(): } browser_settings = { # Tweaking OSR performance (Issue #240) - "windowless_frame_rate": 100 + "windowless_frame_rate": frameRate } cef.Initialize(settings={"windowless_rendering_enabled": True}, switches=switches) + logging.debug("cef initialised") window_info = cef.WindowInfo() window_info.SetAsOffscreen(0) # Initialise SDL2 for video (add other init constants if you # require other SDL2 functionality e.g. mixer, # TTF, joystick etc. sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) + logging.debug("SDL2 initialised") # Create the window window = sdl2.video.SDL_CreateWindow( 'cefpython3 SDL2 Demo', @@ -127,8 +139,10 @@ def main(): # Begin the main rendering loop running = True # FPS debug variables - #frames = 0 - #lastFrameTick = sdl2.timer.SDL_GetTicks() + if logLevel == logging.DEBUG: + frames = 0 + lastFrameTick = sdl2.timer.SDL_GetTicks() + logging.debug("beginning rendering loop") while running: # record when we started drawing this frame startTime = sdl2.timer.SDL_GetTicks() @@ -277,12 +291,13 @@ def main(): ) sdl2.SDL_RenderPresent(renderer) - # FPS debug code - left here for reference - #frames += 1 - #currentTick = sdl2.timer.SDL_GetTicks() - #if currentTick - lastFrameTick > 1000: - # lastFrameTick = sdl2.timer.SDL_GetTicks() - # print("FPS %d" % (frames / (currentTick / 1000.0))) + # FPS debug code + if logLevel == logging.DEBUG: + frames += 1 + currentTick = sdl2.timer.SDL_GetTicks() + if currentTick - lastFrameTick > 1000: + lastFrameTick = sdl2.timer.SDL_GetTicks() + logging.debug("FPS %d" % (frames / (currentTick / 1000.0))) # regulate frame rate if sdl2.timer.SDL_GetTicks() - startTime < 1000.0 / frameRate: @@ -307,7 +322,7 @@ def get_key_code(key): if key in key_map: return key_map[key] # Key not mapped, raise exception - print("[pysdl2.py] Keyboard mapping incomplete:" + logging.error("Keyboard mapping incomplete:" " unsupported SDL key %d." " See https://wiki.libsdl.org/SDLKeycodeLookup for mapping." % key) @@ -319,12 +334,12 @@ class LoadHandler(object): def OnLoadingStateChange(self, is_loading, **_): if not is_loading: - print("[pysdl2.py] Page loading complete") + logging.info("Page loading complete") def OnLoadError(self, frame, failed_url, **_): if not frame.IsMain(): return - print("[pysdl2.py] Failed to load %s" % failed_url) + logging.error("Failed to load %s" % failed_url) class RenderHandler(object): @@ -396,7 +411,7 @@ def OnPaint(self, element_type, paint_buffer, **_): depth = 32 pitch = self.__width * 4 else: - print("[pysdl2.py] ERROR: Unsupported mode: %s" % mode) + logging.error("ERROR: Unsupported mode: %s" % mode) exit_app() pxbuf = image.tobytes() @@ -421,14 +436,14 @@ def OnPaint(self, element_type, paint_buffer, **_): # Free the surface sdl2.SDL_FreeSurface(surface) else: - print("[pysdl2.py] WARNING: Unsupport element_type in OnPaint") + logging.warning("Unsupport element_type in OnPaint") def exit_app(): """Tidy up SDL2 and CEF before exiting.""" sdl2.SDL_Quit() cef.Shutdown() - print("[pysdl2.py] Exited gracefully") + logging.info("Exited gracefully") if __name__ == "__main__": From 8f2298320a75feb0f630268f1e0ff3ec0af45c14 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Tue, 20 Feb 2018 23:38:48 +0000 Subject: [PATCH 017/238] Tidied up SDL and cef frame rates. Also added argparse and logging modules to handle console messages --- examples/pysdl2.py | 67 ++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 68af6827..7e3e7603 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -36,33 +36,43 @@ https://github.com/neilmunday/pes/blob/master/lib/pes/ui.py """ +import argparse +import logging import sys + +def die(msg): + """ + Helper function to exit application on failed imports etc. + """ + sys.stderr.write("%s\n" % msg) + sys.exit(1) + try: # noinspection PyUnresolvedReferences from cefpython3 import cefpython as cef except ImportError: - print("ERROR: cefpython3 package not found") - print("To install type: `pip install cefpython3`") - sys.exit(1) + die("ERROR: cefpython3 package not found\nTo install type: `pip install cefpython3`") try: # noinspection PyUnresolvedReferences import sdl2 # noinspection PyUnresolvedReferences import sdl2.ext except ImportError: - print("ERROR: SDL2 package not found") - print("To install type: `pip install PySDL2`") - sys.exit(1) + die("ERROR: SDL2 package not found\nTo install type: `pip install PySDL2`") try: # noinspection PyUnresolvedReferences from PIL import Image except ImportError: - print("ERROR: PIL package not found") - print("To install type: pip install Pillow") - sys.exit(1) - + die("ERROR: PIL package not found\nTo install type: pip install Pillow") def main(): + parser = argparse.ArgumentParser(description='PySDL2 / cefpython example', add_help=True) + parser.add_argument('-v', '--verbose', help='Turn on debug info', dest='verbose', action='store_true') + args = parser.parse_args() + logLevel = logging.INFO + if args.verbose: + logLevel = logging.DEBUG + logging.basicConfig(format='[%(filename)s %(levelname)s]: %(message)s', level=logLevel) # The following variables control the dimensions of the window # and browser display area width = 800 @@ -75,7 +85,7 @@ def main(): # Mouse wheel fudge to enhance scrolling scrollEnhance = 40 # desired frame rate - frameRate = 60 + frameRate = 100 # Initialise CEF for offscreen rendering sys.excepthook = cef.ExceptHook switches = { @@ -88,16 +98,18 @@ def main(): } browser_settings = { # Tweaking OSR performance (Issue #240) - "windowless_frame_rate": 100 + "windowless_frame_rate": frameRate } cef.Initialize(settings={"windowless_rendering_enabled": True}, switches=switches) + logging.debug("cef initialised") window_info = cef.WindowInfo() window_info.SetAsOffscreen(0) # Initialise SDL2 for video (add other init constants if you # require other SDL2 functionality e.g. mixer, # TTF, joystick etc. sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) + logging.debug("SDL2 initialised") # Create the window window = sdl2.video.SDL_CreateWindow( 'cefpython3 SDL2 Demo', @@ -127,8 +139,10 @@ def main(): # Begin the main rendering loop running = True # FPS debug variables - #frames = 0 - #lastFrameTick = sdl2.timer.SDL_GetTicks() + if logLevel == logging.DEBUG: + frames = 0 + lastFrameTick = sdl2.timer.SDL_GetTicks() + logging.debug("beginning rendering loop") while running: # record when we started drawing this frame startTime = sdl2.timer.SDL_GetTicks() @@ -277,12 +291,13 @@ def main(): ) sdl2.SDL_RenderPresent(renderer) - # FPS debug code - left here for reference - #frames += 1 - #currentTick = sdl2.timer.SDL_GetTicks() - #if currentTick - lastFrameTick > 1000: - # lastFrameTick = sdl2.timer.SDL_GetTicks() - # print("FPS %d" % (frames / (currentTick / 1000.0))) + # FPS debug code + if logLevel == logging.DEBUG: + frames += 1 + currentTick = sdl2.timer.SDL_GetTicks() + if currentTick - lastFrameTick > 1000: + lastFrameTick = sdl2.timer.SDL_GetTicks() + logging.debug("FPS %d" % (frames / (currentTick / 1000.0))) # regulate frame rate if sdl2.timer.SDL_GetTicks() - startTime < 1000.0 / frameRate: @@ -307,7 +322,7 @@ def get_key_code(key): if key in key_map: return key_map[key] # Key not mapped, raise exception - print("[pysdl2.py] Keyboard mapping incomplete:" + logging.error("Keyboard mapping incomplete:" " unsupported SDL key %d." " See https://wiki.libsdl.org/SDLKeycodeLookup for mapping." % key) @@ -319,12 +334,12 @@ class LoadHandler(object): def OnLoadingStateChange(self, is_loading, **_): if not is_loading: - print("[pysdl2.py] Page loading complete") + logging.info("Page loading complete") def OnLoadError(self, frame, failed_url, **_): if not frame.IsMain(): return - print("[pysdl2.py] Failed to load %s" % failed_url) + logging.error("Failed to load %s" % failed_url) class RenderHandler(object): @@ -396,7 +411,7 @@ def OnPaint(self, element_type, paint_buffer, **_): depth = 32 pitch = self.__width * 4 else: - print("[pysdl2.py] ERROR: Unsupported mode: %s" % mode) + logging.error("ERROR: Unsupported mode: %s" % mode) exit_app() pxbuf = image.tobytes() @@ -421,14 +436,14 @@ def OnPaint(self, element_type, paint_buffer, **_): # Free the surface sdl2.SDL_FreeSurface(surface) else: - print("[pysdl2.py] WARNING: Unsupport element_type in OnPaint") + logging.warning("Unsupport element_type in OnPaint") def exit_app(): """Tidy up SDL2 and CEF before exiting.""" sdl2.SDL_Quit() cef.Shutdown() - print("[pysdl2.py] Exited gracefully") + logging.info("Exited gracefully") if __name__ == "__main__": From f0d7816ca3f3f6054ca1abb3b0399f7c957cdf2a Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Tue, 20 Feb 2018 23:42:05 +0000 Subject: [PATCH 018/238] Added usage info --- examples/pysdl2.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 7e3e7603..267bdc67 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -6,6 +6,13 @@ Requires PySDL2 and SDL2 libraries. +Usage: + + python pysdl2.py [-v] [-h] + + -v turn on debug messages + -h display help info + Tested configurations: - Windows 7: SDL 2.0.7 and PySDL2 0.9.6 - Fedora 26: SDL2 2.0.7 with PySDL2 0.9.6 From 0df88177d813f70fbf6a8845da6df408ea27eeb2 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 21 Feb 2018 21:58:28 +0100 Subject: [PATCH 019/238] Update README-Examples.md - more examples to come --- examples/README-examples.md | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index adae5ecd..0f49dabf 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -3,7 +3,8 @@ Table of contents: * [Hello World!](#hello-world) * [Supported examples](#supported-examples) -* [More examples](#more-examples) +* [Other examples](#other-examples) +* [More examples to come](#more-examples-to-come) ## Hello World! @@ -71,10 +72,11 @@ There are also available unit tests and its usage of the API can be of some use. See [main_test.py](../unittests/main_test.py). -## More examples +## Other examples -There are even more examples available, some of them are externally -maintained. +There are even more examples available, they do not reside in the examples/ +directory. Some of them were created for old verions of CEF and were not +yet ported to latest CEF. Some of them are externally maintained. - Kivy framework: see [Kivy](https://github.com/cztomczak/cefpython/wiki/Kivy) wiki page. @@ -90,5 +92,36 @@ maintained. - Example of using Python network library (urllib3/openssl) instead of Chromium's network library - see [gist by Massimiliano Dal Cero](https://gist.github.com/yattamax/0252a3c5dc54a2f81650d5c0eafabf99) -There are ongoing efforts to add these examples to the official examples/ -directory, see issues in the tracker. +## More examples to come + +Here is a list of issues in the tracker to implement new examples: + +- [Issue #323](../../../issues/323) - "Create cocos2d example" +- [Issue #322](../../../issues/322) - "Create pyglet example" +- [Issue #312](../../../issues/312) - "Easy to use CefBrowser widgets + for many popular GUI toolkits" +- [Issue #301](../../../issues/301) - "Fix cefpython3.wx package to work + with latest v55+" +- [Issue #289](../../../issues/289) - "Pygame / PyOpenGL example" +- [Issue #288](../../../issues/288) - "Create panda3d_.py example" +- [Issue #285](../../../issues/285) - "[kivy_.py] Refactor example, make + it work cross-platform and move it + to examples/" +- [Issue #252](../../../issues/252) - "Use CEF views in Hello World, Tutorial + and Offscreen examples, and in Unit + tests" +- [Issue #224](../../../issues/224) - "Port CEF 1 examples to CEF 3" +- [Issue #109](../../../issues/109) - "The ResourceHandler example" + +Packaging examples: + +- [Issue #407](../../../issues/407) - "Example of packaging app using + Cython compiler" +- [Issue #396](../../../issues/396) - "Example of packaging app using + Nuitka compiler" +- [Issue #338](../../../issues/338) - "Example of packaging app using + cx_Freeze" +- [Issue #337](../../../issues/337) - "Example of packaging app using + py2app" +- [Issue #135](../../../issues/135) - "Example of packaging app using + pyinstaller" \ No newline at end of file From 5119d9d0b03774147299dc71a1dbd04aa33d5671 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 21 Feb 2018 22:01:32 +0100 Subject: [PATCH 020/238] Update README-Examples.md --- examples/README-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index 0f49dabf..65c73116 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -94,7 +94,7 @@ yet ported to latest CEF. Some of them are externally maintained. ## More examples to come -Here is a list of issues in the tracker to implement new examples: +Here is a list of issues in the tracker to create or upgrade examples: - [Issue #323](../../../issues/323) - "Create cocos2d example" - [Issue #322](../../../issues/322) - "Create pyglet example" From c46055d120b0b1e9adbf19bda04b1692ef7f1e76 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Thu, 22 Feb 2018 21:39:18 +0000 Subject: [PATCH 021/238] Fixed: PEP8 conformance, FPS counter and added PySDL2 and SDL2 version info. --- examples/pysdl2.py | 66 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 267bdc67..ba427399 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -47,6 +47,7 @@ import logging import sys + def die(msg): """ Helper function to exit application on failed imports etc. @@ -54,11 +55,13 @@ def die(msg): sys.stderr.write("%s\n" % msg) sys.exit(1) + try: # noinspection PyUnresolvedReferences from cefpython3 import cefpython as cef except ImportError: - die("ERROR: cefpython3 package not found\nTo install type: `pip install cefpython3`") + die("""ERROR: cefpython3 package not found\n + To install type: `pip install cefpython3`""") try: # noinspection PyUnresolvedReferences import sdl2 @@ -72,14 +75,33 @@ def die(msg): except ImportError: die("ERROR: PIL package not found\nTo install type: pip install Pillow") + def main(): - parser = argparse.ArgumentParser(description='PySDL2 / cefpython example', add_help=True) - parser.add_argument('-v', '--verbose', help='Turn on debug info', dest='verbose', action='store_true') + parser = argparse.ArgumentParser( + description='PySDL2 / cefpython example', + add_help=True + ) + parser.add_argument( + '-v', + '--verbose', + help='Turn on debug info', + dest='verbose', + action='store_true' + ) args = parser.parse_args() logLevel = logging.INFO if args.verbose: logLevel = logging.DEBUG - logging.basicConfig(format='[%(filename)s %(levelname)s]: %(message)s', level=logLevel) + logging.basicConfig( + format='[%(filename)s %(levelname)s]: %(message)s', + level=logLevel + ) + logging.info("Using PySDL2 %s" % sdl2.__version__) + version = sdl2.SDL_version() + sdl2.SDL_GetVersion(version) + logging.info( + "Using SDL2 %s.%s.%s" % (version.major, version.minor, version.patch) + ) # The following variables control the dimensions of the window # and browser display area width = 800 @@ -146,13 +168,16 @@ def main(): # Begin the main rendering loop running = True # FPS debug variables - if logLevel == logging.DEBUG: - frames = 0 - lastFrameTick = sdl2.timer.SDL_GetTicks() + frames = 0 logging.debug("beginning rendering loop") + resetFpsTime = True + fpsTime = 0 while running: # record when we started drawing this frame startTime = sdl2.timer.SDL_GetTicks() + if resetFpsTime: + fpsTime = sdl2.timer.SDL_GetTicks() + resetFpsTime = False # Convert SDL2 events into CEF events (where appropriate) events = sdl2.ext.get_events() for event in events: @@ -297,18 +322,17 @@ def main(): sdl2.SDL_Rect(0, headerHeight, browserWidth, browserHeight) ) sdl2.SDL_RenderPresent(renderer) - # FPS debug code - if logLevel == logging.DEBUG: - frames += 1 - currentTick = sdl2.timer.SDL_GetTicks() - if currentTick - lastFrameTick > 1000: - lastFrameTick = sdl2.timer.SDL_GetTicks() - logging.debug("FPS %d" % (frames / (currentTick / 1000.0))) - + frames += 1 + if sdl2.timer.SDL_GetTicks() - fpsTime > 1000: + logging.debug("FPS: %d" % frames) + frames = 0 + resetFpsTime = True # regulate frame rate if sdl2.timer.SDL_GetTicks() - startTime < 1000.0 / frameRate: - sdl2.timer.SDL_Delay((1000 / frameRate) - (sdl2.timer.SDL_GetTicks() - startTime)) + sdl2.timer.SDL_Delay( + (1000 / frameRate) - (sdl2.timer.SDL_GetTicks() - startTime) + ) # User exited exit_app() @@ -329,10 +353,12 @@ def get_key_code(key): if key in key_map: return key_map[key] # Key not mapped, raise exception - logging.error("Keyboard mapping incomplete:" - " unsupported SDL key %d." - " See https://wiki.libsdl.org/SDLKeycodeLookup for mapping." - % key) + logging.error( + """ + Keyboard mapping incomplete: unsupported SDL key %d. + See https://wiki.libsdl.org/SDLKeycodeLookup for mapping. + """ % key + ) return None From 40e37b27d0ffb3436302bb12992f7ccf5525b64d Mon Sep 17 00:00:00 2001 From: cztomczak Date: Fri, 23 Feb 2018 09:21:03 +0100 Subject: [PATCH 022/238] Update pysdl2.py - initial support for Mac --- examples/README-examples.md | 6 +++--- examples/pysdl2.py | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index 65c73116..f4000121 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -45,9 +45,9 @@ workarounds. - [gtk3.py](gtk3.py): example for [PyGObject / PyGI](https://wiki.gnome.org/Projects/PyGObject) library (GTK 3). Currently broken on Mac ([#310](../../../issues/310)). - [pysdl2.py](pysdl2.py): off-screen rendering example for - [PySDL2](https://github.com/marcusva/py-sdl2) library. Currently tested - and works fine on Linux and Windows. For Mac support and performance - tweaking see Issue [#324](../../../issues/324). + [PySDL2](https://github.com/marcusva/py-sdl2) library. There are issues + when running on slow machine - key events are being lost (noticed on Mac). + Example has some issues that are reported in Issue [#324](../../../issues/324). - [pywin32.py](pywin32.py): example for [pywin32](https://github.com/mhammond/pywin32) library - [qt.py](qt.py): example for [PyQt4](https://wiki.python.org/moin/PyQt4), diff --git a/examples/pysdl2.py b/examples/pysdl2.py index ba427399..f15a84b9 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -15,6 +15,7 @@ Tested configurations: - Windows 7: SDL 2.0.7 and PySDL2 0.9.6 +- Mac 10.9: SDL 2.0.7 and PySDL2 0.9.6 - Fedora 26: SDL2 2.0.7 with PySDL2 0.9.6 - Ubuntu 14.04: SDL2 with PySDL2 0.9.6 @@ -22,6 +23,8 @@ 1. Install SDL libraries for your OS, e.g: - Windows: Download SDL2.dll from http://www.libsdl.org/download-2.0.php and put SDL2.dll in C:\Python27\ (where you've installed Python) + - Mac: Install Homebrew from https://brew.sh/ + and then type "brew install sdl2" - Fedora: sudo dnf install SDL2 SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer - Ubuntu: sudo apt-get install libsdl2-dev 2. Install PySDL2 using pip package manager: @@ -60,20 +63,32 @@ def die(msg): # noinspection PyUnresolvedReferences from cefpython3 import cefpython as cef except ImportError: - die("""ERROR: cefpython3 package not found\n - To install type: `pip install cefpython3`""") + die("ERROR: cefpython3 package not found\n" + " To install type: pip install cefpython3") + try: # noinspection PyUnresolvedReferences import sdl2 # noinspection PyUnresolvedReferences import sdl2.ext -except ImportError: - die("ERROR: SDL2 package not found\nTo install type: `pip install PySDL2`") +except ImportError as exc: + excstr = repr(exc) + if "No module named sdl2" in excstr: + die("ERROR: PySDL2 package not found\n" + " To install type: pip install PySDL2") + elif ("could not find any library for SDL2" + " (PYSDL2_DLL_PATH: unset)" in excstr): + die("ERROR: SDL2 package not found.\n" + " See install instructions in top comment in sources.") + else: + die(excstr) + try: # noinspection PyUnresolvedReferences from PIL import Image except ImportError: - die("ERROR: PIL package not found\nTo install type: pip install Pillow") + die("ERROR: PIL package not found\n" + " To install type: pip install Pillow") def main(): From 64532e76fc3087e0f0a07772416b6195d839a9b5 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 23 Feb 2018 09:44:52 +0100 Subject: [PATCH 023/238] Update pysdl2.py - known issues on Mac --- examples/pysdl2.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index f15a84b9..0ece5e12 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -1,10 +1,11 @@ """ Example of embedding CEF browser using PySDL2 library. -This example is incomplete, see "Missing functionality" section -further down. Pull requests for the missing functionality are welcome. +Requires PySDL2 and SDL2 libraries, see install instructions further +down. -Requires PySDL2 and SDL2 libraries. +This example is incomplete and has some issues, see the "Known issues" +section further down. Pull requests with fixes are welcome. Usage: @@ -30,11 +31,14 @@ 2. Install PySDL2 using pip package manager: pip install PySDL2 -Missing functionality: +Known issues (pull requests are welcome): +- There are issues when running on slow machine - key events are being + lost (noticed on Mac only), see Issue #324 for more details - Performance is still not perfect, see Issue #324 for further details - Keyboard modifiers that are not yet handled in this example: ctrl, marking text inputs with the shift key. -- Mouse dragging +- Backspace key doesn't work on Mac +- Dragging with mouse not implemented - Window size is fixed, cannot be resized GUI controls: From 04f5eb93f2b2e0e8c31371467a3584faed7f8d98 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 23 Feb 2018 09:49:40 +0100 Subject: [PATCH 024/238] Update README-examples.md --- examples/README-examples.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index f4000121..8517e4ef 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -45,9 +45,8 @@ workarounds. - [gtk3.py](gtk3.py): example for [PyGObject / PyGI](https://wiki.gnome.org/Projects/PyGObject) library (GTK 3). Currently broken on Mac ([#310](../../../issues/310)). - [pysdl2.py](pysdl2.py): off-screen rendering example for - [PySDL2](https://github.com/marcusva/py-sdl2) library. There are issues - when running on slow machine - key events are being lost (noticed on Mac). - Example has some issues that are reported in Issue [#324](../../../issues/324). + [PySDL2](https://github.com/marcusva/py-sdl2) library. Example has some + issues that are reported in Issue [#324](../../../issues/324). - [pywin32.py](pywin32.py): example for [pywin32](https://github.com/mhammond/pywin32) library - [qt.py](qt.py): example for [PyQt4](https://wiki.python.org/moin/PyQt4), @@ -124,4 +123,4 @@ Packaging examples: - [Issue #337](../../../issues/337) - "Example of packaging app using py2app" - [Issue #135](../../../issues/135) - "Example of packaging app using - pyinstaller" \ No newline at end of file + pyinstaller" From beebbbed9467d8470e54441844a86d0945ad0771 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Sun, 25 Feb 2018 11:34:04 +0000 Subject: [PATCH 025/238] Added debug statements for key presses --- examples/pysdl2.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 0ece5e12..231a2866 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -257,6 +257,7 @@ def main(): "unmodified_character": keycode, "modifiers": cef.EVENTFLAG_NONE } + logging.debug("sending browser keyevent \"char\": %s" % event.text.text) browser.SendKeyEvent(key_event) key_event = { "type": cef.KEYEVENT_KEYUP, @@ -265,6 +266,7 @@ def main(): "unmodified_character": keycode, "modifiers": cef.EVENTFLAG_NONE } + logging.debug("sending browser key event \"up\": %s" % event.text.text) browser.SendKeyEvent(key_event) elif event.type == sdl2.SDL_KEYDOWN: # Handle key down events for non-text keys From 9b6b157713b5f48e0f5a340b4ddd59dc55d0c252 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Sun, 25 Feb 2018 21:32:13 +0000 Subject: [PATCH 026/238] Added debugging to all SDL2 events --- examples/pysdl2.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 231a2866..8da17bcc 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -204,10 +204,14 @@ def main(): or (event.type == sdl2.SDL_KEYDOWN and event.key.keysym.sym == sdl2.SDLK_ESCAPE)): running = False + logging.debug("SDL2 QUIT event") break if event.type == sdl2.SDL_MOUSEBUTTONDOWN: if event.button.button == sdl2.SDL_BUTTON_LEFT: if event.button.y > headerHeight: + logging.debug( + "SDL2 MOUSEBUTTONDOWN event (left button)" + ) # Mouse click triggered in browser region browser.SendMouseClickEvent( event.button.x, @@ -219,6 +223,7 @@ def main(): elif event.type == sdl2.SDL_MOUSEBUTTONUP: if event.button.button == sdl2.SDL_BUTTON_LEFT: if event.button.y > headerHeight: + logging.debug("SDL2 MOUSEBUTTONUP event (left button)") # Mouse click triggered in browser region browser.SendMouseClickEvent( event.button.x, @@ -234,6 +239,7 @@ def main(): event.motion.y - headerHeight, False) elif event.type == sdl2.SDL_MOUSEWHEEL: + logging.debug("SDL2 MOUSEWHEEL event") # Mouse wheel event x = event.wheel.x if x < 0: @@ -249,6 +255,7 @@ def main(): elif event.type == sdl2.SDL_TEXTINPUT: # Handle text events to get actual characters typed rather # than the key pressed. + logging.debug("SDL2 TEXTINPUT event: %s" % event.text.text) keycode = ord(event.text.text) key_event = { "type": cef.KEYEVENT_CHAR, @@ -257,7 +264,6 @@ def main(): "unmodified_character": keycode, "modifiers": cef.EVENTFLAG_NONE } - logging.debug("sending browser keyevent \"char\": %s" % event.text.text) browser.SendKeyEvent(key_event) key_event = { "type": cef.KEYEVENT_KEYUP, @@ -266,10 +272,10 @@ def main(): "unmodified_character": keycode, "modifiers": cef.EVENTFLAG_NONE } - logging.debug("sending browser key event \"up\": %s" % event.text.text) browser.SendKeyEvent(key_event) elif event.type == sdl2.SDL_KEYDOWN: # Handle key down events for non-text keys + logging.debug("SDL2 KEYDOWN event") if event.key.keysym.sym == sdl2.SDLK_RETURN: keycode = event.key.keysym.sym key_event = { @@ -302,6 +308,7 @@ def main(): browser.SendKeyEvent(key_event) elif event.type == sdl2.SDL_KEYUP: # Handle key up events for non-text keys + logging.debug("SDL2 KEYUP event") if event.key.keysym.sym in [ sdl2.SDLK_RETURN, sdl2.SDLK_BACKSPACE, From 9b0a8b0921c3b6b2d6d8b82fcf90c0bfa2240d38 Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Wed, 28 Feb 2018 23:50:28 +0000 Subject: [PATCH 027/238] Added ability for the user to select from hardware or software renderering --- examples/pysdl2.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 8da17bcc..2863aaa8 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -9,9 +9,10 @@ Usage: - python pysdl2.py [-v] [-h] + python pysdl2.py [-v] [-h] [-r {software|hardware}] -v turn on debug messages + -r specify hardware or software (default) rendering -h display help info Tested configurations: @@ -107,6 +108,14 @@ def main(): dest='verbose', action='store_true' ) + parser.add_argument( + '-r', + '--renderer', + help='Specify hardware or software rendering', + default='software', + dest='renderer', + choices=['software', 'hardware'] + ) args = parser.parse_args() logLevel = logging.INFO if args.verbose: @@ -169,9 +178,23 @@ def main(): ) # Define default background colour (black in this case) backgroundColour = sdl2.SDL_Color(0, 0, 0) - # Create the renderer using hardware acceleration - renderer = sdl2.SDL_CreateRenderer(window, -1, - sdl2.render.SDL_RENDERER_ACCELERATED) + renderer = None + if args.renderer == 'hardware': + # Create the renderer using hardware acceleration + logging.info("Using hardware rendering") + renderer = sdl2.SDL_CreateRenderer( + window, + -1, + sdl2.render.SDL_RENDERER_ACCELERATED + ) + else: + # Create the renderer using software acceleration + logging.info("Using software rendering") + renderer = sdl2.SDL_CreateRenderer( + window, + -1, + sdl2.render.SDL_RENDERER_SOFTWARE + ) # Set-up the RenderHandler, passing in the SDL2 renderer renderHandler = RenderHandler(renderer, width, height - headerHeight) # Create the browser instance From da50a9294abffe3e74c4c0651018ae5f597c66ce Mon Sep 17 00:00:00 2001 From: Neil Munday Date: Sat, 3 Mar 2018 09:16:28 +0000 Subject: [PATCH 028/238] Changed default renderer to hardware --- examples/pysdl2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/pysdl2.py b/examples/pysdl2.py index 2863aaa8..74bc5423 100644 --- a/examples/pysdl2.py +++ b/examples/pysdl2.py @@ -12,7 +12,7 @@ python pysdl2.py [-v] [-h] [-r {software|hardware}] -v turn on debug messages - -r specify hardware or software (default) rendering + -r specify hardware (default) or software rendering -h display help info Tested configurations: @@ -112,7 +112,7 @@ def main(): '-r', '--renderer', help='Specify hardware or software rendering', - default='software', + default='hardware', dest='renderer', choices=['software', 'hardware'] ) From 836f88ddeb60932990dd91418b72a9b24eb67fb0 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 9 Mar 2018 10:10:36 +0100 Subject: [PATCH 029/238] Update README - Sponsors section --- README.md | 62 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 25f04808..d2873954 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Table of contents: * [Introduction](#introduction) -* [Major sponsors](#major-sponsors) +* [Sponsors](#Sponsors) * [Funding for v64.0 release](#funding-for-v640-release) * [Install](#install) * [Tutorial](#tutorial) @@ -39,32 +39,48 @@ applications. You can use it for web scraping or as a web crawler, or other kind of internet bots. -## Major sponsors - - - - -
- - - - -
- - - - -
- - - - -
-
+## Sponsors + + + + + + + + +
+ + +
+ www.blueplanet.com +
+ + +
+ clearchat.com +
+ + +
+ www.rentouch.ch +
+ + +
+ www.jetbrains.com/pycharm/ +
See the [Support development](#support-development) section for a list of all the individuals and companies supporting CEF Python. +If you would like to sponsor CEF Python development efforts and see your company +logo with a link here, please contact Czarek (contact details are available in his +[Resume](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view)). +This README page alone has 1,070 visitors and 2,402 views every two weeks, +so your company logo and a website link will be visible to many Python developers. +The statistics are from Mar 9, 2018. Complete statistics are available in this topic +on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpython/CjkZF2P4rMk/discussion). + ## Funding for v64.0 release From de6e99cbfe6269fbc13b4a093899c49e12eb9a4d Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 9 Mar 2018 10:16:34 +0100 Subject: [PATCH 030/238] Update README.md - styling --- README.md | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d2873954..eabffd05 100644 --- a/README.md +++ b/README.md @@ -44,28 +44,36 @@ or other kind of internet bots.
- - -
- www.blueplanet.com +
- - -
- clearchat.com +
- - -
- www.rentouch.ch +
- - -
- www.jetbrains.com/pycharm/ +
From bbf3597ba47f72db66cf304ab8eb3ccfc3a7130c Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 9 Mar 2018 10:21:26 +0100 Subject: [PATCH 031/238] Update README - fix link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eabffd05..c1d162ad 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Table of contents: * [Introduction](#introduction) -* [Sponsors](#Sponsors) +* [Sponsors](#sponsors) * [Funding for v64.0 release](#funding-for-v640-release) * [Install](#install) * [Tutorial](#tutorial) From 25c0968fb5d79b64001ad1c412861d736c6677a6 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 16:31:08 +0200 Subject: [PATCH 032/238] Update README. Lampix is sponsoring the v66 release of cefpython. --- README.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c1d162ad..a4264edd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Table of contents: * [Introduction](#introduction) * [Sponsors](#sponsors) -* [Funding for v64.0 release](#funding-for-v640-release) +* [Funding for v66.0 release](#funding-for-v660-release) * [Install](#install) * [Tutorial](#tutorial) * [Examples](#examples) @@ -43,6 +43,14 @@ or other kind of internet bots. + + + @@ -90,11 +100,14 @@ The statistics are from Mar 9, 2018. Complete statistics are available in this t on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpython/CjkZF2P4rMk/discussion). -## Funding for v64.0 release +## Funding for v66.0 release -For those interested in sponsoring a v64.0 release please see -[Issue #370](../../issues/370). +I am happy to announce that Lampix is sponsoring the v66 release of cefpython. +Lampix is the first hardware and software solution that turns any surface +into a smart, augmented reality or interactive surface. Please visit its +website here: https://lampix.com/ +[![lampix600](https://user-images.githubusercontent.com/1187415/40367671-40fecd4e-5dda-11e8-8ef9-1e3d91298c8a.jpg)](https://lampix.com/) ## Install From 9d7ebe52f40f8f03563d622b0abd3c8702e9ac9c Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 19:51:30 +0200 Subject: [PATCH 033/238] Update automate-git.py from upstream --- tools/automate-git.py | 1044 ++++++++++++++++++++++++++++++----------- 1 file changed, 771 insertions(+), 273 deletions(-) diff --git a/tools/automate-git.py b/tools/automate-git.py index 9b3db231..4f247930 100644 --- a/tools/automate-git.py +++ b/tools/automate-git.py @@ -1,104 +1,19 @@ -""" See automate.py. This script is for internal usage only, don't -call it directly. This is a modified copy of automate-git.py from -upstream CEF. - -Some modifications were applied for CEF Python specific use case. -There is a patch file with the same name as this script that contains -differences from the original file. - -------------------------------------------------------------------------------- - -Usage: automate-git.py [options] - - This utility implements automation for the download, update, build and -distribution of CEF. - -Options: - -h, --help show this help message and exit - --download-dir=DIR Download directory with no spaces [required]. - --depot-tools-dir=DIR - Download directory for depot_tools. - --depot-tools-archive=DEPOTTOOLSARCHIVE - Zip archive file that contains a single top-level - depot_tools directory. - --branch=BRANCH Branch of CEF to build (trunk, 1916, ...). This will - be used to name the CEF download directory and to - identify the correct URL if --url is not specified. - The default value is trunk. - --url=URL CEF download URL. If not specified the default URL - will be used. - --chromium-url=CHROMIUMURL - Chromium download URL. If not specified the default - URL will be used. - --checkout=CHECKOUT Version of CEF to checkout. If not specified the most - recent remote version of the branch will be used. - --chromium-checkout=CHROMIUMCHECKOUT - Version of Chromium to checkout (Git branch/hash/tag). - This overrides the value specified by CEF in - CHROMIUM_BUILD_COMPATIBILITY.txt. - --force-config Force creation of a new gclient config file. - --force-clean Force a clean checkout of Chromium and CEF. This will - trigger a new update, build and distribution. - --force-clean-deps Force a clean checkout of Chromium dependencies. Used - in combination with --force-clean. - --dry-run Output commands without executing them. - --dry-run-platform=DRYRUNPLATFORM - Simulate a dry run on the specified platform (windows, - macosx, linux). Must be used in combination with the - --dry-run flag. - --force-update Force a Chromium and CEF update. This will trigger a - new build and distribution. - --no-update Do not update Chromium or CEF. Pass --force-build or - --force-distrib if you desire a new build or - distribution. - --no-cef-update Do not update CEF. Pass --force-build or --force- - distrib if you desire a new build or distribution. - --no-chromium-update Do not update Chromium. - --no-depot-tools-update - Do not update depot_tools. - --force-build Force CEF debug and release builds. This builds - [build-target] on all platforms and chrome_sandbox on - Linux. - --no-build Do not build CEF. - --build-target=BUILDTARGET - Target name(s) to build (defaults to "cefclient"). - --build-tests Also build the cef_unittests target. - --no-debug-build Don't perform the CEF debug build. - --no-release-build Don't perform the CEF release build. - --verbose-build Show all command lines while building. - --build-log-file Write build logs to file. The file will be named - "build-[branch]-[debug|release].log" in the download - directory. - --x64-build Create a 64-bit build. - --arm-build Create an ARM build. - --force-distrib Force creation of a CEF binary distribution. - --no-distrib Don't create a CEF binary distribution. - --minimal-distrib Create a minimal CEF binary distribution. - --minimal-distrib-only - Create a minimal CEF binary distribution only. - --client-distrib Create a client CEF binary distribution. - --client-distrib-only - Create a client CEF binary distribution only. - --no-distrib-docs Don't create CEF documentation. - --no-distrib-archive Don't create archives for output directories. - --clean-artifacts Clean the artifacts output directory. - --distrib-subdir=DISTRIBSUBDIR - CEF distrib dir name, child of - chromium/src/cef/binary_distrib -""" - # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. +from datetime import datetime +import json from optparse import OptionParser import os +import re import shlex import shutil import subprocess import sys import tempfile import urllib +import urllib2 import zipfile ## @@ -110,6 +25,7 @@ cef_git_url = 'https://bitbucket.org/chromiumembedded/cef.git' +chromium_channel_json_url = 'https://omahaproxy.appspot.com/all.json' ## # Global system variables. @@ -118,21 +34,22 @@ # Script directory. script_dir = os.path.dirname(__file__) - ## # Helper functions. ## + def msg(message): """ Output a message. """ sys.stdout.write('--> ' + message + "\n") + def run(command_line, working_dir, depot_tools_dir=None, output_file=None): """ Runs the specified command. """ # add depot_tools to the path env = os.environ if not depot_tools_dir is None: - env['PATH'] = depot_tools_dir+os.pathsep+env['PATH'] + env['PATH'] = depot_tools_dir + os.pathsep + env['PATH'] sys.stdout.write('-------- Running "'+command_line+'" in "'+\ working_dir+'"...'+"\n") @@ -140,27 +57,39 @@ def run(command_line, working_dir, depot_tools_dir=None, output_file=None): args = shlex.split(command_line.replace('\\', '\\\\')) if not output_file: - return subprocess.check_call(args, cwd=working_dir, env=env, - shell=(sys.platform == 'win32')) - with open(output_file, "w") as f: - return subprocess.check_call(args, cwd=working_dir, env=env, - shell=(sys.platform == 'win32'), - stderr=subprocess.STDOUT, stdout=f) + return subprocess.check_call( + args, cwd=working_dir, env=env, shell=(sys.platform == 'win32')) + try: + msg('Writing %s' % output_file) + with open(output_file, "w") as f: + return subprocess.check_call( + args, + cwd=working_dir, + env=env, + shell=(sys.platform == 'win32'), + stderr=subprocess.STDOUT, + stdout=f) + except subprocess.CalledProcessError: + msg('ERROR Run failed. See %s for output.' % output_file) + raise + def create_directory(path): """ Creates a directory if it doesn't already exist. """ if not os.path.exists(path): - msg("Creating directory %s" % (path)); + msg("Creating directory %s" % (path)) if not options.dryrun: os.makedirs(path) + def delete_directory(path): """ Removes an existing directory. """ if os.path.exists(path): - msg("Removing directory %s" % (path)); + msg("Removing directory %s" % (path)) if not options.dryrun: shutil.rmtree(path, onerror=onerror) + def copy_directory(source, target, allow_overwrite=False): """ Copies a directory from source to target. """ if not options.dryrun and os.path.exists(target): @@ -168,10 +97,11 @@ def copy_directory(source, target, allow_overwrite=False): raise Exception("Directory %s already exists" % (target)) remove_directory(target) if os.path.exists(source): - msg("Copying directory %s to %s" % (source, target)); + msg("Copying directory %s to %s" % (source, target)) if not options.dryrun: shutil.copytree(source, target) + def move_directory(source, target, allow_overwrite=False): """ Copies a directory from source to target. """ if not options.dryrun and os.path.exists(target): @@ -179,14 +109,16 @@ def move_directory(source, target, allow_overwrite=False): raise Exception("Directory %s already exists" % (target)) remove_directory(target) if os.path.exists(source): - msg("Moving directory %s to %s" % (source, target)); + msg("Moving directory %s to %s" % (source, target)) if not options.dryrun: shutil.move(source, target) + def is_git_checkout(path): """ Returns true if the path represents a git checkout. """ return os.path.exists(os.path.join(path, '.git')) + def exec_cmd(cmd, path): """ Execute the specified command and return the result. """ out = '' @@ -194,10 +126,12 @@ def exec_cmd(cmd, path): sys.stdout.write("-------- Running \"%s\" in \"%s\"...\n" % (cmd, path)) parts = cmd.split() try: - process = subprocess.Popen(parts, cwd=path, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=(sys.platform == 'win32')) + process = subprocess.Popen( + parts, + cwd=path, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=(sys.platform == 'win32')) out, err = process.communicate() except IOError, (errno, strerror): raise @@ -205,6 +139,7 @@ def exec_cmd(cmd, path): raise return {'out': out, 'err': err} + def get_git_hash(path, branch): """ Returns the git hash for the specified branch/tag/hash. """ cmd = "%s rev-parse %s" % (git_exe, branch) @@ -213,6 +148,17 @@ def get_git_hash(path, branch): return result['out'].strip() return 'Unknown' + +def get_git_date(path, branch): + """ Returns the date for the specified branch/tag/hash. """ + cmd = "%s show -s --format=%%ct %s" % (git_exe, branch) + result = exec_cmd(cmd, path) + if result['out'] != '': + return datetime.utcfromtimestamp( + int(result['out'].strip())).strftime('%Y-%m-%d %H:%M:%S UTC') + return 'Unknown' + + def get_git_url(path): """ Returns the origin url for the specified path. """ cmd = "%s config --get remote.origin.url" % (git_exe) @@ -221,6 +167,7 @@ def get_git_url(path): return result['out'].strip() return 'Unknown' + def download_and_extract(src, target): """ Extracts the contents of src, which may be a URL or local file, to the target directory. """ @@ -232,7 +179,7 @@ def download_and_extract(src, target): response = opener.open(src) temporary = True - handle, archive_path = tempfile.mkstemp(suffix = '.zip') + handle, archive_path = tempfile.mkstemp(suffix='.zip') os.write(handle, response.read()) os.close(handle) elif os.path.exists(src): @@ -258,6 +205,7 @@ def download_and_extract(src, target): if temporary and os.path.exists(archive_path): os.remove(archive_path) + def read_file(path): """ Read a file. """ if os.path.exists(path): @@ -268,11 +216,13 @@ def read_file(path): else: raise Exception("Path does not exist: %s" % (path)) + def read_config_file(path): """ Read a configuration file. """ # Parse the contents. return eval(read_file(path), {'__builtins__': None}, None) + def write_config_file(path, contents): """ Write a configuration file. """ msg('Writing file: %s' % path) @@ -284,6 +234,7 @@ def write_config_file(path, contents): fp.write("}\n") fp.close() + def read_branch_config_file(path): """ Read the CEF branch from the specified path. """ config_file = os.path.join(path, 'cef.branch') @@ -293,12 +244,14 @@ def read_branch_config_file(path): return contents['branch'] return '' + def write_branch_config_file(path, branch): """ Write the CEF branch to the specified path. """ config_file = os.path.join(path, 'cef.branch') if not os.path.isfile(config_file): write_config_file(config_file, {'branch': branch}) + def remove_deps_entry(path, entry): """ Remove an entry from the Chromium DEPS file at the specified path. """ msg('Updating DEPS file: %s' % path) @@ -322,6 +275,7 @@ def remove_deps_entry(path, entry): fp.write(line) fp.close() + def apply_deps_patch(): """ Patch the Chromium DEPS file if necessary. """ # Starting with 43.0.2357.126 the DEPS file is now 100% Git and the .DEPS.git @@ -335,13 +289,13 @@ def apply_deps_patch(): if os.path.isfile(deps_path): msg("Chromium DEPS file: %s" % (deps_path)) - patch_file = os.path.join(cef_dir, 'patch', 'patches', deps_file + '.patch') - if os.path.exists(patch_file): + patch_file = os.path.join(cef_dir, 'patch', 'patches', deps_file) + if os.path.exists(patch_file + ".patch"): # Attempt to apply the DEPS patch file that may exist with newer branches. patch_tool = os.path.join(cef_dir, 'tools', 'patcher.py') run('%s %s --patch-file "%s" --patch-dir "%s"' % - (python_exe, patch_tool, patch_file, chromium_src_dir), - chromium_src_dir, depot_tools_dir) + (python_exe, patch_tool, patch_file, + chromium_src_dir), chromium_src_dir, depot_tools_dir) elif cef_branch != 'trunk' and int(cef_branch) <= 1916: # Release branch DEPS files older than 37.0.2007.0 may include a 'src' # entry. This entry needs to be removed otherwise `gclient sync` will @@ -350,6 +304,16 @@ def apply_deps_patch(): else: raise Exception("Path does not exist: %s" % (deps_path)) + +def run_patch_updater(args='', output_file=None): + """ Run the patch updater script. """ + tool = os.path.join(cef_src_dir, 'tools', 'patch_updater.py') + if len(args) > 0: + args = ' ' + args + run('%s %s%s' % (python_exe, tool, args), cef_src_dir, depot_tools_dir, + output_file) + + def onerror(func, path, exc_info): """ Error handler for ``shutil.rmtree``. @@ -370,6 +334,274 @@ def onerror(func, path, exc_info): raise +def read_json_url(url): + """ Read a JSON URL. """ + msg('Downloading %s' % url) + response = urllib2.urlopen(url) + return json.loads(response.read()) + + +g_channel_data = None + + +def get_chromium_channel_data(os, channel, param=None): + """ Returns all data for the specified Chromium channel. """ + global g_channel_data + + if g_channel_data is None: + g_channel_data = read_json_url(chromium_channel_json_url) + assert len(g_channel_data) > 0, 'Failed to load Chromium channel data' + + for oses in g_channel_data: + if oses['os'] == os: + for version in oses['versions']: + if version['channel'] == channel: + assert version['os'] == os + assert version['channel'] == channel + if param is None: + return version + else: + assert param in version, 'Missing parameter %s for Chromium channel %s %s' % ( + param, os, channel) + return version[param] + raise Exception("Invalid Chromium channel value: %s" % channel) + raise Exception("Invalid Chromium os value: %s" % os) + + +def get_chromium_channel_commit(os, channel): + """ Returns the current branch commit for the specified Chromium channel. """ + return get_chromium_channel_data(os, channel, 'branch_commit') + + +def get_chromium_channel_version(os, channel): + """ Returns the current version for the specified Chromium channel. """ + return get_chromium_channel_data(os, channel, 'current_version') + + +def get_chromium_master_position(commit): + """ Returns the closest master position for the specified Chromium commit. """ + # Using -2 because a "Publish DEPS" commit which does not have a master + # position may be first. + cmd = "%s log -2 %s" % (git_exe, commit) + result = exec_cmd(cmd, chromium_src_dir) + if result['out'] != '': + match = re.search(r'refs/heads/master@{#([\d]+)}', result['out']) + assert match != None, 'Failed to find position' + return int(match.groups()[0]) + return None + + +def get_chromium_master_commit(position): + """ Returns the master commit for the specified Chromium commit position. """ + cmd = '%s log -1 --grep=refs/heads/master@{#%s} origin/master' % ( + git_exe, str(position)) + result = exec_cmd(cmd, chromium_src_dir) + if result['out'] != '': + match = re.search(r'^commit ([a-f0-9]+)', result['out']) + assert match != None, 'Failed to find commit' + return match.groups()[0] + return None + + +def get_chromium_versions(commit): + """ Returns the list of Chromium versions that contain the specified commit. + Versions are listed oldest to newest. """ + cmd = '%s tag --contains %s' % (git_exe, commit) + result = exec_cmd(cmd, chromium_src_dir) + if result['out'] != '': + return [line.strip() for line in result['out'].strip().split('\n')] + return None + + +def get_chromium_compat_version(): + """ Returns the compatible Chromium version specified by the CEF checkout. """ + compat_path = os.path.join(cef_dir, 'CHROMIUM_BUILD_COMPATIBILITY.txt') + msg("Reading %s" % compat_path) + config = read_config_file(compat_path) + + if 'chromium_checkout' in config: + return config['chromium_checkout'] + raise Exception("Missing chromium_checkout value in %s" % (compat_path)) + + +def get_chromium_target_version(os='win', channel='canary', target_distance=0): + """ Returns the target Chromium version based on a heuristic. """ + # The current compatible version from CEF. + compat_version = chromium_compat_version + compat_commit = get_git_hash(chromium_src_dir, compat_version) + if compat_version == compat_commit: + versions = get_chromium_versions(compat_commit) + if len(versions) > 0: + compat_version = 'refs/tags/' + versions[0] + # Closest version may not align with the compat position, so adjust the + # commit to match. + compat_commit = get_git_hash(chromium_src_dir, compat_version) + compat_position = get_chromium_master_position(compat_commit) + compat_date = get_git_date(chromium_src_dir, compat_commit) + + # The most recent channel version from the Chromium website. + channel_version = 'refs/tags/' + get_chromium_channel_version(os, channel) + channel_commit = get_chromium_channel_commit(os, channel) + channel_position = get_chromium_master_position(channel_commit) + channel_date = get_git_date(chromium_src_dir, channel_commit) + + if compat_position >= channel_position: + # Already compatible with the channel version or newer. + target_version = compat_version + target_commit = compat_commit + target_position = compat_position + target_date = compat_date + elif target_distance <= 0 or compat_position + target_distance >= channel_position: + # Channel version is within the target distance. + target_version = channel_version + target_commit = channel_commit + target_position = channel_position + target_date = channel_date + else: + # Find an intermediary version that's within the target distance. + target_position = compat_position + target_distance + target_commit = get_chromium_master_commit(target_position) + versions = get_chromium_versions(target_commit) + if len(versions) > 0: + target_version = 'refs/tags/' + versions[0] + # Closest version may not align with the target position, so adjust the + # commit and position to match. + target_commit = get_git_hash(chromium_src_dir, target_version) + target_position = get_chromium_master_position(target_commit) + else: + target_version = target_commit + target_date = get_git_date(chromium_src_dir, target_commit) + + msg("") + msg("Computed Chromium update for %s %s at distance %d" % (os, channel, + target_distance)) + msg("Compat: %s %s %s (#%d)" % (compat_date, compat_version, compat_commit, + compat_position)) + msg("Target: %s %s %s (#%d)" % (target_date, target_version, target_commit, + target_position)) + msg("Channel: %s %s %s (#%d)" % (channel_date, channel_version, + channel_commit, channel_position)) + msg("") + + return target_version + + +def get_build_directory_name(is_debug): + build_dir = ('Debug' if is_debug else 'Release') + '_' + if use_gn: + # CEF uses a consistent directory naming scheme for GN via + # GetAllPlatformConfigs in tools/gn_args.py. + if options.x64build: + build_dir += 'GN_x64' + elif options.armbuild: + build_dir += 'GN_arm' + else: + build_dir += 'GN_x86' + else: + # GYP outputs both x86 and x64 builds to the same directory on Linux and + # Mac OS X. On Windows it suffixes the directory name for x64 builds. + if platform == 'windows' and options.x64build: + build_dir += 'x64' + return build_dir + + +def read_update_file(): + update_path = os.path.join(cef_src_dir, 'CHROMIUM_UPDATE.txt') + if not os.path.exists(update_path): + msg("Missing file: %s" % update_path) + return None + + msg("Reading %s" % update_path) + return read_config_file(update_path) + + +def log_chromium_changes(): + """ Evaluate the Chromium checkout for changes. """ + config = read_update_file() + if config is None: + msg("Skipping Chromium changes log.") + return + + if 'files' in config: + out_file = os.path.join(download_dir, 'chromium_update_changes.diff') + if os.path.exists(out_file): + os.remove(out_file) + + old_commit = get_chromium_master_commit( + get_chromium_master_position(chromium_compat_version)) + new_commit = get_chromium_master_commit( + get_chromium_master_position(chromium_checkout)) + + cmd = '%s diff --relative --no-prefix %s..%s -- %s' % ( + git_exe, old_commit, new_commit, ' '.join(config['files'])) + result = exec_cmd(cmd, chromium_src_dir) + if result['out'] != '': + msg('Writing %s' % out_file) + with open(out_file, 'w') as fp: + fp.write(result['out']) + + +def check_pattern_matches(output_file=None): + """ Evaluate the Chromium checkout for pattern matches. """ + config = read_update_file() + if config is None: + msg("Skipping Chromium pattern matching.") + return + + if 'patterns' in config: + if output_file is None: + fp = sys.stdout + else: + msg('Writing %s' % output_file) + fp = open(output_file, 'w') + + has_output = False + for entry in config['patterns']: + msg("Evaluating pattern: %s" % entry['pattern']) + + # Read patterns from a file to avoid formatting problems. + pattern_handle, pattern_file = tempfile.mkstemp() + os.write(pattern_handle, entry['pattern']) + os.close(pattern_handle) + + cmd = '%s grep -n -f %s' % (git_exe, pattern_file) + result = exec_cmd(cmd, chromium_src_dir) + os.remove(pattern_file) + + if result['out'] != '': + write_msg = True + re_exclude = re.compile( + entry['exclude_matches']) if 'exclude_matches' in entry else None + + for line in result['out'].split('\n'): + line = line.strip() + if len(line) == 0: + continue + skip = not re_exclude is None and re_exclude.match(line) != None + if not skip: + if write_msg: + if has_output: + fp.write('\n') + fp.write('!!!! WARNING: FOUND PATTERN: %s\n' % entry['pattern']) + if 'message' in entry: + fp.write(entry['message'] + '\n') + fp.write('\n') + write_msg = False + fp.write(line + '\n') + has_output = True + + if not output_file is None: + if has_output: + msg('ERROR Matches found. See %s for output.' % out_file) + else: + fp.write('Good news! No matches.\n') + fp.close() + + if has_output: + # Don't continue when we know the build will be wrong. + sys.exit(1) + + ## # Program entry point. ## @@ -388,10 +620,17 @@ def onerror(func, path, exc_info): parser = OptionParser(description=disc) # Setup options. -parser.add_option('--download-dir', dest='downloaddir', metavar='DIR', - help='Download directory with no spaces [required].') -parser.add_option('--depot-tools-dir', dest='depottoolsdir', metavar='DIR', - help='Download directory for depot_tools.', default='') +parser.add_option( + '--download-dir', + dest='downloaddir', + metavar='DIR', + help='Download directory with no spaces [required].') +parser.add_option( + '--depot-tools-dir', + dest='depottoolsdir', + metavar='DIR', + help='Download directory for depot_tools.', + default='') parser.add_option('--depot-tools-archive', dest='depottoolsarchive', help='Zip archive file that contains a single top-level '+\ 'depot_tools directory.', default='') @@ -418,11 +657,24 @@ def onerror(func, path, exc_info): 'branch/hash/tag). This overrides the value specified '+\ 'by CEF in CHROMIUM_BUILD_COMPATIBILITY.txt.', default='') +parser.add_option('--chromium-channel', dest='chromiumchannel', + help='Chromium channel to check out (canary, dev, beta or '+\ + 'stable). This overrides the value specified by CEF '+\ + 'in CHROMIUM_BUILD_COMPATIBILITY.txt.', + default='') +parser.add_option('--chromium-channel-distance', dest='chromiumchanneldistance', + help='The target number of commits to step in the '+\ + 'channel, or 0 to use the newest channel version. '+\ + 'Used in combination with --chromium-channel.', + default='') # Miscellaneous options. -parser.add_option('--force-config', - action='store_true', dest='forceconfig', default=False, - help='Force creation of a new gclient config file.') +parser.add_option( + '--force-config', + action='store_true', + dest='forceconfig', + default=False, + help='Force creation of a new gclient config file.') parser.add_option('--force-clean', action='store_true', dest='forceclean', default=False, help='Force a clean checkout of Chromium and CEF. This will'+\ @@ -431,9 +683,12 @@ def onerror(func, path, exc_info): action='store_true', dest='forcecleandeps', default=False, help='Force a clean checkout of Chromium dependencies. Used'+\ ' in combination with --force-clean.') -parser.add_option('--dry-run', - action='store_true', dest='dryrun', default=False, - help="Output commands without executing them.") +parser.add_option( + '--dry-run', + action='store_true', + dest='dryrun', + default=False, + help="Output commands without executing them.") parser.add_option('--dry-run-platform', dest='dryrunplatform', default=None, help='Simulate a dry run on the specified platform '+\ '(windows, macosx, linux). Must be used in combination'+\ @@ -454,12 +709,47 @@ def onerror(func, path, exc_info): help='Do not update CEF. Pass --force-build or '+\ '--force-distrib if you desire a new build or '+\ 'distribution.') -parser.add_option('--no-chromium-update', - action='store_true', dest='nochromiumupdate', default=False, - help='Do not update Chromium.') -parser.add_option('--no-depot-tools-update', - action='store_true', dest='nodepottoolsupdate', default=False, - help='Do not update depot_tools.') +parser.add_option('--force-cef-update', + action='store_true', dest='forcecefupdate', default=False, + help='Force a CEF update. This will cause local changes in '+\ + 'the CEF checkout to be discarded and patch files to '+\ + 'be reapplied.') +parser.add_option( + '--no-chromium-update', + action='store_true', + dest='nochromiumupdate', + default=False, + help='Do not update Chromium.') +parser.add_option( + '--no-depot-tools-update', + action='store_true', + dest='nodepottoolsupdate', + default=False, + help='Do not update depot_tools.') +parser.add_option('--fast-update', + action='store_true', dest='fastupdate', default=False, + help='Update existing Chromium/CEF checkouts for fast incremental '+\ + 'builds by attempting to minimize the number of modified files. '+\ + 'The update will fail if there are unstaged CEF changes or if '+\ + 'Chromium changes are not included in a patch file.') +parser.add_option( + '--force-patch-update', + action='store_true', + dest='forcepatchupdate', + default=False, + help='Force update of patch files.') +parser.add_option( + '--resave', + action='store_true', + dest='resave', + default=False, + help='Resave patch files.') +parser.add_option( + '--log-chromium-changes', + action='store_true', + dest='logchromiumchanges', + default=False, + help='Create a log of the Chromium changes.') # Build-related options. parser.add_option('--force-build', @@ -467,63 +757,167 @@ def onerror(func, path, exc_info): help='Force CEF debug and release builds. This builds '+\ '[build-target] on all platforms and chrome_sandbox '+\ 'on Linux.') -parser.add_option('--no-build', - action='store_true', dest='nobuild', default=False, - help='Do not build CEF.') -parser.add_option('--build-target', dest='buildtarget', default='cefclient', - help='Target name(s) to build (defaults to "cefclient").') -parser.add_option('--build-tests', - action='store_true', dest='buildtests', default=False, - help='Also build the cef_unittests target.') -parser.add_option('--no-debug-build', - action='store_true', dest='nodebugbuild', default=False, - help="Don't perform the CEF debug build.") -parser.add_option('--no-release-build', - action='store_true', dest='noreleasebuild', default=False, - help="Don't perform the CEF release build.") -parser.add_option('--verbose-build', - action='store_true', dest='verbosebuild', default=False, - help='Show all command lines while building.') +parser.add_option( + '--no-build', + action='store_true', + dest='nobuild', + default=False, + help='Do not build CEF.') +parser.add_option( + '--build-target', + dest='buildtarget', + default='cefclient', + help='Target name(s) to build (defaults to "cefclient").') +parser.add_option( + '--build-tests', + action='store_true', + dest='buildtests', + default=False, + help='Also build the test target specified via --test-target.') +parser.add_option( + '--no-debug-build', + action='store_true', + dest='nodebugbuild', + default=False, + help="Don't perform the CEF debug build.") +parser.add_option( + '--no-release-build', + action='store_true', + dest='noreleasebuild', + default=False, + help="Don't perform the CEF release build.") +parser.add_option( + '--verbose-build', + action='store_true', + dest='verbosebuild', + default=False, + help='Show all command lines while building.') +parser.add_option( + '--build-failure-limit', + dest='buildfailurelimit', + default=1, + type="int", + help='Keep going until N jobs fail.') parser.add_option('--build-log-file', action='store_true', dest='buildlogfile', default=False, help='Write build logs to file. The file will be named '+\ '"build-[branch]-[debug|release].log" in the download '+\ 'directory.') -parser.add_option('--x64-build', - action='store_true', dest='x64build', default=False, - help='Create a 64-bit build.') -parser.add_option('--arm-build', - action='store_true', dest='armbuild', default=False, - help='Create an ARM build.') +parser.add_option( + '--x64-build', + action='store_true', + dest='x64build', + default=False, + help='Create a 64-bit build.') +parser.add_option( + '--arm-build', + action='store_true', + dest='armbuild', + default=False, + help='Create an ARM build.') + +# Test-related options. +parser.add_option( + '--run-tests', + action='store_true', + dest='runtests', + default=False, + help='Run the ceftests target.') +parser.add_option( + '--no-debug-tests', + action='store_true', + dest='nodebugtests', + default=False, + help="Don't run debug build tests.") +parser.add_option( + '--no-release-tests', + action='store_true', + dest='noreleasetests', + default=False, + help="Don't run release build tests.") +parser.add_option( + '--test-target', + dest='testtarget', + default='ceftests', + help='Test target name to build (defaults to "ceftests").') +parser.add_option( + '--test-prefix', + dest='testprefix', + default='', + help='Prefix for running the test executable (e.g. `xvfb-run` on Linux).') +parser.add_option( + '--test-args', + dest='testargs', + default='', + help='Arguments that will be passed to the test executable.') # Distribution-related options. -parser.add_option('--force-distrib', - action='store_true', dest='forcedistrib', default=False, - help='Force creation of a CEF binary distribution.') -parser.add_option('--no-distrib', - action='store_true', dest='nodistrib', default=False, - help="Don't create a CEF binary distribution.") -parser.add_option('--minimal-distrib', - action='store_true', dest='minimaldistrib', default=False, - help='Create a minimal CEF binary distribution.') -parser.add_option('--minimal-distrib-only', - action='store_true', dest='minimaldistribonly', default=False, - help='Create a minimal CEF binary distribution only.') -parser.add_option('--client-distrib', - action='store_true', dest='clientdistrib', default=False, - help='Create a client CEF binary distribution.') -parser.add_option('--client-distrib-only', - action='store_true', dest='clientdistribonly', default=False, - help='Create a client CEF binary distribution only.') -parser.add_option('--no-distrib-docs', - action='store_true', dest='nodistribdocs', default=False, - help="Don't create CEF documentation.") -parser.add_option('--no-distrib-archive', - action='store_true', dest='nodistribarchive', default=False, - help="Don't create archives for output directories.") -parser.add_option('--clean-artifacts', - action='store_true', dest='cleanartifacts', default=False, - help='Clean the artifacts output directory.') +parser.add_option( + '--force-distrib', + action='store_true', + dest='forcedistrib', + default=False, + help='Force creation of a CEF binary distribution.') +parser.add_option( + '--no-distrib', + action='store_true', + dest='nodistrib', + default=False, + help="Don't create a CEF binary distribution.") +parser.add_option( + '--minimal-distrib', + action='store_true', + dest='minimaldistrib', + default=False, + help='Create a minimal CEF binary distribution.') +parser.add_option( + '--minimal-distrib-only', + action='store_true', + dest='minimaldistribonly', + default=False, + help='Create a minimal CEF binary distribution only.') +parser.add_option( + '--client-distrib', + action='store_true', + dest='clientdistrib', + default=False, + help='Create a client CEF binary distribution.') +parser.add_option( + '--client-distrib-only', + action='store_true', + dest='clientdistribonly', + default=False, + help='Create a client CEF binary distribution only.') +parser.add_option( + '--sandbox-distrib', + action='store_true', + dest='sandboxdistrib', + default=False, + help='Create a cef_sandbox static library distribution.') +parser.add_option( + '--sandbox-distrib-only', + action='store_true', + dest='sandboxdistribonly', + default=False, + help='Create a cef_sandbox static library distribution only.') +parser.add_option( + '--no-distrib-docs', + action='store_true', + dest='nodistribdocs', + default=False, + help="Don't create CEF documentation.") +parser.add_option( + '--no-distrib-archive', + action='store_true', + dest='nodistribarchive', + default=False, + help="Don't create archives for output directories.") +parser.add_option( + '--clean-artifacts', + action='store_true', + dest='cleanartifacts', + default=False, + help='Clean the artifacts output directory.') parser.add_option('--distrib-subdir', dest='distribsubdir', help='CEF distrib dir name, child of '+\ 'chromium/src/cef/binary_distrib', @@ -542,23 +936,23 @@ def onerror(func, path, exc_info): options.nochromiumupdate = True options.nodepottoolsupdate = True +if options.runtests: + options.buildtests = True + if (options.nochromiumupdate and options.forceupdate) or \ (options.nocefupdate and options.forceupdate) or \ (options.nobuild and options.forcebuild) or \ - (options.nodistrib and options.forcedistrib): - # -- CEF Python modification below - if (options.nocefupdate and options.forceupdate): - pass - else: - print "Invalid combination of options." - parser.print_help(sys.stderr) - sys.exit() - # -- + (options.nodistrib and options.forcedistrib) or \ + ((options.forceclean or options.forcecleandeps) and options.fastupdate) or \ + (options.chromiumcheckout and options.chromiumchannel): + print "Invalid combination of options." + parser.print_help(sys.stderr) + sys.exit() if (options.noreleasebuild and \ (options.minimaldistrib or options.minimaldistribonly or \ options.clientdistrib or options.clientdistribonly)) or \ - (options.minimaldistribonly and options.clientdistribonly): + (options.minimaldistribonly + options.clientdistribonly + options.sandboxdistribonly > 1): print 'Invalid combination of options.' parser.print_help(sys.stderr) sys.exit() @@ -568,6 +962,11 @@ def onerror(func, path, exc_info): parser.print_help(sys.stderr) sys.exit() +if (options.buildtests or options.runtests) and len(options.testtarget) == 0: + print "A test target must be specified via --test-target." + parser.print_help(sys.stderr) + sys.exit() + # Operating system. if options.dryrun and options.dryrunplatform is not None: platform = options.dryrunplatform @@ -601,13 +1000,20 @@ def onerror(func, path, exc_info): parser.print_help(sys.stderr) sys.exit() +if platform != 'windows' and (options.sandboxdistrib or + options.sandboxdistribonly): + print 'The sandbox distribution is only supported on Windows.' + sys.exit() + # CEF branch. if options.branch != 'trunk' and not options.branch.isdigit(): print 'Invalid branch value: %s' % (options.branch) + sys.exit() + cef_branch = options.branch if cef_branch != 'trunk' and int(cef_branch) <= 1453: - print 'The requested branch is too old to build using this tool' + print 'The requested branch is too old to build using this tool.' sys.exit() # True if the requested branch is 2272 or newer. @@ -674,22 +1080,38 @@ def onerror(func, path, exc_info): # Options that force the sources to change. force_change = options.forceclean or options.forceupdate +# Options that cause local changes to be discarded. +discard_local_changes = force_change or options.forcecefupdate + +if options.resave and (options.forcepatchupdate or discard_local_changes): + print '--resave cannot be combined with options that modify or discard patches.' + parser.print_help(sys.stderr) + sys.exit() + if platform == 'windows': # Avoid errors when the "vs_toolchain.py update" Chromium hook runs. os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0' +download_dir = os.path.abspath(options.downloaddir) +chromium_dir = os.path.join(download_dir, 'chromium') +chromium_src_dir = os.path.join(chromium_dir, 'src') +out_src_dir = os.path.join(chromium_src_dir, 'out') +cef_src_dir = os.path.join(chromium_src_dir, 'cef') + +if options.fastupdate and os.path.exists(cef_src_dir): + cef_dir = cef_src_dir +else: + cef_dir = os.path.join(download_dir, 'cef') ## # Manage the download directory. ## # Create the download directory if necessary. -download_dir = os.path.abspath(options.downloaddir) create_directory(download_dir) msg("Download Directory: %s" % (download_dir)) - ## # Manage the depot_tools directory. ## @@ -716,16 +1138,16 @@ def onerror(func, path, exc_info): download_and_extract(options.depottoolsarchive, depot_tools_dir) else: # On Linux and OS X check out depot_tools using Git. - run('git clone '+depot_tools_url+' '+depot_tools_dir, download_dir) + run('git clone ' + depot_tools_url + ' ' + depot_tools_dir, download_dir) if not options.nodepottoolsupdate: # Update depot_tools. # On Windows this will download required python and git binaries. msg('Updating depot_tools') if platform == 'windows': - run('update_depot_tools.bat', depot_tools_dir, depot_tools_dir); + run('update_depot_tools.bat', depot_tools_dir, depot_tools_dir) else: - run('update_depot_tools', depot_tools_dir, depot_tools_dir); + run('update_depot_tools', depot_tools_dir, depot_tools_dir) # Determine the executables to use. if platform == 'windows': @@ -742,13 +1164,10 @@ def onerror(func, path, exc_info): git_exe = 'git' python_exe = 'python' - ## # Manage the cef directory. ## -cef_dir = os.path.join(download_dir, 'cef') - # Delete the existing CEF directory if requested. if options.forceclean and os.path.exists(cef_dir): delete_directory(cef_dir) @@ -788,35 +1207,40 @@ def onerror(func, path, exc_info): # Create the CEF checkout if necessary. if not options.nocefupdate and not os.path.exists(cef_dir): cef_checkout_new = True - run('%s clone %s %s' % (git_exe, cef_url, cef_dir), download_dir, \ + run('%s clone %s %s' % (git_exe, cef_url, cef_dir), download_dir, depot_tools_dir) else: cef_checkout_new = False -# Update the CEF checkout if necessary. +# Determine if the CEF checkout needs to change. if not options.nocefupdate and os.path.exists(cef_dir): cef_current_hash = get_git_hash(cef_dir, 'HEAD') if not cef_checkout_new: - # Fetch new sources. + # Fetch updated sources. run('%s fetch' % (git_exe), cef_dir, depot_tools_dir) cef_desired_hash = get_git_hash(cef_dir, cef_checkout) cef_checkout_changed = cef_checkout_new or force_change or \ + options.forcecefupdate or \ cef_current_hash != cef_desired_hash msg("CEF Current Checkout: %s" % (cef_current_hash)) msg("CEF Desired Checkout: %s (%s)" % (cef_desired_hash, cef_checkout)) if cef_checkout_changed: - # Checkout the requested branch. + if cef_dir == cef_src_dir: + # Running in fast update mode. Backup and revert the patched files before + # changing the CEF checkout. + run_patch_updater("--backup --revert") + + # Update the CEF checkout. run('%s checkout %s%s' % - (git_exe, ('--force ' if options.forceclean else ''), cef_checkout), \ + (git_exe, '--force ' if discard_local_changes else '', cef_checkout), \ cef_dir, depot_tools_dir) else: cef_checkout_changed = False - ## # Manage the out directory. ## @@ -829,21 +1253,15 @@ def onerror(func, path, exc_info): msg("CEF Output Directory: %s" % (out_dir)) - ## # Manage the chromium directory. ## # Create the chromium directory if necessary. -chromium_dir = os.path.join(download_dir, 'chromium') create_directory(chromium_dir) -chromium_src_dir = os.path.join(chromium_dir, 'src') -cef_src_dir = os.path.join(chromium_src_dir, 'cef') -out_src_dir = os.path.join(chromium_src_dir, 'out') - if options.chromiumurl != '': - chromium_url = options.chromiumurl; + chromium_url = options.chromiumurl else: chromium_url = 'https://chromium.googlesource.com/chromium/src.git' @@ -883,8 +1301,8 @@ def onerror(func, path, exc_info): # Initial Chromium checkout. if not options.nochromiumupdate and not os.path.exists(chromium_src_dir): chromium_checkout_new = True - run("gclient sync --nohooks --with_branch_heads --jobs 16", chromium_dir, \ - depot_tools_dir) + run("gclient sync --nohooks --with_branch_heads --disable-syntax-validation --jobs 16", \ + chromium_dir, depot_tools_dir) else: chromium_checkout_new = False @@ -895,18 +1313,25 @@ def onerror(func, path, exc_info): if os.path.exists(chromium_src_dir): msg("Chromium URL: %s" % (get_git_url(chromium_src_dir))) -# Determine the Chromium checkout options required by CEF. -if options.chromiumcheckout == '': - # Read the build compatibility file to identify the checkout name. - compat_path = os.path.join(cef_dir, 'CHROMIUM_BUILD_COMPATIBILITY.txt') - config = read_config_file(compat_path) +# Fetch Chromium changes so that we can perform the necessary calculations using +# local history. +if not options.nochromiumupdate and os.path.exists(chromium_src_dir): + # Fetch updated sources. + run("%s fetch" % (git_exe), chromium_src_dir, depot_tools_dir) + # Also fetch tags, which are required for release branch builds. + run("%s fetch --tags" % (git_exe), chromium_src_dir, depot_tools_dir) - if 'chromium_checkout' in config: - chromium_checkout = config['chromium_checkout'] - else: - raise Exception("Missing chromium_checkout value in %s" % (compat_path)) -else: +# Determine the Chromium checkout options required by CEF. +chromium_compat_version = get_chromium_compat_version() +if len(options.chromiumcheckout) > 0: chromium_checkout = options.chromiumcheckout +elif len(options.chromiumchannel) > 0: + target_distance = int(options.chromiumchanneldistance + ) if len(options.chromiumchanneldistance) > 0 else 0 + chromium_checkout = get_chromium_target_version( + channel=options.chromiumchannel, target_distance=target_distance) +else: + chromium_checkout = chromium_compat_version # Determine if the Chromium checkout needs to change. if not options.nochromiumupdate and os.path.exists(chromium_src_dir): @@ -921,10 +1346,15 @@ def onerror(func, path, exc_info): else: chromium_checkout_changed = options.dryrun -# Delete the existing src/cef directory. It will be re-copied from the download -# directory later. -if cef_checkout_changed and os.path.exists(cef_src_dir): - delete_directory(cef_src_dir) +if cef_checkout_changed: + if cef_dir != cef_src_dir and os.path.exists(cef_src_dir): + # Delete the existing src/cef directory. It will be re-copied from the + # download directory later. + delete_directory(cef_src_dir) +elif chromium_checkout_changed and cef_dir == cef_src_dir: + # Running in fast update mode. Backup and revert the patched files before + # changing the Chromium checkout. + run_patch_updater("--backup --revert") # Delete the existing src/out directory if requested. if options.forceclean and os.path.exists(out_src_dir): @@ -934,14 +1364,14 @@ def onerror(func, path, exc_info): # directory. It will be moved back from the download directory later. if os.path.exists(out_src_dir): old_branch = read_branch_config_file(out_src_dir) - if old_branch != '' and (chromium_checkout_changed or \ + if old_branch != '' and (chromium_checkout_changed or old_branch != cef_branch): old_out_dir = os.path.join(download_dir, 'out_' + old_branch) move_directory(out_src_dir, old_out_dir) # Update the Chromium checkout. if chromium_checkout_changed: - if not chromium_checkout_new: + if not chromium_checkout_new and not options.fastupdate: if options.forceclean and options.forcecleandeps: # Remove all local changes including third-party git checkouts managed by # gclient. @@ -950,14 +1380,9 @@ def onerror(func, path, exc_info): # Revert all changes in the Chromium checkout. run("gclient revert --nohooks", chromium_dir, depot_tools_dir) - # Fetch new sources. - run("%s fetch" % (git_exe), chromium_src_dir, depot_tools_dir) - # Also fetch tags, which are required for release branch builds. - run("%s fetch --tags" % (git_exe), chromium_src_dir, depot_tools_dir) - # Checkout the requested branch. run("%s checkout %s%s" % \ - (git_exe, ('--force ' if options.forceclean else ''), chromium_checkout), \ + (git_exe, '--force ' if discard_local_changes else '', chromium_checkout), \ chromium_src_dir, depot_tools_dir) # Patch the Chromium DEPS file if necessary. @@ -968,9 +1393,8 @@ def onerror(func, path, exc_info): os.environ['GYP_CHROMIUM_NO_ACTION'] = '1' # Update third-party dependencies including branch/tag information. - run("gclient sync %s--with_branch_heads --jobs 16" % \ - (('--reset ' if options.forceclean else '')), \ - chromium_dir, depot_tools_dir) + run("gclient sync %s--with_branch_heads --disable-syntax-validation --jobs 16" % \ + ('--reset ' if discard_local_changes else ''), chromium_dir, depot_tools_dir) # Clear the GYP_CHROMIUM_NO_ACTION value. del os.environ['GYP_CHROMIUM_NO_ACTION'] @@ -978,8 +1402,13 @@ def onerror(func, path, exc_info): # Delete the src/out directory created by `gclient sync`. delete_directory(out_src_dir) -# Restore the src/cef directory. -if os.path.exists(cef_dir) and not os.path.exists(cef_src_dir): +if cef_dir == cef_src_dir: + # Running in fast update mode. + if cef_checkout_changed or chromium_checkout_changed: + # Check and restore the patched files. + run_patch_updater("--reapply --restore") +elif os.path.exists(cef_dir) and not os.path.exists(cef_src_dir): + # Restore the src/cef directory. copy_directory(cef_dir, cef_src_dir) # Restore the src/out directory. @@ -993,6 +1422,32 @@ def onerror(func, path, exc_info): # Write the config file for identifying the branch. write_branch_config_file(out_src_dir, cef_branch) +if options.logchromiumchanges and chromium_checkout != chromium_compat_version: + log_chromium_changes() + +if options.forcepatchupdate or ((chromium_checkout_new or not options.fastupdate) and \ + chromium_checkout_changed and \ + chromium_checkout != chromium_compat_version): + # Not using the known-compatible Chromium version. Try to update patch files. + if options.logchromiumchanges: + out_file = os.path.join(download_dir, 'chromium_update_patches.txt') + if os.path.exists(out_file): + os.remove(out_file) + else: + out_file = None + run_patch_updater(output_file=out_file) +elif options.resave: + # Resave patch files. + run_patch_updater("--resave") + +if chromium_checkout != chromium_compat_version: + if options.logchromiumchanges: + out_file = os.path.join(download_dir, 'chromium_update_patterns.txt') + if os.path.exists(out_file): + os.remove(out_file) + else: + out_file = None + check_pattern_matches(output_file=out_file) ## # Build CEF. @@ -1032,69 +1487,106 @@ def onerror(func, path, exc_info): msg('%s=%s' % (key, os.environ[key])) # Run the cef_create_projects script to generate project files. - path = os.path.join(cef_src_dir, 'cef_create_projects'+script_ext) + path = os.path.join(cef_src_dir, 'cef_create_projects' + script_ext) run(path, cef_src_dir, depot_tools_dir) # Build using Ninja. - command = 'ninja -C ' + command = 'ninja ' if options.verbosebuild: - command = 'ninja -v -C' - - # -- CEF Python modification below - assert os.environ['CEFPYTHON_NINJA_JOBS'] - command = 'ninja -v -j' + os.environ['CEFPYTHON_NINJA_JOBS'] + ' -C' - # -- - + command += '-v ' + if options.buildfailurelimit != 1: + command += '-k %d ' % options.buildfailurelimit + command += '-C ' target = ' ' + options.buildtarget if options.buildtests: - target = target + ' cef_unittests' + target += ' ' + options.testtarget if platform == 'linux': - target = target + ' chrome_sandbox' - - build_dir_suffix = '' - if use_gn: - # CEF uses a consistent directory naming scheme for GN via - # GetAllPlatformConfigs in tools/gn_args.py. - if options.x64build: - build_dir_suffix = '_GN_x64' - elif options.armbuild: - build_dir_suffix = '_GN_arm' - else: - build_dir_suffix = '_GN_x86' - else: - # GYP outputs both x86 and x64 builds to the same directory on Linux and - # Mac OS X. On Windows it suffixes the directory name for x64 builds. - if platform == 'windows' and options.x64build: - build_dir_suffix = '_x64' + target += ' chrome_sandbox' + # Make a CEF Debug build. if not options.nodebugbuild: - build_path = os.path.join('out', 'Debug' + build_dir_suffix) + build_path = os.path.join('out', get_build_directory_name(True)) if use_gn: args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') - if os.path.exists(args_path): - msg(args_path + ' contents:\n' + read_file(args_path)) + msg(args_path + ' contents:\n' + read_file(args_path)) - # Make a CEF Debug build. run(command + build_path + target, chromium_src_dir, depot_tools_dir, os.path.join(download_dir, 'build-%s-debug.log' % (cef_branch)) \ if options.buildlogfile else None) + if use_gn and platform == 'windows': + # Make the separate cef_sandbox.lib build when GN is_official_build=true. + build_path += '_sandbox' + if os.path.exists(os.path.join(chromium_src_dir, build_path)): + args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') + msg(args_path + ' contents:\n' + read_file(args_path)) + + run(command + build_path + ' cef_sandbox', chromium_src_dir, depot_tools_dir, + os.path.join(download_dir, 'build-%s-debug-sandbox.log' % (cef_branch)) \ + if options.buildlogfile else None) + + # Make a CEF Release build. if not options.noreleasebuild: - build_path = os.path.join('out', 'Release' + build_dir_suffix) + build_path = os.path.join('out', get_build_directory_name(False)) if use_gn: args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') - if os.path.exists(args_path): - msg(args_path + ' contents:\n' + read_file(args_path)) + msg(args_path + ' contents:\n' + read_file(args_path)) - # Make a CEF Release build. run(command + build_path + target, chromium_src_dir, depot_tools_dir, os.path.join(download_dir, 'build-%s-release.log' % (cef_branch)) \ if options.buildlogfile else None) + if use_gn and platform == 'windows': + # Make the separate cef_sandbox.lib build when GN is_official_build=true. + build_path += '_sandbox' + if os.path.exists(os.path.join(chromium_src_dir, build_path)): + args_path = os.path.join(chromium_src_dir, build_path, 'args.gn') + msg(args_path + ' contents:\n' + read_file(args_path)) + + run(command + build_path + ' cef_sandbox', chromium_src_dir, depot_tools_dir, + os.path.join(download_dir, 'build-%s-release-sandbox.log' % (cef_branch)) \ + if options.buildlogfile else None) + elif not options.nobuild: msg('Not building. The source hashes have not changed and ' + 'the output folder "%s" already exists' % (out_src_dir)) +## +# Run CEF tests. +## + +if options.runtests: + if platform == 'windows': + test_exe = '%s.exe' % options.testtarget + elif platform == 'macosx': + test_exe = '%s.app/Contents/MacOS/%s' % (options.testtarget, + options.testtarget) + elif platform == 'linux': + test_exe = options.testtarget + + test_prefix = options.testprefix + if len(test_prefix) > 0: + test_prefix += ' ' + + test_args = options.testargs + if len(test_args) > 0: + test_args = ' ' + test_args + + if not options.nodebugtests: + build_path = os.path.join(out_src_dir, get_build_directory_name(True)) + test_path = os.path.join(build_path, test_exe) + if os.path.exists(test_path): + run(test_prefix + test_path + test_args, build_path, depot_tools_dir) + else: + msg('Not running debug tests. Missing executable: %s' % test_path) + + if not options.noreleasetests: + build_path = os.path.join(out_src_dir, get_build_directory_name(False)) + test_path = os.path.join(build_path, test_exe) + if os.path.exists(test_path): + run(test_prefix + test_path + test_args, build_path, depot_tools_dir) + else: + msg('Not running release tests. Missing executable: %s' % test_path) ## # Create the CEF binary distribution. @@ -1113,19 +1605,23 @@ def onerror(func, path, exc_info): distrib_types.append('minimal') elif options.clientdistribonly: distrib_types.append('client') + elif options.sandboxdistribonly: + distrib_types.append('sandbox') else: distrib_types.append('standard') if options.minimaldistrib: distrib_types.append('minimal') if options.clientdistrib: distrib_types.append('client') + if options.sandboxdistrib: + distrib_types.append('sandbox') cef_tools_dir = os.path.join(cef_src_dir, 'tools') # Create the requested distribution types. first_type = True for type in distrib_types: - path = os.path.join(cef_tools_dir, 'make_distrib'+script_ext) + path = os.path.join(cef_tools_dir, 'make_distrib' + script_ext) if options.nodebugbuild or options.noreleasebuild or type != 'standard': path = path + ' --allow-partial' path = path + ' --ninja-build' @@ -1138,6 +1634,8 @@ def onerror(func, path, exc_info): path = path + ' --minimal' elif type == 'client': path = path + ' --client' + elif type == 'sandbox': + path = path + ' --sandbox' if first_type: if options.nodistribdocs: From b416a5e901174cd522477bf25594afdbb16612ae Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 19:55:03 +0200 Subject: [PATCH 034/238] Update README --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a4264edd..67b5e4be 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,6 @@ or other kind of internet bots. See the [Support development](#support-development) section for a list of all the individuals and companies supporting CEF Python. -If you would like to sponsor CEF Python development efforts and see your company -logo with a link here, please contact Czarek (contact details are available in his -[Resume](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view)). -This README page alone has 1,070 visitors and 2,402 views every two weeks, -so your company logo and a website link will be visible to many Python developers. -The statistics are from Mar 9, 2018. Complete statistics are available in this topic -on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpython/CjkZF2P4rMk/discussion). - ## Funding for v66.0 release @@ -174,6 +166,13 @@ a higher priority. If you are interested in sponsorship opportunities please contact Czarek directly - contact details are available in his [Resume](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view). +If you would like to sponsor CEF Python development efforts and see your company +logo with a link in README, please contact Czarek. +This README page alone has 1,070 visitors and 2,402 views every two weeks, +so your company logo and a website link will be visible to many Python developers. +The statistics are from Mar 9, 2018. Complete statistics are available in this topic +on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpython/CjkZF2P4rMk/discussion). + ### Thanks * [2017] Many thanks to [ClearChat Inc.](https://clearchat.com/) for sponsoring From 108a3665e951bfab0dcd4a9587185fe9ff98354d Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 20:13:58 +0200 Subject: [PATCH 035/238] Apply custom patch to automate-git.py --- tools/automate-git.py | 143 +++++++++++++++++++++++++- tools/automate-git.py.patch | 197 +++++++++++++++++++++++++++++++++--- 2 files changed, 325 insertions(+), 15 deletions(-) diff --git a/tools/automate-git.py b/tools/automate-git.py index 4f247930..b819c7bd 100644 --- a/tools/automate-git.py +++ b/tools/automate-git.py @@ -1,3 +1,128 @@ +""" See automate.py. This script is for internal usage only, don't +call it directly. This is a modified copy of automate-git.py from +upstream CEF. + +Some modifications were applied for CEF Python specific use case. +There is a patch file with the same name as this script that contains +differences from the original file. + +------------------------------------------------------------------------------- + +Usage: automate-git.py [options] + + This utility implements automation for the download, update, build and +distribution of CEF. + +Options: + -h, --help show this help message and exit + --download-dir=DIR Download directory with no spaces [required]. + --depot-tools-dir=DIR + Download directory for depot_tools. + --depot-tools-archive=DEPOTTOOLSARCHIVE + Zip archive file that contains a single top-level + depot_tools directory. + --branch=BRANCH Branch of CEF to build (trunk, 1916, ...). This will + be used to name the CEF download directory and to + identify the correct URL if --url is not specified. + The default value is trunk. + --url=URL CEF download URL. If not specified the default URL + will be used. + --chromium-url=CHROMIUMURL + Chromium download URL. If not specified the default + URL will be used. + --checkout=CHECKOUT Version of CEF to checkout. If not specified the most + recent remote version of the branch will be used. + --chromium-checkout=CHROMIUMCHECKOUT + Version of Chromium to checkout (Git branch/hash/tag). + This overrides the value specified by CEF in + CHROMIUM_BUILD_COMPATIBILITY.txt. + --chromium-channel=CHROMIUMCHANNEL + Chromium channel to check out (canary, dev, beta or + stable). This overrides the value specified by CEF in + CHROMIUM_BUILD_COMPATIBILITY.txt. + --chromium-channel-distance=CHROMIUMCHANNELDISTANCE + The target number of commits to step in the channel, + or 0 to use the newest channel version. Used in + combination with --chromium-channel. + --force-config Force creation of a new gclient config file. + --force-clean Force a clean checkout of Chromium and CEF. This will + trigger a new update, build and distribution. + --force-clean-deps Force a clean checkout of Chromium dependencies. Used + in combination with --force-clean. + --dry-run Output commands without executing them. + --dry-run-platform=DRYRUNPLATFORM + Simulate a dry run on the specified platform (windows, + macosx, linux). Must be used in combination with the + --dry-run flag. + --force-update Force a Chromium and CEF update. This will trigger a + new build and distribution. + --no-update Do not update Chromium or CEF. Pass --force-build or + --force-distrib if you desire a new build or + distribution. + --no-cef-update Do not update CEF. Pass --force-build or --force- + distrib if you desire a new build or distribution. + --force-cef-update Force a CEF update. This will cause local changes in + the CEF checkout to be discarded and patch files to be + reapplied. + --no-chromium-update Do not update Chromium. + --no-depot-tools-update + Do not update depot_tools. + --fast-update Update existing Chromium/CEF checkouts for fast + incremental builds by attempting to minimize the + number of modified files. The update will fail if + there are unstaged CEF changes or if Chromium changes + are not included in a patch file. + --force-patch-update Force update of patch files. + --resave Resave patch files. + --log-chromium-changes + Create a log of the Chromium changes. + --force-build Force CEF debug and release builds. This builds + [build-target] on all platforms and chrome_sandbox on + Linux. + --no-build Do not build CEF. + --build-target=BUILDTARGET + Target name(s) to build (defaults to "cefclient"). + --build-tests Also build the test target specified via --test- + target. + --no-debug-build Don't perform the CEF debug build. + --no-release-build Don't perform the CEF release build. + --verbose-build Show all command lines while building. + --build-failure-limit=BUILDFAILURELIMIT + Keep going until N jobs fail. + --build-log-file Write build logs to file. The file will be named + "build-[branch]-[debug|release].log" in the download + directory. + --x64-build Create a 64-bit build. + --arm-build Create an ARM build. + --run-tests Run the ceftests target. + --no-debug-tests Don't run debug build tests. + --no-release-tests Don't run release build tests. + --test-target=TESTTARGET + Test target name to build (defaults to "ceftests"). + --test-prefix=TESTPREFIX + Prefix for running the test executable (e.g. `xvfb- + run` on Linux). + --test-args=TESTARGS Arguments that will be passed to the test executable. + --force-distrib Force creation of a CEF binary distribution. + --no-distrib Don't create a CEF binary distribution. + --minimal-distrib Create a minimal CEF binary distribution. + --minimal-distrib-only + Create a minimal CEF binary distribution only. + --client-distrib Create a client CEF binary distribution. + --client-distrib-only + Create a client CEF binary distribution only. + --sandbox-distrib Create a cef_sandbox static library distribution. + --sandbox-distrib-only + Create a cef_sandbox static library distribution only. + --no-distrib-docs Don't create CEF documentation. + --no-distrib-archive Don't create archives for output directories. + --clean-artifacts Clean the artifacts output directory. + --distrib-subdir=DISTRIBSUBDIR + CEF distrib dir name, child of + chromium/src/cef/binary_distrib + +""" + # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. @@ -945,9 +1070,14 @@ def check_pattern_matches(output_file=None): (options.nodistrib and options.forcedistrib) or \ ((options.forceclean or options.forcecleandeps) and options.fastupdate) or \ (options.chromiumcheckout and options.chromiumchannel): - print "Invalid combination of options." - parser.print_help(sys.stderr) - sys.exit() + # -- CEF Python modification below + if (options.nocefupdate and options.forceupdate): + pass + else: + print "Invalid combination of options." + parser.print_help(sys.stderr) + sys.exit() + # -- if (options.noreleasebuild and \ (options.minimaldistrib or options.minimaldistribonly or \ @@ -1494,9 +1624,16 @@ def check_pattern_matches(output_file=None): command = 'ninja ' if options.verbosebuild: command += '-v ' + + # -- CEF Python modification below + assert os.environ['CEFPYTHON_NINJA_JOBS'] + command += '-j' + os.environ['CEFPYTHON_NINJA_JOBS'] + ' ' + # -- + if options.buildfailurelimit != 1: command += '-k %d ' % options.buildfailurelimit command += '-C ' + target = ' ' + options.buildtarget if options.buildtests: target += ' ' + options.testtarget diff --git a/tools/automate-git.py.patch b/tools/automate-git.py.patch index c999df72..f8f8bb56 100644 --- a/tools/automate-git.py.patch +++ b/tools/automate-git.py.patch @@ -1,8 +1,8 @@ diff --git automate-git.py automate-git.py -index d5e75ae..9b3db23 100644 +index 4f24793..b819c7b 100644 --- automate-git.py +++ automate-git.py -@@ -1,3 +1,92 @@ +@@ -1,3 +1,128 @@ +""" See automate.py. This script is for internal usage only, don't +call it directly. This is a modified copy of automate-git.py from +upstream CEF. @@ -41,6 +41,14 @@ index d5e75ae..9b3db23 100644 + Version of Chromium to checkout (Git branch/hash/tag). + This overrides the value specified by CEF in + CHROMIUM_BUILD_COMPATIBILITY.txt. ++ --chromium-channel=CHROMIUMCHANNEL ++ Chromium channel to check out (canary, dev, beta or ++ stable). This overrides the value specified by CEF in ++ CHROMIUM_BUILD_COMPATIBILITY.txt. ++ --chromium-channel-distance=CHROMIUMCHANNELDISTANCE ++ The target number of commits to step in the channel, ++ or 0 to use the newest channel version. Used in ++ combination with --chromium-channel. + --force-config Force creation of a new gclient config file. + --force-clean Force a clean checkout of Chromium and CEF. This will + trigger a new update, build and distribution. @@ -58,24 +66,48 @@ index d5e75ae..9b3db23 100644 + distribution. + --no-cef-update Do not update CEF. Pass --force-build or --force- + distrib if you desire a new build or distribution. ++ --force-cef-update Force a CEF update. This will cause local changes in ++ the CEF checkout to be discarded and patch files to be ++ reapplied. + --no-chromium-update Do not update Chromium. + --no-depot-tools-update + Do not update depot_tools. ++ --fast-update Update existing Chromium/CEF checkouts for fast ++ incremental builds by attempting to minimize the ++ number of modified files. The update will fail if ++ there are unstaged CEF changes or if Chromium changes ++ are not included in a patch file. ++ --force-patch-update Force update of patch files. ++ --resave Resave patch files. ++ --log-chromium-changes ++ Create a log of the Chromium changes. + --force-build Force CEF debug and release builds. This builds + [build-target] on all platforms and chrome_sandbox on + Linux. + --no-build Do not build CEF. + --build-target=BUILDTARGET + Target name(s) to build (defaults to "cefclient"). -+ --build-tests Also build the cef_unittests target. ++ --build-tests Also build the test target specified via --test- ++ target. + --no-debug-build Don't perform the CEF debug build. + --no-release-build Don't perform the CEF release build. + --verbose-build Show all command lines while building. ++ --build-failure-limit=BUILDFAILURELIMIT ++ Keep going until N jobs fail. + --build-log-file Write build logs to file. The file will be named + "build-[branch]-[debug|release].log" in the download + directory. + --x64-build Create a 64-bit build. + --arm-build Create an ARM build. ++ --run-tests Run the ceftests target. ++ --no-debug-tests Don't run debug build tests. ++ --no-release-tests Don't run release build tests. ++ --test-target=TESTTARGET ++ Test target name to build (defaults to "ceftests"). ++ --test-prefix=TESTPREFIX ++ Prefix for running the test executable (e.g. `xvfb- ++ run` on Linux). ++ --test-args=TESTARGS Arguments that will be passed to the test executable. + --force-distrib Force creation of a CEF binary distribution. + --no-distrib Don't create a CEF binary distribution. + --minimal-distrib Create a minimal CEF binary distribution. @@ -84,21 +116,25 @@ index d5e75ae..9b3db23 100644 + --client-distrib Create a client CEF binary distribution. + --client-distrib-only + Create a client CEF binary distribution only. ++ --sandbox-distrib Create a cef_sandbox static library distribution. ++ --sandbox-distrib-only ++ Create a cef_sandbox static library distribution only. + --no-distrib-docs Don't create CEF documentation. + --no-distrib-archive Don't create archives for output directories. + --clean-artifacts Clean the artifacts output directory. + --distrib-subdir=DISTRIBSUBDIR + CEF distrib dir name, child of + chromium/src/cef/binary_distrib ++ +""" + # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights # reserved. Use of this source code is governed by a BSD-style license that # can be found in the LICENSE file. -@@ -457,9 +546,14 @@ if (options.nochromiumupdate and options.forceupdate) or \ - (options.nocefupdate and options.forceupdate) or \ - (options.nobuild and options.forcebuild) or \ - (options.nodistrib and options.forcedistrib): +@@ -945,9 +1070,14 @@ if (options.nochromiumupdate and options.forceupdate) or \ + (options.nodistrib and options.forcedistrib) or \ + ((options.forceclean or options.forcecleandeps) and options.fastupdate) or \ + (options.chromiumcheckout and options.chromiumchannel): - print "Invalid combination of options." - parser.print_help(sys.stderr) - sys.exit() @@ -113,16 +149,153 @@ index d5e75ae..9b3db23 100644 if (options.noreleasebuild and \ (options.minimaldistrib or options.minimaldistribonly or \ -@@ -945,6 +1039,12 @@ if not options.nobuild and (chromium_checkout_changed or \ - command = 'ninja -C ' +@@ -1494,9 +1624,16 @@ if not options.nobuild and (chromium_checkout_changed or \ + command = 'ninja ' if options.verbosebuild: - command = 'ninja -v -C' + command += '-v ' + + # -- CEF Python modification below + assert os.environ['CEFPYTHON_NINJA_JOBS'] -+ command = 'ninja -v -j' + os.environ['CEFPYTHON_NINJA_JOBS'] + ' -C' ++ command += '-j' + os.environ['CEFPYTHON_NINJA_JOBS'] + ' ' + # -- ++ + if options.buildfailurelimit != 1: + command += '-k %d ' % options.buildfailurelimit + command += '-C ' + target = ' ' + options.buildtarget if options.buildtests: - target = target + ' cef_unittests' + target += ' ' + options.testtarget +diff --git automate-git.py.patch automate-git.py.patch +index c999df7..4dcd59f 100644 +--- automate-git.py.patch ++++ automate-git.py.patch +@@ -1,128 +0,0 @@ +-diff --git automate-git.py automate-git.py +-index d5e75ae..9b3db23 100644 +---- automate-git.py +-+++ automate-git.py +-@@ -1,3 +1,92 @@ +-+""" See automate.py. This script is for internal usage only, don't +-+call it directly. This is a modified copy of automate-git.py from +-+upstream CEF. +-+ +-+Some modifications were applied for CEF Python specific use case. +-+There is a patch file with the same name as this script that contains +-+differences from the original file. +-+ +-+------------------------------------------------------------------------------- +-+ +-+Usage: automate-git.py [options] +-+ +-+ This utility implements automation for the download, update, build and +-+distribution of CEF. +-+ +-+Options: +-+ -h, --help show this help message and exit +-+ --download-dir=DIR Download directory with no spaces [required]. +-+ --depot-tools-dir=DIR +-+ Download directory for depot_tools. +-+ --depot-tools-archive=DEPOTTOOLSARCHIVE +-+ Zip archive file that contains a single top-level +-+ depot_tools directory. +-+ --branch=BRANCH Branch of CEF to build (trunk, 1916, ...). This will +-+ be used to name the CEF download directory and to +-+ identify the correct URL if --url is not specified. +-+ The default value is trunk. +-+ --url=URL CEF download URL. If not specified the default URL +-+ will be used. +-+ --chromium-url=CHROMIUMURL +-+ Chromium download URL. If not specified the default +-+ URL will be used. +-+ --checkout=CHECKOUT Version of CEF to checkout. If not specified the most +-+ recent remote version of the branch will be used. +-+ --chromium-checkout=CHROMIUMCHECKOUT +-+ Version of Chromium to checkout (Git branch/hash/tag). +-+ This overrides the value specified by CEF in +-+ CHROMIUM_BUILD_COMPATIBILITY.txt. +-+ --force-config Force creation of a new gclient config file. +-+ --force-clean Force a clean checkout of Chromium and CEF. This will +-+ trigger a new update, build and distribution. +-+ --force-clean-deps Force a clean checkout of Chromium dependencies. Used +-+ in combination with --force-clean. +-+ --dry-run Output commands without executing them. +-+ --dry-run-platform=DRYRUNPLATFORM +-+ Simulate a dry run on the specified platform (windows, +-+ macosx, linux). Must be used in combination with the +-+ --dry-run flag. +-+ --force-update Force a Chromium and CEF update. This will trigger a +-+ new build and distribution. +-+ --no-update Do not update Chromium or CEF. Pass --force-build or +-+ --force-distrib if you desire a new build or +-+ distribution. +-+ --no-cef-update Do not update CEF. Pass --force-build or --force- +-+ distrib if you desire a new build or distribution. +-+ --no-chromium-update Do not update Chromium. +-+ --no-depot-tools-update +-+ Do not update depot_tools. +-+ --force-build Force CEF debug and release builds. This builds +-+ [build-target] on all platforms and chrome_sandbox on +-+ Linux. +-+ --no-build Do not build CEF. +-+ --build-target=BUILDTARGET +-+ Target name(s) to build (defaults to "cefclient"). +-+ --build-tests Also build the cef_unittests target. +-+ --no-debug-build Don't perform the CEF debug build. +-+ --no-release-build Don't perform the CEF release build. +-+ --verbose-build Show all command lines while building. +-+ --build-log-file Write build logs to file. The file will be named +-+ "build-[branch]-[debug|release].log" in the download +-+ directory. +-+ --x64-build Create a 64-bit build. +-+ --arm-build Create an ARM build. +-+ --force-distrib Force creation of a CEF binary distribution. +-+ --no-distrib Don't create a CEF binary distribution. +-+ --minimal-distrib Create a minimal CEF binary distribution. +-+ --minimal-distrib-only +-+ Create a minimal CEF binary distribution only. +-+ --client-distrib Create a client CEF binary distribution. +-+ --client-distrib-only +-+ Create a client CEF binary distribution only. +-+ --no-distrib-docs Don't create CEF documentation. +-+ --no-distrib-archive Don't create archives for output directories. +-+ --clean-artifacts Clean the artifacts output directory. +-+ --distrib-subdir=DISTRIBSUBDIR +-+ CEF distrib dir name, child of +-+ chromium/src/cef/binary_distrib +-+""" +-+ +- # Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights +- # reserved. Use of this source code is governed by a BSD-style license that +- # can be found in the LICENSE file. +-@@ -457,9 +546,14 @@ if (options.nochromiumupdate and options.forceupdate) or \ +- (options.nocefupdate and options.forceupdate) or \ +- (options.nobuild and options.forcebuild) or \ +- (options.nodistrib and options.forcedistrib): +-- print "Invalid combination of options." +-- parser.print_help(sys.stderr) +-- sys.exit() +-+ # -- CEF Python modification below +-+ if (options.nocefupdate and options.forceupdate): +-+ pass +-+ else: +-+ print "Invalid combination of options." +-+ parser.print_help(sys.stderr) +-+ sys.exit() +-+ # -- +- +- if (options.noreleasebuild and \ +- (options.minimaldistrib or options.minimaldistribonly or \ +-@@ -945,6 +1039,12 @@ if not options.nobuild and (chromium_checkout_changed or \ +- command = 'ninja -C ' +- if options.verbosebuild: +- command = 'ninja -v -C' +-+ +-+ # -- CEF Python modification below +-+ assert os.environ['CEFPYTHON_NINJA_JOBS'] +-+ command = 'ninja -v -j' + os.environ['CEFPYTHON_NINJA_JOBS'] + ' -C' +-+ # -- +-+ +- target = ' ' + options.buildtarget +- if options.buildtests: +- target = target + ' cef_unittests' From 2bf1758fc157018dd3d4a40402491bbedaaa7e51 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 20:56:58 +0200 Subject: [PATCH 036/238] Update build instructions doc --- docs/Build-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Build-instructions.md b/docs/Build-instructions.md index 91014dab..60becb6b 100644 --- a/docs/Build-instructions.md +++ b/docs/Build-instructions.md @@ -198,7 +198,7 @@ requirements common for all platforms. and copy it to /usr/bin and chmod 755. * Install/upgrade required packages using one of the three methods below (these packages should be upgraded each time you update to newer CEF): - 1. Type command: `sudo apt-get install bison build-essential cdbs curl devscripts dpkg-dev elfutils fakeroot flex g++ git-core git-svn gperf libapache2-mod-php5 libasound2-dev libav-tools libbrlapi-dev libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexif-dev libffi-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev openbox patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto python-dev python-psutil python-numpy python-opencv python-openssl python-yaml rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho fonts-thai-tlwg wdiff wget zip` + 1. Type command: `sudo apt-get install bison build-essential cdbs curl devscripts dpkg-dev elfutils fakeroot flex g++ git-core git-svn gperf libapache2-mod-php5 libasound2-dev libav-tools libbrlapi-dev libbz2-dev libcairo2-dev libcap-dev libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexif-dev libffi-dev libgconf2-dev libgconf-2-4 libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev openbox patch perl php5-cgi pkg-config python python-cherrypy3 python-crypto python-dev python-psutil python-numpy python-opencv python-openssl python-yaml rpm ruby subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho fonts-thai-tlwg wdiff wget zip` 2. See the list of packages on the [cef/AutomatedBuildSetup.md](https://bitbucket.org/chromiumembedded/cef/wiki/AutomatedBuildSetup.md#markdown-header-linux-configuration) wiki page. From cef0ca5f8258f7bbac886944332b3def3173f298 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 20:57:27 +0200 Subject: [PATCH 037/238] Add --use-system-freetype flag to automate.py (#402) --- tools/automate.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/automate.py b/tools/automate.py index 360ffed4..f9d3ddf9 100644 --- a/tools/automate.py +++ b/tools/automate.py @@ -33,6 +33,7 @@ [--build-dir BUILD_DIR] [--cef-build-dir CEF_BUILD_DIR] [--ninja-jobs JOBS] [--gyp-generators GENERATORS] [--gyp-msvs-version MSVS] + [--use-system-freetype USE_SYSTEM_FREETYPE] automate.py (-h | --help) [type -h to show full description for options] Options: @@ -61,6 +62,7 @@ By default set to cpu_count / 2. --gyp-generators= Set GYP_GENERATORS [default: ninja]. --gyp-msvs-version= Set GYP_MSVS_VERSION. + --use-system-freetype Use system Freetype library on Linux (Issue #402) """ @@ -103,6 +105,7 @@ class Options(object): ninja_jobs = None gyp_generators = "ninja" # Even though CEF uses now GN, still some GYP gyp_msvs_version = "" # env variables are being used. + use_system_freetype = False # Internal options depot_tools_dir = "" @@ -878,6 +881,10 @@ def getenv(): if Options.release_build and not Options.fast_build: env["GN_DEFINES"] += " is_official_build=true" + # Isssue #402 - Blurry font rendering on Linux + if Options.use_system_freetype: + env["GN_DEFINES"] += " use_system_freetype=true" + # GYP configuration is DEPRECATED, however it is still set in # upstream Linux configuration on AutomatedBuildSetup wiki page, # so setting it here as well. From c4b392379a5f914aca6a2fd52e8734a57383fad9 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 21:06:47 +0200 Subject: [PATCH 038/238] Add --no-depot-tools-update to automate.py (#428) --- tools/automate.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/automate.py b/tools/automate.py index f9d3ddf9..4ba57b17 100644 --- a/tools/automate.py +++ b/tools/automate.py @@ -34,6 +34,7 @@ [--ninja-jobs JOBS] [--gyp-generators GENERATORS] [--gyp-msvs-version MSVS] [--use-system-freetype USE_SYSTEM_FREETYPE] + [--no-depot-tools-update NO_DEPOT_TOOLS_UPDATE] automate.py (-h | --help) [type -h to show full description for options] Options: @@ -63,6 +64,10 @@ --gyp-generators= Set GYP_GENERATORS [default: ninja]. --gyp-msvs-version= Set GYP_MSVS_VERSION. --use-system-freetype Use system Freetype library on Linux (Issue #402) + --no-depot-tools-update Do not update depot_tools/ directory. When building + old unsupported versions of Chromium you want to + manually checkout an old version of depot tools + from the time of the release. """ @@ -106,6 +111,7 @@ class Options(object): gyp_generators = "ninja" # Even though CEF uses now GN, still some GYP gyp_msvs_version = "" # env variables are being used. use_system_freetype = False + no_depot_tools_update = False # Internal options depot_tools_dir = "" @@ -944,6 +950,8 @@ def run_automate_git(): args.append("--x64-build") args.append("--download-dir=" + Options.cef_build_dir) args.append("--branch=" + Options.cef_branch) + if Options.no_depot_tools_update: + args.append("--no-depot-tools-update") if Options.release_build: args.append("--no-debug-build") args.append("--verbose-build") From f87422b1060c34ca6fd4464f520aeeea10dcfbe5 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 21:37:57 +0200 Subject: [PATCH 039/238] Update patches (#125, #251) --- patches/issue251.patch | 366 ----------------------------------------- patches/patch.py | 11 +- 2 files changed, 3 insertions(+), 374 deletions(-) delete mode 100644 patches/issue251.patch diff --git a/patches/issue251.patch b/patches/issue251.patch deleted file mode 100644 index dabe3474..00000000 --- a/patches/issue251.patch +++ /dev/null @@ -1,366 +0,0 @@ -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 - -@@ -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 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 - - #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 handler = - browser_->GetClient()->GetRenderHandler(); - if (handler.get()) { -- CefRefPtr drag_data(new CefDragDataImpl(drop_data)); -+ CefRefPtr cef_image(new CefImageImpl(image)); -+ CefPoint cef_image_pos(CefPoint(image_offset.x(), image_offset.y())); -+ CefRefPtr 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..6db3da39 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 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 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,18 @@ void CefDragDataImpl::SetReadOnly(bool read_only) { - - read_only_ = read_only; - } -+ -+CefRefPtr 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_); -+ return image_ ? true : false; -+} -diff --git libcef/common/drag_data_impl.h libcef/common/drag_data_impl.h -index 64f29ed3..37c398d2 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,9 @@ class CefDragDataImpl : public CefDragData { - public: - CefDragDataImpl(); - explicit CefDragDataImpl(const content::DropData& data); -+ CefDragDataImpl(const content::DropData& data, -+ CefRefPtr image, -+ const CefPoint& image_hotspot); - - CefRefPtr 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 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 +60,8 @@ class CefDragDataImpl : public CefDragData { - - private: - content::DropData data_; -+ CefRefPtr 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 _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 CefCppToCRefCounted 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 GetImage() OVERRIDE; -+ CefPoint GetImageHotspot() OVERRIDE; -+ bool HasImage() OVERRIDE; - }; - - #endif // CEF_LIBCEF_DLL_CTOCPP_DRAG_DATA_CTOCPP_H_ -diff --git tests/ceftests/os_rendering_unittest.cc tests/ceftests/os_rendering_unittest.cc -index 8fa110fa..c8f49d9c 100644 ---- tests/ceftests/os_rendering_unittest.cc -+++ tests/ceftests/os_rendering_unittest.cc -@@ -1007,6 +1007,28 @@ class OSRTestHandler : public RoutingTestHandler, - CefRenderHandler::DragOperationsMask allowed_ops, - int x, int y) override { - if (test_type_ == OSR_TEST_DRAG_DROP_START_DRAGGING && started()) { -+ // Drag image representation -+ EXPECT_TRUE(drag_data->HasImage()); -+ CefRefPtr image = drag_data->GetImage(); -+ EXPECT_TRUE(image.get() != NULL); -+ if (image.get()) { -+ // Drag image height seem to be always + 1px greater than -+ // the drag rect on Linux. But whether this is true on all -+ // platforms not sure, so to be safe lets allow it to be -+ // +/- 1px. -+ EXPECT_GE(image->GetWidth(), GetScaledInt(kDragDivRect.width)); -+ EXPECT_LE(image->GetWidth(), GetScaledInt(kDragDivRect.width) + 1); -+ EXPECT_GE(image->GetHeight(), GetScaledInt(kDragDivRect.height)); -+ EXPECT_LE(image->GetHeight(), GetScaledInt(kDragDivRect.height) + 1); -+ } -+ // During testing hotspot was (15, 23) and with scale_factor 2x -+ // it was (15, 18). I don't know how the algorithm works, so -+ // testing only rect boundaries. -+ CefPoint hotspot = drag_data->GetImageHotspot(); -+ EXPECT_GT(hotspot.x, 0); -+ EXPECT_LT(hotspot.x, GetScaledInt(kDragDivRect.width)); -+ EXPECT_GT(hotspot.y, 0); -+ EXPECT_LT(hotspot.y, GetScaledInt(kDragDivRect.height)); - DestroySucceededTestSoon(); - return false; - } else if ((test_type_ == OSR_TEST_DRAG_DROP_UPDATE_CURSOR || diff --git a/patches/patch.py b/patches/patch.py index 80a33921..5fe98998 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -13,9 +13,9 @@ # noinspection PyUnresolvedReferences patches.extend([ { - # Fixes HTTPS cache problems with private certificates - 'name': 'issue125', - 'path': '../net/http/' + # (Disabled) Fixes HTTPS cache problems with private certificates + # 'name': 'issue125', + # 'path': '../net/http/' }, ]) @@ -28,9 +28,4 @@ 'name': 'issue231', 'path': './' }, - { - # Adds drag-image representation during drag & drop in OSR mode. - 'name': 'issue251', - 'path': './' - }, ]) From 1846d64dc5ba15e5a11e25762ddde761473f8b2c Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 21:55:54 +0200 Subject: [PATCH 040/238] Update docs on Issue #125 patch being disabled --- api/ApplicationSettings.md | 14 ++++++++------ docs/Migration-guide.md | 7 +++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/ApplicationSettings.md b/api/ApplicationSettings.md index 8bebae68..7f0be88e 100644 --- a/api/ApplicationSettings.md +++ b/api/ApplicationSettings.md @@ -233,12 +233,14 @@ RequestHandler.[_OnCertificateError()](#_oncertificateerror) callback. Note that disk caching is enabled only when the "cache_path" option is set. -__NOTE ON CACHING__: the official CEF Python binary releases incorporate a patch -that changes the caching behavior on sites with SSL certificate errors -when used with this setting. Chromium by default disallows caching of -content when there is certificate error. CEF Python applies a patch to -Chromium sources to allow for caching even when there is certificate error, -but only when the "ignore_certificate_errors" option is set to True. +__NOTE ON CACHING__: Chromium by default disallows caching of +content when there is certificate error. There is a issue125.patch +in the patches/ directory that can be enabled when doing a custom +CEF build. This patch changes the caching behavior on sites with SSL +certificate errors when used with this setting. This patch can be +applied Chromium sources to allow for caching even when there is +certificate error, but only when the "ignore_certificate_errors" +option is set to True. When it's set to False then the Chromium's caching behavior does not change. Enabling caching with certificate errors is useful on local private networks that use self-signed SSL certificates. See the diff --git a/docs/Migration-guide.md b/docs/Migration-guide.md index ae06f835..b2eed623 100644 --- a/docs/Migration-guide.md +++ b/docs/Migration-guide.md @@ -36,6 +36,7 @@ Table of contents: * [v55.3+ Handlers' callbacks and other interfaces](#v553-handlers-callbacks-and-other-interfaces) * [v56+ MacOS 10.9+ required to run](#v56-macos-109-required-to-run) * [v57.1+ High DPI support on Windows](#v571-high-dpi-support-on-windows) +* [v66.0+ Linux patch that fixed HTTPS cache problems on pages with certificate errors was disabled](#v660-linux-patch-that-fixed-https-cache-problems-on-pages-with-certificate-errors-was-disabled) @@ -295,3 +296,9 @@ option should have its value set to an empty string (a default now) for High DPI support. In previous versions the default value was "system_dpi" and if you have set it explicitilly in your application, then you should change it to an empty string now. + +## v66.0+ Linux patch that fixed HTTPS cache problems on pages with certificate errors was disabled + +See Issue [#125](../../../issues/125) for more details. + + From b05234f892908e7653036d982e1168dc2b5de7f1 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 22 May 2018 22:04:46 +0200 Subject: [PATCH 041/238] Fix link --- api/ApplicationSettings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/ApplicationSettings.md b/api/ApplicationSettings.md index 7f0be88e..be86c4b7 100644 --- a/api/ApplicationSettings.md +++ b/api/ApplicationSettings.md @@ -244,7 +244,7 @@ option is set to True. When it's set to False then the Chromium's caching behavior does not change. Enabling caching with certificate errors is useful on local private networks that use self-signed SSL certificates. See the -referenced CEF topic in [Issue #125](../issues/125) for more details. +referenced CEF topic in [Issue #125](../../../issues/125) for more details. ### javascript_flags From 691a0f6ac2fc7852706858907a2917dd8abd9cc0 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 23 May 2018 11:29:07 +0200 Subject: [PATCH 042/238] Fix patches and update build instructions --- docs/Build-instructions.md | 3 +-- patches/issue231.patch | 2 +- patches/patch.py | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/Build-instructions.md b/docs/Build-instructions.md index 60becb6b..507cbc92 100644 --- a/docs/Build-instructions.md +++ b/docs/Build-instructions.md @@ -194,7 +194,7 @@ requirements common for all platforms. * Install packages: `sudo apt-get install cmake g++ libgtk2.0-dev libgtkglext1-dev` * If building CEF from sources: * Official binaries are built on Ubuntu 14.04 (cmake 2.8.12, g++ 4.8.4) - * Download [ninja](http://martine.github.io/ninja/) 1.7.1 or later + * Download [ninja](https://github.com/ninja-build/ninja/releases) 1.7.1 or later and copy it to /usr/bin and chmod 755. * Install/upgrade required packages using one of the three methods below (these packages should be upgraded each time you update to newer CEF): @@ -223,7 +223,6 @@ requirements common for all platforms. * Download [cmake](https://cmake.org/download/) and add it to PATH. - ### All platforms * Install/update dependencies for the tools by executing: diff --git a/patches/issue231.patch b/patches/issue231.patch index 6e62498e..8bcb91fb 100644 --- a/patches/issue231.patch +++ b/patches/issue231.patch @@ -115,7 +115,7 @@ index 15026ab5..a3d21052 100644 --- libcef_dll/wrapper/libcef_dll_wrapper.cc +++ libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -880,6 +880,23 @@ CEF_GLOBAL bool CefGetPath(PathKey key, CefString& path) { - return _retval?true:false; + return _retval ? true : false; } +CEF_GLOBAL bool CefOverridePath(PathKey key, const CefString& path) { diff --git a/patches/patch.py b/patches/patch.py index 5fe98998..b6358b4d 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -1,6 +1,6 @@ # CEF Python patches to Chromium and CEF. # See upstream cef/patch/patch.cfg for how patching works in CEF. -# Current working directory is cef_build_dir/chromium/cef/ . +# Current working directory is cef_build_dir/chromium/src/ . # See also docs/Build-instructions.md and tools/automate.py . import platform @@ -12,11 +12,11 @@ # ALL PLATFORMS # noinspection PyUnresolvedReferences patches.extend([ - { - # (Disabled) Fixes HTTPS cache problems with private certificates - # 'name': 'issue125', - # 'path': '../net/http/' - }, + #{ + # # (Disabled) Fixes HTTPS cache problems with private certificates + # 'name': 'issue125', + # 'path': 'net/http/' + #}, ]) # LINUX @@ -26,6 +26,6 @@ { # Discovery of the "icudtl.dat" file fails on Linux. 'name': 'issue231', - 'path': './' + 'path': 'cef/' }, ]) From 2fb9ae156802c12b9941f61661318386dbf3bfe2 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Thu, 24 May 2018 10:27:42 +0200 Subject: [PATCH 043/238] Update README - logos and thanks --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 67b5e4be..9c4fa340 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Lampix is the first hardware and software solution that turns any surface into a smart, augmented reality or interactive surface. Please visit its website here: https://lampix.com/ -[![lampix600](https://user-images.githubusercontent.com/1187415/40367671-40fecd4e-5dda-11e8-8ef9-1e3d91298c8a.jpg)](https://lampix.com/) +[![lampix600](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix600.png)](https://lampix.com/) ## Install @@ -175,6 +175,8 @@ on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpyt ### Thanks +* [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 + release for all platforms * [2017] Many thanks to [ClearChat Inc.](https://clearchat.com/) for sponsoring the v55/v56 releases for all platforms * [2016-2018] Thanks to JetBrains for providing an Open Source license for From 9306e8928d828593f9aef179fabdfe8f3e312376 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 24 May 2018 13:31:38 +0200 Subject: [PATCH 044/238] Update CEF header files to CEF branch 3359 rev d49d25f (#403) --- src/include/base/cef_atomic_ref_count.h | 65 +- src/include/base/cef_atomicops.h | 3 +- src/include/base/cef_basictypes.h | 30 +- src/include/base/cef_bind.h | 393 +-- src/include/base/cef_bind_helpers.h | 63 +- src/include/base/cef_build.h | 16 +- src/include/base/cef_callback.h | 234 +- src/include/base/cef_callback_list.h | 59 +- src/include/base/cef_cancelable_callback.h | 53 +- src/include/base/cef_lock.h | 8 +- src/include/base/cef_logging.h | 244 +- src/include/base/cef_macros.h | 30 +- src/include/base/cef_move.h | 26 +- src/include/base/cef_platform_thread.h | 17 +- src/include/base/cef_ref_counted.h | 74 +- src/include/base/cef_scoped_ptr.h | 80 +- src/include/base/cef_string16.h | 35 +- src/include/base/cef_template_util.h | 110 +- src/include/base/cef_thread_checker.h | 11 +- .../base/cef_thread_collision_warner.h | 32 +- src/include/base/cef_trace_event.h | 179 +- src/include/base/cef_tuple.h | 1159 +++++--- src/include/base/cef_weak_ptr.h | 49 +- .../base/internal/cef_atomicops_arm_gcc.h | 53 +- .../cef_atomicops_atomicword_compat.h | 38 +- src/include/base/internal/cef_atomicops_mac.h | 6 +- .../base/internal/cef_atomicops_x86_gcc.h | 63 +- .../base/internal/cef_atomicops_x86_msvc.h | 39 +- src/include/base/internal/cef_bind_internal.h | 2382 ++++++++++------- .../base/internal/cef_bind_internal_win.h | 318 +-- .../base/internal/cef_callback_internal.h | 9 +- .../cef_raw_scoped_refptr_mismatch_checker.h | 129 +- ...location.h => cef_accessibility_handler.h} | 38 +- src/include/cef_app.h | 7 +- src/include/cef_application_mac.h | 16 +- src/include/cef_auth_callback.h | 6 +- src/include/cef_base.h | 80 +- src/include/cef_browser.h | 248 +- src/include/cef_browser_process_handler.h | 4 +- src/include/cef_callback.h | 6 +- src/include/cef_client.h | 58 +- src/include/cef_command_line.h | 42 +- src/include/cef_context_menu_handler.h | 52 +- src/include/cef_cookie.h | 40 +- src/include/cef_crash_util.h | 14 +- src/include/cef_dialog_handler.h | 5 +- src/include/cef_display_handler.h | 30 +- src/include/cef_dom.h | 86 +- src/include/cef_download_handler.h | 20 +- src/include/cef_download_item.h | 34 +- src/include/cef_drag_data.h | 60 +- src/include/cef_drag_handler.h | 6 +- src/include/cef_extension.h | 117 + src/include/cef_extension_handler.h | 199 ++ src/include/cef_file_util.h | 11 + src/include/cef_focus_handler.h | 8 +- src/include/cef_frame.h | 50 +- src/include/cef_image.h | 26 +- src/include/cef_jsdialog_handler.h | 6 +- src/include/cef_keyboard_handler.h | 8 +- src/include/cef_life_span_handler.h | 6 +- src/include/cef_menu_model.h | 116 +- src/include/cef_menu_model_delegate.h | 8 +- src/include/cef_navigation_entry.h | 20 +- src/include/cef_origin_whitelist.h | 1 - src/include/cef_parser.h | 6 +- src/include/cef_print_handler.h | 31 +- src/include/cef_print_settings.h | 47 +- src/include/cef_process_message.h | 10 +- src/include/cef_render_handler.h | 50 +- src/include/cef_render_process_handler.h | 16 +- src/include/cef_request.h | 78 +- src/include/cef_request_context.h | 137 +- src/include/cef_request_context_handler.h | 10 + src/include/cef_request_handler.h | 57 +- src/include/cef_resource_bundle.h | 6 +- src/include/cef_resource_bundle_handler.h | 7 +- src/include/cef_resource_handler.h | 8 +- src/include/cef_response.h | 26 +- src/include/cef_response_filter.h | 4 +- src/include/cef_sandbox_win.h | 8 +- src/include/cef_scheme.h | 9 +- src/include/cef_server.h | 315 +++ src/include/cef_ssl_info.h | 5 +- src/include/cef_ssl_status.h | 10 +- src/include/cef_stream.h | 43 +- src/include/cef_string_visitor.h | 2 +- src/include/cef_task.h | 17 +- src/include/cef_thread.h | 8 +- src/include/cef_trace.h | 3 +- src/include/cef_urlrequest.h | 29 +- src/include/cef_v8.h | 231 +- src/include/cef_values.h | 180 +- src/include/cef_waitable_event.h | 10 +- src/include/cef_web_plugin.h | 17 +- src/include/cef_x509_certificate.h | 42 +- src/include/cef_xml_reader.h | 60 +- src/include/cef_zip_reader.h | 25 +- src/include/internal/cef_export.h | 10 +- src/include/internal/cef_linux.h | 24 +- src/include/internal/cef_logging_internal.h | 2 + src/include/internal/cef_mac.h | 26 +- src/include/internal/cef_ptr.h | 10 +- src/include/internal/cef_string.h | 1 - src/include/internal/cef_string_list.h | 3 +- src/include/internal/cef_string_map.h | 7 +- src/include/internal/cef_string_multimap.h | 9 +- src/include/internal/cef_string_types.h | 72 +- src/include/internal/cef_string_wrappers.h | 128 +- src/include/internal/cef_thread_internal.h | 2 +- src/include/internal/cef_time.h | 2 +- src/include/internal/cef_types.h | 494 ++-- src/include/internal/cef_types_linux.h | 11 +- src/include/internal/cef_types_mac.h | 11 +- src/include/internal/cef_types_win.h | 15 +- src/include/internal/cef_types_wrappers.h | 323 +-- src/include/internal/cef_win.h | 35 +- .../cef_test_helpers.h} | 72 +- src/include/test/cef_translator_test.h | 265 +- src/include/views/cef_box_layout.h | 4 +- src/include/views/cef_browser_view.h | 4 +- src/include/views/cef_button.h | 12 +- src/include/views/cef_button_delegate.h | 4 +- src/include/views/cef_display.h | 16 +- src/include/views/cef_fill_layout.h | 3 +- src/include/views/cef_label_button.h | 23 +- src/include/views/cef_layout.h | 6 +- src/include/views/cef_menu_button.h | 4 +- src/include/views/cef_menu_button_delegate.h | 18 +- src/include/views/cef_panel.h | 28 +- src/include/views/cef_panel_delegate.h | 3 +- src/include/views/cef_scroll_view.h | 14 +- src/include/views/cef_textfield.h | 73 +- src/include/views/cef_textfield_delegate.h | 4 +- src/include/views/cef_view.h | 97 +- src/include/views/cef_view_delegate.h | 8 +- src/include/views/cef_window.h | 75 +- src/include/views/cef_window_delegate.h | 25 +- src/include/wrapper/cef_closure_task.h | 3 +- src/include/wrapper/cef_helpers.h | 26 +- src/include/wrapper/cef_message_router.h | 53 +- src/include/wrapper/cef_resource_manager.h | 34 +- .../wrapper/cef_stream_resource_handler.h | 3 +- src/include/wrapper/cef_xml_object.h | 7 +- src/include/wrapper/cef_zip_archive.h | 8 +- 145 files changed, 6190 insertions(+), 4829 deletions(-) rename src/include/{cef_geolocation.h => cef_accessibility_handler.h} (68%) create mode 100644 src/include/cef_extension.h create mode 100644 src/include/cef_extension_handler.h create mode 100644 src/include/cef_server.h rename src/include/{cef_geolocation_handler.h => test/cef_test_helpers.h} (50%) diff --git a/src/include/base/cef_atomic_ref_count.h b/src/include/base/cef_atomic_ref_count.h index bdbad6c9..4d677797 100644 --- a/src/include/base/cef_atomic_ref_count.h +++ b/src/include/base/cef_atomic_ref_count.h @@ -39,14 +39,49 @@ #define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ #pragma once -#if defined(BASE_ATOMIC_REF_COUNT_H_) -// Do nothing if the Chromium header has already been included. -// This can happen in cases where Chromium code is used directly by the -// client application. When using Chromium code directly always include -// the Chromium header first to avoid type conflicts. -#elif defined(USING_CHROMIUM_INCLUDES) +#if defined(USING_CHROMIUM_INCLUDES) // When building CEF include the Chromium header directly. #include "base/atomic_ref_count.h" + +// Used when declaring a base::AtomicRefCount value. This is an object type with +// Chromium headers. +#define ATOMIC_DECLARATION (0) + +// Maintaining compatibility with AtompicRefCount* functions that were removed +// from Chromium in http://crrev.com/ee96d561. +namespace base { + +// Increment a reference count by 1. +inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { + const_cast(ptr)->Increment(); +} + +// Decrement a reference count by 1 and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->Decrement(); +} + +// Return whether the reference count is one. If the reference count is used +// in the conventional way, a refrerence count of 1 implies that the current +// thread owns the reference and no other thread shares it. This call performs +// the test for a reference count of one, and performs the memory barrier +// needed for the owning thread to act on the object, knowing that it has +// exclusive access to the object. +inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->IsOne(); +} + +// Return whether the reference count is zero. With conventional object +// referencing counting, the object will be destroyed, so the reference count +// should never be zero. Hence this is generally used for a debug check. +inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->IsZero(); +} + +} // namespace base + #else // !USING_CHROMIUM_INCLUDES // The following is substantially similar to the Chromium implementation. // If the Chromium implementation diverges the below implementation should be @@ -56,14 +91,18 @@ // Annotations are not currently supported. #define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ -#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ +#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ + +// Used when declaring a base::AtomicRefCount value. This is an integer/ptr type +// with CEF headers. +#define ATOMIC_DECLARATION = 0 namespace base { typedef subtle::Atomic32 AtomicRefCount; // Increment a reference count by "increment", which must exceed 0. -inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, +inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr, AtomicRefCount increment) { subtle::NoBarrier_AtomicIncrement(ptr, increment); } @@ -72,7 +111,7 @@ inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, // and return whether the result is non-zero. // Insert barriers to ensure that state written before the reference count // became zero will be visible to a thread that has just made the count zero. -inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr, +inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr, AtomicRefCount decrement) { ANNOTATE_HAPPENS_BEFORE(ptr); bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0); @@ -83,14 +122,14 @@ inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr, } // Increment a reference count by 1. -inline void AtomicRefCountInc(volatile AtomicRefCount *ptr) { +inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { base::AtomicRefCountIncN(ptr, 1); } // Decrement a reference count by 1 and return whether the result is non-zero. // Insert barriers to ensure that state written before the reference count // became zero will be visible to a thread that has just made the count zero. -inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) { +inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { return base::AtomicRefCountDecN(ptr, 1); } @@ -100,7 +139,7 @@ inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) { // the test for a reference count of one, and performs the memory barrier // needed for the owning thread to act on the object, knowing that it has // exclusive access to the object. -inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) { +inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { bool res = (subtle::Acquire_Load(ptr) == 1); if (res) { ANNOTATE_HAPPENS_AFTER(ptr); @@ -111,7 +150,7 @@ inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) { // Return whether the reference count is zero. With conventional object // referencing counting, the object will be destroyed, so the reference count // should never be zero. Hence this is generally used for a debug check. -inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) { +inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { bool res = (subtle::Acquire_Load(ptr) == 0); if (res) { ANNOTATE_HAPPENS_AFTER(ptr); diff --git a/src/include/base/cef_atomicops.h b/src/include/base/cef_atomicops.h index ae74802f..96aebabf 100644 --- a/src/include/base/cef_atomicops.h +++ b/src/include/base/cef_atomicops.h @@ -122,8 +122,7 @@ Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value); // *ptr with the increment applied. This routine implies no memory barriers. Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); -Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, - Atomic32 increment); +Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); // These following lower-level operations are typically useful only to people // implementing higher-level synchronization operations like spinlocks, diff --git a/src/include/base/cef_basictypes.h b/src/include/base/cef_basictypes.h index 193e910f..e38f4f72 100644 --- a/src/include/base/cef_basictypes.h +++ b/src/include/base/cef_basictypes.h @@ -32,8 +32,8 @@ #define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ #pragma once -#include // For UINT_MAX -#include // For size_t +#include // For UINT_MAX +#include // For size_t #include "include/base/cef_build.h" @@ -43,34 +43,44 @@ // On Mac OS X, |long long| is used for 64-bit types for compatibility with // format macros even in the LP64 model. #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) -typedef long int64; // NOLINT(runtime/int) -typedef unsigned long uint64; // NOLINT(runtime/int) +typedef long int64; +typedef unsigned long uint64; #else -typedef long long int64; // NOLINT(runtime/int) -typedef unsigned long long uint64; // NOLINT(runtime/int) +typedef long long int64; +typedef unsigned long long uint64; #endif // TODO: Remove these type guards. These are to avoid conflicts with // obsolete/protypes.h in the Gecko SDK. #ifndef _INT32 #define _INT32 -typedef int int32; +typedef int int32; #endif // TODO: Remove these type guards. These are to avoid conflicts with // obsolete/protypes.h in the Gecko SDK. #ifndef _UINT32 #define _UINT32 -typedef unsigned int uint32; +typedef unsigned int uint32; +#endif + +#ifndef _INT16 +#define _INT16 +typedef short int16; +#endif + +#ifndef _UINT16 +#define _UINT16 +typedef unsigned short uint16; #endif // UTF-16 character type. // This should be kept synchronized with base/strings/string16.h #ifndef char16 #if defined(WCHAR_T_IS_UTF16) -typedef wchar_t char16; +typedef wchar_t char16; #elif defined(WCHAR_T_IS_UTF32) -typedef unsigned short char16; +typedef unsigned short char16; #endif #endif diff --git a/src/include/base/cef_bind.h b/src/include/base/cef_bind.h index 8ee406d7..77c9c557 100644 --- a/src/include/base/cef_bind.h +++ b/src/include/base/cef_bind.h @@ -89,34 +89,32 @@ namespace base { template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void()> - ::UnboundRunType> +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void()>::UnboundRunType> Bind(Functor functor) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; typedef cef_internal::BindState BindState; - return Callback( new BindState(cef_internal::MakeRunnable(functor))); } template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> Bind(Functor functor, const P1& p1) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -131,39 +129,39 @@ Bind(Functor functor, const P1& p1) { // invoked function will receive a reference to the stored copy of the // argument and not the original. COMPILE_ASSERT( - !(is_non_const_reference::value ), + !(is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); - typedef cef_internal::BindState::StorageType)> BindState; - + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)> + BindState; return Callback( new BindState(cef_internal::MakeRunnable(functor), p1)); } template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> Bind(Functor functor, const P1& p1, const P2& p2) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -179,43 +177,43 @@ Bind(Functor functor, const P1& p1, const P2& p2) { // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p2_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; return Callback( new BindState(cef_internal::MakeRunnable(functor), p1, p2)); } template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -231,18 +229,17 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value || + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); @@ -250,29 +247,30 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { p2_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p3_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; return Callback( new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3)); } template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -288,19 +286,18 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); @@ -310,33 +307,42 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { p3_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p4_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; return Callback( new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4)); } -template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> -Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, - const P5& p5) { +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -352,20 +358,19 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); @@ -377,35 +382,46 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, p4_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p5_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; return Callback( new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5)); } -template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> -Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, - const P5& p5, const P6& p6) { +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -421,21 +437,20 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); @@ -449,37 +464,50 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, p5_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p6_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - - - return Callback( - new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); } -template -base::Callback< - typename cef_internal::BindState< - typename cef_internal::FunctorTraits::RunnableType, - typename cef_internal::FunctorTraits::RunType, - void(typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> - ::UnboundRunType> -Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, - const P5& p5, const P6& p6, const P7& p7) { +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) { // Typedefs for how to store and run the functor. - typedef typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; typedef typename cef_internal::FunctorTraits::RunType RunType; // Use RunnableType::RunType instead of RunType above because our @@ -495,22 +523,21 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, // argument and not the original. COMPILE_ASSERT( !(is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value || - is_non_const_reference::value ), + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), do_not_bind_functions_with_nonconst_ref); // For methods, we need to be careful for parameter 1. We do not require // a scoped_refptr because BindState<> itself takes care of AddRef() for // methods. We also disallow binding of an array as the method's target // object. - COMPILE_ASSERT( - cef_internal::HasIsMethodTag::value || - !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, - p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || !is_array::value, first_bound_argument_to_method_cannot_be_array); @@ -526,19 +553,19 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4, p6_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, p7_is_refcounted_type_and_needs_scoped_refptr); - typedef cef_internal::BindState::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType, - typename cef_internal::CallbackParamTraits::StorageType)> BindState; - - - return Callback( - new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, - p7)); + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, p7)); } } // namespace base diff --git a/src/include/base/cef_bind_helpers.h b/src/include/base/cef_bind_helpers.h index dde1d0dc..2b4798b2 100644 --- a/src/include/base/cef_bind_helpers.h +++ b/src/include/base/cef_bind_helpers.h @@ -274,20 +274,20 @@ class SupportsAddRefAndRelease { // instantiate Base is made. We disable the warning for this definition. #if defined(OS_WIN) #pragma warning(push) -#pragma warning(disable:4624) +#pragma warning(disable : 4624) #endif - struct Base : public T, public BaseMixin { - }; + struct Base : public T, public BaseMixin {}; #if defined(OS_WIN) #pragma warning(pop) #endif - template struct Helper {}; + template + struct Helper {}; template static No& Check(Helper<&C::AddRef>*); - template + template static Yes& Check(...); public: @@ -297,22 +297,18 @@ class SupportsAddRefAndRelease { // Helpers to assert that arguments of a recounted type are bound with a // scoped_refptr. template -struct UnsafeBindtoRefCountedArgHelper : false_type { -}; +struct UnsafeBindtoRefCountedArgHelper : false_type {}; template struct UnsafeBindtoRefCountedArgHelper - : integral_constant::value> { -}; + : integral_constant::value> {}; template -struct UnsafeBindtoRefCountedArg : false_type { -}; +struct UnsafeBindtoRefCountedArg : false_type {}; template struct UnsafeBindtoRefCountedArg - : UnsafeBindtoRefCountedArgHelper::value, T> { -}; + : UnsafeBindtoRefCountedArgHelper::value, T> {}; template class HasIsMethodTag { @@ -334,6 +330,7 @@ class UnretainedWrapper { public: explicit UnretainedWrapper(T* o) : ptr_(o) {} T* get() const { return ptr_; } + private: T* ptr_; }; @@ -343,6 +340,7 @@ class ConstRefWrapper { public: explicit ConstRefWrapper(const T& o) : ptr_(&o) {} const T& get() const { return *ptr_; } + private: const T* ptr_; }; @@ -355,7 +353,7 @@ struct IgnoreResultHelper { }; template -struct IgnoreResultHelper > { +struct IgnoreResultHelper> { explicit IgnoreResultHelper(const Callback& functor) : functor_(functor) {} const Callback& functor_; @@ -409,8 +407,7 @@ class PassedWrapper { public: explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {} PassedWrapper(const PassedWrapper& other) - : is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) { - } + : is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {} T Pass() const { CHECK(is_valid_); is_valid_ = false; @@ -430,7 +427,7 @@ struct UnwrapTraits { }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef T* ForwardType; static ForwardType Unwrap(UnretainedWrapper unretained) { return unretained.get(); @@ -438,7 +435,7 @@ struct UnwrapTraits > { }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef const T& ForwardType; static ForwardType Unwrap(ConstRefWrapper const_ref) { return const_ref.get(); @@ -446,31 +443,27 @@ struct UnwrapTraits > { }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef T* ForwardType; static ForwardType Unwrap(const scoped_refptr& o) { return o.get(); } }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef const WeakPtr& ForwardType; static ForwardType Unwrap(const WeakPtr& o) { return o; } }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef T* ForwardType; - static ForwardType Unwrap(const OwnedWrapper& o) { - return o.get(); - } + static ForwardType Unwrap(const OwnedWrapper& o) { return o.get(); } }; template -struct UnwrapTraits > { +struct UnwrapTraits> { typedef T ForwardType; - static T Unwrap(PassedWrapper& o) { - return o.Pass(); - } + static T Unwrap(PassedWrapper& o) { return o.Pass(); } }; // Utility for handling different refcounting semantics in the Bind() @@ -505,7 +498,7 @@ struct MaybeRefcount { // No need to additionally AddRef() and Release() since we are storing a // scoped_refptr<> inside the storage object already. template -struct MaybeRefcount > { +struct MaybeRefcount> { static void AddRef(const scoped_refptr& o) {} static void Release(const scoped_refptr& o) {} }; @@ -526,10 +519,10 @@ template struct IsWeakMethod : public false_type {}; template -struct IsWeakMethod > : public true_type {}; +struct IsWeakMethod> : public true_type {}; template -struct IsWeakMethod > > : public true_type {}; +struct IsWeakMethod>> : public true_type {}; } // namespace cef_internal @@ -567,14 +560,14 @@ static inline cef_internal::IgnoreResultHelper IgnoreResult(T data) { } template -static inline cef_internal::IgnoreResultHelper > -IgnoreResult(const Callback& data) { - return cef_internal::IgnoreResultHelper >(data); +static inline cef_internal::IgnoreResultHelper> IgnoreResult( + const Callback& data) { + return cef_internal::IgnoreResultHelper>(data); } void DoNothing(); -template +template void DeletePointer(T* obj) { delete obj; } diff --git a/src/include/base/cef_build.h b/src/include/base/cef_build.h index 81ee851f..1e2065ce 100644 --- a/src/include/base/cef_build.h +++ b/src/include/base/cef_build.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - #ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_ #define CEF_INCLUDE_BASE_CEF_BUILD_H_ #pragma once @@ -116,12 +115,10 @@ // Type detection for wchar_t. #if defined(OS_WIN) #define WCHAR_T_IS_UTF16 -#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ - defined(__WCHAR_MAX__) && \ +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) #define WCHAR_T_IS_UTF32 -#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \ - defined(__WCHAR_MAX__) && \ +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to // compile in this mode (in particular, Chrome doesn't). This is intended for @@ -181,7 +178,7 @@ // Visual Studio 2010 and later support override. #define OVERRIDE override #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. #define OVERRIDE override #else @@ -191,10 +188,9 @@ // Check for C++11 template alias support which was added in VS2013 and GCC4.7. // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf -#if __cplusplus > 199711L || \ - (defined(_MSC_VER) && _MSC_VER >= 1800) || \ - (defined(__GNUC__) && \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) +#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) #define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT #endif diff --git a/src/include/base/cef_callback.h b/src/include/base/cef_callback.h index 611fba50..16e238a9 100644 --- a/src/include/base/cef_callback.h +++ b/src/include/base/cef_callback.h @@ -45,9 +45,9 @@ // If the Chromium implementation diverges the below implementation should be // updated to match. -#include "include/base/internal/cef_callback_internal.h" #include "include/base/cef_callback_forward.h" #include "include/base/cef_template_util.h" +#include "include/base/internal/cef_callback_internal.h" // NOTE: Header files that do not require the full definition of Callback or // Closure should #include "base/cef_callback_forward.h" instead of this file. @@ -407,21 +407,20 @@ class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -437,9 +436,7 @@ class Callback : public cef_internal::CallbackBase { } private: - typedef R(*PolymorphicInvoke)( - cef_internal::BindStateBase*); - + typedef R (*PolymorphicInvoke)(cef_internal::BindStateBase*); }; template @@ -447,21 +444,20 @@ class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -477,10 +473,9 @@ class Callback : public cef_internal::CallbackBase { } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType); }; template @@ -488,21 +483,20 @@ class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -520,11 +514,10 @@ class Callback : public cef_internal::CallbackBase { } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; template @@ -532,21 +525,20 @@ class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2, A3); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -566,12 +558,11 @@ class Callback : public cef_internal::CallbackBase { } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; template @@ -579,21 +570,20 @@ class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2, A3, A4); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -615,36 +605,38 @@ class Callback : public cef_internal::CallbackBase { } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; -template +template class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2, A3, A4, A5); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -660,45 +652,47 @@ class Callback : public cef_internal::CallbackBase { PolymorphicInvoke f = reinterpret_cast(polymorphic_invoke_); - return f(bind_state_.get(), cef_internal::CallbackForward(a1), - cef_internal::CallbackForward(a2), - cef_internal::CallbackForward(a3), - cef_internal::CallbackForward(a4), - cef_internal::CallbackForward(a5)); + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5)); } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; -template +template class Callback : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2, A3, A4, A5, A6); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -715,47 +709,51 @@ class Callback : public cef_internal::CallbackBase { PolymorphicInvoke f = reinterpret_cast(polymorphic_invoke_); - return f(bind_state_.get(), cef_internal::CallbackForward(a1), - cef_internal::CallbackForward(a2), - cef_internal::CallbackForward(a3), - cef_internal::CallbackForward(a4), - cef_internal::CallbackForward(a5), - cef_internal::CallbackForward(a6)); + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6)); } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; -template -class Callback : public cef_internal::CallbackBase { +template +class Callback + : public cef_internal::CallbackBase { public: typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); - Callback() : CallbackBase(NULL) { } + Callback() : CallbackBase(NULL) {} // Note that this constructor CANNOT be explicit, and that Bind() CANNOT // return the exact Callback<> type. See base/bind.h for details. template - Callback(cef_internal::BindState* bind_state) + Callback( + cef_internal::BindState* bind_state) : CallbackBase(bind_state) { - // Force the assignment to a local variable of PolymorphicInvoke // so the compiler will typecheck that the passed in Run() method has // the correct type. PolymorphicInvoke invoke_func = - &cef_internal::BindState - ::InvokerType::Run; + &cef_internal::BindState::InvokerType::Run; polymorphic_invoke_ = reinterpret_cast(invoke_func); } @@ -773,29 +771,25 @@ class Callback : public cef_internal::CallbackBas PolymorphicInvoke f = reinterpret_cast(polymorphic_invoke_); - return f(bind_state_.get(), cef_internal::CallbackForward(a1), - cef_internal::CallbackForward(a2), - cef_internal::CallbackForward(a3), - cef_internal::CallbackForward(a4), - cef_internal::CallbackForward(a5), - cef_internal::CallbackForward(a6), - cef_internal::CallbackForward(a7)); + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6), cef_internal::CallbackForward(a7)); } private: - typedef R(*PolymorphicInvoke)( + typedef R (*PolymorphicInvoke)( cef_internal::BindStateBase*, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType, - typename cef_internal::CallbackParamTraits::ForwardType); - + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); }; - // Syntactic sugar to make Callbacks easier to declare since it // will be used in a lot of APIs with delayed execution. typedef Callback Closure; diff --git a/src/include/base/cef_callback_list.h b/src/include/base/cef_callback_list.h index 73dd9f75..e0ef3665 100644 --- a/src/include/base/cef_callback_list.h +++ b/src/include/base/cef_callback_list.h @@ -48,12 +48,12 @@ #include #include "include/base/cef_basictypes.h" -#include "include/base/cef_callback.h" -#include "include/base/internal/cef_callback_internal.h" #include "include/base/cef_build.h" +#include "include/base/cef_callback.h" #include "include/base/cef_logging.h" #include "include/base/cef_macros.h" #include "include/base/cef_scoped_ptr.h" +#include "include/base/internal/cef_callback_internal.h" // OVERVIEW: // @@ -120,9 +120,7 @@ class CallbackListBase { public: Subscription(CallbackListBase* list, typename std::list::iterator iter) - : list_(list), - iter_(iter) { - } + : list_(list), iter_(iter) {} ~Subscription() { if (list_->active_iterator_count_) { @@ -167,14 +165,12 @@ class CallbackListBase { class Iterator { public: explicit Iterator(CallbackListBase* list) - : list_(list), - list_iter_(list_->callbacks_.begin()) { + : list_(list), list_iter_(list_->callbacks_.begin()) { ++list_->active_iterator_count_; } Iterator(const Iterator& iter) - : list_(iter.list_), - list_iter_(iter.list_iter_) { + : list_(iter.list_), list_iter_(iter.list_iter_) { ++list_->active_iterator_count_; } @@ -210,9 +206,7 @@ class CallbackListBase { // Returns an instance of a CallbackListBase::Iterator which can be used // to run callbacks. - Iterator GetIterator() { - return Iterator(this); - } + Iterator GetIterator() { return Iterator(this); } // Compact the list: remove any entries which were NULLed out during // iteration. @@ -242,11 +236,12 @@ class CallbackListBase { } // namespace cef_internal -template class CallbackList; +template +class CallbackList; template <> class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase> { public: typedef Callback CallbackType; @@ -267,7 +262,7 @@ class CallbackList template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase> { public: typedef Callback CallbackType; @@ -288,7 +283,7 @@ class CallbackList template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase> { public: typedef Callback CallbackType; @@ -310,7 +305,7 @@ class CallbackList template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase> { public: typedef Callback CallbackType; @@ -333,7 +328,7 @@ class CallbackList template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase> { public: typedef Callback CallbackType; @@ -357,7 +352,8 @@ class CallbackList template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase< + Callback> { public: typedef Callback CallbackType; @@ -380,11 +376,15 @@ class CallbackList DISALLOW_COPY_AND_ASSIGN(CallbackList); }; -template +template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase< + Callback> { public: typedef Callback CallbackType; @@ -408,11 +408,16 @@ class CallbackList DISALLOW_COPY_AND_ASSIGN(CallbackList); }; -template +template class CallbackList - : public cef_internal::CallbackListBase > { + : public cef_internal::CallbackListBase< + Callback> { public: typedef Callback CallbackType; diff --git a/src/include/base/cef_cancelable_callback.h b/src/include/base/cef_cancelable_callback.h index 8f5979eb..febce3a3 100644 --- a/src/include/base/cef_cancelable_callback.h +++ b/src/include/base/cef_cancelable_callback.h @@ -83,8 +83,8 @@ // updated to match. #include "include/base/cef_bind.h" -#include "include/base/cef_callback.h" #include "include/base/cef_build.h" +#include "include/base/cef_callback.h" #include "include/base/cef_logging.h" #include "include/base/cef_macros.h" #include "include/base/cef_weak_ptr.h" @@ -102,8 +102,7 @@ class CancelableCallback { // |callback| must not be null. explicit CancelableCallback(const base::Callback& callback) - : weak_factory_(this), - callback_(callback) { + : weak_factory_(this), callback_(callback) { DCHECK(!callback.is_null()); InitializeForwarder(); } @@ -118,9 +117,7 @@ class CancelableCallback { } // Returns true if the wrapped callback has been cancelled. - bool IsCancelled() const { - return callback_.is_null(); - } + bool IsCancelled() const { return callback_.is_null(); } // Sets |callback| as the closure that may be cancelled. |callback| may not // be null. Outstanding and any previously wrapped callbacks are cancelled. @@ -137,14 +134,10 @@ class CancelableCallback { } // Returns a callback that can be disabled by calling Cancel(). - const base::Callback& callback() const { - return forwarder_; - } + const base::Callback& callback() const { return forwarder_; } private: - void Forward() { - callback_.Run(); - } + void Forward() { callback_.Run(); } // Helper method to bind |forwarder_| using a weak pointer from // |weak_factory_|. @@ -154,7 +147,7 @@ class CancelableCallback { } // Used to ensure Forward() is not run when this object is destroyed. - base::WeakPtrFactory > weak_factory_; + base::WeakPtrFactory> weak_factory_; // The wrapper closure. base::Callback forwarder_; @@ -172,8 +165,7 @@ class CancelableCallback { // |callback| must not be null. explicit CancelableCallback(const base::Callback& callback) - : weak_factory_(this), - callback_(callback) { + : weak_factory_(this), callback_(callback) { DCHECK(!callback.is_null()); InitializeForwarder(); } @@ -188,9 +180,7 @@ class CancelableCallback { } // Returns true if the wrapped callback has been cancelled. - bool IsCancelled() const { - return callback_.is_null(); - } + bool IsCancelled() const { return callback_.is_null(); } // Sets |callback| as the closure that may be cancelled. |callback| may not // be null. Outstanding and any previously wrapped callbacks are cancelled. @@ -207,14 +197,10 @@ class CancelableCallback { } // Returns a callback that can be disabled by calling Cancel(). - const base::Callback& callback() const { - return forwarder_; - } + const base::Callback& callback() const { return forwarder_; } private: - void Forward(A1 a1) const { - callback_.Run(a1); - } + void Forward(A1 a1) const { callback_.Run(a1); } // Helper method to bind |forwarder_| using a weak pointer from // |weak_factory_|. @@ -224,7 +210,7 @@ class CancelableCallback { } // Used to ensure Forward() is not run when this object is destroyed. - base::WeakPtrFactory > weak_factory_; + base::WeakPtrFactory> weak_factory_; // The wrapper closure. base::Callback forwarder_; @@ -242,8 +228,7 @@ class CancelableCallback { // |callback| must not be null. explicit CancelableCallback(const base::Callback& callback) - : weak_factory_(this), - callback_(callback) { + : weak_factory_(this), callback_(callback) { DCHECK(!callback.is_null()); InitializeForwarder(); } @@ -258,9 +243,7 @@ class CancelableCallback { } // Returns true if the wrapped callback has been cancelled. - bool IsCancelled() const { - return callback_.is_null(); - } + bool IsCancelled() const { return callback_.is_null(); } // Sets |callback| as the closure that may be cancelled. |callback| may not // be null. Outstanding and any previously wrapped callbacks are cancelled. @@ -277,14 +260,10 @@ class CancelableCallback { } // Returns a callback that can be disabled by calling Cancel(). - const base::Callback& callback() const { - return forwarder_; - } + const base::Callback& callback() const { return forwarder_; } private: - void Forward(A1 a1, A2 a2) const { - callback_.Run(a1, a2); - } + void Forward(A1 a1, A2 a2) const { callback_.Run(a1, a2); } // Helper method to bind |forwarder_| using a weak pointer from // |weak_factory_|. @@ -294,7 +273,7 @@ class CancelableCallback { } // Used to ensure Forward() is not run when this object is destroyed. - base::WeakPtrFactory > weak_factory_; + base::WeakPtrFactory> weak_factory_; // The wrapper closure. base::Callback forwarder_; diff --git a/src/include/base/cef_lock.h b/src/include/base/cef_lock.h index 9f872bb5..6909bd6f 100644 --- a/src/include/base/cef_lock.h +++ b/src/include/base/cef_lock.h @@ -125,9 +125,7 @@ class AutoLock { public: struct AlreadyAcquired {}; - explicit AutoLock(Lock& lock) : lock_(lock) { - lock_.Acquire(); - } + explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) { lock_.AssertAcquired(); @@ -153,9 +151,7 @@ class AutoUnlock { lock_.Release(); } - ~AutoUnlock() { - lock_.Acquire(); - } + ~AutoUnlock() { lock_.Acquire(); } private: Lock& lock_; diff --git a/src/include/base/cef_logging.h b/src/include/base/cef_logging.h index 75e35d96..8d8bb889 100644 --- a/src/include/base/cef_logging.h +++ b/src/include/base/cef_logging.h @@ -158,9 +158,9 @@ // updated to match. #include -#include #include #include +#include #include "include/base/cef_build.h" #include "include/base/cef_macros.h" @@ -201,32 +201,27 @@ const LogSeverity LOG_DFATAL = LOG_FATAL; // A few definitions of macros that don't generate much code. These are used // by LOG() and LOG_IF, etc. Since these are used all over our code, it's // better to have compact code for these operations. -#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ - cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO , \ - ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ - cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING , \ - ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ - cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR , \ - ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ - cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL , \ - ##__VA_ARGS__) -#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ - cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL , \ - ##__VA_ARGS__) - -#define COMPACT_GOOGLE_LOG_INFO \ - COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) -#define COMPACT_GOOGLE_LOG_WARNING \ - COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) -#define COMPACT_GOOGLE_LOG_ERROR \ - COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) -#define COMPACT_GOOGLE_LOG_FATAL \ - COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) -#define COMPACT_GOOGLE_LOG_DFATAL \ - COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage) +#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL, \ + ##__VA_ARGS__) + +#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) +#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) +#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) +#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) +#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage) #if defined(OS_WIN) // wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets @@ -236,7 +231,7 @@ const LogSeverity LOG_DFATAL = LOG_FATAL; // the Windows SDK does for consistency. #define ERROR 0 #define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \ - COMPACT_GOOGLE_LOG_EX_ERROR(ClassName , ##__VA_ARGS__) + COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR // Needed for LOG_IS_ON(ERROR). const LogSeverity LOG_0 = LOG_ERROR; @@ -246,7 +241,7 @@ const LogSeverity LOG_0 = LOG_ERROR; // LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will // always fire if they fail. #define LOG_IS_ON(severity) \ - ((::cef::logging::LOG_ ## severity) >= ::cef::logging::GetMinLogLevel()) + ((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel()) // We can't do any caching tricks with VLOG_IS_ON() like the // google-glog version since it requires GCC extensions. This means @@ -257,8 +252,8 @@ const LogSeverity LOG_0 = LOG_ERROR; // Helper macro which avoids evaluating the arguments to a stream if // the condition doesn't hold. -#define LAZY_STREAM(stream, condition) \ - !(condition) ? (void) 0 : ::cef::logging::LogMessageVoidify() & (stream) +#define LAZY_STREAM(stream, condition) \ + !(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream) // We use the preprocessor's merging operator, "##", so that, e.g., // LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny @@ -268,7 +263,7 @@ const LogSeverity LOG_0 = LOG_ERROR; // impossible to stream something like a string directly to an unnamed // ostream. We employ a neat hack by calling the stream() member // function of LogMessage which seems to avoid the problem. -#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream() +#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream() #define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity)) #define LOG_IF(severity, condition) \ @@ -286,16 +281,18 @@ const LogSeverity LOG_0 = LOG_ERROR; #define VLOG_IF(verbose_level, condition) \ LAZY_STREAM(VLOG_STREAM(verbose_level), \ - VLOG_IS_ON(verbose_level) && (condition)) + VLOG_IS_ON(verbose_level) && (condition)) -#if defined (OS_WIN) -#define VPLOG_STREAM(verbose_level) \ - cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \ - ::cef::logging::GetLastSystemErrorCode()).stream() +#if defined(OS_WIN) +#define VPLOG_STREAM(verbose_level) \ + cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() #elif defined(OS_POSIX) -#define VPLOG_STREAM(verbose_level) \ - cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \ - ::cef::logging::GetLastSystemErrorCode()).stream() +#define VPLOG_STREAM(verbose_level) \ + cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() #endif #define VPLOG(verbose_level) \ @@ -303,34 +300,35 @@ const LogSeverity LOG_0 = LOG_ERROR; #define VPLOG_IF(verbose_level, condition) \ LAZY_STREAM(VPLOG_STREAM(verbose_level), \ - VLOG_IS_ON(verbose_level) && (condition)) + VLOG_IS_ON(verbose_level) && (condition)) // TODO(akalin): Add more VLOG variants, e.g. VPLOG. -#define LOG_ASSERT(condition) \ +#define LOG_ASSERT(condition) \ LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " #define SYSLOG_ASSERT(condition) \ SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " #if defined(OS_WIN) -#define PLOG_STREAM(severity) \ - COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \ - ::cef::logging::GetLastSystemErrorCode()).stream() +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() #elif defined(OS_POSIX) -#define PLOG_STREAM(severity) \ - COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ - ::cef::logging::GetLastSystemErrorCode()).stream() +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() #endif -#define PLOG(severity) \ - LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) +#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) #define PLOG_IF(severity, condition) \ LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) // The actual stream used isn't important. -#define EAT_STREAM_PARAMETERS \ - true ? (void) 0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL) +#define EAT_STREAM_PARAMETERS \ + true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL) // CHECK dies with a fatal error if condition is not true. It is *not* // controlled by NDEBUG, so the check will be executed regardless of @@ -341,28 +339,27 @@ const LogSeverity LOG_0 = LOG_ERROR; #define CHECK(condition) \ LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \ - << "Check failed: " #condition ". " + << "Check failed: " #condition ". " -#define PCHECK(condition) \ +#define PCHECK(condition) \ LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \ - << "Check failed: " #condition ". " + << "Check failed: " #condition ". " // Helper macro for binary operators. // Don't use this macro directly in your code, use CHECK_EQ et al below. // // TODO(akalin): Rewrite this so that constructs like if (...) // CHECK_EQ(...) else { ... } work properly. -#define CHECK_OP(name, op, val1, val2) \ - if (std::string* _result = \ - cef::logging::Check##name##Impl((val1), (val2), \ - #val1 " " #op " " #val2)) \ - cef::logging::LogMessage(__FILE__, __LINE__, _result).stream() +#define CHECK_OP(name, op, val1, val2) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, _result).stream() // Build the error message string. This is separate from the "Impl" // function template because it is not performance critical and so can // be out of line, while the "Impl" code should be inline. Caller // takes ownership of the returned string. -template +template std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { std::ostringstream ss; ss << names << " (" << v1 << " vs. " << v2 << ")"; @@ -374,51 +371,60 @@ std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { #if !defined(COMPILER_MSVC) // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated // in logging.cc. -extern template std::string* MakeCheckOpString( - const int&, const int&, const char* names); -extern template -std::string* MakeCheckOpString( - const unsigned long&, const unsigned long&, const char* names); -extern template -std::string* MakeCheckOpString( - const unsigned long&, const unsigned int&, const char* names); -extern template -std::string* MakeCheckOpString( - const unsigned int&, const unsigned long&, const char* names); -extern template -std::string* MakeCheckOpString( - const std::string&, const std::string&, const char* name); +extern template std::string* MakeCheckOpString(const int&, + const int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned int&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const std::string&, + const std::string&, + const char* name); #endif // Helper functions for CHECK_OP macro. // The (int, int) specialization works around the issue that the compiler // will not instantiate the template version of the function on values of // unnamed enum type - see comment below. -#define DEFINE_CHECK_OP_IMPL(name, op) \ - template \ - inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ - const char* names) { \ - if (v1 op v2) return NULL; \ - else return MakeCheckOpString(v1, v2, names); \ - } \ +#define DEFINE_CHECK_OP_IMPL(name, op) \ + template \ + inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ + const char* names) { \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ + } \ inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ - if (v1 op v2) return NULL; \ - else return MakeCheckOpString(v1, v2, names); \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ } DEFINE_CHECK_OP_IMPL(EQ, ==) DEFINE_CHECK_OP_IMPL(NE, !=) DEFINE_CHECK_OP_IMPL(LE, <=) -DEFINE_CHECK_OP_IMPL(LT, < ) +DEFINE_CHECK_OP_IMPL(LT, <) DEFINE_CHECK_OP_IMPL(GE, >=) -DEFINE_CHECK_OP_IMPL(GT, > ) +DEFINE_CHECK_OP_IMPL(GT, >) #undef DEFINE_CHECK_OP_IMPL #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) #define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) #define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) -#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) +#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2) #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) -#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) +#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2) #if defined(NDEBUG) #define ENABLE_DLOG 0 @@ -471,11 +477,9 @@ enum { DEBUG_MODE = ENABLE_DLOG }; #undef ENABLE_DLOG -#define DLOG(severity) \ - LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) +#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) -#define DPLOG(severity) \ - LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) +#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) @@ -486,7 +490,7 @@ enum { DEBUG_MODE = ENABLE_DLOG }; #if DCHECK_IS_ON() #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ - COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__) + COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL const LogSeverity LOG_DCHECK = LOG_FATAL; @@ -494,7 +498,7 @@ const LogSeverity LOG_DCHECK = LOG_FATAL; // These are just dummy values. #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ - COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) + COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__) #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO const LogSeverity LOG_DCHECK = LOG_INFO; @@ -505,22 +509,23 @@ const LogSeverity LOG_DCHECK = LOG_INFO; // variable warnings if the only use of a variable is in a DCHECK. // This behavior is different from DLOG_IF et al. -#define DCHECK(condition) \ - LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ +#define DCHECK(condition) \ + LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ << "Check failed: " #condition ". " -#define DPCHECK(condition) \ - LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ +#define DPCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ << "Check failed: " #condition ". " // Helper macro for binary operators. // Don't use this macro directly in your code, use DCHECK_EQ et al below. -#define DCHECK_OP(name, op, val1, val2) \ - if (DCHECK_IS_ON()) \ - if (std::string* _result = cef::logging::Check##name##Impl( \ - (val1), (val2), #val1 " " #op " " #val2)) \ - cef::logging::LogMessage(__FILE__, __LINE__, \ - ::cef::logging::LOG_DCHECK, _result).stream() +#define DCHECK_OP(name, op, val1, val2) \ + if (DCHECK_IS_ON()) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \ + _result) \ + .stream() // Equality/Inequality checks - compare two values, and log a // LOG_DCHECK message including the two values when the result is not @@ -544,13 +549,13 @@ const LogSeverity LOG_DCHECK = LOG_INFO; #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) -#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) +#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2) #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) -#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) +#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2) #if defined(NDEBUG) && defined(OS_CHROMEOS) -#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \ - __FUNCTION__ << ". " +#define NOTREACHED() \ + LOG(ERROR) << "NOTREACHED() hit in " << __FUNCTION__ << ". " #else #define NOTREACHED() DCHECK(false) #endif @@ -577,7 +582,9 @@ class LogMessage { LogMessage(const char* file, int line, std::string* result); // Used for DCHECK_EQ(), etc. Takes ownership of the given string. - LogMessage(const char* file, int line, LogSeverity severity, + LogMessage(const char* file, + int line, + LogSeverity severity, std::string* result); ~LogMessage(); @@ -617,7 +624,7 @@ class LogMessage { // A non-macro interface to the log facility; (useful // when the logging level is not a compile-time constant). -inline void LogAtLevel(int const log_level, std::string const &msg) { +inline void LogAtLevel(int const log_level, std::string const& msg) { LogMessage(__FILE__, __LINE__, log_level).stream() << msg; } @@ -626,10 +633,10 @@ inline void LogAtLevel(int const log_level, std::string const &msg) { // is not used" and "statement has no effect". class LogMessageVoidify { public: - LogMessageVoidify() { } + LogMessageVoidify() {} // This has to be an operator with a precedence lower than << but // higher than ?: - void operator&(std::ostream&) { } + void operator&(std::ostream&) {} }; #if defined(OS_WIN) @@ -739,12 +746,13 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { #elif NOTIMPLEMENTED_POLICY == 4 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG #elif NOTIMPLEMENTED_POLICY == 5 -#define NOTIMPLEMENTED() do {\ - static bool logged_once = false;\ - LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ - logged_once = true;\ -} while(0);\ -EAT_STREAM_PARAMETERS +#define NOTIMPLEMENTED() \ + do { \ + static bool logged_once = false; \ + LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \ + logged_once = true; \ + } while (0); \ + EAT_STREAM_PARAMETERS #endif #endif // !USING_CHROMIUM_INCLUDES diff --git a/src/include/base/cef_macros.h b/src/include/base/cef_macros.h index df3f9b7c..e714529c 100644 --- a/src/include/base/cef_macros.h +++ b/src/include/base/cef_macros.h @@ -41,7 +41,7 @@ // If the Chromium implementation diverges the below implementation should be // updated to match. -#include // For size_t. +#include // For size_t. #include "include/base/cef_build.h" // For COMPILER_MSVC #if !defined(arraysize) @@ -126,14 +126,13 @@ char (&ArraySizeHelper(const T (&array)[N]))[N]; namespace cef { template -struct CompileAssert { -}; +struct CompileAssert {}; } // namespace cef -#define COMPILE_ASSERT(expr, msg) \ - typedef cef::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] \ - ALLOW_UNUSED_TYPE +#define COMPILE_ASSERT(expr, msg) \ + typedef cef::CompileAssert<(bool(expr))> \ + msg[bool(expr) ? 1 : -1] ALLOW_UNUSED_TYPE // Implementation details of COMPILE_ASSERT: // @@ -182,13 +181,12 @@ struct CompileAssert { #endif // !USING_CHROMIUM_INCLUDES -#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST) -#if defined(COMPILER_MSVC) +#if !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) // MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. // The warning remains disabled until popped by MSVC_POP_WARNING. -#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ - __pragma(warning(disable:n)) +#define MSVC_PUSH_DISABLE_WARNING(n) \ + __pragma(warning(push)) __pragma(warning(disable : n)) // MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level // remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all @@ -198,6 +196,10 @@ struct CompileAssert { // Pop effects of innermost MSVC_PUSH_* macro. #define MSVC_POP_WARNING() __pragma(warning(pop)) +#endif // !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) + +#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST) +#if defined(COMPILER_MSVC) // Allows |this| to be passed as an argument in constructor initializer lists. // This uses push/pop instead of the seemingly simpler suppress feature to avoid // having the warning be disabled for more than just |code|. @@ -207,13 +209,11 @@ struct CompileAssert { // // Compiler warning C4355: 'this': used in base member initializer list: // http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx -#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ - code \ - MSVC_POP_WARNING() +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) \ + MSVC_PUSH_DISABLE_WARNING(4355) \ + code MSVC_POP_WARNING() #else // !COMPILER_MSVC - #define ALLOW_THIS_IN_INITIALIZER_LIST(code) code - #endif // !COMPILER_MSVC #endif // !ALLOW_THIS_IN_INITIALIZER_LIST diff --git a/src/include/base/cef_move.h b/src/include/base/cef_move.h index 3c3c4913..da47d2d3 100644 --- a/src/include/base/cef_move.h +++ b/src/include/base/cef_move.h @@ -240,20 +240,22 @@ // // The workaround is to explicitly declare your copy constructor. // -#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \ - private: \ - struct rvalue_type { \ +#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \ + private: \ + struct rvalue_type { \ explicit rvalue_type(type* object) : object(object) {} \ - type* object; \ - }; \ - type(type&); \ - void operator=(type&); \ - public: \ - operator rvalue_type() { return rvalue_type(this); } \ - type Pass() { return type(rvalue_type(this)); } \ - typedef void MoveOnlyTypeForCPP03; \ + type* object; \ + }; \ + type(type&); \ + void operator=(type&); \ + \ + public: \ + operator rvalue_type() { return rvalue_type(this); } \ + type Pass() { return type(rvalue_type(this)); } \ + typedef void MoveOnlyTypeForCPP03; \ + \ private: - + #endif // !USING_CHROMIUM_INCLUDES #endif // CEF_INCLUDE_BASE_CEF_MOVE_H_ diff --git a/src/include/base/cef_platform_thread.h b/src/include/base/cef_platform_thread.h index 91611360..d3fdd798 100644 --- a/src/include/base/cef_platform_thread.h +++ b/src/include/base/cef_platform_thread.h @@ -69,21 +69,14 @@ class PlatformThreadRef { public: typedef cef_platform_thread_handle_t RefType; - PlatformThreadRef() - : id_(0) { - } + PlatformThreadRef() : id_(0) {} - explicit PlatformThreadRef(RefType id) - : id_(id) { - } + explicit PlatformThreadRef(RefType id) : id_(id) {} - bool operator==(PlatformThreadRef other) const { - return id_ == other.id_; - } + bool operator==(PlatformThreadRef other) const { return id_ == other.id_; } + + bool is_null() const { return id_ == 0; } - bool is_null() const { - return id_ == 0; - } private: RefType id_; }; diff --git a/src/include/base/cef_ref_counted.h b/src/include/base/cef_ref_counted.h index 61d4de68..480b1ce9 100644 --- a/src/include/base/cef_ref_counted.h +++ b/src/include/base/cef_ref_counted.h @@ -64,43 +64,43 @@ class RefCountedBase { protected: RefCountedBase() : ref_count_(0) - #if DCHECK_IS_ON() - , in_dtor_(false) - #endif - { +#if DCHECK_IS_ON() + , + in_dtor_(false) +#endif + { } ~RefCountedBase() { - #if DCHECK_IS_ON() +#if DCHECK_IS_ON() DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; - #endif +#endif } - void AddRef() const { - // TODO(maruel): Add back once it doesn't assert 500 times/sec. - // Current thread books the critical section "AddRelease" - // without release it. - // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); - #if DCHECK_IS_ON() +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() DCHECK(!in_dtor_); - #endif +#endif ++ref_count_; } // Returns true if the object should self-delete. bool Release() const { - // TODO(maruel): Add back once it doesn't assert 500 times/sec. - // Current thread books the critical section "AddRelease" - // without release it. - // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); - #if DCHECK_IS_ON() +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() DCHECK(!in_dtor_); - #endif +#endif if (--ref_count_ == 0) { - #if DCHECK_IS_ON() +#if DCHECK_IS_ON() in_dtor_ = true; - #endif +#endif return true; } return false; @@ -160,9 +160,7 @@ class RefCounted : public cef_subtle::RefCountedBase { public: RefCounted() {} - void AddRef() const { - cef_subtle::RefCountedBase::AddRef(); - } + void AddRef() const { cef_subtle::RefCountedBase::AddRef(); } void Release() const { if (cef_subtle::RefCountedBase::Release()) { @@ -178,18 +176,19 @@ class RefCounted : public cef_subtle::RefCountedBase { }; // Forward declaration. -template class RefCountedThreadSafe; +template +class RefCountedThreadSafe; // Default traits for RefCountedThreadSafe. Deletes the object when its ref // count reaches 0. Overload to delete it on a different thread etc. -template +template struct DefaultRefCountedThreadSafeTraits { static void Destruct(const T* x) { // Delete through RefCountedThreadSafe to make child classes only need to be // friend with RefCountedThreadSafe instead of this struct, which is an // implementation detail. - RefCountedThreadSafe::DeleteInternal(x); + RefCountedThreadSafe::DeleteInternal( + x); } }; @@ -205,14 +204,12 @@ struct DefaultRefCountedThreadSafeTraits { // private: // friend class base::RefCountedThreadSafe; // ~MyFoo(); -template > +template > class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase { public: RefCountedThreadSafe() {} - void AddRef() const { - cef_subtle::RefCountedThreadSafeBase::AddRef(); - } + void AddRef() const { cef_subtle::RefCountedThreadSafeBase::AddRef(); } void Release() const { if (cef_subtle::RefCountedThreadSafeBase::Release()) { @@ -234,9 +231,9 @@ class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase { // A thread-safe wrapper for some piece of data so we can place other // things in scoped_refptrs<>. // -template +template class RefCountedData - : public base::RefCountedThreadSafe< base::RefCountedData > { + : public base::RefCountedThreadSafe> { public: RefCountedData() : data() {} RefCountedData(const T& in_value) : data(in_value) {} @@ -244,7 +241,7 @@ class RefCountedData T data; private: - friend class base::RefCountedThreadSafe >; + friend class base::RefCountedThreadSafe>; ~RefCountedData() {} }; @@ -303,8 +300,7 @@ class scoped_refptr { public: typedef T element_type; - scoped_refptr() : ptr_(NULL) { - } + scoped_refptr() : ptr_(NULL) {} scoped_refptr(T* p) : ptr_(p) { if (ptr_) @@ -364,9 +360,7 @@ class scoped_refptr { *pp = p; } - void swap(scoped_refptr& r) { - swap(&r.ptr_); - } + void swap(scoped_refptr& r) { swap(&r.ptr_); } protected: T* ptr_; diff --git a/src/include/base/cef_scoped_ptr.h b/src/include/base/cef_scoped_ptr.h index 56355897..eb9e0e29 100644 --- a/src/include/base/cef_scoped_ptr.h +++ b/src/include/base/cef_scoped_ptr.h @@ -154,7 +154,8 @@ class RefCountedThreadSafeBase; template struct DefaultDeleter { DefaultDeleter() {} - template DefaultDeleter(const DefaultDeleter& other) { + template + DefaultDeleter(const DefaultDeleter& other) { // IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor // if U* is implicitly convertible to T* and U is not an array type. // @@ -194,7 +195,8 @@ struct DefaultDeleter { // References: // C++98 [expr.delete]p3 // http://cplusplus.github.com/LWG/lwg-defects.html#938 - template void operator()(U* array) const; + template + void operator()(U* array) const; }; template @@ -209,18 +211,18 @@ struct DefaultDeleter { // scoped_ptr foo_ptr( // static_cast(malloc(sizeof(int)))); struct FreeDeleter { - inline void operator()(void* ptr) const { - free(ptr); - } + inline void operator()(void* ptr) const { free(ptr); } }; namespace cef_internal { -template struct IsNotRefCounted { +template +struct IsNotRefCounted { enum { - value = !base::is_convertible::value && - !base::is_convertible:: - value + value = + !base::is_convertible::value && + !base::is_convertible::value }; }; @@ -229,7 +231,7 @@ template struct IsNotRefCounted { template class scoped_ptr_impl { public: - explicit scoped_ptr_impl(T* p) : data_(p) { } + explicit scoped_ptr_impl(T* p) : data_(p) {} // Initializer for deleters that have data parameters. scoped_ptr_impl(T* p, const D& d) : data_(p, d) {} @@ -309,7 +311,8 @@ class scoped_ptr_impl { private: // Needed to allow type-converting constructor. - template friend class scoped_ptr_impl; + template + friend class scoped_ptr_impl; // Use the empty base class optimization to allow us to have a D // member, while avoiding any space overhead for it when D is an @@ -346,7 +349,7 @@ class scoped_ptr_impl { // unique_ptr<> features. Known deficiencies include not supporting move-only // deleteres, function pointers as deleters, and deleters with reference // types. -template > +template > class scoped_ptr { MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue) @@ -359,13 +362,13 @@ class scoped_ptr { typedef D deleter_type; // Constructor. Defaults to initializing with NULL. - scoped_ptr() : impl_(NULL) { } + scoped_ptr() : impl_(NULL) {} // Constructor. Takes ownership of p. - explicit scoped_ptr(element_type* p) : impl_(p) { } + explicit scoped_ptr(element_type* p) : impl_(p) {} // Constructor. Allows initialization of a stateful deleter. - scoped_ptr(element_type* p, const D& d) : impl_(p, d) { } + scoped_ptr(element_type* p, const D& d) : impl_(p, d) {} // Constructor. Allows construction from a scoped_ptr rvalue for a // convertible type and deleter. @@ -383,7 +386,7 @@ class scoped_ptr { } // Constructor. Move constructor for C++03 move emulation of this type. - scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { } + scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {} // operator=. Allows assignment from a scoped_ptr rvalue for a convertible // type and deleter. @@ -412,7 +415,7 @@ class scoped_ptr { assert(impl_.get() != NULL); return *impl_.get(); } - element_type* operator->() const { + element_type* operator->() const { assert(impl_.get() != NULL); return impl_.get(); } @@ -443,18 +446,14 @@ class scoped_ptr { bool operator!=(const element_type* p) const { return impl_.get() != p; } // Swap two scoped pointers. - void swap(scoped_ptr& p2) { - impl_.swap(p2.impl_); - } + void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); } // Release a pointer. // The return value is the current pointer held by this object. // If this object holds a NULL pointer, the return value is NULL. // After this operation, this object will hold a NULL pointer, // and will not own the object any more. - element_type* release() WARN_UNUSED_RESULT { - return impl_.release(); - } + element_type* release() WARN_UNUSED_RESULT { return impl_.release(); } // C++98 doesn't support functions templates with default parameters which // makes it hard to write a PassAs() that understands converting the deleter @@ -469,7 +468,8 @@ class scoped_ptr { private: // Needed to reach into |impl_| in the constructor. - template friend class scoped_ptr; + template + friend class scoped_ptr; base::cef_internal::scoped_ptr_impl impl_; // Forbidden for API compatibility with std::unique_ptr. @@ -479,8 +479,10 @@ class scoped_ptr { // doesn't make sense, and if U == T, it still doesn't make sense // because you should never have the same object owned by two different // scoped_ptrs. - template bool operator==(scoped_ptr const& p2) const; - template bool operator!=(scoped_ptr const& p2) const; + template + bool operator==(scoped_ptr const& p2) const; + template + bool operator!=(scoped_ptr const& p2) const; }; template @@ -493,7 +495,7 @@ class scoped_ptr { typedef D deleter_type; // Constructor. Defaults to initializing with NULL. - scoped_ptr() : impl_(NULL) { } + scoped_ptr() : impl_(NULL) {} // Constructor. Stores the given array. Note that the argument's type // must exactly match T*. In particular: @@ -511,10 +513,10 @@ class scoped_ptr { // to work around this may use implicit_cast(). // However, because of the first bullet in this comment, users MUST // NOT use implicit_cast() to upcast the static type of the array. - explicit scoped_ptr(element_type* array) : impl_(array) { } + explicit scoped_ptr(element_type* array) : impl_(array) {} // Constructor. Move constructor for C++03 move emulation of this type. - scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { } + scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {} // operator=. Move operator= for C++03 move emulation of this type. scoped_ptr& operator=(RValue rhs) { @@ -553,18 +555,14 @@ class scoped_ptr { bool operator!=(element_type* array) const { return impl_.get() != array; } // Swap two scoped pointers. - void swap(scoped_ptr& p2) { - impl_.swap(p2.impl_); - } + void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); } // Release a pointer. // The return value is the current pointer held by this object. // If this object holds a NULL pointer, the return value is NULL. // After this operation, this object will hold a NULL pointer, // and will not own the object any more. - element_type* release() WARN_UNUSED_RESULT { - return impl_.release(); - } + element_type* release() WARN_UNUSED_RESULT { return impl_.release(); } private: // Force element_type to be a complete type. @@ -578,20 +576,24 @@ class scoped_ptr { // private and has no definition. This is disabled because it is not safe to // call delete[] on an array whose static type does not match its dynamic // type. - template explicit scoped_ptr(U* array); + template + explicit scoped_ptr(U* array); explicit scoped_ptr(int disallow_construction_from_null); // Disable reset() from any type other than element_type*, for the same // reasons as the constructor above. - template void reset(U* array); + template + void reset(U* array); void reset(int disallow_reset_from_null); // Forbid comparison of scoped_ptr types. If U != T, it totally // doesn't make sense, and if U == T, it still doesn't make sense // because you should never have the same object owned by two different // scoped_ptrs. - template bool operator==(scoped_ptr const& p2) const; - template bool operator!=(scoped_ptr const& p2) const; + template + bool operator==(scoped_ptr const& p2) const; + template + bool operator!=(scoped_ptr const& p2) const; }; // Free functions diff --git a/src/include/base/cef_string16.h b/src/include/base/cef_string16.h index 51760f43..42756407 100644 --- a/src/include/base/cef_string16.h +++ b/src/include/base/cef_string16.h @@ -112,26 +112,19 @@ struct string16_char_traits { typedef mbstate_t state_type; typedef std::fpos pos_type; - static void assign(char_type& c1, const char_type& c2) { - c1 = c2; - } + static void assign(char_type& c1, const char_type& c2) { c1 = c2; } - static bool eq(const char_type& c1, const char_type& c2) { - return c1 == c2; - } - static bool lt(const char_type& c1, const char_type& c2) { - return c1 < c2; - } + static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; } + static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; } static int compare(const char_type* s1, const char_type* s2, size_t n) { return c16memcmp(s1, s2, n); } - static size_t length(const char_type* s) { - return c16len(s); - } + static size_t length(const char_type* s) { return c16len(s); } - static const char_type* find(const char_type* s, size_t n, + static const char_type* find(const char_type* s, + size_t n, const char_type& a) { return c16memchr(s, a, n); } @@ -152,21 +145,15 @@ struct string16_char_traits { return eq_int_type(c, eof()) ? 0 : c; } - static char_type to_char_type(const int_type& c) { - return char_type(c); - } + static char_type to_char_type(const int_type& c) { return char_type(c); } - static int_type to_int_type(const char_type& c) { - return int_type(c); - } + static int_type to_int_type(const char_type& c) { return int_type(c); } static bool eq_int_type(const int_type& c1, const int_type& c2) { return c1 == c2; } - static int_type eof() { - return static_cast(EOF); - } + static int_type eof() { return static_cast(EOF); } }; typedef std::basic_string string16; @@ -217,8 +204,8 @@ extern void PrintTo(const string16& str, std::ostream* out); // // TODO(mark): File this bug with Apple and update this note with a bug number. -extern template -class std::basic_string; +extern template class std::basic_string; #endif // WCHAR_T_IS_UTF32 diff --git a/src/include/base/cef_template_util.h b/src/include/base/cef_template_util.h index 098bf463..38fa5839 100644 --- a/src/include/base/cef_template_util.h +++ b/src/include/base/cef_template_util.h @@ -53,70 +53,92 @@ namespace base { // template definitions from tr1 -template +template struct integral_constant { static const T value = v; typedef T value_type; typedef integral_constant type; }; -template const T integral_constant::value; +template +const T integral_constant::value; typedef integral_constant true_type; typedef integral_constant false_type; -template struct is_pointer : false_type {}; -template struct is_pointer : true_type {}; +template +struct is_pointer : false_type {}; +template +struct is_pointer : true_type {}; // Member function pointer detection up to four params. Add more as needed // below. This is built-in to C++ 11, and we can remove this when we switch. -template +template struct is_member_function_pointer : false_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; template -struct is_member_function_pointer : true_type {}; +struct is_member_function_pointer : true_type {}; -template -struct is_member_function_pointer : true_type {}; -template : true_type {}; +template -struct is_member_function_pointer : true_type {}; - - -template struct is_same : public false_type {}; -template struct is_same : true_type {}; - -template struct is_array : public false_type {}; -template struct is_array : public true_type {}; -template struct is_array : public true_type {}; - -template struct is_non_const_reference : false_type {}; -template struct is_non_const_reference : true_type {}; -template struct is_non_const_reference : false_type {}; - -template struct is_const : false_type {}; -template struct is_const : true_type {}; - -template struct is_void : false_type {}; -template <> struct is_void : true_type {}; +struct is_member_function_pointer : true_type {}; + +template +struct is_same : public false_type {}; +template +struct is_same : true_type {}; + +template +struct is_array : public false_type {}; +template +struct is_array : public true_type {}; +template +struct is_array : public true_type {}; + +template +struct is_non_const_reference : false_type {}; +template +struct is_non_const_reference : true_type {}; +template +struct is_non_const_reference : false_type {}; + +template +struct is_const : false_type {}; +template +struct is_const : true_type {}; + +template +struct is_void : false_type {}; +template <> +struct is_void : true_type {}; namespace cef_internal { @@ -152,7 +174,7 @@ struct ConvertHelper { // is_class type_trait implementation. struct IsClassHelper { template - static YesType Test(void(C::*)(void)); + static YesType Test(void (C::*)(void)); template static NoType Test(...); @@ -168,22 +190,22 @@ template struct is_convertible : integral_constant( - cef_internal::ConvertHelper::Create())) == - sizeof(cef_internal::YesType)> { -}; + cef_internal::ConvertHelper::Create())) == + sizeof(cef_internal::YesType)> {}; template struct is_class : integral_constant(0)) == - sizeof(cef_internal::YesType)> { -}; + sizeof(cef_internal::YesType)> {}; -template +template struct enable_if {}; -template -struct enable_if { typedef T type; }; +template +struct enable_if { + typedef T type; +}; } // namespace base diff --git a/src/include/base/cef_thread_checker.h b/src/include/base/cef_thread_checker.h index 42bac7fc..e48c8d03 100644 --- a/src/include/base/cef_thread_checker.h +++ b/src/include/base/cef_thread_checker.h @@ -58,7 +58,6 @@ #define ENABLE_THREAD_CHECKER 0 #endif - namespace base { namespace cef_internal { @@ -69,9 +68,7 @@ namespace cef_internal { // right version for your build configuration. class ThreadCheckerDoNothing { public: - bool CalledOnValidThread() const { - return true; - } + bool CalledOnValidThread() const { return true; } void DetachFromThread() {} }; @@ -110,11 +107,9 @@ class ThreadCheckerDoNothing { // // In Release mode, CalledOnValidThread will always return true. #if ENABLE_THREAD_CHECKER -class ThreadChecker : public cef_internal::ThreadCheckerImpl { -}; +class ThreadChecker : public cef_internal::ThreadCheckerImpl {}; #else -class ThreadChecker : public cef_internal::ThreadCheckerDoNothing { -}; +class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {}; #endif // ENABLE_THREAD_CHECKER #undef ENABLE_THREAD_CHECKER diff --git a/src/include/base/cef_thread_collision_warner.h b/src/include/base/cef_thread_collision_warner.h index 8f60a546..53f6ef6d 100644 --- a/src/include/base/cef_thread_collision_warner.h +++ b/src/include/base/cef_thread_collision_warner.h @@ -139,24 +139,22 @@ // DFAKE_MUTEX(shareable_section_); // }; - #if DCHECK_IS_ON() // Defines a class member that acts like a mutex. It is used only as a // verification tool. -#define DFAKE_MUTEX(obj) \ - mutable base::ThreadCollisionWarner obj +#define DFAKE_MUTEX(obj) mutable base::ThreadCollisionWarner obj // Asserts the call is never called simultaneously in two threads. Used at // member function scope. #define DFAKE_SCOPED_LOCK(obj) \ - base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj) + base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj) // Asserts the call is never called simultaneously in two threads. Used at // member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks. #define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \ - base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj) + base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj) // Asserts the code is always executed in the same thread. #define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \ - base::ThreadCollisionWarner::Check check_##obj(&obj) + base::ThreadCollisionWarner::Check check_##obj(&obj) #else @@ -187,13 +185,9 @@ class ThreadCollisionWarner { public: // The parameter asserter is there only for test purpose explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter()) - : valid_thread_id_(0), - counter_(0), - asserter_(asserter) {} + : valid_thread_id_(0), counter_(0), asserter_(asserter) {} - ~ThreadCollisionWarner() { - delete asserter_; - } + ~ThreadCollisionWarner() { delete asserter_; } // This class is meant to be used through the macro // DFAKE_SCOPED_LOCK_THREAD_LOCKED @@ -202,8 +196,7 @@ class ThreadCollisionWarner { // from one thread class Check { public: - explicit Check(ThreadCollisionWarner* warner) - : warner_(warner) { + explicit Check(ThreadCollisionWarner* warner) : warner_(warner) { warner_->EnterSelf(); } @@ -219,14 +212,11 @@ class ThreadCollisionWarner { // DFAKE_SCOPED_LOCK class ScopedCheck { public: - explicit ScopedCheck(ThreadCollisionWarner* warner) - : warner_(warner) { + explicit ScopedCheck(ThreadCollisionWarner* warner) : warner_(warner) { warner_->Enter(); } - ~ScopedCheck() { - warner_->Leave(); - } + ~ScopedCheck() { warner_->Leave(); } private: ThreadCollisionWarner* warner_; @@ -243,9 +233,7 @@ class ThreadCollisionWarner { warner_->EnterSelf(); } - ~ScopedRecursiveCheck() { - warner_->Leave(); - } + ~ScopedRecursiveCheck() { warner_->Leave(); } private: ThreadCollisionWarner* warner_; diff --git a/src/include/base/cef_trace_event.h b/src/include/base/cef_trace_event.h index 20723fbb..1b2cad01 100644 --- a/src/include/base/cef_trace_event.h +++ b/src/include/base/cef_trace_event.h @@ -160,32 +160,29 @@ // enabled, then this does nothing. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define TRACE_EVENT0(category, name) \ +#define TRACE_EVENT0(category, name) \ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \ CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) -#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ +#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \ CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) -#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val) \ - cef_trace_event_begin(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val, false); \ +#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false); \ CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) // Implementation detail: trace event macros create temporary variable names. // These macros give each temporary variable a unique name based on the line // number to prevent name collisions. -#define CEF_INTERNAL_TRACE_EVENT_UID3(a,b) \ - cef_trace_event_unique_##a##b -#define CEF_INTERNAL_TRACE_EVENT_UID2(a,b) \ - CEF_INTERNAL_TRACE_EVENT_UID3(a,b) +#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b +#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b) #define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \ CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) // Implementation detail: internal macro to end end event when the scope ends. -#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \ - cef_trace_event::CefTraceEndOnScopeClose \ - CEF_INTERNAL_TRACE_EVENT_UID(profileScope)(category, name) +#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \ + cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \ + profileScope)(category, name) // Records a single event called "name" immediately, with 0, 1 or 2 // associated arguments. If the category is not enabled, then this @@ -196,18 +193,18 @@ cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false) #define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false) -#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, false) +#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) #define TRACE_EVENT_COPY_INSTANT0(category, name) \ cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true) #define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true) -#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ +#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, true) + arg2_val, true) // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 // associated arguments. If the category is not enabled, then this @@ -218,18 +215,18 @@ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false) #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false) -#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, false) +#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) #define TRACE_EVENT_COPY_BEGIN0(category, name) \ cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true) #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true) -#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ +#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, true) + arg2_val, true) // Records a single END event for "name" immediately. If the category // is not enabled, then this does nothing. @@ -239,18 +236,18 @@ cef_trace_event_end(category, name, NULL, 0, NULL, 0, false) #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false) -#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, false) +#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) #define TRACE_EVENT_COPY_END0(category, name) \ cef_trace_event_end(category, name, NULL, 0, NULL, 0, true) #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true) -#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ - arg2_val, true) +#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) // Records the value of a counter called "name" immediately. Value // must be representable as a 32 bit integer. @@ -266,14 +263,14 @@ // values as a stacked-bar chart. // - category and name strings must have application lifetime (statics or // literals). They may not include " chars. -#define TRACE_COUNTER2(category, name, value1_name, value1_val, \ - value2_name, value2_val) \ - cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ - value2_val, false) -#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ - value2_name, value2_val) \ +#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \ + value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, false) +#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ + value2_name, value2_val) \ cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ - value2_val, true) + value2_val, true) // Records the value of a counter called "name" immediately. Value // must be representable as a 32 bit integer. @@ -298,14 +295,13 @@ // bits will be xored with a hash of the process ID so that the same pointer // on two different processes will not collide. #define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ - value2_name, value2_val) \ - cef_trace_counter_id(category, name, id, value1_name, value1_val, \ - value2_name, value2_val, false) -#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \ - value1_val, value2_name, value2_val) \ - cef_trace_counter_id(category, name, id, value1_name, value1_val, \ - value2_name, value2_val, true) - + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, false) +#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, true) // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 // associated arguments. If the category is not enabled, then this @@ -325,23 +321,22 @@ // args. #define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false) -#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ +#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ - 0, false) + 0, false) #define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val, false) + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true) -#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, \ - arg1_val) \ - cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ - 0, true) -#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \ - arg1_val, arg2_name, arg2_val) \ - cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) // Records a single ASYNC_STEP_INTO event for |step| immediately. If the // category is not enabled, then this does nothing. The |name| and |id| must @@ -351,16 +346,16 @@ // ASYNC_STEP_PAST events. #define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \ cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false) -#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, \ - arg1_name, arg1_val) \ - cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ - arg1_val, false) +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, false) #define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \ cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true) -#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, \ - arg1_name, arg1_val) \ - cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ - arg1_val, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, true) // Records a single ASYNC_STEP_PAST event for |step| immediately. If the // category is not enabled, then this does nothing. The |name| and |id| must @@ -370,38 +365,37 @@ // ASYNC_STEP_INTO events. #define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \ cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false) -#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, \ - arg1_name, arg1_val) \ - cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ - arg1_val, false) +#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, false) #define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \ cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true) -#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, \ - arg1_name, arg1_val) \ - cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ - arg1_val, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, true) // Records a single ASYNC_END event for "name" immediately. If the category // is not enabled, then this does nothing. #define TRACE_EVENT_ASYNC_END0(category, name, id) \ cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false) -#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ +#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ - false) + false) #define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val) \ - cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val, false) + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) #define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true) -#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, \ - arg1_val) \ +#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ - true) -#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \ - arg1_val, arg2_name, arg2_val) \ - cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ - arg2_name, arg2_val, true) + true) +#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) namespace cef_trace_event { @@ -409,8 +403,7 @@ namespace cef_trace_event { class CefTraceEndOnScopeClose { public: CefTraceEndOnScopeClose(const char* category, const char* name) - : category_(category), name_(name) { - } + : category_(category), name_(name) {} ~CefTraceEndOnScopeClose() { cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false); } diff --git a/src/include/base/cef_tuple.h b/src/include/base/cef_tuple.h index 2268792d..aeb6e9ce 100644 --- a/src/include/base/cef_tuple.h +++ b/src/include/base/cef_tuple.h @@ -96,7 +96,7 @@ struct TupleTraits { }; template -struct TupleTypes { }; +struct TupleTypes {}; // Tuple ----------------------------------------------------------------------- // @@ -138,8 +138,7 @@ struct Tuple2 { Tuple2() {} Tuple2(typename TupleTraits::ParamType a, typename TupleTraits::ParamType b) - : a(a), b(b) { - } + : a(a), b(b) {} A a; B b; @@ -156,8 +155,7 @@ struct Tuple3 { Tuple3(typename TupleTraits::ParamType a, typename TupleTraits::ParamType b, typename TupleTraits::ParamType c) - : a(a), b(b), c(c){ - } + : a(a), b(b), c(c) {} A a; B b; @@ -177,8 +175,7 @@ struct Tuple4 { typename TupleTraits::ParamType b, typename TupleTraits::ParamType c, typename TupleTraits::ParamType d) - : a(a), b(b), c(c), d(d) { - } + : a(a), b(b), c(c), d(d) {} A a; B b; @@ -197,12 +194,11 @@ struct Tuple5 { Tuple5() {} Tuple5(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e) - : a(a), b(b), c(c), d(d), e(e) { - } + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e) + : a(a), b(b), c(c), d(d), e(e) {} A a; B b; @@ -223,13 +219,12 @@ struct Tuple6 { Tuple6() {} Tuple6(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f) - : a(a), b(b), c(c), d(d), e(e), f(f) { - } + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f) + : a(a), b(b), c(c), d(d), e(e), f(f) {} A a; B b; @@ -252,14 +247,13 @@ struct Tuple7 { Tuple7() {} Tuple7(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g) { - } + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {} A a; B b; @@ -270,7 +264,13 @@ struct Tuple7 { G g; }; -template struct Tuple8 { public: @@ -285,15 +285,14 @@ struct Tuple8 { Tuple8() {} Tuple8(typename TupleTraits::ParamType a, - typename TupleTraits::ParamType b, - typename TupleTraits::ParamType c, - typename TupleTraits::ParamType d, - typename TupleTraits::ParamType e, - typename TupleTraits::ParamType f, - typename TupleTraits::ParamType g, - typename TupleTraits::ParamType h) - : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) { - } + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g, + typename TupleTraits::ParamType h) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {} A a; B b; @@ -311,127 +310,151 @@ struct Tuple8 { // definitions of class types the tuple takes as parameters. template <> -struct TupleTypes< Tuple0 > { +struct TupleTypes { typedef Tuple0 ValueTuple; typedef Tuple0 RefTuple; typedef Tuple0 ParamTuple; }; template -struct TupleTypes< Tuple1 > { +struct TupleTypes> { typedef Tuple1::ValueType> ValueTuple; typedef Tuple1::RefType> RefTuple; typedef Tuple1::ParamType> ParamTuple; }; template -struct TupleTypes< Tuple2 > { +struct TupleTypes> { typedef Tuple2::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple2::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple2::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple2::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; template -struct TupleTypes< Tuple3 > { +struct TupleTypes> { typedef Tuple3::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple3::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple3::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple3::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; template -struct TupleTypes< Tuple4 > { +struct TupleTypes> { typedef Tuple4::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple4::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple4::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple4::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; template -struct TupleTypes< Tuple5 > { +struct TupleTypes> { typedef Tuple5::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple5::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple5::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple5::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; template -struct TupleTypes< Tuple6 > { +struct TupleTypes> { typedef Tuple6::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple6::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple6::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple6::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; template -struct TupleTypes< Tuple7 > { +struct TupleTypes> { typedef Tuple7::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple7::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple7::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple7::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; -template -struct TupleTypes< Tuple8 > { +struct TupleTypes> { typedef Tuple8::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, @@ -439,15 +462,17 @@ struct TupleTypes< Tuple8 > { typename TupleTraits::ValueType, typename TupleTraits::ValueType, typename TupleTraits::ValueType, - typename TupleTraits::ValueType> ValueTuple; -typedef Tuple8::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType, - typename TupleTraits::RefType> RefTuple; + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple8::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; typedef Tuple8::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, @@ -455,7 +480,8 @@ typedef Tuple8::RefType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, typename TupleTraits::ParamType, - typename TupleTraits::ParamType> ParamTuple; + typename TupleTraits::ParamType> + ParamTuple; }; // Tuple creators ------------------------------------------------------------- @@ -483,36 +509,59 @@ inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { } template -inline Tuple4 MakeTuple(const A& a, const B& b, const C& c, +inline Tuple4 MakeTuple(const A& a, + const B& b, + const C& c, const D& d) { return Tuple4(a, b, c, d); } template -inline Tuple5 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e) { +inline Tuple5 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e) { return Tuple5(a, b, c, d, e); } template -inline Tuple6 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e, const F& f) { +inline Tuple6 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f) { return Tuple6(a, b, c, d, e, f); } template -inline Tuple7 MakeTuple(const A& a, const B& b, const C& c, - const D& d, const E& e, const F& f, +inline Tuple7 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, const G& g) { return Tuple7(a, b, c, d, e, f, g); } -template -inline Tuple8 MakeTuple(const A& a, const B& b, - const C& c, const D& d, - const E& e, const F& f, - const G& g, const H& h) { +inline Tuple8 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, + const G& g, + const H& h) { return Tuple8(a, b, c, d, e, f, g, h); } @@ -545,22 +594,31 @@ inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { } template -inline Tuple6 MakeRefTuple(A& a, B& b, C& c, D& d, E& e, +inline Tuple6 MakeRefTuple(A& a, + B& b, + C& c, + D& d, + E& e, F& f) { return Tuple6(a, b, c, d, e, f); } template -inline Tuple7 MakeRefTuple(A& a, B& b, C& c, D& d, - E& e, F& f, G& g) { +inline Tuple7 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g) { return Tuple7(a, b, c, d, e, f, g); } -template -inline Tuple8 MakeRefTuple(A& a, B& b, C& c, - D& d, E& e, F& f, - G& g, H& h) { +inline Tuple8 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h) { return Tuple8(a, b, c, d, e, f, g, h); } @@ -590,7 +648,7 @@ inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); } -template +template inline void DispatchToMethod(ObjT* obj, Method method, const Tuple2& arg) { @@ -598,16 +656,18 @@ inline void DispatchToMethod(ObjT* obj, base::cef_internal::UnwrapTraits::Unwrap(arg.b)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), @@ -615,8 +675,9 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(arg.d)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), @@ -625,9 +686,16 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(arg.e)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), @@ -637,9 +705,17 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(arg.f)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple7& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), @@ -650,9 +726,18 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(arg.g)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple8& arg) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), @@ -681,20 +766,20 @@ inline void DispatchToFunction(Function function, const Tuple1& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); } -template +template inline void DispatchToFunction(Function function, const Tuple2& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b)); } -template +template inline void DispatchToFunction(Function function, const Tuple3& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c)); } -template +template inline void DispatchToFunction(Function function, const Tuple4& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), @@ -703,7 +788,7 @@ inline void DispatchToFunction(Function function, base::cef_internal::UnwrapTraits::Unwrap(arg.d)); } -template +template inline void DispatchToFunction(Function function, const Tuple5& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), @@ -713,7 +798,7 @@ inline void DispatchToFunction(Function function, base::cef_internal::UnwrapTraits::Unwrap(arg.e)); } -template +template inline void DispatchToFunction(Function function, const Tuple6& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), @@ -724,8 +809,14 @@ inline void DispatchToFunction(Function function, base::cef_internal::UnwrapTraits::Unwrap(arg.f)); } -template +template inline void DispatchToFunction(Function function, const Tuple7& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), @@ -737,8 +828,15 @@ inline void DispatchToFunction(Function function, base::cef_internal::UnwrapTraits::Unwrap(arg.g)); } -template +template inline void DispatchToFunction(Function function, const Tuple8& arg) { (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), @@ -756,7 +854,8 @@ inline void DispatchToFunction(Function function, template inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple0& arg, Tuple0*) { + const Tuple0& arg, + Tuple0*) { (obj->*method)(); } @@ -768,38 +867,46 @@ inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { template inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple1& arg, Tuple0*) { + const Tuple1& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); } -template +template inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple2& arg, Tuple0*) { + const Tuple2& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple3& arg, Tuple0*) { +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple4& arg, Tuple0*) { +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c), base::cef_internal::UnwrapTraits::Unwrap(arg.d)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple5& arg, Tuple0*) { +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c), @@ -807,10 +914,18 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(arg.e)); } -template -inline void DispatchToMethod(ObjT* obj, Method method, - const Tuple6& arg, Tuple0*) { +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& arg, + Tuple0*) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), base::cef_internal::UnwrapTraits::Unwrap(arg.b), base::cef_internal::UnwrapTraits::Unwrap(arg.c), @@ -821,80 +936,96 @@ inline void DispatchToMethod(ObjT* obj, Method method, // Dispatchers with 1 out param. -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple0& in, Tuple1* out) { (obj->*method)(&out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const InA& in, Tuple1* out) { (obj->*method)(in, &out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple1& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple2& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - base::cef_internal::UnwrapTraits::Unwrap(in.b), - &out->a); + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), - base::cef_internal::UnwrapTraits::Unwrap(in.c), - &out->a); + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), - base::cef_internal::UnwrapTraits::Unwrap(in.d), - &out->a); + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), - base::cef_internal::UnwrapTraits::Unwrap(in.e), - &out->a); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& in, Tuple1* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), @@ -902,92 +1033,120 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), base::cef_internal::UnwrapTraits::Unwrap(in.e), - base::cef_internal::UnwrapTraits::Unwrap(in.f), - &out->a); + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a); } // Dispatchers with 2 out params. -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple0& in, Tuple2* out) { (obj->*method)(&out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const InA& in, Tuple2* out) { (obj->*method)(in, &out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple1& in, Tuple2* out) { - (obj->*method)( - base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, &out->b); + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple2& in, Tuple2* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - base::cef_internal::UnwrapTraits::Unwrap(in.b), - &out->a, + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& in, Tuple2* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), - base::cef_internal::UnwrapTraits::Unwrap(in.c), - &out->a, + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& in, Tuple2* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), - base::cef_internal::UnwrapTraits::Unwrap(in.d), - &out->a, + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& in, Tuple2* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), - base::cef_internal::UnwrapTraits::Unwrap(in.e), - &out->a, + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, &out->b); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& in, Tuple2* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), @@ -995,99 +1154,136 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), base::cef_internal::UnwrapTraits::Unwrap(in.e), - base::cef_internal::UnwrapTraits::Unwrap(in.f), - &out->a, + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, &out->b); } // Dispatchers with 3 out params. -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple0& in, Tuple3* out) { (obj->*method)(&out->a, &out->b, &out->c); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const InA& in, Tuple3* out) { (obj->*method)(in, &out->a, &out->b, &out->c); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple1& in, Tuple3* out) { - (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - &out->a, - &out->b, - &out->c); + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple2& in, Tuple3* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - base::cef_internal::UnwrapTraits::Unwrap(in.b), - &out->a, - &out->b, - &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& in, Tuple3* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), - base::cef_internal::UnwrapTraits::Unwrap(in.c), - &out->a, - &out->b, - &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& in, Tuple3* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), - base::cef_internal::UnwrapTraits::Unwrap(in.d), - &out->a, - &out->b, - &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& in, Tuple3* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), - base::cef_internal::UnwrapTraits::Unwrap(in.e), - &out->a, - &out->b, - &out->c); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& in, Tuple3* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), @@ -1095,109 +1291,149 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), base::cef_internal::UnwrapTraits::Unwrap(in.e), - base::cef_internal::UnwrapTraits::Unwrap(in.f), - &out->a, - &out->b, - &out->c); + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c); } // Dispatchers with 4 out params. -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple0& in, Tuple4* out) { (obj->*method)(&out->a, &out->b, &out->c, &out->d); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const InA& in, Tuple4* out) { - (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), - &out->a, - &out->b, - &out->c, - &out->d); + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple1& in, Tuple4* out) { - (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - &out->a, - &out->b, - &out->c, - &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple2& in, Tuple4* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - base::cef_internal::UnwrapTraits::Unwrap(in.b), - &out->a, - &out->b, - &out->c, - &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& in, Tuple4* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), - base::cef_internal::UnwrapTraits::Unwrap(in.c), - &out->a, - &out->b, - &out->c, - &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& in, Tuple4* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), - base::cef_internal::UnwrapTraits::Unwrap(in.d), - &out->a, - &out->b, - &out->c, - &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& in, Tuple4* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), - base::cef_internal::UnwrapTraits::Unwrap(in.e), - &out->a, - &out->b, - &out->c, - &out->d); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& in, Tuple4* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), @@ -1205,116 +1441,157 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), base::cef_internal::UnwrapTraits::Unwrap(in.e), - base::cef_internal::UnwrapTraits::Unwrap(in.f), - &out->a, - &out->b, - &out->c, - &out->d); + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d); } // Dispatchers with 5 out params. -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple0& in, Tuple5* out) { (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); } -template -inline void DispatchToMethod(ObjT* obj, Method method, +template +inline void DispatchToMethod(ObjT* obj, + Method method, const InA& in, Tuple5* out) { - (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple1& in, Tuple5* out) { - (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple2& in, Tuple5* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), - base::cef_internal::UnwrapTraits::Unwrap(in.b), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple3& in, Tuple5* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), - base::cef_internal::UnwrapTraits::Unwrap(in.c), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple4& in, Tuple5* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), - base::cef_internal::UnwrapTraits::Unwrap(in.d), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple5& in, Tuple5* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), base::cef_internal::UnwrapTraits::Unwrap(in.b), base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), - base::cef_internal::UnwrapTraits::Unwrap(in.e), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); -} - -template -inline void DispatchToMethod(ObjT* obj, Method method, + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, const Tuple6& in, Tuple5* out) { (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), @@ -1322,16 +1599,12 @@ inline void DispatchToMethod(ObjT* obj, Method method, base::cef_internal::UnwrapTraits::Unwrap(in.c), base::cef_internal::UnwrapTraits::Unwrap(in.d), base::cef_internal::UnwrapTraits::Unwrap(in.e), - base::cef_internal::UnwrapTraits::Unwrap(in.f), - &out->a, - &out->b, - &out->c, - &out->d, - &out->e); + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d, &out->e); } } // namespace base -#endif // !USING_CHROMIUM_INCLUDES +#endif // !USING_CHROMIUM_INCLUDES #endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_ diff --git a/src/include/base/cef_weak_ptr.h b/src/include/base/cef_weak_ptr.h index 217f12cf..1ba34b9d 100644 --- a/src/include/base/cef_weak_ptr.h +++ b/src/include/base/cef_weak_ptr.h @@ -117,8 +117,10 @@ namespace base { -template class SupportsWeakPtr; -template class WeakPtr; +template +class SupportsWeakPtr; +template +class WeakPtr; namespace cef_internal { // These classes are part of the WeakPtr implementation. @@ -164,9 +166,7 @@ class WeakReferenceOwner { WeakReference GetRef() const; - bool HasRefs() const { - return flag_.get() && !flag_->HasOneRef(); - } + bool HasRefs() const { return flag_.get() && !flag_->HasOneRef(); } void Invalidate(); @@ -198,10 +198,10 @@ class SupportsWeakPtrBase { // conversion will only compile if there is exists a Base which inherits // from SupportsWeakPtr. See base::AsWeakPtr() below for a helper // function that makes calling this easier. - template + template static WeakPtr StaticAsWeakPtr(Derived* t) { - typedef - is_convertible convertible; + typedef is_convertible + convertible; COMPILE_ASSERT(convertible::value, AsWeakPtr_argument_inherits_from_SupportsWeakPtr); return AsWeakPtrImpl(t, *t); @@ -212,8 +212,8 @@ class SupportsWeakPtrBase { // which is an instance of SupportsWeakPtr. We can then safely // static_cast the Base* to a Derived*. template - static WeakPtr AsWeakPtrImpl( - Derived* t, const SupportsWeakPtr&) { + static WeakPtr AsWeakPtrImpl(Derived* t, + const SupportsWeakPtr&) { WeakPtr ptr = t->Base::AsWeakPtr(); return WeakPtr(ptr.ref_, static_cast(ptr.ptr_)); } @@ -221,7 +221,8 @@ class SupportsWeakPtrBase { } // namespace cef_internal -template class WeakPtrFactory; +template +class WeakPtrFactory; // The WeakPtr class holds a weak reference to |T*|. // @@ -239,14 +240,12 @@ template class WeakPtrFactory; template class WeakPtr : public cef_internal::WeakPtrBase { public: - WeakPtr() : ptr_(NULL) { - } + WeakPtr() : ptr_(NULL) {} // Allow conversion from U to T provided U "is a" T. Note that this // is separate from the (implicit) copy constructor. template - WeakPtr(const WeakPtr& other) : WeakPtrBase(other), ptr_(other.ptr_) { - } + WeakPtr(const WeakPtr& other) : WeakPtrBase(other), ptr_(other.ptr_) {} T* get() const { return ref_.is_valid() ? ptr_ : NULL; } @@ -280,18 +279,19 @@ class WeakPtr : public cef_internal::WeakPtrBase { private: // Explicitly declare comparison operators as required by the bool // trick, but keep them private. - template bool operator==(WeakPtr const&) const; - template bool operator!=(WeakPtr const&) const; + template + bool operator==(WeakPtr const&) const; + template + bool operator!=(WeakPtr const&) const; friend class cef_internal::SupportsWeakPtrBase; - template friend class WeakPtr; + template + friend class WeakPtr; friend class SupportsWeakPtr; friend class WeakPtrFactory; WeakPtr(const cef_internal::WeakReference& ref, T* ptr) - : WeakPtrBase(ref), - ptr_(ptr) { - } + : WeakPtrBase(ref), ptr_(ptr) {} // This pointer is only valid when ref_.is_valid() is true. Otherwise, its // value is undefined (as opposed to NULL). @@ -306,12 +306,9 @@ class WeakPtr : public cef_internal::WeakPtrBase { template class WeakPtrFactory { public: - explicit WeakPtrFactory(T* ptr) : ptr_(ptr) { - } + explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {} - ~WeakPtrFactory() { - ptr_ = NULL; - } + ~WeakPtrFactory() { ptr_ = NULL; } WeakPtr GetWeakPtr() { DCHECK(ptr_); diff --git a/src/include/base/internal/cef_atomicops_arm_gcc.h b/src/include/base/internal/cef_atomicops_arm_gcc.h index c228b6af..2e39ce3c 100644 --- a/src/include/base/internal/cef_atomicops_arm_gcc.h +++ b/src/include/base/internal/cef_atomicops_arm_gcc.h @@ -85,9 +85,9 @@ inline void MemoryBarrier() { // variant of the target architecture is being used. This tests against // any known ARMv6 or ARMv7 variant, where it is possible to directly // use ldrex/strex instructions to implement fast atomic operations. -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \ defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \ - defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ + defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \ defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) @@ -103,16 +103,17 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, // reloop = 0 // if (prev_value != old_value) // reloop = STREX(ptr, new_value) - __asm__ __volatile__(" ldrex %0, [%3]\n" - " mov %1, #0\n" - " cmp %0, %4\n" + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " mov %1, #0\n" + " cmp %0, %4\n" #ifdef __thumb2__ - " it eq\n" + " it eq\n" #endif - " strexeq %1, %5, [%3]\n" - : "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr) - : "r"(ptr), "r"(old_value), "r"(new_value) - : "cc", "memory"); + " strexeq %1, %5, [%3]\n" + : "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(old_value), "r"(new_value) + : "cc", "memory"); } while (reloop != 0); return prev_value; } @@ -143,12 +144,13 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, // value += increment // reloop = STREX(ptr, value) // - __asm__ __volatile__(" ldrex %0, [%3]\n" - " add %0, %0, %4\n" - " strex %1, %0, [%3]\n" - : "=&r"(value), "=&r"(reloop), "+m"(*ptr) - : "r"(ptr), "r"(increment) - : "cc", "memory"); + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " add %0, %0, %4\n" + " strex %1, %0, [%3]\n" + : "=&r"(value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(increment) + : "cc", "memory"); } while (reloop); return value; } @@ -171,18 +173,19 @@ inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, do { // old_value = LDREX(ptr) // reloop = STREX(ptr, new_value) - __asm__ __volatile__(" ldrex %0, [%3]\n" - " strex %1, %4, [%3]\n" - : "=&r"(old_value), "=&r"(reloop), "+m"(*ptr) - : "r"(ptr), "r"(new_value) - : "cc", "memory"); + __asm__ __volatile__( + " ldrex %0, [%3]\n" + " strex %1, %4, [%3]\n" + : "=&r"(old_value), "=&r"(reloop), "+m"(*ptr) + : "r"(ptr), "r"(new_value) + : "cc", "memory"); } while (reloop != 0); return old_value; } // This tests against any known ARMv5 variant. #elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \ - defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) + defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) // The kernel also provides a helper function to perform an atomic // compare-and-swap operation at the hard-wired address 0xffff0fc0. @@ -281,7 +284,7 @@ inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr, } #else -# error "Your CPU's ARM architecture is not supported yet" +#error "Your CPU's ARM architecture is not supported yet" #endif // NOTE: Atomicity of the following load and store operations is only @@ -301,7 +304,9 @@ inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { *ptr = value; } -inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { return *ptr; } +inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { + return *ptr; +} inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { Atomic32 value = *ptr; diff --git a/src/include/base/internal/cef_atomicops_atomicword_compat.h b/src/include/base/internal/cef_atomicops_atomicword_compat.h index 985f0f9b..f905de85 100644 --- a/src/include/base/internal/cef_atomicops_atomicword_compat.h +++ b/src/include/base/internal/cef_atomicops_atomicword_compat.h @@ -52,26 +52,26 @@ namespace subtle { inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr, AtomicWord old_value, AtomicWord new_value) { - return NoBarrier_CompareAndSwap( - reinterpret_cast(ptr), old_value, new_value); + return NoBarrier_CompareAndSwap(reinterpret_cast(ptr), + old_value, new_value); } inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr, AtomicWord new_value) { - return NoBarrier_AtomicExchange( - reinterpret_cast(ptr), new_value); + return NoBarrier_AtomicExchange(reinterpret_cast(ptr), + new_value); } inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr, AtomicWord increment) { - return NoBarrier_AtomicIncrement( - reinterpret_cast(ptr), increment); + return NoBarrier_AtomicIncrement(reinterpret_cast(ptr), + increment); } inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr, AtomicWord increment) { - return Barrier_AtomicIncrement( - reinterpret_cast(ptr), increment); + return Barrier_AtomicIncrement(reinterpret_cast(ptr), + increment); } inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr, @@ -88,24 +88,22 @@ inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr, reinterpret_cast(ptr), old_value, new_value); } -inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) { - NoBarrier_Store( - reinterpret_cast(ptr), value); +inline void NoBarrier_Store(volatile AtomicWord* ptr, AtomicWord value) { + NoBarrier_Store(reinterpret_cast(ptr), value); } inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) { - return base::subtle::Acquire_Store( - reinterpret_cast(ptr), value); + return base::subtle::Acquire_Store(reinterpret_cast(ptr), + value); } inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) { - return base::subtle::Release_Store( - reinterpret_cast(ptr), value); + return base::subtle::Release_Store(reinterpret_cast(ptr), + value); } -inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) { - return NoBarrier_Load( - reinterpret_cast(ptr)); +inline AtomicWord NoBarrier_Load(volatile const AtomicWord* ptr) { + return NoBarrier_Load(reinterpret_cast(ptr)); } inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) { @@ -118,8 +116,8 @@ inline AtomicWord Release_Load(volatile const AtomicWord* ptr) { reinterpret_cast(ptr)); } -} // namespace base::subtle -} // namespace base +} // namespace base::subtle +} // namespace base #endif // !defined(ARCH_CPU_64_BITS) diff --git a/src/include/base/internal/cef_atomicops_mac.h b/src/include/base/internal/cef_atomicops_mac.h index 9f268dd6..374ae35d 100644 --- a/src/include/base/internal/cef_atomicops_mac.h +++ b/src/include/base/internal/cef_atomicops_mac.h @@ -170,7 +170,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr, Atomic64 prev_value; do { if (OSAtomicCompareAndSwap64Barrier( - old_value, new_value, reinterpret_cast(ptr))) { + old_value, new_value, reinterpret_cast(ptr))) { return old_value; } prev_value = *ptr; @@ -217,7 +217,7 @@ inline Atomic64 Release_Load(volatile const Atomic64* ptr) { #endif // defined(__LP64__) -} // namespace base::subtle -} // namespace base +} // namespace base::subtle +} // namespace base #endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_ diff --git a/src/include/base/internal/cef_atomicops_x86_gcc.h b/src/include/base/internal/cef_atomicops_x86_gcc.h index 0e2139d9..b93df21b 100644 --- a/src/include/base/internal/cef_atomicops_x86_gcc.h +++ b/src/include/base/internal/cef_atomicops_x86_gcc.h @@ -38,11 +38,10 @@ // Features of this x86. Values may not be correct before main() is run, // but are set conservatively. struct AtomicOps_x86CPUFeatureStruct { - bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence - // after acquire compare-and-swap. + bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence + // after acquire compare-and-swap. }; -extern struct AtomicOps_x86CPUFeatureStruct - AtomicOps_Internalx86CPUFeatures; +extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") @@ -56,8 +55,8 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, Atomic32 new_value) { Atomic32 prev; __asm__ __volatile__("lock; cmpxchgl %1,%2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) + : "=a"(prev) + : "q"(new_value), "m"(*ptr), "0"(old_value) : "memory"); return prev; } @@ -65,8 +64,8 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value) { __asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg. - : "=r" (new_value) - : "m" (*ptr), "0" (new_value) + : "=r"(new_value) + : "m"(*ptr), "0"(new_value) : "memory"); return new_value; // Now it's the previous value. } @@ -75,8 +74,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { Atomic32 temp = increment; __asm__ __volatile__("lock; xaddl %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); + : "+r"(temp), "+m"(*ptr) + : + : "memory"); // temp now holds the old value of *ptr return temp + increment; } @@ -85,8 +85,9 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { Atomic32 temp = increment; __asm__ __volatile__("lock; xaddl %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); + : "+r"(temp), "+m"(*ptr) + : + : "memory"); // temp now holds the old value of *ptr if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { __asm__ __volatile__("lfence" : : : "memory"); @@ -125,7 +126,7 @@ inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { ATOMICOPS_COMPILER_BARRIER(); - *ptr = value; // An x86 store acts as a release barrier. + *ptr = value; // An x86 store acts as a release barrier. // See comments in Atomic64 version of Release_Store(), below. } @@ -134,7 +135,7 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { } inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) { - Atomic32 value = *ptr; // An x86 load acts as a acquire barrier. + Atomic32 value = *ptr; // An x86 load acts as a acquire barrier. // See comments in Atomic64 version of Release_Store(), below. ATOMICOPS_COMPILER_BARRIER(); return value; @@ -154,8 +155,8 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, Atomic64 new_value) { Atomic64 prev; __asm__ __volatile__("lock; cmpxchgq %1,%2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) + : "=a"(prev) + : "q"(new_value), "m"(*ptr), "0"(old_value) : "memory"); return prev; } @@ -163,8 +164,8 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value) { __asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg. - : "=r" (new_value) - : "m" (*ptr), "0" (new_value) + : "=r"(new_value) + : "m"(*ptr), "0"(new_value) : "memory"); return new_value; // Now it's the previous value. } @@ -173,8 +174,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { Atomic64 temp = increment; __asm__ __volatile__("lock; xaddq %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); + : "+r"(temp), "+m"(*ptr) + : + : "memory"); // temp now contains the previous value of *ptr return temp + increment; } @@ -183,8 +185,9 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { Atomic64 temp = increment; __asm__ __volatile__("lock; xaddq %0,%1" - : "+r" (temp), "+m" (*ptr) - : : "memory"); + : "+r"(temp), "+m"(*ptr) + : + : "memory"); // temp now contains the previous value of *ptr if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) { __asm__ __volatile__("lfence" : : : "memory"); @@ -204,9 +207,9 @@ inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { ATOMICOPS_COMPILER_BARRIER(); - *ptr = value; // An x86 store acts as a release barrier - // for current AMD/Intel chips as of Jan 2008. - // See also Acquire_Load(), below. + *ptr = value; // An x86 store acts as a release barrier + // for current AMD/Intel chips as of Jan 2008. + // See also Acquire_Load(), below. // When new chips come out, check: // IA-32 Intel Architecture Software Developer's Manual, Volume 3: @@ -227,9 +230,9 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { } inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) { - Atomic64 value = *ptr; // An x86 load acts as a acquire barrier, - // for current AMD/Intel chips as of Jan 2008. - // See also Release_Store(), above. + Atomic64 value = *ptr; // An x86 load acts as a acquire barrier, + // for current AMD/Intel chips as of Jan 2008. + // See also Release_Store(), above. ATOMICOPS_COMPILER_BARRIER(); return value; } @@ -257,8 +260,8 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, #endif // defined(__x86_64__) -} // namespace base::subtle -} // namespace base +} // namespace base::subtle +} // namespace base #undef ATOMICOPS_COMPILER_BARRIER diff --git a/src/include/base/internal/cef_atomicops_x86_msvc.h b/src/include/base/internal/cef_atomicops_x86_msvc.h index 12bb0f46..a262c81f 100644 --- a/src/include/base/internal/cef_atomicops_x86_msvc.h +++ b/src/include/base/internal/cef_atomicops_x86_msvc.h @@ -55,25 +55,23 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, Atomic32 old_value, Atomic32 new_value) { LONG result = _InterlockedCompareExchange( - reinterpret_cast(ptr), - static_cast(new_value), + reinterpret_cast(ptr), static_cast(new_value), static_cast(old_value)); return static_cast(result); } inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value) { - LONG result = _InterlockedExchange( - reinterpret_cast(ptr), - static_cast(new_value)); + LONG result = _InterlockedExchange(reinterpret_cast(ptr), + static_cast(new_value)); return static_cast(result); } inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment) { - return _InterlockedExchangeAdd( - reinterpret_cast(ptr), - static_cast(increment)) + increment; + return _InterlockedExchangeAdd(reinterpret_cast(ptr), + static_cast(increment)) + + increment; } inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, @@ -112,11 +110,11 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { NoBarrier_AtomicExchange(ptr, value); - // acts as a barrier in this implementation + // acts as a barrier in this implementation } inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) { - *ptr = value; // works w/o barrier for current Intel chips as of June 2005 + *ptr = value; // works w/o barrier for current Intel chips as of June 2005 // See comments in Atomic64 version of Release_Store() below. } @@ -144,24 +142,24 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr, Atomic64 old_value, Atomic64 new_value) { PVOID result = InterlockedCompareExchangePointer( - reinterpret_cast(ptr), - reinterpret_cast(new_value), reinterpret_cast(old_value)); + reinterpret_cast(ptr), + reinterpret_cast(new_value), reinterpret_cast(old_value)); return reinterpret_cast(result); } inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value) { - PVOID result = InterlockedExchangePointer( - reinterpret_cast(ptr), - reinterpret_cast(new_value)); + PVOID result = + InterlockedExchangePointer(reinterpret_cast(ptr), + reinterpret_cast(new_value)); return reinterpret_cast(result); } inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) { - return InterlockedExchangeAdd64( - reinterpret_cast(ptr), - static_cast(increment)) + increment; + return InterlockedExchangeAdd64(reinterpret_cast(ptr), + static_cast(increment)) + + increment; } inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, @@ -175,11 +173,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { NoBarrier_AtomicExchange(ptr, value); - // acts as a barrier in this implementation + // acts as a barrier in this implementation } inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) { - *ptr = value; // works w/o barrier for current Intel chips as of June 2005 + *ptr = value; // works w/o barrier for current Intel chips as of June 2005 // When new chips come out, check: // IA-32 Intel Architecture Software Developer's Manual, Volume 3: @@ -215,7 +213,6 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, return NoBarrier_CompareAndSwap(ptr, old_value, new_value); } - #endif // defined(_WIN64) } // namespace base::subtle diff --git a/src/include/base/internal/cef_bind_internal.h b/src/include/base/internal/cef_bind_internal.h index a097978b..64eeb3f3 100644 --- a/src/include/base/internal/cef_bind_internal.h +++ b/src/include/base/internal/cef_bind_internal.h @@ -125,17 +125,13 @@ class RunnableAdapter; // Function: Arity 0. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(); + typedef R(RunType)(); - explicit RunnableAdapter(R(*function)()) - : function_(function) { - } + explicit RunnableAdapter(R (*function)()) : function_(function) {} - R Run() { - return function_(); - } + R Run() { return function_(); } private: R (*function_)(); @@ -143,18 +139,14 @@ class RunnableAdapter { // Method: Arity 0. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(T*); + typedef R(RunType)(T*); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)()) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)()) : method_(method) {} - R Run(T* object) { - return (object->*method_)(); - } + R Run(T* object) { return (object->*method_)(); } private: R (T::*method_)(); @@ -162,18 +154,14 @@ class RunnableAdapter { // Const Method: Arity 0. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(const T*); + typedef R(RunType)(const T*); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)() const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)() const) : method_(method) {} - R Run(const T* object) { - return (object->*method_)(); - } + R Run(const T* object) { return (object->*method_)(); } private: R (T::*method_)() const; @@ -181,13 +169,11 @@ class RunnableAdapter { // Function: Arity 1. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1); + typedef R(RunType)(A1); - explicit RunnableAdapter(R(*function)(A1)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1)) : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1) { return function_(CallbackForward(a1)); @@ -199,14 +185,12 @@ class RunnableAdapter { // Method: Arity 1. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(T*, A1); + typedef R(RunType)(T*, A1); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1)) : method_(method) {} R Run(T* object, typename CallbackParamTraits::ForwardType a1) { return (object->*method_)(CallbackForward(a1)); @@ -218,14 +202,12 @@ class RunnableAdapter { // Const Method: Arity 1. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1); + typedef R(RunType)(const T*, A1); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1) const) : method_(method) {} R Run(const T* object, typename CallbackParamTraits::ForwardType a1) { return (object->*method_)(CallbackForward(a1)); @@ -237,16 +219,14 @@ class RunnableAdapter { // Function: Arity 2. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2); + typedef R(RunType)(A1, A2); - explicit RunnableAdapter(R(*function)(A1, A2)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2)) : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2) { + typename CallbackParamTraits::ForwardType a2) { return function_(CallbackForward(a1), CallbackForward(a2)); } @@ -256,17 +236,16 @@ class RunnableAdapter { // Method: Arity 2. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2); + typedef R(RunType)(T*, A1, A2); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2)) : method_(method) {} - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2) { + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); } @@ -276,17 +255,16 @@ class RunnableAdapter { // Const Method: Arity 2. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2); + typedef R(RunType)(const T*, A1, A2); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2) const) : method_(method) {} - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2) { + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); } @@ -296,19 +274,17 @@ class RunnableAdapter { // Function: Arity 3. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3); + typedef R(RunType)(A1, A2, A3); - explicit RunnableAdapter(R(*function)(A1, A2, A3)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2, A3)) : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { return function_(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3)); + CallbackForward(a3)); } private: @@ -317,20 +293,19 @@ class RunnableAdapter { // Method: Arity 3. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2, A3); + typedef R(RunType)(T*, A1, A2, A3); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3)) : method_(method) {} - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3) { + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3)); + CallbackForward(a3)); } private: @@ -339,20 +314,20 @@ class RunnableAdapter { // Const Method: Arity 3. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2, A3); + typedef R(RunType)(const T*, A1, A2, A3); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3) const) + : method_(method) {} - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3) { + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3)); + CallbackForward(a3)); } private: @@ -361,20 +336,19 @@ class RunnableAdapter { // Function: Arity 4. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4); + typedef R(RunType)(A1, A2, A3, A4); - explicit RunnableAdapter(R(*function)(A1, A2, A3, A4)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { return function_(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4)); + CallbackForward(a3), CallbackForward(a4)); } private: @@ -382,23 +356,26 @@ class RunnableAdapter { }; // Method: Arity 4. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2, A3, A4); + typedef R(RunType)(T*, A1, A2, A3, A4); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4)) : method_(method) {} - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4) { + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4)); + CallbackForward(a3), CallbackForward(a4)); } private: @@ -406,23 +383,27 @@ class RunnableAdapter { }; // Const Method: Arity 4. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2, A3, A4); + typedef R(RunType)(const T*, A1, A2, A3, A4); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4) const) + : method_(method) {} - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4) { + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4)); + CallbackForward(a3), CallbackForward(a4)); } private: @@ -430,23 +411,27 @@ class RunnableAdapter { }; // Function: Arity 5. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5); + typedef R(RunType)(A1, A2, A3, A4, A5); - explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { return function_(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); } private: @@ -454,24 +439,30 @@ class RunnableAdapter { }; // Method: Arity 5. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2, A3, A4, A5); + typedef R(RunType)(T*, A1, A2, A3, A4, A5); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5)) + : method_(method) {} - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5) { + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); } private: @@ -479,24 +470,30 @@ class RunnableAdapter { }; // Const Method: Arity 5. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2, A3, A4, A5); + typedef R(RunType)(const T*, A1, A2, A3, A4, A5); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5) const) + : method_(method) {} - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5) { + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); } private: @@ -504,25 +501,29 @@ class RunnableAdapter { }; // Function: Arity 6. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6); + typedef R(RunType)(A1, A2, A3, A4, A5, A6); - explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { return function_(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); } private: @@ -530,26 +531,32 @@ class RunnableAdapter { }; // Method: Arity 6. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6); + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6)) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6)) + : method_(method) {} - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6) { + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); } private: @@ -557,26 +564,32 @@ class RunnableAdapter { }; // Const Method: Arity 6. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6); + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6) const) - : method_(method) { - } + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6) const) + : method_(method) {} - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6) { + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); } private: @@ -584,26 +597,32 @@ class RunnableAdapter { }; // Function: Arity 7. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7); + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); - explicit RunnableAdapter(R(*function)(A1, A2, A3, A4, A5, A6, A7)) - : function_(function) { - } + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6, - typename CallbackParamTraits::ForwardType a7) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { return function_(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6), CallbackForward(a7)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); } private: @@ -611,27 +630,35 @@ class RunnableAdapter { }; // Method: Arity 7. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(T*, A1, A2, A3, A4, A5, A6, A7); + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6, A7); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7)) - : method_(method) { - } - - R Run(T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6, - typename CallbackParamTraits::ForwardType a7) { + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6), CallbackForward(a7)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); } private: @@ -639,34 +666,41 @@ class RunnableAdapter { }; // Const Method: Arity 7. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); typedef true_type IsMethod; - explicit RunnableAdapter(R(T::*method)(A1, A2, A3, A4, A5, A6, A7) const) - : method_(method) { - } - - R Run(const T* object, typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6, - typename CallbackParamTraits::ForwardType a7) { + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { return (object->*method_)(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6), CallbackForward(a7)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); } private: R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const; }; - // FunctionTraits<> // // Breaks a function signature apart into typedefs for easier introspection. @@ -708,8 +742,12 @@ struct FunctionTraits { typedef A4 A4Type; }; -template +template struct FunctionTraits { typedef R ReturnType; typedef A1 A1Type; @@ -719,8 +757,13 @@ struct FunctionTraits { typedef A5 A5Type; }; -template +template struct FunctionTraits { typedef R ReturnType; typedef A1 A1Type; @@ -731,8 +774,14 @@ struct FunctionTraits { typedef A6 A6Type; }; -template +template struct FunctionTraits { typedef R ReturnType; typedef A1 A1Type; @@ -744,7 +793,6 @@ struct FunctionTraits { typedef A7 A7Type; }; - // ForceVoidReturn<> // // Set of templates that support forcing the function return type to void. @@ -776,25 +824,39 @@ struct ForceVoidReturn { typedef void(RunType)(A1, A2, A3, A4); }; -template +template struct ForceVoidReturn { typedef void(RunType)(A1, A2, A3, A4, A5); }; -template +template struct ForceVoidReturn { typedef void(RunType)(A1, A2, A3, A4, A5, A6); }; -template +template struct ForceVoidReturn { typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7); }; - // FunctorTraits<> // // See description at top of file. @@ -805,19 +867,18 @@ struct FunctorTraits { }; template -struct FunctorTraits > { +struct FunctorTraits> { typedef typename FunctorTraits::RunnableType RunnableType; - typedef typename ForceVoidReturn< - typename RunnableType::RunType>::RunType RunType; + typedef + typename ForceVoidReturn::RunType RunType; }; template -struct FunctorTraits > { +struct FunctorTraits> { typedef Callback RunnableType; typedef typename Callback::RunType RunType; }; - // MakeRunnable<> // // Converts a passed in functor to a RunnableType using type inference. @@ -828,19 +889,18 @@ typename FunctorTraits::RunnableType MakeRunnable(const T& t) { } template -typename FunctorTraits::RunnableType -MakeRunnable(const IgnoreResultHelper& t) { +typename FunctorTraits::RunnableType MakeRunnable( + const IgnoreResultHelper& t) { return MakeRunnable(t.functor_); } template -const typename FunctorTraits >::RunnableType& -MakeRunnable(const Callback& t) { +const typename FunctorTraits>::RunnableType& MakeRunnable( + const Callback& t) { DCHECK(!t.is_null()); return t; } - // InvokeHelper<> // // There are 3 logical InvokeHelper<> specializations: normal, void-return, @@ -858,45 +918,38 @@ MakeRunnable(const Callback& t) { // // WeakCalls similarly need special syntax that is applied to the first // argument to check if they should no-op themselves. -template struct InvokeHelper; template -struct InvokeHelper { - static ReturnType MakeItSo(Runnable runnable) { - return runnable.Run(); - } +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable) { return runnable.Run(); } }; template -struct InvokeHelper { - static void MakeItSo(Runnable runnable) { - runnable.Run(); - } +struct InvokeHelper { + static void MakeItSo(Runnable runnable) { runnable.Run(); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static ReturnType MakeItSo(Runnable runnable, A1 a1) { return runnable.Run(CallbackForward(a1)); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static void MakeItSo(Runnable runnable, A1 a1) { runnable.Run(CallbackForward(a1)); } }; template -struct InvokeHelper { +struct InvokeHelper { static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) { if (!weak_ptr.get()) { return; @@ -905,25 +958,22 @@ struct InvokeHelper -struct InvokeHelper { +template +struct InvokeHelper { static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { return runnable.Run(CallbackForward(a1), CallbackForward(a2)); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { runnable.Run(CallbackForward(a1), CallbackForward(a2)); } }; template -struct InvokeHelper { +struct InvokeHelper { static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) { if (!weak_ptr.get()) { return; @@ -932,27 +982,27 @@ struct InvokeHelper -struct InvokeHelper { +template +struct InvokeHelper { static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { return runnable.Run(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3)); + CallbackForward(a3)); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3)); } }; template -struct InvokeHelper { +struct InvokeHelper { static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) { if (!weak_ptr.get()) { return; @@ -961,147 +1011,223 @@ struct InvokeHelper -struct InvokeHelper { +template +struct InvokeHelper { static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { return runnable.Run(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4)); + CallbackForward(a3), CallbackForward(a4)); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4)); + CallbackForward(a4)); } }; -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, - A4 a4) { +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4) { if (!weak_ptr.get()) { return; } runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4)); - } -}; - -template -struct InvokeHelper { - static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, - A5 a5) { + CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, + A1 a1, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { return runnable.Run(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); } }; -template -struct InvokeHelper { +template +struct InvokeHelper { static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5)); - } -}; - -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, - A4 a4, A5 a5) { + CallbackForward(a4), CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { if (!weak_ptr.get()) { return; } runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5)); + CallbackForward(a4), CallbackForward(a5)); } }; -template -struct InvokeHelper { - static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, - A5 a5, A6 a6) { +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { return runnable.Run(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6)); + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); } }; -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, - A6 a6) { +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); - } -}; - -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, - A4 a4, A5 a5, A6 a6) { + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6) { if (!weak_ptr.get()) { return; } runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); - } -}; - -template -struct InvokeHelper { - static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, - A5 a5, A6 a6, A7 a7) { + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { return runnable.Run(CallbackForward(a1), CallbackForward(a2), - CallbackForward(a3), CallbackForward(a4), CallbackForward(a5), - CallbackForward(a6), CallbackForward(a7)); - } -}; - -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, - A6 a6, A7 a7) { + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), - CallbackForward(a7)); - } -}; - -template -struct InvokeHelper { - static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3, - A4 a4, A5 a5, A6 a6, A7 a7) { + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6, + A7 a7) { if (!weak_ptr.get()) { return; } runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), - CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), - CallbackForward(a7)); + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); } }; @@ -1139,22 +1265,21 @@ struct Invoker<0, StorageType, R()> { // InvokeHelper<>::MakeItSo() call below. return InvokeHelper - ::MakeItSo(storage->runnable_); + typename StorageType::RunnableType, + void()>::MakeItSo(storage->runnable_); } }; // Arity 1 -> 1. -template +template struct Invoker<0, StorageType, R(X1)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1) { + typename CallbackParamTraits::ForwardType x1) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1162,14 +1287,15 @@ struct Invoker<0, StorageType, R(X1)> { // InvokeHelper<>::MakeItSo() call below. return InvokeHelper::ForwardType x1)> - ::MakeItSo(storage->runnable_, CallbackForward(x1)); + typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType + x1)>::MakeItSo(storage->runnable_, + CallbackForward(x1)); } }; // Arity 1 -> 0. -template +template struct Invoker<1, StorageType, R(X1)> { typedef R(RunType)(BindStateBase*); @@ -1186,24 +1312,24 @@ struct Invoker<1, StorageType, R(X1)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1)); } }; // Arity 2 -> 2. -template +template struct Invoker<0, StorageType, R(X1, X2)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1211,24 +1337,25 @@ struct Invoker<0, StorageType, R(X1, X2)> { // InvokeHelper<>::MakeItSo() call below. return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2)); + typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); } }; // Arity 2 -> 1. -template +template struct Invoker<1, StorageType, R(X1, X2)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2) { + typename CallbackParamTraits::ForwardType x2) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1239,16 +1366,17 @@ struct Invoker<1, StorageType, R(X1, X2)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); return InvokeHelper::ForwardType x2)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); } }; // Arity 2 -> 0. -template +template struct Invoker<2, StorageType, R(X1, X2)> { typedef R(RunType)(BindStateBase*); @@ -1268,29 +1396,31 @@ struct Invoker<2, StorageType, R(X1, X2)> { typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2)); } }; // Arity 3 -> 3. -template +template struct Invoker<0, StorageType, R(X1, X2, X3)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2, X3); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1298,28 +1428,33 @@ struct Invoker<0, StorageType, R(X1, X2, X3)> { // InvokeHelper<>::MakeItSo() call below. return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3)); + typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); } }; // Arity 3 -> 2. -template +template struct Invoker<1, StorageType, R(X1, X2, X3)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2, X3); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3) { + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1330,26 +1465,31 @@ struct Invoker<1, StorageType, R(X1, X2, X3)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); return InvokeHelper::ForwardType x2, - typename CallbackParamTraits::ForwardType x3)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); } }; // Arity 3 -> 1. -template +template struct Invoker<2, StorageType, R(X1, X2, X3)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X3); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x3) { + typename CallbackParamTraits::ForwardType x3) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1363,18 +1503,23 @@ struct Invoker<2, StorageType, R(X1, X2, X3)> { typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); return InvokeHelper::ForwardType x3)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); } }; // Arity 3 -> 0. -template +template struct Invoker<3, StorageType, R(X1, X2, X3)> { typedef R(RunType)(BindStateBase*); @@ -1397,32 +1542,36 @@ struct Invoker<3, StorageType, R(X1, X2, X3)> { typename Bound3UnwrapTraits::ForwardType x3 = Bound3UnwrapTraits::Unwrap(storage->p3_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3)); } }; // Arity 4 -> 4. -template +template struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2, X3, X4); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1430,32 +1579,38 @@ struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { // InvokeHelper<>::MakeItSo() call below. return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4)); + typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); } }; // Arity 4 -> 3. -template +template struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2, X3, X4); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4) { + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1466,30 +1621,36 @@ struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); return InvokeHelper::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); } }; // Arity 4 -> 2. -template +template struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X3, X4); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4) { + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1503,28 +1664,34 @@ struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); return InvokeHelper::ForwardType x3, - typename CallbackParamTraits::ForwardType x4)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); } }; // Arity 4 -> 1. -template +template struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X4); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x4) { + typename CallbackParamTraits::ForwardType x4) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1541,20 +1708,26 @@ struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { typename Bound3UnwrapTraits::ForwardType x3 = Bound3UnwrapTraits::Unwrap(storage->p3_); return InvokeHelper::ForwardType x4)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); } }; // Arity 4 -> 0. -template +template struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { typedef R(RunType)(BindStateBase*); @@ -1580,72 +1753,81 @@ struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { typename Bound4UnwrapTraits::ForwardType x4 = Bound4UnwrapTraits::Unwrap(storage->p4_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4)); } }; // Arity 5 -> 5. -template +template struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2, X3, X4, X5); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, // you really want to warp ahead and step through the // InvokeHelper<>::MakeItSo() call below. - return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); } }; // Arity 5 -> 4. -template +template struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2, X3, X4, X5); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5) { + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1655,34 +1837,39 @@ struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); - return InvokeHelper::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); } }; // Arity 5 -> 3. -template +template struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X3, X4, X5); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5) { + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1695,32 +1882,37 @@ struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { Bound1UnwrapTraits::Unwrap(storage->p1_); typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); - return InvokeHelper::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); } }; // Arity 5 -> 2. -template +template struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X4, X5); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5) { + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1736,30 +1928,35 @@ struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { Bound2UnwrapTraits::Unwrap(storage->p2_); typename Bound3UnwrapTraits::ForwardType x3 = Bound3UnwrapTraits::Unwrap(storage->p3_); - return InvokeHelper::ForwardType x4, - typename CallbackParamTraits::ForwardType x5)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); } }; // Arity 5 -> 1. -template +template struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X5); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x5) { + typename CallbackParamTraits::ForwardType x5) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1778,22 +1975,27 @@ struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { Bound3UnwrapTraits::Unwrap(storage->p3_); typename Bound4UnwrapTraits::ForwardType x4 = Bound4UnwrapTraits::Unwrap(storage->p4_); - return InvokeHelper::ForwardType x5)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); } }; // Arity 5 -> 0. -template +template struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { typedef R(RunType)(BindStateBase*); @@ -1822,79 +2024,90 @@ struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { typename Bound5UnwrapTraits::ForwardType x5 = Bound5UnwrapTraits::Unwrap(storage->p5_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5)); } }; // Arity 6 -> 6. -template +template struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, // you really want to warp ahead and step through the // InvokeHelper<>::MakeItSo() call below. - return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 5. -template +template struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2, X3, X4, X5, X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1904,38 +2117,44 @@ struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); - return InvokeHelper::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 4. -template +template struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X3, X4, X5, X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1948,36 +2167,42 @@ struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { Bound1UnwrapTraits::Unwrap(storage->p1_); typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); - return InvokeHelper::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 3. -template +template struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X4, X5, X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -1993,34 +2218,40 @@ struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { Bound2UnwrapTraits::Unwrap(storage->p2_); typename Bound3UnwrapTraits::ForwardType x3 = Bound3UnwrapTraits::Unwrap(storage->p3_); - return InvokeHelper::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 2. -template +template struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X5, X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2039,32 +2270,38 @@ struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { Bound3UnwrapTraits::Unwrap(storage->p3_); typename Bound4UnwrapTraits::ForwardType x4 = Bound4UnwrapTraits::Unwrap(storage->p4_); - return InvokeHelper::ForwardType x5, - typename CallbackParamTraits::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 1. -template +template struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X6); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x6) { + typename CallbackParamTraits::ForwardType x6) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2086,24 +2323,30 @@ struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { Bound4UnwrapTraits::Unwrap(storage->p4_); typename Bound5UnwrapTraits::ForwardType x5 = Bound5UnwrapTraits::Unwrap(storage->p5_); - return InvokeHelper::ForwardType x6)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 6 -> 0. -template +template struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { typedef R(RunType)(BindStateBase*); @@ -2135,86 +2378,99 @@ struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { typename Bound6UnwrapTraits::ForwardType x6 = Bound6UnwrapTraits::Unwrap(storage->p6_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename Bound6UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); } }; // Arity 7 -> 7. -template +template struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, // you really want to warp ahead and step through the // InvokeHelper<>::MakeItSo() call below. - return InvokeHelper::ForwardType x1, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 6. -template +template struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2224,41 +2480,48 @@ struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typename Bound1UnwrapTraits::ForwardType x1 = Bound1UnwrapTraits::Unwrap(storage->p1_); - return InvokeHelper::ForwardType x2, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 5. -template +template struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X3, X4, X5, X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2271,39 +2534,46 @@ struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { Bound1UnwrapTraits::Unwrap(storage->p1_); typename Bound2UnwrapTraits::ForwardType x2 = Bound2UnwrapTraits::Unwrap(storage->p2_); - return InvokeHelper::ForwardType x3, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 4. -template +template struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X4, X5, X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2319,37 +2589,44 @@ struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { Bound2UnwrapTraits::Unwrap(storage->p2_); typename Bound3UnwrapTraits::ForwardType x3 = Bound3UnwrapTraits::Unwrap(storage->p3_); - return InvokeHelper::ForwardType x4, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 3. -template +template struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X5, X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2368,35 +2645,42 @@ struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { Bound3UnwrapTraits::Unwrap(storage->p3_); typename Bound4UnwrapTraits::ForwardType x4 = Bound4UnwrapTraits::Unwrap(storage->p4_); - return InvokeHelper::ForwardType x5, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 2. -template +template struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X6, X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x6, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2418,33 +2702,40 @@ struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { Bound4UnwrapTraits::Unwrap(storage->p4_); typename Bound5UnwrapTraits::ForwardType x5 = Bound5UnwrapTraits::Unwrap(storage->p5_); - return InvokeHelper::ForwardType x6, - typename CallbackParamTraits::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 1. -template +template struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*, - typename CallbackParamTraits::ForwardType); + typename CallbackParamTraits::ForwardType); typedef R(UnboundRunType)(X7); static R Run(BindStateBase* base, - typename CallbackParamTraits::ForwardType x7) { + typename CallbackParamTraits::ForwardType x7) { StorageType* storage = static_cast(base); // Local references to make debugger stepping easier. If in a debugger, @@ -2469,25 +2760,32 @@ struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { Bound5UnwrapTraits::Unwrap(storage->p5_); typename Bound6UnwrapTraits::ForwardType x6 = Bound6UnwrapTraits::Unwrap(storage->p6_); - return InvokeHelper::ForwardType x7)> - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename Bound6UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; // Arity 7 -> 0. -template +template struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typedef R(RunType)(BindStateBase*); @@ -2522,22 +2820,20 @@ struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { typename Bound7UnwrapTraits::ForwardType x7 = Bound7UnwrapTraits::Unwrap(storage->p7_); return InvokeHelper - ::MakeItSo(storage->runnable_, CallbackForward(x1), - CallbackForward(x2), CallbackForward(x3), - CallbackForward(x4), CallbackForward(x5), - CallbackForward(x6), CallbackForward(x7)); + typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename Bound6UnwrapTraits::ForwardType, + typename Bound7UnwrapTraits::ForwardType)>:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); } }; - // BindState<> // // This stores all the state passed into Bind() and is also where most @@ -2560,11 +2856,9 @@ struct BindState : public BindStateBase { typedef Invoker<0, BindState, RunType> InvokerType; typedef typename InvokerType::UnboundRunType UnboundRunType; explicit BindState(const Runnable& runnable) - : BindStateBase(&Destroy), - runnable_(runnable) { - } + : BindStateBase(&Destroy), runnable_(runnable) {} - ~BindState() { } + ~BindState() {} static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2584,14 +2878,13 @@ struct BindState : public BindStateBase { typedef UnwrapTraits Bound1UnwrapTraits; BindState(const Runnable& runnable, const P1& p1) - : BindStateBase(&Destroy), - runnable_(runnable), - p1_(p1) { + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1) { MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2613,15 +2906,13 @@ struct BindState : public BindStateBase { typedef UnwrapTraits Bound2UnwrapTraits; BindState(const Runnable& runnable, const P1& p1, const P2& p2) - : BindStateBase(&Destroy), - runnable_(runnable), - p1_(p1), - p2_(p2) { + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), p2_(p2) { MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2632,10 +2923,12 @@ struct BindState : public BindStateBase { P2 p2_; }; -template -struct BindState - : public BindStateBase { +template +struct BindState : public BindStateBase { typedef Runnable RunnableType; typedef IsWeakMethod::value, P1> IsWeakCall; typedef Invoker<3, BindState, RunType> InvokerType; @@ -2655,8 +2948,9 @@ struct BindState MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2668,8 +2962,12 @@ struct BindState P3 p3_; }; -template +template struct BindState : public BindStateBase { typedef Runnable RunnableType; @@ -2683,8 +2981,11 @@ struct BindState typedef UnwrapTraits Bound3UnwrapTraits; typedef UnwrapTraits Bound4UnwrapTraits; - BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, - const P4& p4) + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4) : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), @@ -2694,8 +2995,9 @@ struct BindState MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2708,8 +3010,13 @@ struct BindState P4 p4_; }; -template +template struct BindState : public BindStateBase { typedef Runnable RunnableType; @@ -2724,8 +3031,12 @@ struct BindState typedef UnwrapTraits Bound4UnwrapTraits; typedef UnwrapTraits Bound5UnwrapTraits; - BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, - const P4& p4, const P5& p5) + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), @@ -2736,8 +3047,9 @@ struct BindState MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2751,8 +3063,14 @@ struct BindState P5 p5_; }; -template +template struct BindState : public BindStateBase { typedef Runnable RunnableType; @@ -2768,8 +3086,13 @@ struct BindState typedef UnwrapTraits Bound5UnwrapTraits; typedef UnwrapTraits Bound6UnwrapTraits; - BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, - const P4& p4, const P5& p5, const P6& p6) + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), @@ -2781,8 +3104,9 @@ struct BindState MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); @@ -2797,8 +3121,15 @@ struct BindState P6 p6_; }; -template +template struct BindState : public BindStateBase { typedef Runnable RunnableType; @@ -2815,8 +3146,14 @@ struct BindState typedef UnwrapTraits Bound6UnwrapTraits; typedef UnwrapTraits Bound7UnwrapTraits; - BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3, - const P4& p4, const P5& p5, const P6& p6, const P7& p7) + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), @@ -2829,8 +3166,9 @@ struct BindState MaybeRefcount::value, P1>::AddRef(p1_); } - ~BindState() { MaybeRefcount::value, - P1>::Release(p1_); } + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } static void Destroy(BindStateBase* self) { delete static_cast(self); diff --git a/src/include/base/internal/cef_bind_internal_win.h b/src/include/base/internal/cef_bind_internal_win.h index 1b061ccd..4a363def 100644 --- a/src/include/base/internal/cef_bind_internal_win.h +++ b/src/include/base/internal/cef_bind_internal_win.h @@ -48,338 +48,344 @@ class RunnableAdapter; // __stdcall Function: Arity 0. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(); + typedef R(RunType)(); - explicit RunnableAdapter(R(__stdcall *function)()) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)()) : function_(function) {} - R Run() { - return function_(); - } + R Run() { return function_(); } private: - R (__stdcall *function_)(); + R(__stdcall* function_)(); }; // __fastcall Function: Arity 0. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(); + typedef R(RunType)(); - explicit RunnableAdapter(R(__fastcall *function)()) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)()) : function_(function) {} - R Run() { - return function_(); - } + R Run() { return function_(); } private: - R (__fastcall *function_)(); + R(__fastcall* function_)(); }; // __stdcall Function: Arity 1. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1); + typedef R(RunType)(A1); - explicit RunnableAdapter(R(__stdcall *function)(A1)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1)) : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1) { return function_(a1); } private: - R (__stdcall *function_)(A1); + R(__stdcall* function_)(A1); }; // __fastcall Function: Arity 1. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1); + typedef R(RunType)(A1); - explicit RunnableAdapter(R(__fastcall *function)(A1)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1)) : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1) { return function_(a1); } private: - R (__fastcall *function_)(A1); + R(__fastcall* function_)(A1); }; // __stdcall Function: Arity 2. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2); + typedef R(RunType)(A1, A2); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2) { + typename CallbackParamTraits::ForwardType a2) { return function_(a1, a2); } private: - R (__stdcall *function_)(A1, A2); + R(__stdcall* function_)(A1, A2); }; // __fastcall Function: Arity 2. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2); + typedef R(RunType)(A1, A2); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2) { + typename CallbackParamTraits::ForwardType a2) { return function_(a1, a2); } private: - R (__fastcall *function_)(A1, A2); + R(__fastcall* function_)(A1, A2); }; // __stdcall Function: Arity 3. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3); + typedef R(RunType)(A1, A2, A3); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { return function_(a1, a2, a3); } private: - R (__stdcall *function_)(A1, A2, A3); + R(__stdcall* function_)(A1, A2, A3); }; // __fastcall Function: Arity 3. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3); + typedef R(RunType)(A1, A2, A3); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { return function_(a1, a2, a3); } private: - R (__fastcall *function_)(A1, A2, A3); + R(__fastcall* function_)(A1, A2, A3); }; // __stdcall Function: Arity 4. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4); + typedef R(RunType)(A1, A2, A3, A4); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { return function_(a1, a2, a3, a4); } private: - R (__stdcall *function_)(A1, A2, A3, A4); + R(__stdcall* function_)(A1, A2, A3, A4); }; // __fastcall Function: Arity 4. template -class RunnableAdapter { +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4); + typedef R(RunType)(A1, A2, A3, A4); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { return function_(a1, a2, a3, a4); } private: - R (__fastcall *function_)(A1, A2, A3, A4); + R(__fastcall* function_)(A1, A2, A3, A4); }; // __stdcall Function: Arity 5. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5); + typedef R(RunType)(A1, A2, A3, A4, A5); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { return function_(a1, a2, a3, a4, a5); } private: - R (__stdcall *function_)(A1, A2, A3, A4, A5); + R(__stdcall* function_)(A1, A2, A3, A4, A5); }; // __fastcall Function: Arity 5. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5); + typedef R(RunType)(A1, A2, A3, A4, A5); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { return function_(a1, a2, a3, a4, a5); } private: - R (__fastcall *function_)(A1, A2, A3, A4, A5); + R(__fastcall* function_)(A1, A2, A3, A4, A5); }; // __stdcall Function: Arity 6. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6); + typedef R(RunType)(A1, A2, A3, A4, A5, A6); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { return function_(a1, a2, a3, a4, a5, a6); } private: - R (__stdcall *function_)(A1, A2, A3, A4, A5, A6); + R(__stdcall* function_)(A1, A2, A3, A4, A5, A6); }; // __fastcall Function: Arity 6. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6); + typedef R(RunType)(A1, A2, A3, A4, A5, A6); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { return function_(a1, a2, a3, a4, a5, a6); } private: - R (__fastcall *function_)(A1, A2, A3, A4, A5, A6); + R(__fastcall* function_)(A1, A2, A3, A4, A5, A6); }; // __stdcall Function: Arity 7. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7); + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); - explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6, A7)) - : function_(function) { - } + explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6, - typename CallbackParamTraits::ForwardType a7) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { return function_(a1, a2, a3, a4, a5, a6, a7); } private: - R (__stdcall *function_)(A1, A2, A3, A4, A5, A6, A7); + R(__stdcall* function_)(A1, A2, A3, A4, A5, A6, A7); }; // __fastcall Function: Arity 7. -template -class RunnableAdapter { +template +class RunnableAdapter { public: - typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7); + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); - explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6, A7)) - : function_(function) { - } + explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} R Run(typename CallbackParamTraits::ForwardType a1, - typename CallbackParamTraits::ForwardType a2, - typename CallbackParamTraits::ForwardType a3, - typename CallbackParamTraits::ForwardType a4, - typename CallbackParamTraits::ForwardType a5, - typename CallbackParamTraits::ForwardType a6, - typename CallbackParamTraits::ForwardType a7) { + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { return function_(a1, a2, a3, a4, a5, a6, a7); } private: - R (__fastcall *function_)(A1, A2, A3, A4, A5, A6, A7); + R(__fastcall* function_)(A1, A2, A3, A4, A5, A6, A7); }; } // namespace cef_internal diff --git a/src/include/base/internal/cef_callback_internal.h b/src/include/base/internal/cef_callback_internal.h index 542e8438..1f2e16c9 100644 --- a/src/include/base/internal/cef_callback_internal.h +++ b/src/include/base/internal/cef_callback_internal.h @@ -92,7 +92,7 @@ class CallbackBase { // another type. It is not okay to use void*. We create a InvokeFuncStorage // that that can store our function pointer, and then cast it back to // the original type on usage. - typedef void(*InvokeFuncStorage)(void); + typedef void (*InvokeFuncStorage)(void); // Returns true if this callback equals |other|. |other| may be null. bool Equals(const CallbackBase& other) const; @@ -115,15 +115,16 @@ class CallbackBase { // A helper template to determine if given type is non-const move-only-type, // i.e. if a value of the given type should be passed via .Pass() in a // destructive way. -template struct IsMoveOnlyType { +template +struct IsMoveOnlyType { template static YesType Test(const typename U::MoveOnlyTypeForCPP03*); template static NoType Test(...); - static const bool value = sizeof(Test(0)) == sizeof(YesType) && - !is_const::value; + static const bool value = + sizeof(Test(0)) == sizeof(YesType) && !is_const::value; }; // This is a typetraits object that's used to take an argument type, and diff --git a/src/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h b/src/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h index 8584fcd7..9f2f932f 100644 --- a/src/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h +++ b/src/include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h @@ -51,9 +51,7 @@ namespace cef_internal { template struct NeedsScopedRefptrButGetsRawPtr { #if defined(OS_WIN) - enum { - value = base::false_type::value - }; + enum { value = base::false_type::value }; #else enum { // Human readable translation: you needed to be a scoped_refptr if you are a @@ -77,74 +75,103 @@ struct ParamsUseScopedRefptrCorrectly { }; template -struct ParamsUseScopedRefptrCorrectly > { +struct ParamsUseScopedRefptrCorrectly> { enum { value = !NeedsScopedRefptrButGetsRawPtr::value }; }; template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; -template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; -template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; -template -struct ParamsUseScopedRefptrCorrectly > { - enum { value = !(NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value || - NeedsScopedRefptrButGetsRawPtr::value) }; +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; }; } // namespace cef_internal diff --git a/src/include/cef_geolocation.h b/src/include/cef_accessibility_handler.h similarity index 68% rename from src/include/cef_geolocation.h rename to src/include/cef_accessibility_handler.h index 32005a43..c34e0c57 100644 --- a/src/include/cef_geolocation.h +++ b/src/include/cef_accessibility_handler.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -34,33 +34,33 @@ // tools directory for more information. // -#ifndef CEF_INCLUDE_CEF_GEOLOCATION_H_ -#define CEF_INCLUDE_CEF_GEOLOCATION_H_ +#ifndef CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ +#define CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ #pragma once -#include "include/cef_base.h" +#include "include/cef_values.h" /// -// Implement this interface to receive geolocation updates. The methods of this -// class will be called on the browser process UI thread. +// Implement this interface to receive accessibility notification when +// accessibility events have been registered. The methods of this class will +// be called on the UI thread. /// /*--cef(source=client)--*/ -class CefGetGeolocationCallback : public virtual CefBaseRefCounted { +class CefAccessibilityHandler : public virtual CefBaseRefCounted { public: /// - // Called with the 'best available' location information or, if the location - // update failed, with error information. + // Called after renderer process sends accessibility tree changes to the + // browser process. /// /*--cef()--*/ - virtual void OnLocationUpdate(const CefGeoposition& position) =0; -}; + virtual void OnAccessibilityTreeChange(CefRefPtr value) = 0; -/// -// Request a one-time geolocation update. This function bypasses any user -// permission checks so should only be used by code that is allowed to access -// location information. -/// -/*--cef()--*/ -bool CefGetGeolocation(CefRefPtr callback); + /// + // Called after renderer process sends accessibility location changes to the + // browser process. + /// + /*--cef()--*/ + virtual void OnAccessibilityLocationChange(CefRefPtr value) = 0; +}; -#endif // CEF_INCLUDE_CEF_GEOLOCATION_H_ +#endif // CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ diff --git a/src/include/cef_app.h b/src/include/cef_app.h index 5aca29b3..3962a09c 100644 --- a/src/include/cef_app.h +++ b/src/include/cef_app.h @@ -34,7 +34,6 @@ // tools directory for more information. // - #ifndef CEF_INCLUDE_CEF_APP_H_ #define CEF_INCLUDE_CEF_APP_H_ #pragma once @@ -159,8 +158,7 @@ class CefApp : public virtual CefBaseRefCounted { /*--cef(optional_param=process_type)--*/ virtual void OnBeforeCommandLineProcessing( const CefString& process_type, - CefRefPtr command_line) { - } + CefRefPtr command_line) {} /// // Provides an opportunity to register custom schemes. Do not keep a reference @@ -170,8 +168,7 @@ class CefApp : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void OnRegisterCustomSchemes( - CefRawPtr registrar) { - } + CefRawPtr registrar) {} /// // Return the handler for resource bundle events. If diff --git a/src/include/cef_application_mac.h b/src/include/cef_application_mac.h index 473e9972..e2858c48 100644 --- a/src/include/cef_application_mac.h +++ b/src/include/cef_application_mac.h @@ -31,7 +31,9 @@ #define CEF_INCLUDE_CEF_APPLICATION_MAC_H_ #pragma once +#ifdef __cplusplus #include "include/cef_base.h" +#endif // __cplusplus #if defined(OS_MACOSX) && defined(__OBJC__) @@ -82,25 +84,27 @@ @protocol CefAppProtocol @end +#ifdef __cplusplus + // Controls the state of |isHandlingSendEvent| in the event loop so that it is // reset properly. class CefScopedSendingEvent { public: CefScopedSendingEvent() - : app_(static_cast*>( - [NSApplication sharedApplication])), - handling_([app_ isHandlingSendEvent]) { + : app_(static_cast*>( + [NSApplication sharedApplication])), + handling_([app_ isHandlingSendEvent]) { [app_ setHandlingSendEvent:YES]; } - ~CefScopedSendingEvent() { - [app_ setHandlingSendEvent:handling_]; - } + ~CefScopedSendingEvent() { [app_ setHandlingSendEvent:handling_]; } private: NSApplication* app_; BOOL handling_; }; +#endif // __cplusplus + #endif // defined(OS_MACOSX) && defined(__OBJC__) #endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_ diff --git a/src/include/cef_auth_callback.h b/src/include/cef_auth_callback.h index ca511fdc..fc8a10a9 100644 --- a/src/include/cef_auth_callback.h +++ b/src/include/cef_auth_callback.h @@ -50,15 +50,15 @@ class CefAuthCallback : public virtual CefBaseRefCounted { /// // Continue the authentication request. /// - /*--cef(capi_name=cont)--*/ + /*--cef(capi_name=cont,optional_param=username,optional_param=password)--*/ virtual void Continue(const CefString& username, - const CefString& password) =0; + const CefString& password) = 0; /// // Cancel the authentication request. /// /*--cef()--*/ - virtual void Cancel() =0; + virtual void Cancel() = 0; }; #endif // CEF_INCLUDE_CEF_AUTH_CALLBACK_H_ diff --git a/src/include/cef_base.h b/src/include/cef_base.h index c152cf06..816108e2 100644 --- a/src/include/cef_base.h +++ b/src/include/cef_base.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - #ifndef CEF_INCLUDE_CEF_BASE_H_ #define CEF_INCLUDE_CEF_BASE_H_ #pragma once @@ -56,18 +55,18 @@ class CefBaseRefCounted { // Called to increment the reference count for the object. Should be called // for every new copy of a pointer to a given object. /// - virtual void AddRef() const =0; + virtual void AddRef() const = 0; /// // Called to decrement the reference count for the object. Returns true if // the reference count is 0, in which case the object should self-delete. /// - virtual bool Release() const =0; + virtual bool Release() const = 0; /// // Returns true if the reference count is 1. /// - virtual bool HasOneRef() const =0; + virtual bool HasOneRef() const = 0; protected: virtual ~CefBaseRefCounted() {} @@ -91,23 +90,17 @@ class CefRefCount { /// // Increment the reference count. /// - void AddRef() const { - base::AtomicRefCountInc(&ref_count_); - } + void AddRef() const { base::AtomicRefCountInc(&ref_count_); } /// // Decrement the reference count. Returns true if the reference count is 0. /// - bool Release() const { - return !base::AtomicRefCountDec(&ref_count_); - } + bool Release() const { return !base::AtomicRefCountDec(&ref_count_); } /// // Returns true if the reference count is 1. /// - bool HasOneRef() const { - return base::AtomicRefCountIsOne(&ref_count_); - } + bool HasOneRef() const { return base::AtomicRefCountIsOne(&ref_count_); } private: mutable base::AtomicRefCount ref_count_; @@ -118,23 +111,20 @@ class CefRefCount { // Macro that provides a reference counting implementation for classes extending // CefBase. /// -#define IMPLEMENT_REFCOUNTING(ClassName) \ - public: \ - void AddRef() const OVERRIDE { \ - ref_count_.AddRef(); \ - } \ - bool Release() const OVERRIDE { \ - if (ref_count_.Release()) { \ - delete static_cast(this); \ - return true; \ - } \ - return false; \ - } \ - bool HasOneRef() const OVERRIDE { \ - return ref_count_.HasOneRef(); \ - } \ - private: \ - CefRefCount ref_count_; +#define IMPLEMENT_REFCOUNTING(ClassName) \ + public: \ + void AddRef() const OVERRIDE { ref_count_.AddRef(); } \ + bool Release() const OVERRIDE { \ + if (ref_count_.Release()) { \ + delete static_cast(this); \ + return true; \ + } \ + return false; \ + } \ + bool HasOneRef() const OVERRIDE { return ref_count_.HasOneRef(); } \ + \ + private: \ + CefRefCount ref_count_; /// // Macro that provides a locking implementation. Use the Lock() and Unlock() @@ -169,19 +159,21 @@ class CefRefCount { // value_++; // } /// -#define IMPLEMENT_LOCKING(ClassName) \ - public: \ - class AutoLock { \ - public: \ - explicit AutoLock(ClassName* base) : base_(base) { base_->Lock(); } \ - ~AutoLock() { base_->Unlock(); } \ - private: \ - ClassName* base_; \ - DISALLOW_COPY_AND_ASSIGN(AutoLock); \ - }; \ - void Lock() { lock_.Acquire(); } \ - void Unlock() { lock_.Release(); } \ - private: \ - base::Lock lock_; +#define IMPLEMENT_LOCKING(ClassName) \ + public: \ + class AutoLock { \ + public: \ + explicit AutoLock(ClassName* base) : base_(base) { base_->Lock(); } \ + ~AutoLock() { base_->Unlock(); } \ + \ + private: \ + ClassName* base_; \ + DISALLOW_COPY_AND_ASSIGN(AutoLock); \ + }; \ + void Lock() { lock_.Acquire(); } \ + void Unlock() { lock_.Release(); } \ + \ + private: \ + base::Lock lock_; #endif // CEF_INCLUDE_CEF_BASE_H_ diff --git a/src/include/cef_browser.h b/src/include/cef_browser.h index 3b4ed161..72d9b3ba 100644 --- a/src/include/cef_browser.h +++ b/src/include/cef_browser.h @@ -38,6 +38,7 @@ #define CEF_INCLUDE_CEF_BROWSER_H_ #pragma once +#include #include "include/cef_base.h" #include "include/cef_drag_data.h" #include "include/cef_frame.h" @@ -45,12 +46,10 @@ #include "include/cef_navigation_entry.h" #include "include/cef_process_message.h" #include "include/cef_request_context.h" -#include class CefBrowserHost; class CefClient; - /// // Class used to represent a browser window. When used in the browser process // the methods of this class may be called on any thread unless otherwise @@ -65,122 +64,123 @@ class CefBrowser : public virtual CefBaseRefCounted { // browser process. /// /*--cef()--*/ - virtual CefRefPtr GetHost() =0; + virtual CefRefPtr GetHost() = 0; /// // Returns true if the browser can navigate backwards. /// /*--cef()--*/ - virtual bool CanGoBack() =0; + virtual bool CanGoBack() = 0; /// // Navigate backwards. /// /*--cef()--*/ - virtual void GoBack() =0; + virtual void GoBack() = 0; /// // Returns true if the browser can navigate forwards. /// /*--cef()--*/ - virtual bool CanGoForward() =0; + virtual bool CanGoForward() = 0; /// // Navigate forwards. /// /*--cef()--*/ - virtual void GoForward() =0; + virtual void GoForward() = 0; /// // Returns true if the browser is currently loading. /// /*--cef()--*/ - virtual bool IsLoading() =0; + virtual bool IsLoading() = 0; /// // Reload the current page. /// /*--cef()--*/ - virtual void Reload() =0; + virtual void Reload() = 0; /// // Reload the current page ignoring any cached data. /// /*--cef()--*/ - virtual void ReloadIgnoreCache() =0; + virtual void ReloadIgnoreCache() = 0; /// // Stop loading the page. /// /*--cef()--*/ - virtual void StopLoad() =0; + virtual void StopLoad() = 0; /// - // Returns the globally unique identifier for this browser. + // Returns the globally unique identifier for this browser. This value is also + // used as the tabId for extension APIs. /// /*--cef()--*/ - virtual int GetIdentifier() =0; + virtual int GetIdentifier() = 0; /// // Returns true if this object is pointing to the same handle as |that| // object. /// /*--cef()--*/ - virtual bool IsSame(CefRefPtr that) =0; + virtual bool IsSame(CefRefPtr that) = 0; /// // Returns true if the window is a popup window. /// /*--cef()--*/ - virtual bool IsPopup() =0; + virtual bool IsPopup() = 0; /// // Returns true if a document has been loaded in the browser. /// /*--cef()--*/ - virtual bool HasDocument() =0; + virtual bool HasDocument() = 0; /// // Returns the main (top-level) frame for the browser window. /// /*--cef()--*/ - virtual CefRefPtr GetMainFrame() =0; + virtual CefRefPtr GetMainFrame() = 0; /// // Returns the focused frame for the browser window. /// /*--cef()--*/ - virtual CefRefPtr GetFocusedFrame() =0; + virtual CefRefPtr GetFocusedFrame() = 0; /// // Returns the frame with the specified identifier, or NULL if not found. /// /*--cef(capi_name=get_frame_byident)--*/ - virtual CefRefPtr GetFrame(int64 identifier) =0; + virtual CefRefPtr GetFrame(int64 identifier) = 0; /// // Returns the frame with the specified name, or NULL if not found. /// /*--cef(optional_param=name)--*/ - virtual CefRefPtr GetFrame(const CefString& name) =0; + virtual CefRefPtr GetFrame(const CefString& name) = 0; /// // Returns the number of frames that currently exist. /// /*--cef()--*/ - virtual size_t GetFrameCount() =0; + virtual size_t GetFrameCount() = 0; /// // Returns the identifiers of all existing frames. /// /*--cef(count_func=identifiers:GetFrameCount)--*/ - virtual void GetFrameIdentifiers(std::vector& identifiers) =0; + virtual void GetFrameIdentifiers(std::vector& identifiers) = 0; /// // Returns the names of all existing frames. /// /*--cef()--*/ - virtual void GetFrameNames(std::vector& names) =0; + virtual void GetFrameNames(std::vector& names) = 0; /// // Send a message to the specified |target_process|. Returns true if the @@ -188,10 +188,9 @@ class CefBrowser : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual bool SendProcessMessage(CefProcessId target_process, - CefRefPtr message) =0; + CefRefPtr message) = 0; }; - /// // Callback interface for CefBrowserHost::RunFileDialog. The methods of this // class will be called on the browser process UI thread. @@ -209,10 +208,9 @@ class CefRunFileDialogCallback : public virtual CefBaseRefCounted { /*--cef(index_param=selected_accept_filter,optional_param=file_paths)--*/ virtual void OnFileDialogDismissed( int selected_accept_filter, - const std::vector& file_paths) =0; + const std::vector& file_paths) = 0; }; - /// // Callback interface for CefBrowserHost::GetNavigationEntries. The methods of // this class will be called on the browser process UI thread. @@ -231,10 +229,9 @@ class CefNavigationEntryVisitor : public virtual CefBaseRefCounted { virtual bool Visit(CefRefPtr entry, bool current, int index, - int total) =0; + int total) = 0; }; - /// // Callback interface for CefBrowserHost::PrintToPDF. The methods of this class // will be called on the browser process UI thread. @@ -248,10 +245,9 @@ class CefPdfPrintCallback : public virtual CefBaseRefCounted { // successfully or false otherwise. /// /*--cef()--*/ - virtual void OnPdfPrintFinished(const CefString& path, bool ok) =0; + virtual void OnPdfPrintFinished(const CefString& path, bool ok) = 0; }; - /// // Callback interface for CefBrowserHost::DownloadImage. The methods of this // class will be called on the browser process UI thread. @@ -266,13 +262,11 @@ class CefDownloadImageCallback : public virtual CefBaseRefCounted { // multiple scale factors, or empty if the download failed. /// /*--cef(optional_param=image)--*/ - virtual void OnDownloadImageFinished( - const CefString& image_url, - int http_status_code, - CefRefPtr image) =0; + virtual void OnDownloadImageFinished(const CefString& image_url, + int http_status_code, + CefRefPtr image) = 0; }; - /// // Class used to represent the browser process aspects of a browser window. The // methods of this class can only be called in the browser process. They may be @@ -321,7 +315,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // Returns the hosted browser object. /// /*--cef()--*/ - virtual CefRefPtr GetBrowser() =0; + virtual CefRefPtr GetBrowser() = 0; /// // Request that the browser close. The JavaScript 'onbeforeunload' event will @@ -334,7 +328,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // information. /// /*--cef()--*/ - virtual void CloseBrowser(bool force_close) =0; + virtual void CloseBrowser(bool force_close) = 0; /// // Helper for closing a browser. Call this method from the top-level window @@ -345,13 +339,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // information. This method must be called on the browser process UI thread. /// /*--cef()--*/ - virtual bool TryCloseBrowser() =0; + virtual bool TryCloseBrowser() = 0; /// // Set whether the browser is focused. /// /*--cef()--*/ - virtual void SetFocus(bool focus) =0; + virtual void SetFocus(bool focus) = 0; /// // Retrieve the window handle for this browser. If this browser is wrapped in @@ -359,41 +353,41 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // thread and it will return the handle for the top-level native window. /// /*--cef()--*/ - virtual CefWindowHandle GetWindowHandle() =0; + virtual CefWindowHandle GetWindowHandle() = 0; /// // Retrieve the window handle of the browser that opened this browser. Will // return NULL for non-popup windows or if this browser is wrapped in a // CefBrowserView. This method can be used in combination with custom handling - // of modal windows. + // of modal windows. /// /*--cef()--*/ - virtual CefWindowHandle GetOpenerWindowHandle() =0; + virtual CefWindowHandle GetOpenerWindowHandle() = 0; /// // Returns true if this browser is wrapped in a CefBrowserView. /// /*--cef()--*/ - virtual bool HasView() =0; + virtual bool HasView() = 0; /// // Returns the client for this browser. /// /*--cef()--*/ - virtual CefRefPtr GetClient() =0; + virtual CefRefPtr GetClient() = 0; /// // Returns the request context for this browser. /// /*--cef()--*/ - virtual CefRefPtr GetRequestContext() =0; + virtual CefRefPtr GetRequestContext() = 0; /// // Get the current zoom level. The default zoom level is 0.0. This method can // only be called on the UI thread. /// /*--cef()--*/ - virtual double GetZoomLevel() =0; + virtual double GetZoomLevel() = 0; /// // Change the zoom level to the specified value. Specify 0.0 to reset the @@ -402,7 +396,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // UI thread. /// /*--cef()--*/ - virtual void SetZoomLevel(double zoomLevel) =0; + virtual void SetZoomLevel(double zoomLevel) = 0; /// // Call to run a file chooser dialog. Only a single file chooser dialog may be @@ -427,13 +421,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted { const CefString& default_file_path, const std::vector& accept_filters, int selected_accept_filter, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Download the file at |url| using CefDownloadHandler. /// /*--cef()--*/ - virtual void StartDownload(const CefString& url) =0; + virtual void StartDownload(const CefString& url) = 0; /// // Download |image_url| and execute |callback| on completion with the images @@ -452,13 +446,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted { bool is_favicon, uint32 max_image_size, bool bypass_cache, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Print the current browser contents. /// /*--cef()--*/ - virtual void Print() =0; + virtual void Print() = 0; /// // Print the current browser contents to the PDF file specified by |path| and @@ -469,25 +463,31 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /*--cef(optional_param=callback)--*/ virtual void PrintToPDF(const CefString& path, const CefPdfPrintSettings& settings, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// - // Search for |searchText|. |identifier| can be used to have multiple searches - // running simultaniously. |forward| indicates whether to search forward or - // backward within the page. |matchCase| indicates whether the search should - // be case-sensitive. |findNext| indicates whether this is the first request - // or a follow-up. The CefFindHandler instance, if any, returned via - // CefClient::GetFindHandler will be called to report find results. + // Search for |searchText|. |identifier| must be a unique ID and these IDs + // must strictly increase so that newer requests always have greater IDs than + // older requests. If |identifier| is zero or less than the previous ID value + // then it will be automatically assigned a new valid ID. |forward| indicates + // whether to search forward or backward within the page. |matchCase| + // indicates whether the search should be case-sensitive. |findNext| indicates + // whether this is the first request or a follow-up. The CefFindHandler + // instance, if any, returned via CefClient::GetFindHandler will be called to + // report find results. /// /*--cef()--*/ - virtual void Find(int identifier, const CefString& searchText, - bool forward, bool matchCase, bool findNext) =0; + virtual void Find(int identifier, + const CefString& searchText, + bool forward, + bool matchCase, + bool findNext) = 0; /// // Cancel all searches that are currently going on. /// /*--cef()--*/ - virtual void StopFinding(bool clearSelection) =0; + virtual void StopFinding(bool clearSelection) = 0; /// // Open developer tools (DevTools) in its own browser. The DevTools browser @@ -503,20 +503,20 @@ class CefBrowserHost : public virtual CefBaseRefCounted { virtual void ShowDevTools(const CefWindowInfo& windowInfo, CefRefPtr client, const CefBrowserSettings& settings, - const CefPoint& inspect_element_at) =0; + const CefPoint& inspect_element_at) = 0; /// // Explicitly close the associated DevTools browser, if any. /// /*--cef()--*/ - virtual void CloseDevTools() =0; + virtual void CloseDevTools() = 0; /// // Returns true if this browser currently has an associated DevTools browser. // Must be called on the browser process UI thread. /// /*--cef()--*/ - virtual bool HasDevTools() =0; + virtual bool HasDevTools() = 0; /// // Retrieve a snapshot of current navigation entries as values sent to the @@ -526,38 +526,38 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /*--cef()--*/ virtual void GetNavigationEntries( CefRefPtr visitor, - bool current_only) =0; + bool current_only) = 0; /// // Set whether mouse cursor change is disabled. /// /*--cef()--*/ - virtual void SetMouseCursorChangeDisabled(bool disabled) =0; + virtual void SetMouseCursorChangeDisabled(bool disabled) = 0; /// // Returns true if mouse cursor change is disabled. /// /*--cef()--*/ - virtual bool IsMouseCursorChangeDisabled() =0; + virtual bool IsMouseCursorChangeDisabled() = 0; /// // If a misspelled word is currently selected in an editable node calling // this method will replace it with the specified |word|. /// /*--cef()--*/ - virtual void ReplaceMisspelling(const CefString& word) =0; + virtual void ReplaceMisspelling(const CefString& word) = 0; /// // Add the specified |word| to the spelling dictionary. /// /*--cef()--*/ - virtual void AddWordToDictionary(const CefString& word) =0; + virtual void AddWordToDictionary(const CefString& word) = 0; /// // Returns true if window rendering is disabled. /// /*--cef()--*/ - virtual bool IsWindowRenderingDisabled() =0; + virtual bool IsWindowRenderingDisabled() = 0; /// // Notify the browser that the widget has been resized. The browser will first @@ -566,7 +566,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void WasResized() =0; + virtual void WasResized() = 0; /// // Notify the browser that it has been hidden or shown. Layouting and @@ -574,7 +574,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // hidden. This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void WasHidden(bool hidden) =0; + virtual void WasHidden(bool hidden) = 0; /// // Send a notification to the browser that the screen info has changed. The @@ -585,7 +585,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // disabled. /// /*--cef()--*/ - virtual void NotifyScreenInfoChanged() =0; + virtual void NotifyScreenInfoChanged() = 0; /// // Invalidate the view. The browser will call CefRenderHandler::OnPaint @@ -593,13 +593,13 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // disabled. /// /*--cef()--*/ - virtual void Invalidate(PaintElementType type) =0; + virtual void Invalidate(PaintElementType type) = 0; /// // Send a key event to the browser. /// /*--cef()--*/ - virtual void SendKeyEvent(const CefKeyEvent& event) =0; + virtual void SendKeyEvent(const CefKeyEvent& event) = 0; /// // Send a mouse click event to the browser. The |x| and |y| coordinates are @@ -608,7 +608,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /*--cef()--*/ virtual void SendMouseClickEvent(const CefMouseEvent& event, MouseButtonType type, - bool mouseUp, int clickCount) =0; + bool mouseUp, + int clickCount) = 0; /// // Send a mouse move event to the browser. The |x| and |y| coordinates are @@ -616,7 +617,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void SendMouseMoveEvent(const CefMouseEvent& event, - bool mouseLeave) =0; + bool mouseLeave) = 0; /// // Send a mouse wheel event to the browser. The |x| and |y| coordinates are @@ -627,26 +628,27 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void SendMouseWheelEvent(const CefMouseEvent& event, - int deltaX, int deltaY) =0; + int deltaX, + int deltaY) = 0; /// // Send a focus event to the browser. /// /*--cef()--*/ - virtual void SendFocusEvent(bool setFocus) =0; + virtual void SendFocusEvent(bool setFocus) = 0; /// // Send a capture lost event to the browser. /// /*--cef()--*/ - virtual void SendCaptureLostEvent() =0; + virtual void SendCaptureLostEvent() = 0; /// // Notify the browser that the window hosting it is about to be moved or // resized. This method is only used on Windows and Linux. /// /*--cef()--*/ - virtual void NotifyMoveOrResizeStarted() =0; + virtual void NotifyMoveOrResizeStarted() = 0; /// // Returns the maximum rate in frames per second (fps) that CefRenderHandler:: @@ -656,7 +658,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // can only be called on the UI thread. /// /*--cef()--*/ - virtual int GetWindowlessFrameRate() =0; + virtual int GetWindowlessFrameRate() = 0; /// // Set the maximum rate in frames per second (fps) that CefRenderHandler:: @@ -666,7 +668,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // set at browser creation via CefBrowserSettings.windowless_frame_rate. /// /*--cef()--*/ - virtual void SetWindowlessFrameRate(int frame_rate) =0; + virtual void SetWindowlessFrameRate(int frame_rate) = 0; /// // Begins a new composition or updates the existing composition. Blink has a @@ -696,7 +698,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { const CefString& text, const std::vector& underlines, const CefRange& replacement_range, - const CefRange& selection_range) =0; + const CefRange& selection_range) = 0; /// // Completes the existing composition by optionally inserting the specified @@ -710,7 +712,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /*--cef(optional_param=text)--*/ virtual void ImeCommitText(const CefString& text, const CefRange& replacement_range, - int relative_cursor_pos) =0; + int relative_cursor_pos) = 0; /// // Completes the existing composition by applying the current composition node @@ -719,7 +721,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void ImeFinishComposingText(bool keep_selection) =0; + virtual void ImeFinishComposingText(bool keep_selection) = 0; /// // Cancels the existing composition and discards the composition node @@ -728,7 +730,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void ImeCancelComposition() =0; + virtual void ImeCancelComposition() = 0; /// // Call this method when the user drags the mouse into the web view (before @@ -741,8 +743,8 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void DragTargetDragEnter(CefRefPtr drag_data, - const CefMouseEvent& event, - DragOperationsMask allowed_ops) =0; + const CefMouseEvent& event, + DragOperationsMask allowed_ops) = 0; /// // Call this method each time the mouse is moved across the web view during @@ -752,7 +754,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void DragTargetDragOver(const CefMouseEvent& event, - DragOperationsMask allowed_ops) =0; + DragOperationsMask allowed_ops) = 0; /// // Call this method when the user drags the mouse out of the web view (after @@ -760,7 +762,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void DragTargetDragLeave() =0; + virtual void DragTargetDragLeave() = 0; /// // Call this method when the user completes the drag operation by dropping @@ -770,7 +772,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void DragTargetDrop(const CefMouseEvent& event) =0; + virtual void DragTargetDrop(const CefMouseEvent& event) = 0; /// // Call this method when the drag operation started by a @@ -782,7 +784,7 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void DragSourceEndedAt(int x, int y, DragOperationsMask op) =0; + virtual void DragSourceEndedAt(int x, int y, DragOperationsMask op) = 0; /// // Call this method when the drag operation started by a @@ -794,14 +796,68 @@ class CefBrowserHost : public virtual CefBaseRefCounted { // This method is only used when window rendering is disabled. /// /*--cef()--*/ - virtual void DragSourceSystemDragEnded() =0; + virtual void DragSourceSystemDragEnded() = 0; /// // Returns the current visible navigation entry for this browser. This method // can only be called on the UI thread. /// /*--cef()--*/ - virtual CefRefPtr GetVisibleNavigationEntry() =0; + virtual CefRefPtr GetVisibleNavigationEntry() = 0; + + /// + // Set accessibility state for all frames. |accessibility_state| may be + // default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT + // then accessibility will be disabled by default and the state may be further + // controlled with the "force-renderer-accessibility" and + // "disable-renderer-accessibility" command-line switches. If + // |accessibility_state| is STATE_ENABLED then accessibility will be enabled. + // If |accessibility_state| is STATE_DISABLED then accessibility will be + // completely disabled. + // + // For windowed browsers accessibility will be enabled in Complete mode (which + // corresponds to kAccessibilityModeComplete in Chromium). In this mode all + // platform accessibility objects will be created and managed by Chromium's + // internal implementation. The client needs only to detect the screen reader + // and call this method appropriately. For example, on macOS the client can + // handle the @"AXEnhancedUserInterface" accessibility attribute to detect + // VoiceOver state changes and on Windows the client can handle WM_GETOBJECT + // with OBJID_CLIENT to detect accessibility readers. + // + // For windowless browsers accessibility will be enabled in TreeOnly mode + // (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In + // this mode renderer accessibility is enabled, the full tree is computed, and + // events are passed to CefAccessibiltyHandler, but platform accessibility + // objects are not created. The client may implement platform accessibility + // objects using CefAccessibiltyHandler callbacks if desired. + /// + /*--cef()--*/ + virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0; + + /// + // Enable notifications of auto resize via CefDisplayHandler::OnAutoResize. + // Notifications are disabled by default. |min_size| and |max_size| define the + // range of allowed sizes. + /// + /*--cef()--*/ + virtual void SetAutoResizeEnabled(bool enabled, + const CefSize& min_size, + const CefSize& max_size) = 0; + + /// + // Returns the extension hosted in this browser or NULL if no extension is + // hosted. See CefRequestContext::LoadExtension for details. + /// + /*--cef()--*/ + virtual CefRefPtr GetExtension() = 0; + + /// + // Returns true if this browser is hosting an extension background script. + // Background hosts do not have a window and are not displayable. See + // CefRequestContext::LoadExtension for details. + /// + /*--cef()--*/ + virtual bool IsBackgroundHost() = 0; }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/src/include/cef_browser_process_handler.h b/src/include/cef_browser_process_handler.h index e65503fb..fb770997 100644 --- a/src/include/cef_browser_process_handler.h +++ b/src/include/cef_browser_process_handler.h @@ -84,9 +84,7 @@ class CefBrowserProcessHandler : public virtual CefBaseRefCounted { // provided then printing will not be supported on the Linux platform. /// /*--cef()--*/ - virtual CefRefPtr GetPrintHandler() { - return NULL; - } + virtual CefRefPtr GetPrintHandler() { return NULL; } /// // Called from any thread when work has been scheduled for the browser process diff --git a/src/include/cef_callback.h b/src/include/cef_callback.h index 5be51e94..e206cb97 100644 --- a/src/include/cef_callback.h +++ b/src/include/cef_callback.h @@ -50,13 +50,13 @@ class CefCallback : public virtual CefBaseRefCounted { // Continue processing. /// /*--cef(capi_name=cont)--*/ - virtual void Continue() =0; + virtual void Continue() = 0; /// // Cancel processing. /// /*--cef()--*/ - virtual void Cancel() =0; + virtual void Cancel() = 0; }; /// @@ -69,7 +69,7 @@ class CefCompletionCallback : public virtual CefBaseRefCounted { // Method that will be called once the task is complete. /// /*--cef()--*/ - virtual void OnComplete() =0; + virtual void OnComplete() = 0; }; #endif // CEF_INCLUDE_CEF_CALLBACK_H_ diff --git a/src/include/cef_client.h b/src/include/cef_client.h index 9421c7c0..59173c77 100644 --- a/src/include/cef_client.h +++ b/src/include/cef_client.h @@ -46,7 +46,6 @@ #include "include/cef_drag_handler.h" #include "include/cef_find_handler.h" #include "include/cef_focus_handler.h" -#include "include/cef_geolocation_handler.h" #include "include/cef_jsdialog_handler.h" #include "include/cef_keyboard_handler.h" #include "include/cef_life_span_handler.h" @@ -75,108 +74,75 @@ class CefClient : public virtual CefBaseRefCounted { // implementation will be used. /// /*--cef()--*/ - virtual CefRefPtr GetDialogHandler() { - return NULL; - } + virtual CefRefPtr GetDialogHandler() { return NULL; } /// // Return the handler for browser display state events. /// /*--cef()--*/ - virtual CefRefPtr GetDisplayHandler() { - return NULL; - } + virtual CefRefPtr GetDisplayHandler() { return NULL; } /// // Return the handler for download events. If no handler is returned downloads // will not be allowed. /// /*--cef()--*/ - virtual CefRefPtr GetDownloadHandler() { - return NULL; - } + virtual CefRefPtr GetDownloadHandler() { return NULL; } /// // Return the handler for drag events. /// /*--cef()--*/ - virtual CefRefPtr GetDragHandler() { - return NULL; - } + virtual CefRefPtr GetDragHandler() { return NULL; } /// // Return the handler for find result events. /// /*--cef()--*/ - virtual CefRefPtr GetFindHandler() { - return NULL; - } + virtual CefRefPtr GetFindHandler() { return NULL; } /// // Return the handler for focus events. /// /*--cef()--*/ - virtual CefRefPtr GetFocusHandler() { - return NULL; - } - - /// - // Return the handler for geolocation permissions requests. If no handler is - // provided geolocation access will be denied by default. - /// - /*--cef()--*/ - virtual CefRefPtr GetGeolocationHandler() { - return NULL; - } + virtual CefRefPtr GetFocusHandler() { return NULL; } /// // Return the handler for JavaScript dialogs. If no handler is provided the // default implementation will be used. /// /*--cef()--*/ - virtual CefRefPtr GetJSDialogHandler() { - return NULL; - } + virtual CefRefPtr GetJSDialogHandler() { return NULL; } /// // Return the handler for keyboard events. /// /*--cef()--*/ - virtual CefRefPtr GetKeyboardHandler() { - return NULL; - } + virtual CefRefPtr GetKeyboardHandler() { return NULL; } /// // Return the handler for browser life span events. /// /*--cef()--*/ - virtual CefRefPtr GetLifeSpanHandler() { - return NULL; - } + virtual CefRefPtr GetLifeSpanHandler() { return NULL; } /// // Return the handler for browser load status events. /// /*--cef()--*/ - virtual CefRefPtr GetLoadHandler() { - return NULL; - } + virtual CefRefPtr GetLoadHandler() { return NULL; } /// // Return the handler for off-screen rendering events. /// /*--cef()--*/ - virtual CefRefPtr GetRenderHandler() { - return NULL; - } + virtual CefRefPtr GetRenderHandler() { return NULL; } /// // Return the handler for browser request events. /// /*--cef()--*/ - virtual CefRefPtr GetRequestHandler() { - return NULL; - } + virtual CefRefPtr GetRequestHandler() { return NULL; } /// // Called when a new message is received from a different process. Return true diff --git a/src/include/cef_command_line.h b/src/include/cef_command_line.h index 5e581b6e..dd5491cd 100644 --- a/src/include/cef_command_line.h +++ b/src/include/cef_command_line.h @@ -38,9 +38,9 @@ #define CEF_INCLUDE_CEF_COMMAND_LINE_H_ #pragma once -#include "include/cef_base.h" #include #include +#include "include/cef_base.h" /// // Class used to create and/or parse command line arguments. Arguments with @@ -76,20 +76,20 @@ class CefCommandLine : public virtual CefBaseRefCounted { // function returns false. /// /*--cef()--*/ - virtual bool IsValid() =0; + virtual bool IsValid() = 0; /// // Returns true if the values of this object are read-only. Some APIs may // expose read-only objects. /// /*--cef()--*/ - virtual bool IsReadOnly() =0; + virtual bool IsReadOnly() = 0; /// // Returns a writable copy of this object. /// /*--cef()--*/ - virtual CefRefPtr Copy() =0; + virtual CefRefPtr Copy() = 0; /// // Initialize the command line with the specified |argc| and |argv| values. @@ -97,112 +97,112 @@ class CefCommandLine : public virtual CefBaseRefCounted { // supported on non-Windows platforms. /// /*--cef()--*/ - virtual void InitFromArgv(int argc, const char* const* argv) =0; + virtual void InitFromArgv(int argc, const char* const* argv) = 0; /// // Initialize the command line with the string returned by calling // GetCommandLineW(). This method is only supported on Windows. /// /*--cef()--*/ - virtual void InitFromString(const CefString& command_line) =0; + virtual void InitFromString(const CefString& command_line) = 0; /// // Reset the command-line switches and arguments but leave the program // component unchanged. /// /*--cef()--*/ - virtual void Reset() =0; + virtual void Reset() = 0; /// // Retrieve the original command line string as a vector of strings. // The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } /// /*--cef()--*/ - virtual void GetArgv(std::vector& argv) =0; + virtual void GetArgv(std::vector& argv) = 0; /// // Constructs and returns the represented command line string. Use this method // cautiously because quoting behavior is unclear. /// /*--cef()--*/ - virtual CefString GetCommandLineString() =0; + virtual CefString GetCommandLineString() = 0; /// // Get the program part of the command line string (the first item). /// /*--cef()--*/ - virtual CefString GetProgram() =0; + virtual CefString GetProgram() = 0; /// // Set the program part of the command line string (the first item). /// /*--cef()--*/ - virtual void SetProgram(const CefString& program) =0; + virtual void SetProgram(const CefString& program) = 0; /// // Returns true if the command line has switches. /// /*--cef()--*/ - virtual bool HasSwitches() =0; + virtual bool HasSwitches() = 0; /// // Returns true if the command line contains the given switch. /// /*--cef()--*/ - virtual bool HasSwitch(const CefString& name) =0; + virtual bool HasSwitch(const CefString& name) = 0; /// // Returns the value associated with the given switch. If the switch has no // value or isn't present this method returns the empty string. /// /*--cef()--*/ - virtual CefString GetSwitchValue(const CefString& name) =0; + virtual CefString GetSwitchValue(const CefString& name) = 0; /// // Returns the map of switch names and values. If a switch has no value an // empty string is returned. /// /*--cef()--*/ - virtual void GetSwitches(SwitchMap& switches) =0; + virtual void GetSwitches(SwitchMap& switches) = 0; /// // Add a switch to the end of the command line. If the switch has no value // pass an empty value string. /// /*--cef()--*/ - virtual void AppendSwitch(const CefString& name) =0; + virtual void AppendSwitch(const CefString& name) = 0; /// // Add a switch with the specified value to the end of the command line. /// /*--cef()--*/ virtual void AppendSwitchWithValue(const CefString& name, - const CefString& value) =0; + const CefString& value) = 0; /// // True if there are remaining command line arguments. /// /*--cef()--*/ - virtual bool HasArguments() =0; + virtual bool HasArguments() = 0; /// // Get the remaining command line arguments. /// /*--cef()--*/ - virtual void GetArguments(ArgumentList& arguments) =0; + virtual void GetArguments(ArgumentList& arguments) = 0; /// // Add an argument to the end of the command line. /// /*--cef()--*/ - virtual void AppendArgument(const CefString& argument) =0; + virtual void AppendArgument(const CefString& argument) = 0; /// // Insert a command before the current command. // Common for debuggers, like "valgrind" or "gdb --args". /// /*--cef()--*/ - virtual void PrependWrapper(const CefString& wrapper) =0; + virtual void PrependWrapper(const CefString& wrapper) = 0; }; #endif // CEF_INCLUDE_CEF_COMMAND_LINE_H_ diff --git a/src/include/cef_context_menu_handler.h b/src/include/cef_context_menu_handler.h index 7619b8ed..2a2a73e6 100644 --- a/src/include/cef_context_menu_handler.h +++ b/src/include/cef_context_menu_handler.h @@ -45,7 +45,6 @@ class CefContextMenuParams; - /// // Callback interface used for continuation of custom context menu display. /// @@ -59,16 +58,15 @@ class CefRunContextMenuCallback : public virtual CefBaseRefCounted { // |event_flags|. /// /*--cef(capi_name=cont)--*/ - virtual void Continue(int command_id, EventFlags event_flags) =0; + virtual void Continue(int command_id, EventFlags event_flags) = 0; /// // Cancel context menu display. /// /*--cef()--*/ - virtual void Cancel() =0; + virtual void Cancel() = 0; }; - /// // Implement this interface to handle context menu events. The methods of this // class will be called on the UI thread. @@ -122,7 +120,9 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted { CefRefPtr frame, CefRefPtr params, int command_id, - EventFlags event_flags) { return false; } + EventFlags event_flags) { + return false; + } /// // Called when the context menu is dismissed irregardless of whether the menu @@ -133,7 +133,6 @@ class CefContextMenuHandler : public virtual CefBaseRefCounted { CefRefPtr frame) {} }; - /// // Provides information about the context menu state. The ethods of this class // can only be accessed on browser process the UI thread. @@ -151,49 +150,49 @@ class CefContextMenuParams : public virtual CefBaseRefCounted { // Coords are relative to the associated RenderView's origin. /// /*--cef()--*/ - virtual int GetXCoord() =0; + virtual int GetXCoord() = 0; /// // Returns the Y coordinate of the mouse where the context menu was invoked. // Coords are relative to the associated RenderView's origin. /// /*--cef()--*/ - virtual int GetYCoord() =0; + virtual int GetYCoord() = 0; /// // Returns flags representing the type of node that the context menu was // invoked on. /// /*--cef(default_retval=CM_TYPEFLAG_NONE)--*/ - virtual TypeFlags GetTypeFlags() =0; + virtual TypeFlags GetTypeFlags() = 0; /// // Returns the URL of the link, if any, that encloses the node that the // context menu was invoked on. /// /*--cef()--*/ - virtual CefString GetLinkUrl() =0; + virtual CefString GetLinkUrl() = 0; /// // Returns the link URL, if any, to be used ONLY for "copy link address". We // don't validate this field in the frontend process. /// /*--cef()--*/ - virtual CefString GetUnfilteredLinkUrl() =0; + virtual CefString GetUnfilteredLinkUrl() = 0; /// // Returns the source URL, if any, for the element that the context menu was // invoked on. Example of elements with source URLs are img, audio, and video. /// /*--cef()--*/ - virtual CefString GetSourceUrl() =0; + virtual CefString GetSourceUrl() = 0; /// // Returns true if the context menu was invoked on an image which has // non-empty contents. /// /*--cef()--*/ - virtual bool HasImageContents() =0; + virtual bool HasImageContents() = 0; /// // Returns the title text or the alt text if the context menu was invoked on @@ -206,87 +205,88 @@ class CefContextMenuParams : public virtual CefBaseRefCounted { // Returns the URL of the top level page that the context menu was invoked on. /// /*--cef()--*/ - virtual CefString GetPageUrl() =0; + virtual CefString GetPageUrl() = 0; /// // Returns the URL of the subframe that the context menu was invoked on. /// /*--cef()--*/ - virtual CefString GetFrameUrl() =0; + virtual CefString GetFrameUrl() = 0; /// // Returns the character encoding of the subframe that the context menu was // invoked on. /// /*--cef()--*/ - virtual CefString GetFrameCharset() =0; + virtual CefString GetFrameCharset() = 0; /// // Returns the type of context node that the context menu was invoked on. /// /*--cef(default_retval=CM_MEDIATYPE_NONE)--*/ - virtual MediaType GetMediaType() =0; + virtual MediaType GetMediaType() = 0; /// // Returns flags representing the actions supported by the media element, if // any, that the context menu was invoked on. /// /*--cef(default_retval=CM_MEDIAFLAG_NONE)--*/ - virtual MediaStateFlags GetMediaStateFlags() =0; + virtual MediaStateFlags GetMediaStateFlags() = 0; /// // Returns the text of the selection, if any, that the context menu was // invoked on. /// /*--cef()--*/ - virtual CefString GetSelectionText() =0; + virtual CefString GetSelectionText() = 0; /// // Returns the text of the misspelled word, if any, that the context menu was // invoked on. /// /*--cef()--*/ - virtual CefString GetMisspelledWord() =0; + virtual CefString GetMisspelledWord() = 0; /// // Returns true if suggestions exist, false otherwise. Fills in |suggestions| // from the spell check service for the misspelled word if there is one. /// /*--cef()--*/ - virtual bool GetDictionarySuggestions(std::vector& suggestions) =0; + virtual bool GetDictionarySuggestions( + std::vector& suggestions) = 0; /// // Returns true if the context menu was invoked on an editable node. /// /*--cef()--*/ - virtual bool IsEditable() =0; + virtual bool IsEditable() = 0; /// // Returns true if the context menu was invoked on an editable node where // spell-check is enabled. /// /*--cef()--*/ - virtual bool IsSpellCheckEnabled() =0; + virtual bool IsSpellCheckEnabled() = 0; /// // Returns flags representing the actions supported by the editable node, if // any, that the context menu was invoked on. /// /*--cef(default_retval=CM_EDITFLAG_NONE)--*/ - virtual EditStateFlags GetEditStateFlags() =0; + virtual EditStateFlags GetEditStateFlags() = 0; /// // Returns true if the context menu contains items specified by the renderer // process (for example, plugin placeholder or pepper plugin menu items). /// /*--cef()--*/ - virtual bool IsCustomMenu() =0; + virtual bool IsCustomMenu() = 0; /// // Returns true if the context menu was invoked from a pepper plugin. /// /*--cef()--*/ - virtual bool IsPepperMenu() =0; + virtual bool IsPepperMenu() = 0; }; #endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ diff --git a/src/include/cef_cookie.h b/src/include/cef_cookie.h index 28f056d8..eb57630a 100644 --- a/src/include/cef_cookie.h +++ b/src/include/cef_cookie.h @@ -38,9 +38,9 @@ #define CEF_INCLUDE_CEF_COOKIE_H_ #pragma once +#include #include "include/cef_base.h" #include "include/cef_callback.h" -#include class CefCookieVisitor; class CefSetCookieCallback; @@ -64,6 +64,17 @@ class CefCookieManager : public virtual CefBaseRefCounted { static CefRefPtr GetGlobalManager( CefRefPtr callback); + /// + // Returns a cookie manager that neither stores nor retrieves cookies. All + // usage of cookies will be blocked including cookies accessed via the network + // (request/response headers), via JavaScript (document.cookie), and via + // CefCookieManager methods. No cookies will be displayed in DevTools. If you + // wish to only block cookies sent via the network use the CefRequestHandler + // CanGetCookies and CanSetCookie methods instead. + /// + /*--cef()--*/ + static CefRefPtr GetBlockingManager(); + /// // Creates a new cookie manager. If |path| is empty data will be stored in // memory only. Otherwise, data will be stored at the specified |path|. To @@ -88,7 +99,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { /*--cef(optional_param=callback)--*/ virtual void SetSupportedSchemes( const std::vector& schemes, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Visit all cookies on the IO thread. The returned cookies are ordered by @@ -96,7 +107,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { // cannot be accessed. /// /*--cef()--*/ - virtual bool VisitAllCookies(CefRefPtr visitor) =0; + virtual bool VisitAllCookies(CefRefPtr visitor) = 0; /// // Visit a subset of cookies on the IO thread. The results are filtered by the @@ -108,7 +119,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { /*--cef()--*/ virtual bool VisitUrlCookies(const CefString& url, bool includeHttpOnly, - CefRefPtr visitor) =0; + CefRefPtr visitor) = 0; /// // Sets a cookie given a valid URL and explicit user-provided cookie @@ -122,7 +133,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { /*--cef(optional_param=callback)--*/ virtual bool SetCookie(const CefString& url, const CefCookie& cookie, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Delete all cookies that match the specified parameters. If both |url| and @@ -139,7 +150,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { optional_param=callback)--*/ virtual bool DeleteCookies(const CefString& url, const CefString& cookie_name, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Sets the directory path that will be used for storing cookie data. If @@ -154,7 +165,7 @@ class CefCookieManager : public virtual CefBaseRefCounted { /*--cef(optional_param=path,optional_param=callback)--*/ virtual bool SetStoragePath(const CefString& path, bool persist_session_cookies, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Flush the backing store (if any) to disk. If |callback| is non-NULL it will @@ -162,10 +173,9 @@ class CefCookieManager : public virtual CefBaseRefCounted { // Returns false if cookies cannot be accessed. /// /*--cef(optional_param=callback)--*/ - virtual bool FlushStore(CefRefPtr callback) =0; + virtual bool FlushStore(CefRefPtr callback) = 0; }; - /// // Interface to implement for visiting cookie values. The methods of this class // will always be called on the IO thread. @@ -181,11 +191,12 @@ class CefCookieVisitor : public virtual CefBaseRefCounted { // no cookies are found. /// /*--cef()--*/ - virtual bool Visit(const CefCookie& cookie, int count, int total, - bool& deleteCookie) =0; + virtual bool Visit(const CefCookie& cookie, + int count, + int total, + bool& deleteCookie) = 0; }; - /// // Interface to implement to be notified of asynchronous completion via // CefCookieManager::SetCookie(). @@ -198,10 +209,9 @@ class CefSetCookieCallback : public virtual CefBaseRefCounted { // cookie was set successfully. /// /*--cef()--*/ - virtual void OnComplete(bool success) =0; + virtual void OnComplete(bool success) = 0; }; - /// // Interface to implement to be notified of asynchronous completion via // CefCookieManager::DeleteCookies(). @@ -214,7 +224,7 @@ class CefDeleteCookiesCallback : public virtual CefBaseRefCounted { // number of cookies that were deleted or -1 if unknown. /// /*--cef()--*/ - virtual void OnComplete(int num_deleted) =0; + virtual void OnComplete(int num_deleted) = 0; }; #endif // CEF_INCLUDE_CEF_COOKIE_H_ diff --git a/src/include/cef_crash_util.h b/src/include/cef_crash_util.h index d9ecfe35..e569df74 100644 --- a/src/include/cef_crash_util.h +++ b/src/include/cef_crash_util.h @@ -121,14 +121,12 @@ // // CrashKeys section: // -// Any number of crash keys can be specified for use by the application. Crash -// key values will be truncated based on the specified size (small = 63 bytes, -// medium = 252 bytes, large = 1008 bytes). The value of crash keys can be set -// from any thread or process using the CefSetCrashKeyValue function. These -// key/value pairs will be sent to the crash server along with the crash dump -// file. Medium and large values will be chunked for submission. For example, -// if your key is named "mykey" then the value will be broken into ordered -// chunks and submitted using keys named "mykey-1", "mykey-2", etc. +// A maximum of 26 crash keys of each size can be specified for use by the +// application. Crash key values will be truncated based on the specified size +// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of +// crash keys can be set from any thread or process using the +// CefSetCrashKeyValue function. These key/value pairs will be sent to the crash +// server along with the crash dump file. /// /*--cef()--*/ bool CefCrashReportingEnabled(); diff --git a/src/include/cef_dialog_handler.h b/src/include/cef_dialog_handler.h index 3ca98fb5..3ce02e6c 100644 --- a/src/include/cef_dialog_handler.h +++ b/src/include/cef_dialog_handler.h @@ -57,16 +57,15 @@ class CefFileDialogCallback : public virtual CefBaseRefCounted { /*--cef(capi_name=cont,index_param=selected_accept_filter, optional_param=file_paths)--*/ virtual void Continue(int selected_accept_filter, - const std::vector& file_paths) =0; + const std::vector& file_paths) = 0; /// // Cancel the file selection. /// /*--cef()--*/ - virtual void Cancel() =0; + virtual void Cancel() = 0; }; - /// // Implement this interface to handle dialog events. The methods of this class // will be called on the browser process UI thread. diff --git a/src/include/cef_display_handler.h b/src/include/cef_display_handler.h index 6147cc79..4fdc3c31 100644 --- a/src/include/cef_display_handler.h +++ b/src/include/cef_display_handler.h @@ -91,8 +91,9 @@ class CefDisplayHandler : public virtual CefBaseRefCounted { // drawing tooltips and the return value is ignored. /// /*--cef(optional_param=text)--*/ - virtual bool OnTooltip(CefRefPtr browser, - CefString& text) { return false; } + virtual bool OnTooltip(CefRefPtr browser, CefString& text) { + return false; + } /// // Called when the browser receives a status message. |value| contains the @@ -108,9 +109,32 @@ class CefDisplayHandler : public virtual CefBaseRefCounted { /// /*--cef(optional_param=message,optional_param=source)--*/ virtual bool OnConsoleMessage(CefRefPtr browser, + cef_log_severity_t level, const CefString& message, const CefString& source, - int line) { return false; } + int line) { + return false; + } + + /// + // Called when auto-resize is enabled via CefBrowserHost::SetAutoResizeEnabled + // and the contents have auto-resized. |new_size| will be the desired size in + // view coordinates. Return true if the resize was handled or false for + // default handling. + /// + /*--cef()--*/ + virtual bool OnAutoResize(CefRefPtr browser, + const CefSize& new_size) { + return false; + } + + /// + // Called when the overall page loading progress has changed. |progress| + // ranges from 0.0 to 1.0. + /// + /*--cef()--*/ + virtual void OnLoadingProgressChange(CefRefPtr browser, + double progress) {} }; #endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ diff --git a/src/include/cef_dom.h b/src/include/cef_dom.h index f653a074..382b1930 100644 --- a/src/include/cef_dom.h +++ b/src/include/cef_dom.h @@ -38,8 +38,8 @@ #define CEF_INCLUDE_CEF_DOM_H_ #pragma once -#include "include/cef_base.h" #include +#include "include/cef_base.h" class CefDOMDocument; class CefDOMNode; @@ -59,10 +59,9 @@ class CefDOMVisitor : public virtual CefBaseRefCounted { // of this method. /// /*--cef()--*/ - virtual void Visit(CefRefPtr document) =0; + virtual void Visit(CefRefPtr document) = 0; }; - /// // Class used to represent a DOM document. The methods of this class should only // be called on the render process main thread thread. @@ -76,89 +75,88 @@ class CefDOMDocument : public virtual CefBaseRefCounted { // Returns the document type. /// /*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/ - virtual Type GetType() =0; + virtual Type GetType() = 0; /// // Returns the root document node. /// /*--cef()--*/ - virtual CefRefPtr GetDocument() =0; + virtual CefRefPtr GetDocument() = 0; /// // Returns the BODY node of an HTML document. /// /*--cef()--*/ - virtual CefRefPtr GetBody() =0; + virtual CefRefPtr GetBody() = 0; /// // Returns the HEAD node of an HTML document. /// /*--cef()--*/ - virtual CefRefPtr GetHead() =0; + virtual CefRefPtr GetHead() = 0; /// // Returns the title of an HTML document. /// /*--cef()--*/ - virtual CefString GetTitle() =0; + virtual CefString GetTitle() = 0; /// // Returns the document element with the specified ID value. /// /*--cef()--*/ - virtual CefRefPtr GetElementById(const CefString& id) =0; + virtual CefRefPtr GetElementById(const CefString& id) = 0; /// // Returns the node that currently has keyboard focus. /// /*--cef()--*/ - virtual CefRefPtr GetFocusedNode() =0; + virtual CefRefPtr GetFocusedNode() = 0; /// // Returns true if a portion of the document is selected. /// /*--cef()--*/ - virtual bool HasSelection() =0; + virtual bool HasSelection() = 0; /// // Returns the selection offset within the start node. /// /*--cef()--*/ - virtual int GetSelectionStartOffset() =0; + virtual int GetSelectionStartOffset() = 0; /// // Returns the selection offset within the end node. /// /*--cef()--*/ - virtual int GetSelectionEndOffset() =0; + virtual int GetSelectionEndOffset() = 0; /// // Returns the contents of this selection as markup. /// /*--cef()--*/ - virtual CefString GetSelectionAsMarkup() =0; + virtual CefString GetSelectionAsMarkup() = 0; /// // Returns the contents of this selection as text. /// /*--cef()--*/ - virtual CefString GetSelectionAsText() =0; + virtual CefString GetSelectionAsText() = 0; /// // Returns the base URL for the document. /// /*--cef()--*/ - virtual CefString GetBaseURL() =0; + virtual CefString GetBaseURL() = 0; /// // Returns a complete URL based on the document base URL and the specified // partial URL. /// /*--cef()--*/ - virtual CefString GetCompleteURL(const CefString& partialURL) =0; + virtual CefString GetCompleteURL(const CefString& partialURL) = 0; }; - /// // Class used to represent a DOM node. The methods of this class should only be // called on the render process main thread. @@ -173,110 +171,110 @@ class CefDOMNode : public virtual CefBaseRefCounted { // Returns the type for this node. /// /*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/ - virtual Type GetType() =0; + virtual Type GetType() = 0; /// // Returns true if this is a text node. /// /*--cef()--*/ - virtual bool IsText() =0; + virtual bool IsText() = 0; /// // Returns true if this is an element node. /// /*--cef()--*/ - virtual bool IsElement() =0; + virtual bool IsElement() = 0; /// // Returns true if this is an editable node. /// /*--cef()--*/ - virtual bool IsEditable() =0; + virtual bool IsEditable() = 0; /// // Returns true if this is a form control element node. /// /*--cef()--*/ - virtual bool IsFormControlElement() =0; + virtual bool IsFormControlElement() = 0; /// // Returns the type of this form control element node. /// /*--cef()--*/ - virtual CefString GetFormControlElementType() =0; + virtual CefString GetFormControlElementType() = 0; /// // Returns true if this object is pointing to the same handle as |that| // object. /// /*--cef()--*/ - virtual bool IsSame(CefRefPtr that) =0; + virtual bool IsSame(CefRefPtr that) = 0; /// // Returns the name of this node. /// /*--cef()--*/ - virtual CefString GetName() =0; + virtual CefString GetName() = 0; /// // Returns the value of this node. /// /*--cef()--*/ - virtual CefString GetValue() =0; + virtual CefString GetValue() = 0; /// // Set the value of this node. Returns true on success. /// /*--cef()--*/ - virtual bool SetValue(const CefString& value) =0; + virtual bool SetValue(const CefString& value) = 0; /// // Returns the contents of this node as markup. /// /*--cef()--*/ - virtual CefString GetAsMarkup() =0; + virtual CefString GetAsMarkup() = 0; /// // Returns the document associated with this node. /// /*--cef()--*/ - virtual CefRefPtr GetDocument() =0; + virtual CefRefPtr GetDocument() = 0; /// // Returns the parent node. /// /*--cef()--*/ - virtual CefRefPtr GetParent() =0; + virtual CefRefPtr GetParent() = 0; /// // Returns the previous sibling node. /// /*--cef()--*/ - virtual CefRefPtr GetPreviousSibling() =0; + virtual CefRefPtr GetPreviousSibling() = 0; /// // Returns the next sibling node. /// /*--cef()--*/ - virtual CefRefPtr GetNextSibling() =0; + virtual CefRefPtr GetNextSibling() = 0; /// // Returns true if this node has child nodes. /// /*--cef()--*/ - virtual bool HasChildren() =0; + virtual bool HasChildren() = 0; /// // Return the first child node. /// /*--cef()--*/ - virtual CefRefPtr GetFirstChild() =0; + virtual CefRefPtr GetFirstChild() = 0; /// // Returns the last child node. /// /*--cef()--*/ - virtual CefRefPtr GetLastChild() =0; + virtual CefRefPtr GetLastChild() = 0; // The following methods are valid only for element nodes. @@ -284,31 +282,31 @@ class CefDOMNode : public virtual CefBaseRefCounted { // Returns the tag name of this element. /// /*--cef()--*/ - virtual CefString GetElementTagName() =0; + virtual CefString GetElementTagName() = 0; /// // Returns true if this element has attributes. /// /*--cef()--*/ - virtual bool HasElementAttributes() =0; + virtual bool HasElementAttributes() = 0; /// // Returns true if this element has an attribute named |attrName|. /// /*--cef()--*/ - virtual bool HasElementAttribute(const CefString& attrName) =0; + virtual bool HasElementAttribute(const CefString& attrName) = 0; /// // Returns the element attribute named |attrName|. /// /*--cef()--*/ - virtual CefString GetElementAttribute(const CefString& attrName) =0; + virtual CefString GetElementAttribute(const CefString& attrName) = 0; /// // Returns a map of all element attributes. /// /*--cef()--*/ - virtual void GetElementAttributes(AttributeMap& attrMap) =0; + virtual void GetElementAttributes(AttributeMap& attrMap) = 0; /// // Set the value for the element attribute named |attrName|. Returns true on @@ -316,19 +314,19 @@ class CefDOMNode : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual bool SetElementAttribute(const CefString& attrName, - const CefString& value) =0; + const CefString& value) = 0; /// // Returns the inner text of the element. /// /*--cef()--*/ - virtual CefString GetElementInnerText() =0; + virtual CefString GetElementInnerText() = 0; /// // Returns the bounds of the element. /// /*--cef()--*/ - virtual CefRect GetElementBounds() =0; + virtual CefRect GetElementBounds() = 0; }; #endif // CEF_INCLUDE_CEF_DOM_H_ diff --git a/src/include/cef_download_handler.h b/src/include/cef_download_handler.h index b32c248e..dfaeba50 100644 --- a/src/include/cef_download_handler.h +++ b/src/include/cef_download_handler.h @@ -42,7 +42,6 @@ #include "include/cef_browser.h" #include "include/cef_download_item.h" - /// // Callback interface used to asynchronously continue a download. /// @@ -56,10 +55,9 @@ class CefBeforeDownloadCallback : public virtual CefBaseRefCounted { // if you do wish to show the default "Save As" dialog. /// /*--cef(capi_name=cont,optional_param=download_path)--*/ - virtual void Continue(const CefString& download_path, bool show_dialog) =0; + virtual void Continue(const CefString& download_path, bool show_dialog) = 0; }; - /// // Callback interface used to asynchronously cancel a download. /// @@ -70,22 +68,21 @@ class CefDownloadItemCallback : public virtual CefBaseRefCounted { // Call to cancel the download. /// /*--cef()--*/ - virtual void Cancel() =0; + virtual void Cancel() = 0; /// // Call to pause the download. /// /*--cef()--*/ - virtual void Pause() =0; + virtual void Pause() = 0; /// // Call to resume the download. /// /*--cef()--*/ - virtual void Resume() =0; + virtual void Resume() = 0; }; - /// // Class used to handle file downloads. The methods of this class will called // on the browser process UI thread. @@ -105,7 +102,7 @@ class CefDownloadHandler : public virtual CefBaseRefCounted { CefRefPtr browser, CefRefPtr download_item, const CefString& suggested_name, - CefRefPtr callback) =0; + CefRefPtr callback) = 0; /// // Called when a download's status or progress information has been updated. @@ -115,10 +112,9 @@ class CefDownloadHandler : public virtual CefBaseRefCounted { // this method. /// /*--cef()--*/ - virtual void OnDownloadUpdated( - CefRefPtr browser, - CefRefPtr download_item, - CefRefPtr callback) {} + virtual void OnDownloadUpdated(CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) {} }; #endif // CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ diff --git a/src/include/cef_download_item.h b/src/include/cef_download_item.h index b0ea797f..930f53bb 100644 --- a/src/include/cef_download_item.h +++ b/src/include/cef_download_item.h @@ -51,104 +51,104 @@ class CefDownloadItem : public virtual CefBaseRefCounted { // function returns false. /// /*--cef()--*/ - virtual bool IsValid() =0; + virtual bool IsValid() = 0; /// // Returns true if the download is in progress. /// /*--cef()--*/ - virtual bool IsInProgress() =0; + virtual bool IsInProgress() = 0; /// // Returns true if the download is complete. /// /*--cef()--*/ - virtual bool IsComplete() =0; + virtual bool IsComplete() = 0; /// // Returns true if the download has been canceled or interrupted. /// /*--cef()--*/ - virtual bool IsCanceled() =0; + virtual bool IsCanceled() = 0; /// // Returns a simple speed estimate in bytes/s. /// /*--cef()--*/ - virtual int64 GetCurrentSpeed() =0; + virtual int64 GetCurrentSpeed() = 0; /// // Returns the rough percent complete or -1 if the receive total size is // unknown. /// /*--cef()--*/ - virtual int GetPercentComplete() =0; + virtual int GetPercentComplete() = 0; /// // Returns the total number of bytes. /// /*--cef()--*/ - virtual int64 GetTotalBytes() =0; + virtual int64 GetTotalBytes() = 0; /// // Returns the number of received bytes. /// /*--cef()--*/ - virtual int64 GetReceivedBytes() =0; + virtual int64 GetReceivedBytes() = 0; /// // Returns the time that the download started. /// /*--cef()--*/ - virtual CefTime GetStartTime() =0; + virtual CefTime GetStartTime() = 0; /// // Returns the time that the download ended. /// /*--cef()--*/ - virtual CefTime GetEndTime() =0; + virtual CefTime GetEndTime() = 0; /// // Returns the full path to the downloaded or downloading file. /// /*--cef()--*/ - virtual CefString GetFullPath() =0; + virtual CefString GetFullPath() = 0; /// // Returns the unique identifier for this download. /// /*--cef()--*/ - virtual uint32 GetId() =0; + virtual uint32 GetId() = 0; /// // Returns the URL. /// /*--cef()--*/ - virtual CefString GetURL() =0; + virtual CefString GetURL() = 0; /// // Returns the original URL before any redirections. /// /*--cef()--*/ - virtual CefString GetOriginalUrl() =0; + virtual CefString GetOriginalUrl() = 0; /// // Returns the suggested file name. /// /*--cef()--*/ - virtual CefString GetSuggestedFileName() =0; + virtual CefString GetSuggestedFileName() = 0; /// // Returns the content disposition. /// /*--cef()--*/ - virtual CefString GetContentDisposition() =0; + virtual CefString GetContentDisposition() = 0; /// // Returns the mime type. /// /*--cef()--*/ - virtual CefString GetMimeType() =0; + virtual CefString GetMimeType() = 0; }; #endif // CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ diff --git a/src/include/cef_drag_data.h b/src/include/cef_drag_data.h index de37ecc4..35661f87 100644 --- a/src/include/cef_drag_data.h +++ b/src/include/cef_drag_data.h @@ -38,10 +38,10 @@ #define CEF_INCLUDE_CEF_DRAG_DATA_H_ #pragma once +#include #include "include/cef_base.h" #include "include/cef_image.h" #include "include/cef_stream.h" -#include /// // Class used to represent drag data. The methods of this class may be called @@ -60,74 +60,74 @@ class CefDragData : public virtual CefBaseRefCounted { // Returns a copy of the current object. /// /*--cef()--*/ - virtual CefRefPtr Clone() =0; + virtual CefRefPtr Clone() = 0; /// // Returns true if this object is read-only. /// /*--cef()--*/ - virtual bool IsReadOnly() =0; + virtual bool IsReadOnly() = 0; /// // Returns true if the drag data is a link. /// /*--cef()--*/ - virtual bool IsLink() =0; + virtual bool IsLink() = 0; /// // Returns true if the drag data is a text or html fragment. /// /*--cef()--*/ - virtual bool IsFragment() =0; + virtual bool IsFragment() = 0; /// // Returns true if the drag data is a file. /// /*--cef()--*/ - virtual bool IsFile() =0; + virtual bool IsFile() = 0; /// // Return the link URL that is being dragged. /// /*--cef()--*/ - virtual CefString GetLinkURL() =0; + virtual CefString GetLinkURL() = 0; /// // Return the title associated with the link being dragged. /// /*--cef()--*/ - virtual CefString GetLinkTitle() =0; + virtual CefString GetLinkTitle() = 0; /// // Return the metadata, if any, associated with the link being dragged. /// /*--cef()--*/ - virtual CefString GetLinkMetadata() =0; + virtual CefString GetLinkMetadata() = 0; /// // Return the plain text fragment that is being dragged. /// /*--cef()--*/ - virtual CefString GetFragmentText() =0; + virtual CefString GetFragmentText() = 0; /// // Return the text/html fragment that is being dragged. /// /*--cef()--*/ - virtual CefString GetFragmentHtml() =0; + virtual CefString GetFragmentHtml() = 0; /// // Return the base URL that the fragment came from. This value is used for // resolving relative URLs and may be empty. /// /*--cef()--*/ - virtual CefString GetFragmentBaseURL() =0; + virtual CefString GetFragmentBaseURL() = 0; /// // Return the name of the file being dragged out of the browser window. /// /*--cef()--*/ - virtual CefString GetFileName() =0; + virtual CefString GetFileName() = 0; /// // Write the contents of the file being dragged out of the web view into @@ -136,50 +136,50 @@ class CefDragData : public virtual CefBaseRefCounted { // Call GetFileName() to get a suggested name for the file. /// /*--cef(optional_param=writer)--*/ - virtual size_t GetFileContents(CefRefPtr writer) =0; + virtual size_t GetFileContents(CefRefPtr writer) = 0; /// // Retrieve the list of file names that are being dragged into the browser // window. /// /*--cef()--*/ - virtual bool GetFileNames(std::vector& names) =0; + virtual bool GetFileNames(std::vector& names) = 0; /// // Set the link URL that is being dragged. /// /*--cef(optional_param=url)--*/ - virtual void SetLinkURL(const CefString& url) =0; + virtual void SetLinkURL(const CefString& url) = 0; /// // Set the title associated with the link being dragged. /// /*--cef(optional_param=title)--*/ - virtual void SetLinkTitle(const CefString& title) =0; + virtual void SetLinkTitle(const CefString& title) = 0; /// // Set the metadata associated with the link being dragged. /// /*--cef(optional_param=data)--*/ - virtual void SetLinkMetadata(const CefString& data) =0; + virtual void SetLinkMetadata(const CefString& data) = 0; /// // Set the plain text fragment that is being dragged. /// /*--cef(optional_param=text)--*/ - virtual void SetFragmentText(const CefString& text) =0; + virtual void SetFragmentText(const CefString& text) = 0; /// // Set the text/html fragment that is being dragged. /// /*--cef(optional_param=html)--*/ - virtual void SetFragmentHtml(const CefString& html) =0; + virtual void SetFragmentHtml(const CefString& html) = 0; /// // Set the base URL that the fragment came from. /// /*--cef(optional_param=base_url)--*/ - virtual void SetFragmentBaseURL(const CefString& base_url) =0; + virtual void SetFragmentBaseURL(const CefString& base_url) = 0; /// // Reset the file contents. You should do this before calling @@ -187,31 +187,33 @@ class CefDragData : public virtual CefBaseRefCounted { // drag in this kind of data. /// /*--cef()--*/ - virtual void ResetFileContents() =0; + virtual void ResetFileContents() = 0; /// // Add a file that is being dragged into the webview. /// /*--cef(optional_param=display_name)--*/ - virtual void AddFile(const CefString& path, const CefString& display_name) =0; + virtual void AddFile(const CefString& path, + const CefString& display_name) = 0; /// - // Get image representation of drag data (may be NULL). + // Get the image representation of drag data. May return NULL if no image + // representation is available. /// /*--cef()--*/ - virtual CefRefPtr GetImage() =0; + virtual CefRefPtr GetImage() = 0; /// - // Get image hotspot (drag start location relative to image dimensions). + // Get the image hotspot (drag start location relative to image dimensions). /// /*--cef()--*/ - virtual CefPoint GetImageHotspot() =0; + virtual CefPoint GetImageHotspot() = 0; /// - // Whether image representation of drag data is available. + // Returns true if an image representation of drag data is available. /// /*--cef()--*/ - virtual bool HasImage() =0; + virtual bool HasImage() = 0; }; #endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ diff --git a/src/include/cef_drag_handler.h b/src/include/cef_drag_handler.h index aee01366..0410c0d8 100644 --- a/src/include/cef_drag_handler.h +++ b/src/include/cef_drag_handler.h @@ -39,8 +39,8 @@ #pragma once #include "include/cef_base.h" -#include "include/cef_drag_data.h" #include "include/cef_browser.h" +#include "include/cef_drag_data.h" /// // Implement this interface to handle events related to dragging. The methods of @@ -60,7 +60,9 @@ class CefDragHandler : public virtual CefBaseRefCounted { /*--cef()--*/ virtual bool OnDragEnter(CefRefPtr browser, CefRefPtr dragData, - DragOperationsMask mask) { return false; } + DragOperationsMask mask) { + return false; + } /// // Called whenever draggable regions for the browser window change. These can diff --git a/src/include/cef_extension.h b/src/include/cef_extension.h new file mode 100644 index 00000000..c34d0132 --- /dev/null +++ b/src/include/cef_extension.h @@ -0,0 +1,117 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_EXTENSION_H_ +#define CEF_INCLUDE_CEF_EXTENSION_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_values.h" + +class CefExtensionHandler; +class CefRequestContext; + +/// +// Object representing an extension. Methods may be called on any thread unless +// otherwise indicated. +/// +/*--cef(source=library)--*/ +class CefExtension : public CefBaseRefCounted { + public: + /// + // Returns the unique extension identifier. This is calculated based on the + // extension public key, if available, or on the extension path. See + // https://developer.chrome.com/extensions/manifest/key for details. + /// + /*--cef()--*/ + virtual CefString GetIdentifier() = 0; + + /// + // Returns the absolute path to the extension directory on disk. This value + // will be prefixed with PK_DIR_RESOURCES if a relative path was passed to + // CefRequestContext::LoadExtension. + /// + /*--cef()--*/ + virtual CefString GetPath() = 0; + + /// + // Returns the extension manifest contents as a CefDictionaryValue object. See + // https://developer.chrome.com/extensions/manifest for details. + /// + /*--cef()--*/ + virtual CefRefPtr GetManifest() = 0; + + /// + // Returns true if this object is the same extension as |that| object. + // Extensions are considered the same if identifier, path and loader context + // match. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) = 0; + + /// + // Returns the handler for this extension. Will return NULL for internal + // extensions or if no handler was passed to CefRequestContext::LoadExtension. + /// + /*--cef()--*/ + virtual CefRefPtr GetHandler() = 0; + + /// + // Returns the request context that loaded this extension. Will return NULL + // for internal extensions or if the extension has been unloaded. See the + // CefRequestContext::LoadExtension documentation for more information about + // loader contexts. Must be called on the browser process UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetLoaderContext() = 0; + + /// + // Returns true if this extension is currently loaded. Must be called on the + // browser process UI thread. + /// + /*--cef()--*/ + virtual bool IsLoaded() = 0; + + /// + // Unload this extension if it is not an internal extension and is currently + // loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded + // on success. + /// + /*--cef()--*/ + virtual void Unload() = 0; +}; + +#endif // CEF_INCLUDE_CEF_EXTENSION_H_ diff --git a/src/include/cef_extension_handler.h b/src/include/cef_extension_handler.h new file mode 100644 index 00000000..7b0b86a3 --- /dev/null +++ b/src/include/cef_extension_handler.h @@ -0,0 +1,199 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_ +#define CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_extension.h" +#include "include/cef_stream.h" + +class CefClient; + +/// +// Callback interface used for asynchronous continuation of +// CefExtensionHandler::GetExtensionResource. +/// +/*--cef(source=library)--*/ +class CefGetExtensionResourceCallback : public CefBaseRefCounted { + public: + /// + // Continue the request. Read the resource contents from |stream|. + /// + /*--cef(capi_name=cont,optional_param=stream)--*/ + virtual void Continue(CefRefPtr stream) = 0; + + /// + // Cancel the request. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +/// +// Implement this interface to handle events related to browser extensions. +// The methods of this class will be called on the UI thread. See +// CefRequestContext::LoadExtension for information about extension loading. +/// +/*--cef(source=client)--*/ +class CefExtensionHandler : public virtual CefBaseRefCounted { + public: + /// + // Called if the CefRequestContext::LoadExtension request fails. |result| will + // be the error code. + /// + /*--cef()--*/ + virtual void OnExtensionLoadFailed(cef_errorcode_t result) {} + + /// + // Called if the CefRequestContext::LoadExtension request succeeds. + // |extension| is the loaded extension. + /// + /*--cef()--*/ + virtual void OnExtensionLoaded(CefRefPtr extension) {} + + /// + // Called after the CefExtension::Unload request has completed. + /// + /*--cef()--*/ + virtual void OnExtensionUnloaded(CefRefPtr extension) {} + + /// + // Called when an extension needs a browser to host a background script + // specified via the "background" manifest key. The browser will have no + // visible window and cannot be displayed. |extension| is the extension that + // is loading the background script. |url| is an internally generated + // reference to an HTML page that will be used to load the background script + // via a + + + +

Off-screen rendering test

+
+ + +""" +g_datauri = html_to_data_uri(g_datauri_data) + + +class OsrTest_IsolatedTest(unittest.TestCase): + def test_osr(self): + """Main entry point. All the code must run inside one + single test, otherwise strange things happen.""" + + print("") + print("CEF Python {ver}".format(ver=cef.__version__)) + print("Python {ver}".format(ver=sys.version[:6])) + + # Application settings + settings = { + "debug": False, + "log_severity": cef.LOGSEVERITY_ERROR, + "log_file": "", + "windowless_rendering_enabled": True + } + if "--debug" in sys.argv: + settings["debug"] = True + settings["log_severity"] = cef.LOGSEVERITY_INFO + + # Initialize + cef.Initialize(settings) + subtest_message("cef.Initialize() ok") + + # Accessibility handler + accessibility_handler = AccessibilityHandler(self) + cef.SetGlobalClientHandler(accessibility_handler) + subtest_message("cef.SetGlobalClientHandler() ok") + + # Global handler + global_handler = GlobalHandler(self) + cef.SetGlobalClientCallback("OnAfterCreated", + global_handler._OnAfterCreated) + subtest_message("cef.SetGlobalClientCallback() ok") + + # Create browser + window_info = cef.WindowInfo() + window_info.SetAsOffscreen(0) + browser = cef.CreateBrowserSync(window_info=window_info, + url=g_datauri) + + # Javascript bindings + bindings = cef.JavascriptBindings( + bindToFrames=False, bindToPopups=False) + bindings.SetProperty("cefpython_version", cef.GetVersion()) + browser.SetJavascriptBindings(bindings) + subtest_message("browser.SetJavascriptBindings() ok") + + # Enable accessibility + browser.SetAccessibilityState(cef.STATE_ENABLED) + subtest_message("cef.SetAccessibilityState(STATE_ENABLED) ok") + + # Client handlers + client_handlers = [LoadHandler(self, g_datauri), + DisplayHandler(self), + RenderHandler(self)] + for handler in client_handlers: + browser.SetClientHandler(handler) + + # Initiate OSR rendering + browser.SendFocusEvent(True) + browser.WasResized() + + # Message loop + run_message_loop() + + # Close browser and clean reference + browser.CloseBrowser(True) + del browser + subtest_message("browser.CloseBrowser() ok") + + # Give it some time to close before checking asserts + # and calling shutdown. + do_message_loop_work(25) + + # Automatic check of asserts in handlers + # noinspection PyTypeChecker + check_auto_asserts(self, [] + client_handlers + + [global_handler, + accessibility_handler]) + + # Test shutdown of CEF + cef.Shutdown() + subtest_message("cef.Shutdown() ok") + + # Display summary + show_test_summary(__file__) + sys.stdout.flush() + + +class AccessibilityHandler(object): + def __init__(self, test_case): + self.test_case = test_case + + # Asserts for True/False will be checked just before shutdown. + # Test whether asserts are working correctly. + self.test_for_True = True + + self.javascript_errors_False = False + self._OnAccessibilityTreeChange_True = False + self._OnAccessibilityLocationChange_True = False + self.loadComplete_True = False + self.layoutComplete_True = False + + def _OnAccessibilityTreeChange(self, value): + self._OnAccessibilityTreeChange_True = True + for event in value: + if "event_type" in event: + if event["event_type"] == "loadComplete": + # LoadHandler.OnLoadEnd is called after this event + self.test_case.assertFalse(self.loadComplete_True) + self.loadComplete_True = True + elif event["event_type"] == "layoutComplete": + # layoutComplete event occurs twice, one when a blank + # page is loaded and second time when loading datauri. + if self.loadComplete_True: + self.test_case.assertFalse(self.layoutComplete_True) + self.layoutComplete_True = True + + def _OnAccessibilityLocationChange(self, **_): + self._OnAccessibilityLocationChange_True = True + + +class RenderHandler(object): + def __init__(self, test_case): + self.test_case = test_case + + # Asserts for True/False will be checked just before shutdown. + # Test whether asserts are working correctly. + self.test_for_True = True + + self.GetViewRect_True = False + self.OnPaint_True = False + + def GetViewRect(self, rect_out, **_): + """Called to retrieve the view rectangle which is relative + to screen coordinates. Return True if the rectangle was + provided.""" + # rect_out --> [x, y, width, height] + self.GetViewRect_True = True + rect_out.extend([0, 0, 800, 600]) + return True + + def OnPaint(self, element_type, paint_buffer, **_): + """Called when an element should be painted.""" + if element_type == cef.PET_VIEW: + self.test_case.assertEqual(paint_buffer.width, 800) + self.test_case.assertEqual(paint_buffer.height, 600) + if not self.OnPaint_True: + self.OnPaint_True = True + subtest_message("RenderHandler.OnPaint: viewport ok") + else: + raise Exception("Unsupported element_type in OnPaint") + + +if __name__ == "__main__": + _test_runner.main(os.path.basename(__file__)) From a737d26cad764c7ccfaf9c8151515dcbc2dce09d Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 18 Aug 2018 15:37:47 +0200 Subject: [PATCH 116/238] Enhance unit tests reliability of js bindings (#59) --- unittests/_common.py | 16 +++++++++++++++- unittests/main_test.py | 23 +++++++++++++++++++---- unittests/osr_test.py | 22 ++++++++++++++++++---- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/unittests/_common.py b/unittests/_common.py index 2c2e52a9..5011bda4 100644 --- a/unittests/_common.py +++ b/unittests/_common.py @@ -13,6 +13,7 @@ MESSAGE_LOOP_RANGE = 100 # each iteration is 0.01 sec g_subtests_ran = 0 +g_js_code_completed = False def subtest_message(message): @@ -50,7 +51,21 @@ def do_message_loop_work(work_loops): time.sleep(0.01) +def js_code_completed(): + """Sometimes window.onload can execute before javascript bindings + are ready if the document loads very fast. When setting javascript + bindings it can take some time, because these bindings are sent + via IPC messaging to the Renderer process.""" + global g_js_code_completed + assert not g_js_code_completed + g_js_code_completed = True + subtest_message("js_code_completed() ok") + + def check_auto_asserts(test_case, objects): + # Check if js code completed + test_case.assertTrue(g_js_code_completed) + # Automatic check of asserts in handlers and in external for obj in objects: test_for_True = False # Test whether asserts are working correctly @@ -170,4 +185,3 @@ def Visit(self, value): self.load_handler.FrameSourceVisitor_True = True self.test_case.assertIn("747ef3e6011b6a61e6b3c6e54bdd2dee", value) - diff --git a/unittests/main_test.py b/unittests/main_test.py index 717daf6d..58fec488 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -31,9 +31,17 @@ msg = msg.replace("error", "error"); document.getElementById("console").innerHTML += msg+"
"; } - window.onload = function(){ - print("window.onload() ok"); - + function onload_helper() { + if (!window.hasOwnProperty("cefpython_version")) { + // Sometimes page could finish loading before javascript + // bindings are available. Javascript bindings are sent + // from the browser process to the renderer process via + // IPC messaging and it can take some time (5-10ms). If + // the page loads very fast window.onload could execute + // before bindings are available. + setTimeout(onload_helper, 10); + return; + } version = cefpython_version print("CEF Python: "+version.version+""); print("Chrome: "+version.chrome_version+""); @@ -78,7 +86,12 @@ py_callback("String sent from Javascript"); print("py_callback() ok"); }); - }; + js_code_completed(); + } + window.onload = function() { + print("window.onload() ok"); + onload_helper(); + } @@ -133,6 +146,7 @@ def test_main(self): external = External(self) bindings = cef.JavascriptBindings( bindToFrames=False, bindToPopups=False) + bindings.SetFunction("js_code_completed", js_code_completed) bindings.SetFunction("test_function", external.test_function) bindings.SetProperty("test_property1", external.test_property1) bindings.SetProperty("test_property2", external.test_property2) @@ -181,6 +195,7 @@ def test_main(self): # and calling shutdown. do_message_loop_work(25) + # Asserts before shutdown # noinspection PyTypeChecker check_auto_asserts(self, [] + client_handlers + [global_handler, diff --git a/unittests/osr_test.py b/unittests/osr_test.py index e1689329..4c26cb8f 100644 --- a/unittests/osr_test.py +++ b/unittests/osr_test.py @@ -31,13 +31,26 @@ msg = msg.replace("error", "error"); document.getElementById("console").innerHTML += msg+"
"; } - window.onload = function(){ - print("window.onload() ok"); - + function onload_helper() { + if (!window.hasOwnProperty("cefpython_version")) { + // Sometimes page could finish loading before javascript + // bindings are available. Javascript bindings are sent + // from the browser process to the renderer process via + // IPC messaging and it can take some time (5-10ms). If + // the page loads very fast window.onload could execute + // before bindings are available. + setTimeout(onload_helper, 10); + return; + } version = cefpython_version print("CEF Python: "+version.version+""); print("Chrome: "+version.chrome_version+""); print("CEF: "+version.cef_version+""); + js_code_completed(); + } + window.onload = function() { + print("window.onload() ok"); + onload_helper(); } @@ -95,6 +108,7 @@ def test_osr(self): # Javascript bindings bindings = cef.JavascriptBindings( bindToFrames=False, bindToPopups=False) + bindings.SetFunction("js_code_completed", js_code_completed) bindings.SetProperty("cefpython_version", cef.GetVersion()) browser.SetJavascriptBindings(bindings) subtest_message("browser.SetJavascriptBindings() ok") @@ -126,7 +140,7 @@ def test_osr(self): # and calling shutdown. do_message_loop_work(25) - # Automatic check of asserts in handlers + # Asserts before shutdown # noinspection PyTypeChecker check_auto_asserts(self, [] + client_handlers + [global_handler, From 073f9d2abcb48091f7bd2288f20825bec44ad44f Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 18 Aug 2018 15:46:36 +0200 Subject: [PATCH 117/238] Fix run_examples.py on Mac with PyQt5 --- tools/run_examples.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/run_examples.py b/tools/run_examples.py index d78a1a47..87fe1296 100644 --- a/tools/run_examples.py +++ b/tools/run_examples.py @@ -188,8 +188,12 @@ def check_installed_packages(): } for package in packages: try: - importlib.import_module(package) - packages[package] = True + if package == "PyQt5": + # Strange issue on Mac, PyQt5 is an empty built-in module + from PyQt5 import QtGui + else: + importlib.import_module(package) + packages[package] = True except ImportError: packages[package] = False packages["gi"] = check_gi_installed() From 1671a40361b283c6b6036614b0615b2898d9872a Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 18 Aug 2018 19:11:10 +0200 Subject: [PATCH 118/238] Add RenderHandler.OnTextSelectionChanged and Browser.Invalidate (#403). Add tests for OnTextSelectionChanged. Add on_load_end() helper func in unit tests. --- api/Browser.md | 17 +++++++++++++++ api/RenderHandler.md | 19 +++++++++++++++++ src/browser.pyx | 7 ++++++- src/cef_v59..v66_changes.txt | 5 +++-- src/client_handler/render_handler.cpp | 8 +++++++ src/client_handler/render_handler.h | 4 ++++ src/extern/cef/cef_browser.pxd | 3 ++- src/extern/cef/cef_types.pxd | 4 ++++ src/handlers/render_handler.pyx | 19 +++++++++++++++++ unittests/_common.py | 12 +++++++++++ unittests/osr_test.py | 30 ++++++++++++++++++++++++++- 11 files changed, 123 insertions(+), 5 deletions(-) diff --git a/api/Browser.md b/api/Browser.md index cf2ab61d..beda31e5 100644 --- a/api/Browser.md +++ b/api/Browser.md @@ -591,6 +591,23 @@ machinery. Returns true if a document has been loaded in the browser. +### Invalidate + +| | | +| --- | --- | +| element_type | PaintElementType | +| __Return__ | void | + +Description from upstream CEF: +> Invalidate the view. The browser will call CefRenderHandler::OnPaint +> asynchronously. This method is only used when window rendering is +> disabled. + +`PaintElementType` enum values defined in cefpython module: +* PET_VIEW +* PET_POPUP + + ### IsFullscreen | | | diff --git a/api/RenderHandler.md b/api/RenderHandler.md index bb25ac01..3b0d0f0d 100644 --- a/api/RenderHandler.md +++ b/api/RenderHandler.md @@ -177,6 +177,25 @@ Called when the browser's cursor has changed. If |type| is CT_CUSTOM then Called when the scroll offset has changed. +### OnTextSelectionChanged + +| Parameter | Type | +| --- | --- | +| browser | [Browser](Browser.md) | +| selected_text | str | +| selected_range | list[x, y] | +| __Return__ | void | + +Description from upstream CEF: +> Called when text selection has changed for the specified |browser|. +> |selected_text| is the currently selected text and |selected_range| is +> the character range. + +NOTE: this callback seems to be called only when selecting text +with a mouse. When selecting text programmatically using javascript +code it doesn't get called. + + ### StartDragging | Parameter | Type | diff --git a/src/browser.pyx b/src/browser.pyx index 5f26e7d7..335654d6 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -247,7 +247,8 @@ cdef class PyBrowser: "GetScreenRect", "OnPopupShow", "OnPopupSize", "OnPaint", "OnCursorChange", "OnScrollOffsetChanged", - "StartDragging", "UpdateDragCursor"] + "StartDragging", "UpdateDragCursor", + "OnTextSelectionChanged"] # JavascriptDialogHandler self.allowedClientCallbacks += ["OnJavascriptDialog", "OnBeforeUnloadJavascriptDialog", @@ -476,6 +477,10 @@ cdef class PyBrowser: cpdef py_bool HasDocument(self): return self.GetCefBrowser().get().HasDocument() + cpdef py_void Invalidate(self, + cef_types.cef_paint_element_type_t element_type): + return self.GetCefBrowserHost().get().Invalidate(element_type) + cpdef py_bool IsFullscreen(self): return bool(self.isFullscreen) diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 7a6fc5fb..2bb23ccf 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -71,6 +71,8 @@ NEW FEATURES ------------ + unittests/osr_test.py - new test for off-screen rendering mode ++ cefpython.SetGlobalClientHandler ++ Browser.Invalidate internal/cef_types.h + cef_log_severity_t: new key LOGSEVERITY_DEBUG (no need to expose, @@ -85,10 +87,9 @@ internal/cef_types.h cef_accessibility_handler.h + CefAccessibilityHandler + CefRenderHandler::GetAccessibilityHandler -+ cefpython.SetGlobalClientHandler cef_render_handler.h -- OnTextSelectionChanged ++ OnTextSelectionChanged cef_browser.h + SetAccessibilityState diff --git a/src/client_handler/render_handler.cpp b/src/client_handler/render_handler.cpp index f6b4d5be..cf45d15e 100644 --- a/src/client_handler/render_handler.cpp +++ b/src/client_handler/render_handler.cpp @@ -106,3 +106,11 @@ void RenderHandler::UpdateDragCursor(CefRefPtr browser, REQUIRE_UI_THREAD(); RenderHandler_UpdateDragCursor(browser, operation); } + +void RenderHandler::OnTextSelectionChanged(CefRefPtr browser, + const CefString& selected_text, + const CefRange& selected_range) { + REQUIRE_UI_THREAD(); + RenderHandler_OnTextSelectionChanged(browser, selected_text, + selected_range); +} diff --git a/src/client_handler/render_handler.h b/src/client_handler/render_handler.h index b9eb59fa..75eee86c 100644 --- a/src/client_handler/render_handler.h +++ b/src/client_handler/render_handler.h @@ -64,6 +64,10 @@ class RenderHandler : public CefRenderHandler, void UpdateDragCursor(CefRefPtr browser, cef_drag_operations_mask_t operation) override; + void OnTextSelectionChanged(CefRefPtr browser, + const CefString& selected_text, + const CefRange& selected_range) override; + private: IMPLEMENT_REFCOUNTING(RenderHandler); }; diff --git a/src/extern/cef/cef_browser.pxd b/src/extern/cef/cef_browser.pxd index 6c5e599a..31a4a29d 100644 --- a/src/extern/cef/cef_browser.pxd +++ b/src/extern/cef/cef_browser.pxd @@ -11,7 +11,7 @@ from libcpp cimport bool as cpp_bool from libcpp.vector cimport vector as cpp_vector from cef_frame cimport CefFrame cimport cef_types -from cef_types cimport int64, cef_state_t +from cef_types cimport int64, cef_state_t, PaintElementType from cef_types cimport CefBrowserSettings, CefPoint from cef_drag_data cimport CefDragData from cef_types cimport CefMouseEvent @@ -87,6 +87,7 @@ cdef extern from "include/cef_browser.h": void AddWordToDictionary(const CefString& word) void SetAccessibilityState(cef_state_t accessibility_state) + void Invalidate(cef_types.cef_paint_element_type_t type) cdef cppclass CefBrowser: diff --git a/src/extern/cef/cef_types.pxd b/src/extern/cef/cef_types.pxd index 70263780..6bd21ba4 100644 --- a/src/extern/cef/cef_types.pxd +++ b/src/extern/cef/cef_types.pxd @@ -377,3 +377,7 @@ cdef extern from "include/internal/cef_types.h": ctypedef enum cef_focus_source_t: FOCUS_SOURCE_NAVIGATION, FOCUS_SOURCE_SYSTEM, + + cdef cppclass CefRange: + int from_val "from" + int to_val "to" diff --git a/src/handlers/render_handler.pyx b/src/handlers/render_handler.pyx index 1594d6bd..a8ad4912 100644 --- a/src/handlers/render_handler.pyx +++ b/src/handlers/render_handler.pyx @@ -4,8 +4,10 @@ include "../cefpython.pyx" include "../browser.pyx" +include "../string_utils.pyx" cimport cef_types +from cef_types cimport CefRange # cef_paint_element_type_t, PaintElementType PET_VIEW = cef_types.PET_VIEW @@ -288,3 +290,20 @@ cdef public void RenderHandler_UpdateDragCursor( (exc_type, exc_value, exc_trace) = sys.exc_info() sys.excepthook(exc_type, exc_value, exc_trace) +cdef public void RenderHandler_OnTextSelectionChanged( + CefRefPtr[CefBrowser] cef_browser, + const CefString& selected_text, + const CefRange& selected_range + ) except * with gil: + cdef PyBrowser browser + try: + browser = GetPyBrowser(cef_browser, "OnTextSelectionChanged") + callback = browser.GetClientCallback("OnTextSelectionChanged") + if callback: + callback(browser=browser, + selected_text=CefToPyString(selected_text), + selected_range=[selected_range.from_val, + selected_range.to_val]) + except: + (exc_type, exc_value, exc_trace) = sys.exc_info() + sys.excepthook(exc_type, exc_value, exc_trace) diff --git a/unittests/_common.py b/unittests/_common.py index 5011bda4..59052583 100644 --- a/unittests/_common.py +++ b/unittests/_common.py @@ -14,6 +14,7 @@ g_subtests_ran = 0 g_js_code_completed = False +g_on_load_end_callbacks = [] def subtest_message(message): @@ -51,6 +52,11 @@ def do_message_loop_work(work_loops): time.sleep(0.01) +def on_load_end(callback, *args): + global g_on_load_end_callbacks + g_on_load_end_callbacks.append([callback, args]) + + def js_code_completed(): """Sometimes window.onload can execute before javascript bindings are ready if the document loads very fast. When setting javascript @@ -154,6 +160,12 @@ def OnLoadEnd(self, browser, frame, http_code, **_): frame.GetSource(self.frame_source_visitor) browser.ExecuteJavascript("print('LoadHandler.OnLoadEnd() ok')") + subtest_message("Executing callbacks registered with on_load_end()") + global g_on_load_end_callbacks + for callback_data in g_on_load_end_callbacks: + callback_data[0](*callback_data[1]) + del g_on_load_end_callbacks + def OnLoadingStateChange(self, browser, is_loading, can_go_back, can_go_forward, **_): if is_loading: diff --git a/unittests/osr_test.py b/unittests/osr_test.py index 4c26cb8f..323f2de6 100644 --- a/unittests/osr_test.py +++ b/unittests/osr_test.py @@ -58,6 +58,7 @@

Off-screen rendering test

+
Test selection.
""" @@ -128,6 +129,9 @@ def test_osr(self): browser.SendFocusEvent(True) browser.WasResized() + # Test selection + on_load_end(select_h1_text, browser) + # Message loop run_message_loop() @@ -188,6 +192,17 @@ def _OnAccessibilityLocationChange(self, **_): self._OnAccessibilityLocationChange_True = True +def select_h1_text(browser): + browser.SendMouseClickEvent(0, 0, cef.MOUSEBUTTON_LEFT, + mouseUp=False, clickCount=1) + browser.SendMouseMoveEvent(400, 20, mouseLeave=False, + modifiers=cef.EVENTFLAG_LEFT_MOUSE_BUTTON) + browser.SendMouseClickEvent(400, 20, cef.MOUSEBUTTON_LEFT, + mouseUp=True, clickCount=1) + browser.Invalidate(cef.PET_VIEW) + subtest_message("select_h1_text() ok") + + class RenderHandler(object): def __init__(self, test_case): self.test_case = test_case @@ -198,6 +213,7 @@ def __init__(self, test_case): self.GetViewRect_True = False self.OnPaint_True = False + self.OnTextSelectionChanged_True = False def GetViewRect(self, rect_out, **_): """Called to retrieve the view rectangle which is relative @@ -208,7 +224,7 @@ def GetViewRect(self, rect_out, **_): rect_out.extend([0, 0, 800, 600]) return True - def OnPaint(self, element_type, paint_buffer, **_): + def OnPaint(self, browser, element_type, paint_buffer, **_): """Called when an element should be painted.""" if element_type == cef.PET_VIEW: self.test_case.assertEqual(paint_buffer.width, 800) @@ -219,6 +235,18 @@ def OnPaint(self, element_type, paint_buffer, **_): else: raise Exception("Unsupported element_type in OnPaint") + def OnTextSelectionChanged(self, selected_text, selected_range, **_): + if not self.OnTextSelectionChanged_True: + self.OnTextSelectionChanged_True = True + # First call + self.test_case.assertEqual(selected_text, "") + self.test_case.assertEqual(selected_range, [0, 0]) + else: + # Second call. + #

tag should be selected. + self.test_case.assertEqual(selected_text, + "Off-screen rendering test") + if __name__ == "__main__": _test_runner.main(os.path.basename(__file__)) From f8a460f4afdc0887aaf866da2b024f86646fbf56 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 18 Aug 2018 20:23:29 +0200 Subject: [PATCH 119/238] Add DisplayHandler.OnAutoResize and Browser.SetAutoResizeEnabled (#403) --- README.md | 114 +++++++++++++------------ api/API-index.md | 4 + api/Browser.md | 17 ++++ api/DisplayHandler.md | 17 ++++ api/RenderHandler.md | 1 + src/browser.pyx | 13 ++- src/cef_v59..v66_changes.txt | 4 +- src/client_handler/display_handler.cpp | 6 ++ src/client_handler/display_handler.h | 3 + src/extern/cef/cef_browser.pxd | 7 +- src/handlers/display_handler.pyx | 19 +++++ unittests/_common.py | 9 ++ unittests/main_test.py | 26 +++++- 13 files changed, 179 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 3b9f1a21..dafbf9ff 100644 --- a/README.md +++ b/README.md @@ -256,61 +256,61 @@ Additional information for v31.2 release: ### API categories -#### Modules - - * [cefpython](api/cefpython.md#cefpython) module - - -#### Settings - - * [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary - * [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary - * [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary - - -#### Classes and objects - - * [Browser](api/Browser.md#browser-object) object - * [Callback](api/Callback.md#callback-object) object - * [Cookie](api/Cookie.md#cookie-class) class - * [CookieManager](api/CookieManager.md#cookiemanager-class) class - * [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) - * [DragData](api/DragData.md#dragdata-object) object - * [Frame](api/Frame.md#frame-object) object - * [Image](api/Image.md#image-object) object - * [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class - * [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object - * [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object - * [Request](api/Request.md#request-class) class - * [Response](api/Response.md#response-object) object - * [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object - * [WebRequest](api/WebRequest.md#webrequest-class) class - * [WindowInfo](api/WindowInfo.md#windowinfo-class) class - * [WindowUtils](api/WindowUtils.md#windowutils-class) class - - -#### Client handlers (interfaces) - - * [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) - * [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) - * [DownloadHandler](api/DownloadHandler.md#downloadhandler) - * [FocusHandler](api/FocusHandler.md#focushandler-interface) - * [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) - * [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) - * [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) - * [LoadHandler](api/LoadHandler.md#loadhandler-interface) - * [RenderHandler](api/RenderHandler.md#renderhandler-interface) - * [RequestHandler](api/RequestHandler.md#requesthandler-interface) - * [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) - * [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) - - -#### Other interfaces - - * [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface - * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface - * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface - +#### Modules + + * [cefpython](api/cefpython.md#cefpython) module + + +#### Settings + + * [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary + * [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary + * [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary + + +#### Classes and objects + + * [Browser](api/Browser.md#browser-object) object + * [Callback](api/Callback.md#callback-object) object + * [Cookie](api/Cookie.md#cookie-class) class + * [CookieManager](api/CookieManager.md#cookiemanager-class) class + * [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) + * [DragData](api/DragData.md#dragdata-object) object + * [Frame](api/Frame.md#frame-object) object + * [Image](api/Image.md#image-object) object + * [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class + * [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object + * [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object + * [Request](api/Request.md#request-class) class + * [Response](api/Response.md#response-object) object + * [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object + * [WebRequest](api/WebRequest.md#webrequest-class) class + * [WindowInfo](api/WindowInfo.md#windowinfo-class) class + * [WindowUtils](api/WindowUtils.md#windowutils-class) class + + +#### Client handlers (interfaces) + + * [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) + * [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) + * [DownloadHandler](api/DownloadHandler.md#downloadhandler) + * [FocusHandler](api/FocusHandler.md#focushandler-interface) + * [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) + * [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) + * [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) + * [LoadHandler](api/LoadHandler.md#loadhandler-interface) + * [RenderHandler](api/RenderHandler.md#renderhandler-interface) + * [RequestHandler](api/RequestHandler.md#requesthandler-interface) + * [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) + * [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) + + +#### Other interfaces + + * [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface + * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface + * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface + ### API index @@ -391,6 +391,7 @@ Additional information for v31.2 release: * [HandleKeyEventAfterTextInputClient](api/Browser.md#handlekeyeventaftertextinputclient) * [HandleKeyEventBeforeTextInputClient](api/Browser.md#handlekeyeventbeforetextinputclient) * [HasDocument](api/Browser.md#hasdocument) + * [Invalidate](api/Browser.md#invalidate) * [IsFullscreen](api/Browser.md#isfullscreen) * [IsLoading](api/Browser.md#isloading) * [IsMouseCursorChangeDisabled](api/Browser.md#ismousecursorchangedisabled) @@ -405,6 +406,7 @@ Additional information for v31.2 release: * [Reload](api/Browser.md#reload) * [ReloadIgnoreCache](api/Browser.md#reloadignorecache) * [ReplaceMisspelling](api/Browser.md#replacemisspelling) + * [SetAutoResizeEnabled](api/Browser.md#setautoresizeenabled) * [SetBounds](api/Browser.md#setbounds) * [SendKeyEvent](api/Browser.md#sendkeyevent) * [SendMouseClickEvent](api/Browser.md#sendmouseclickevent) @@ -519,6 +521,7 @@ Additional information for v31.2 release: * [Visit](api/CookieVisitor.md#visit) * [DisplayHandler (interface)](api/DisplayHandler.md#displayhandler-interface) * [OnAddressChange](api/DisplayHandler.md#onaddresschange) + * [OnAutoResize](api/DisplayHandler.md#onautoresize) * [OnTitleChange](api/DisplayHandler.md#ontitlechange) * [OnTooltip](api/DisplayHandler.md#ontooltip) * [OnStatusMessage](api/DisplayHandler.md#onstatusmessage) @@ -670,6 +673,7 @@ Additional information for v31.2 release: * [OnPaint](api/RenderHandler.md#onpaint) * [OnCursorChange](api/RenderHandler.md#oncursorchange) * [OnScrollOffsetChanged](api/RenderHandler.md#onscrolloffsetchanged) + * [OnTextSelectionChanged](api/RenderHandler.md#ontextselectionchanged) * [StartDragging](api/RenderHandler.md#startdragging) * [UpdateDragCursor](api/RenderHandler.md#updatedragcursor) * [Request (class)](api/Request.md#request-class) diff --git a/api/API-index.md b/api/API-index.md index fb8c5efe..9c5374da 100644 --- a/api/API-index.md +++ b/api/API-index.md @@ -79,6 +79,7 @@ * [HandleKeyEventAfterTextInputClient](Browser.md#handlekeyeventaftertextinputclient) * [HandleKeyEventBeforeTextInputClient](Browser.md#handlekeyeventbeforetextinputclient) * [HasDocument](Browser.md#hasdocument) + * [Invalidate](Browser.md#invalidate) * [IsFullscreen](Browser.md#isfullscreen) * [IsLoading](Browser.md#isloading) * [IsMouseCursorChangeDisabled](Browser.md#ismousecursorchangedisabled) @@ -93,6 +94,7 @@ * [Reload](Browser.md#reload) * [ReloadIgnoreCache](Browser.md#reloadignorecache) * [ReplaceMisspelling](Browser.md#replacemisspelling) + * [SetAutoResizeEnabled](Browser.md#setautoresizeenabled) * [SetBounds](Browser.md#setbounds) * [SendKeyEvent](Browser.md#sendkeyevent) * [SendMouseClickEvent](Browser.md#sendmouseclickevent) @@ -207,6 +209,7 @@ * [Visit](CookieVisitor.md#visit) * [DisplayHandler (interface)](DisplayHandler.md#displayhandler-interface) * [OnAddressChange](DisplayHandler.md#onaddresschange) + * [OnAutoResize](DisplayHandler.md#onautoresize) * [OnTitleChange](DisplayHandler.md#ontitlechange) * [OnTooltip](DisplayHandler.md#ontooltip) * [OnStatusMessage](DisplayHandler.md#onstatusmessage) @@ -358,6 +361,7 @@ * [OnPaint](RenderHandler.md#onpaint) * [OnCursorChange](RenderHandler.md#oncursorchange) * [OnScrollOffsetChanged](RenderHandler.md#onscrolloffsetchanged) + * [OnTextSelectionChanged](RenderHandler.md#ontextselectionchanged) * [StartDragging](RenderHandler.md#startdragging) * [UpdateDragCursor](RenderHandler.md#updatedragcursor) * [Request (class)](Request.md#request-class) diff --git a/api/Browser.md b/api/Browser.md index beda31e5..977d9005 100644 --- a/api/Browser.md +++ b/api/Browser.md @@ -55,6 +55,7 @@ Table of contents: * [HandleKeyEventAfterTextInputClient](#handlekeyeventaftertextinputclient) * [HandleKeyEventBeforeTextInputClient](#handlekeyeventbeforetextinputclient) * [HasDocument](#hasdocument) + * [Invalidate](#invalidate) * [IsFullscreen](#isfullscreen) * [IsLoading](#isloading) * [IsMouseCursorChangeDisabled](#ismousecursorchangedisabled) @@ -69,6 +70,7 @@ Table of contents: * [Reload](#reload) * [ReloadIgnoreCache](#reloadignorecache) * [ReplaceMisspelling](#replacemisspelling) + * [SetAutoResizeEnabled](#setautoresizeenabled) * [SetBounds](#setbounds) * [SendKeyEvent](#sendkeyevent) * [SendMouseClickEvent](#sendmouseclickevent) @@ -753,6 +755,21 @@ If a misspelled word is currently selected in an editable node calling this method will replace it with the specified |word|. +### SetAutoResizeEnabled + +| Parameter | Type | +| --- | --- | +| enabled | bool | +| min_size | list[width, height] | +| max_size | list[width, heifght] | +| __Return__ | void | + +Description from upstream CEF: +> Enable notifications of auto resize via CefDisplayHandler::OnAutoResize. +> Notifications are disabled by default. |min_size| and |max_size| define the +> range of allowed sizes. + + ### SetBounds | Parameter | Type | diff --git a/api/DisplayHandler.md b/api/DisplayHandler.md index 4e45efaf..43f6342f 100644 --- a/api/DisplayHandler.md +++ b/api/DisplayHandler.md @@ -11,6 +11,7 @@ For an example of how to implement handler see [cefpython](cefpython.md).CreateB Table of contents: * [Callbacks](#callbacks) * [OnAddressChange](#onaddresschange) + * [OnAutoResize](#onautoresize) * [OnTitleChange](#ontitlechange) * [OnTooltip](#ontooltip) * [OnStatusMessage](#onstatusmessage) @@ -32,6 +33,22 @@ Table of contents: Called when a frame's address has changed. + +### OnAutoResize + +| Parameter | Type | +| --- | --- | +| browser | [Browser](Browser.md) | +| new_size | list[width, height] | +| __Return__ | bool | + +Description from upstream CEF: +> Called when auto-resize is enabled via CefBrowserHost::SetAutoResizeEnabled +> and the contents have auto-resized. |new_size| will be the desired size in +> view coordinates. Return true if the resize was handled or false for +> default handling. + + ### OnTitleChange | Parameter | Type | diff --git a/api/RenderHandler.md b/api/RenderHandler.md index 3b0d0f0d..a33a2154 100644 --- a/api/RenderHandler.md +++ b/api/RenderHandler.md @@ -22,6 +22,7 @@ Table of contents: * [OnPaint](#onpaint) * [OnCursorChange](#oncursorchange) * [OnScrollOffsetChanged](#onscrolloffsetchanged) + * [OnTextSelectionChanged](#ontextselectionchanged) * [StartDragging](#startdragging) * [UpdateDragCursor](#updatedragcursor) diff --git a/src/browser.pyx b/src/browser.pyx index 335654d6..44ec439d 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -218,7 +218,7 @@ cdef class PyBrowser: # DisplayHandler self.allowedClientCallbacks += [ "OnAddressChange", "OnTitleChange", "OnTooltip", - "OnStatusMessage", "OnConsoleMessage"] + "OnStatusMessage", "OnConsoleMessage", "OnAutoResize"] # KeyboardHandler self.allowedClientCallbacks += ["OnPreKeyEvent", "OnKeyEvent"] # RequestHandler @@ -513,6 +513,17 @@ cdef class PyBrowser: PyToCefString(word, cef_word) self.GetCefBrowserHost().get().ReplaceMisspelling(cef_word) + cpdef py_void SetAutoResizeEnabled(self, + py_bool enabled, + list min_size, + list max_size): + self.GetCefBrowserHost().get().SetAutoResizeEnabled( + bool(enabled), + CefSize(min_size[0], min_size[1]), + CefSize(max_size[0], max_size[1]) + ) + + cpdef py_void SetBounds(self, int x, int y, int width, int height): IF UNAME_SYSNAME == "Linux": x11.SetX11WindowBounds(self.GetCefBrowser(), x, y, width, height) diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 2bb23ccf..27260280 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -93,7 +93,7 @@ cef_render_handler.h cef_browser.h + SetAccessibilityState -- SetAutoResizeEnabled ++ SetAutoResizeEnabled - GetExtension - IsBackgroundHost @@ -101,7 +101,7 @@ cef_cookie.h - GetBlockingManager cef_display_handler.h -- OnAutoResize ++ OnAutoResize - OnLoadingProgressChange cef_drag_data.h diff --git a/src/client_handler/display_handler.cpp b/src/client_handler/display_handler.cpp index 8e770510..f5ad596e 100644 --- a/src/client_handler/display_handler.cpp +++ b/src/client_handler/display_handler.cpp @@ -48,3 +48,9 @@ bool DisplayHandler::OnConsoleMessage(CefRefPtr browser, return DisplayHandler_OnConsoleMessage(browser, level, message, source, line); } + +bool DisplayHandler::OnAutoResize(CefRefPtr browser, + const CefSize& new_size) { + REQUIRE_UI_THREAD(); + return DisplayHandler_OnAutoResize(browser, new_size); +} diff --git a/src/client_handler/display_handler.h b/src/client_handler/display_handler.h index f6f4c865..f058c475 100644 --- a/src/client_handler/display_handler.h +++ b/src/client_handler/display_handler.h @@ -33,6 +33,9 @@ class DisplayHandler : public CefDisplayHandler const CefString& source, int line) override; + bool OnAutoResize(CefRefPtr browser, + const CefSize& new_size) override; + private: IMPLEMENT_REFCOUNTING(DisplayHandler); }; diff --git a/src/extern/cef/cef_browser.pxd b/src/extern/cef/cef_browser.pxd index 31a4a29d..042d0194 100644 --- a/src/extern/cef/cef_browser.pxd +++ b/src/extern/cef/cef_browser.pxd @@ -11,7 +11,7 @@ from libcpp cimport bool as cpp_bool from libcpp.vector cimport vector as cpp_vector from cef_frame cimport CefFrame cimport cef_types -from cef_types cimport int64, cef_state_t, PaintElementType +from cef_types cimport int64, cef_state_t, CefSize from cef_types cimport CefBrowserSettings, CefPoint from cef_drag_data cimport CefDragData from cef_types cimport CefMouseEvent @@ -87,7 +87,10 @@ cdef extern from "include/cef_browser.h": void AddWordToDictionary(const CefString& word) void SetAccessibilityState(cef_state_t accessibility_state) - void Invalidate(cef_types.cef_paint_element_type_t type) + void Invalidate(cef_types.cef_paint_element_type_t element_type) + void SetAutoResizeEnabled(cpp_bool enabled, + const CefSize& min_size, + const CefSize& max_size) cdef cppclass CefBrowser: diff --git a/src/handlers/display_handler.pyx b/src/handlers/display_handler.pyx index 3ad7a7f6..c60e49bc 100644 --- a/src/handlers/display_handler.pyx +++ b/src/handlers/display_handler.pyx @@ -25,6 +25,25 @@ cdef public void DisplayHandler_OnAddressChange( (exc_type, exc_value, exc_trace) = sys.exc_info() sys.excepthook(exc_type, exc_value, exc_trace) + +cdef public cpp_bool DisplayHandler_OnAutoResize( + CefRefPtr[CefBrowser] cef_browser, + const CefSize& new_size + ) except * with gil: + cdef PyBrowser browser + cdef object callback + try: + browser = GetPyBrowser(cef_browser, "OnAutoResize") + callback = browser.GetClientCallback("OnAutoResize") + if callback: + return bool(callback(browser=browser, new_size=[new_size.width, + new_size.height])) + return False + except: + (exc_type, exc_value, exc_trace) = sys.exc_info() + sys.excepthook(exc_type, exc_value, exc_trace) + + cdef public void DisplayHandler_OnTitleChange( CefRefPtr[CefBrowser] cefBrowser, const CefString& cefTitle diff --git a/unittests/_common.py b/unittests/_common.py index 59052583..b71c92f4 100644 --- a/unittests/_common.py +++ b/unittests/_common.py @@ -6,9 +6,18 @@ import base64 import os +import platform import sys import time +# Platforms +SYSTEM = platform.system().upper() +if SYSTEM == "DARWIN": + SYSTEM = "MAC" +WINDOWS = SYSTEM if SYSTEM == "WINDOWS" else False +LINUX = SYSTEM if SYSTEM == "LINUX" else False +MAC = SYSTEM if SYSTEM == "MAC" else False + # To show the window for an extended period of time increase this number. MESSAGE_LOOP_RANGE = 100 # each iteration is 0.01 sec diff --git a/unittests/main_test.py b/unittests/main_test.py index 58fec488..bfa1514c 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -14,6 +14,7 @@ import os import sys + g_datauri_data = """ @@ -134,10 +135,13 @@ def test_main(self): # Create browser browser = cef.CreateBrowserSync(url=g_datauri) self.assertIsNotNone(browser, "Browser object") + browser.SetFocus(True) subtest_message("cef.CreateBrowserSync() ok") # Client handlers - client_handlers = [LoadHandler(self, g_datauri), DisplayHandler(self)] + client_handlers = [LoadHandler(self, g_datauri), + DisplayHandler(self), + DisplayHandler2(self)] for handler in client_handlers: browser.SetClientHandler(handler) subtest_message("browser.SetClientHandler() ok") @@ -161,6 +165,12 @@ def test_main(self): browser.SetJavascriptBindings(bindings) subtest_message("browser.SetJavascriptBindings() ok") + # Set auto resize. Call it after js bindings were set. + browser.SetAutoResizeEnabled(enabled=True, + min_size=[800, 600], + max_size=[800, 600]) + subtest_message("browser.SetAutoResizeEnabled() ok") + # Test Request.SetPostData(list) # noinspection PyArgumentList req = cef.Request.CreateRequest() @@ -210,6 +220,20 @@ def test_main(self): sys.stdout.flush() +class DisplayHandler2(object): + def __init__(self, test_case): + self.test_case = test_case + # Asserts for True/False will be checked just before shutdown. + # Test whether asserts are working correctly. + self.test_for_True = True + self.OnAutoResize_True = False + + def OnAutoResize(self, new_size, **_): + assert not self.OnAutoResize_True + self.OnAutoResize_True = True + self.test_case.assertEqual(new_size, [800, 600]) + + class External(object): """Javascript 'window.external' object.""" From c559f44f70238ac695fbcb380991399cb8b561c4 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 18 Aug 2018 20:39:42 +0200 Subject: [PATCH 120/238] Fix AutoResize unit tests on Linux --- unittests/main_test.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unittests/main_test.py b/unittests/main_test.py index bfa1514c..91f27cc8 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -23,6 +23,8 @@ body,html { font-family: Arial; font-size: 11pt; + width: 800px; + heiht: 600px; } + + +

Javascript Bindings

+
+ + +""" + + +def main(): + cef.Initialize() + browser = cef.CreateBrowserSync(url=cef.GetDataUrl(g_htmlcode), + window_title="OnBeforeClose") + browser.SetClientHandler(LifespanHandler()) + bindings = cef.JavascriptBindings() + bindings.SetFunction("py_function", py_function) + bindings.SetFunction("py_callback", py_callback) + browser.SetJavascriptBindings(bindings) + cef.MessageLoop() + del browser + cef.Shutdown() + + +def py_function(value, js_callback): + print("Value sent from Javascript: "+value) + js_callback.Call("I am a Python string #2", py_callback) + + +def py_callback(value): + print("Value sent from Javascript: "+value) + + +class LifespanHandler(object): + def OnLoadEnd(self, browser, **_): + browser.ExecuteFunction("js_function", "I am a Python string #1") + + +if __name__ == '__main__': + main() diff --git a/examples/snippets/mouse_clicks.py b/examples/snippets/mouse_clicks.py index fcdd5280..e8ace36a 100644 --- a/examples/snippets/mouse_clicks.py +++ b/examples/snippets/mouse_clicks.py @@ -43,7 +43,7 @@ class LifespanHandler(object): def OnLoadEnd(self, browser, **_): # Execute function with a delay of 1 second after page # has completed loading. - print("Page completed loading") + print("Page loading is complete") cef.PostDelayedTask(cef.TID_UI, 1000, click_after_1_second, browser) diff --git a/examples/snippets/network_cookies.py b/examples/snippets/network_cookies.py index 55a71ec0..c3631cff 100644 --- a/examples/snippets/network_cookies.py +++ b/examples/snippets/network_cookies.py @@ -30,7 +30,7 @@ def CanGetCookies(self, frame, request, **_): print("-- CanGetCookies #"+str(self.getcount)) print("url="+request.GetUrl()[0:80]) print("") - # Return True to allow reading cookies and False to block + # Return True to allow reading cookies or False to block return True def CanSetCookie(self, frame, request, cookie, **_): @@ -43,7 +43,7 @@ def CanSetCookie(self, frame, request, cookie, **_): print("Name="+cookie.GetName()) print("Value="+cookie.GetValue()) print("") - # Return True to allow setting cookie and False to block + # Return True to allow setting cookie or False to block return True diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index fdf96cb2..f78800d3 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -82,6 +82,8 @@ NEW FEATURES + onbeforeclose.py + network_cookies.py + mouse_clicks.py + + javascript_bindings.py ++ cef.GetDataUrl internal/cef_types.h + cef_log_severity_t: new key LOGSEVERITY_DEBUG (no need to expose, diff --git a/src/cefpython.pyx b/src/cefpython.pyx index 5a526bcd..1631636f 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -134,6 +134,8 @@ import datetime import random # noinspection PyUnresolvedReferences import struct +# noinspection PyUnresolvedReferences +import base64 # Must use compile-time condition instead of checking sys.version_info.major # otherwise results in "ImportError: cannot import name urlencode" strange @@ -1023,3 +1025,9 @@ cpdef dict GetVersion(): cpdef LoadCrlSetsFile(py_string path): CefLoadCRLSetsFile(PyToCefStringValue(path)) + +cpdef GetDataUrl(data, mediatype="html"): + html = data.encode("utf-8", "replace") + b64 = base64.b64encode(html).decode("utf-8", "replace") + ret = "data:text/html;base64,{data}".format(data=b64) + return ret diff --git a/unittests/_common.py b/unittests/_common.py index a0dc1fd3..684a27b1 100644 --- a/unittests/_common.py +++ b/unittests/_common.py @@ -41,13 +41,6 @@ def show_test_summary(pyfile): + os.path.basename(pyfile)) -def html_to_data_uri(html): - html = html.encode("utf-8", "replace") - b64 = base64.b64encode(html).decode("utf-8", "replace") - ret = "data:text/html;base64,{data}".format(data=b64) - return ret - - def run_message_loop(): # Run message loop for some time. # noinspection PyTypeChecker diff --git a/unittests/main_test.py b/unittests/main_test.py index 25405ce0..b0c2200c 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -112,7 +112,7 @@ """ -g_datauri = html_to_data_uri(g_datauri_data) +g_datauri = cef.GetDataUrl(g_datauri_data) class MainTest_IsolatedTest(unittest.TestCase): diff --git a/unittests/osr_test.py b/unittests/osr_test.py index a5a3753b..0e4191be 100644 --- a/unittests/osr_test.py +++ b/unittests/osr_test.py @@ -62,7 +62,7 @@ """ -g_datauri = html_to_data_uri(g_datauri_data) +g_datauri = cef.GetDataUrl(g_datauri_data) class OsrTest_IsolatedTest(unittest.TestCase): From 6bb2d4ed7c3d498f999d6ac0c042336da1c11b18 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Aug 2018 12:13:43 +0200 Subject: [PATCH 139/238] Add javascript_erors.py and ondomready.py snippets (#403) --- docs/Tutorial.md | 3 +- examples/README-examples.md | 41 +++++++++------- examples/snippets/javascript_bindings.py | 3 +- examples/snippets/javascript_errors.py | 61 ++++++++++++++++++++++++ examples/snippets/ondomready.py | 50 +++++++++++++++++++ src/cef_v59..v66_changes.txt | 2 + 6 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 examples/snippets/javascript_errors.py create mode 100644 examples/snippets/ondomready.py diff --git a/docs/Tutorial.md b/docs/Tutorial.md index c6c0fcf7..ea32cb42 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -9,7 +9,8 @@ basics. This tutorial will discuss the three featured examples: [hello_world.py](../examples/hello_world.py), [tutorial.py](../examples/tutorial.py) and [screenshot.py](../examples/screenshot.py). There are many -more examples that you can find in the [README-examples.md](../examples/README-examples.md) +more examples that you can find in the +[README-examples.md](../examples/README-examples.md) file, but these examples are out of scope for this tutorial. diff --git a/examples/README-examples.md b/examples/README-examples.md index 0f0ef9a4..4ef36045 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -4,8 +4,8 @@ Table of contents: * [Hello World!](#hello-world) * [Supported examples](#supported-examples) * [Featured](#featured) - * [GUI frameworks](#gui-frameworks) * [Snippets](#snippets) + * [GUI frameworks](#gui-frameworks) * [Build executable with PyInstaller](#build-executable-with-pyinstaller) * [Unit tests](#unit-tests) * [Other examples](#other-examples) @@ -42,8 +42,31 @@ workarounds. discussed in great details in Tutorial in the [Off-screen rendering](../docs/Tutorial.md#off-screen-rendering) section. + +### Snippets + +See small code snippets that show various CEF features in the +[examples/snippets/](snippets/) directory: + +- [javascript_bindings.py](snippets/javascript_bindings.py) - Communicate + between Python and Javascript asynchronously using + inter-process messaging with the use of Javascript Bindings. +- [javascript_errors.py](snippets/javascript_errors.py) - Two ways for + intercepting Javascript errors. +- [mouse_clicks.py](snippets/mouse_clicks.py) - Perform mouse clicks + and mouse movements programmatically. +- [network_cookies.py](snippets/network_cookies.py) - Implement + interfaces to block or allow cookies over network requests. +- [onbeforeclose.py](snippets/onbeforeclose.py) - Implement interface + to execute custom code before browser window closes. +- [ondomready.py](snippets/ondomready.py) - Execute custom Python code + on a web page as soon as DOM is ready. + + ### GUI frameworks +Examples of embedding CEF browser using various GUI frameworks: + - [gtk2.py](gtk2.py): example for [PyGTK](http://www.pygtk.org/) library (GTK 2) - [gtk3.py](gtk3.py): example for [PyGObject / PyGI](https://wiki.gnome.org/Projects/PyGObject) @@ -64,22 +87,6 @@ workarounds. toolkit. This example implements High DPI support on Windows. -### Snippets - -See small code snippets that test various features in the -[examples/snippets/](snippets/) directory: - -- [javascript_bindings.py](snippets/javascript_bindings.py) - Communicate - between Python and Javascript asynchronously using - inter-process messaging with the use of Javascript Bindings. -- [mouse_clicks.py](snippets/mouse_clicks.py) - Perform mouse clicks - and mouse movements programmatically. -- [network_cookies.py](snippets/network_cookies.py) - Implement - interfaces to block or allow cookies over network requests. -- [onbeforeclose.py](snippets/onbeforeclose.py) - Implement interface - to execute custom code before browser window closes. - - ### Build executable with PyInstaller - [PyInstaller example](pyinstaller/README-pyinstaller.md): diff --git a/examples/snippets/javascript_bindings.py b/examples/snippets/javascript_bindings.py index 7c7dccc5..63135463 100644 --- a/examples/snippets/javascript_bindings.py +++ b/examples/snippets/javascript_bindings.py @@ -17,7 +17,6 @@ + + +

Javascript Errors

+
+ + +""" + + +def main(): + cef.Initialize() + browser = cef.CreateBrowserSync(url=cef.GetDataUrl(g_htmlcode), + window_title="Javascript Errors") + browser.SetClientHandler(DisplayHandler()) + cef.MessageLoop() + cef.Shutdown() + + +class DisplayHandler(object): + def OnConsoleMessage(self, browser, message, line, **_): + if "error" in message.lower() or "uncaught" in message.lower(): + logmsg = "[Py:OnConsoleMessage] {message} (line {line})" \ + .format(message=message, line=line) + print(logmsg) + browser.ExecuteFunction("print", logmsg) + + +if __name__ == '__main__': + main() diff --git a/examples/snippets/ondomready.py b/examples/snippets/ondomready.py new file mode 100644 index 00000000..caeacc02 --- /dev/null +++ b/examples/snippets/ondomready.py @@ -0,0 +1,50 @@ +""" +Execute custom Python code on a web page as soon as DOM is ready. +Implements a custom "_OnDomReady" event in the LifespanHandler object. +""" + +from cefpython3 import cefpython as cef + + +def main(): + cef.Initialize() + browser = cef.CreateBrowserSync(url="https://www.google.com/", + window_title="_OnDomReady event") + lifespan_handler = LifespanHandler(browser) + browser.SetClientHandler(lifespan_handler) + bindings = cef.JavascriptBindings() + bindings.SetFunction("LifespanHandler_OnDomReady", + lifespan_handler["_OnDomReady"]) + browser.SetJavascriptBindings(bindings) + cef.MessageLoop() + del lifespan_handler + del browser + cef.Shutdown() + + +class LifespanHandler(object): + def __init__(self, browser): + self.browser = browser + + def __getitem__(self, key): + return getattr(self, key) + + def OnLoadStart(self, browser, **_): + browser.ExecuteJavascript(""" + if (document.readyState === "complete") { + LifespanHandler_OnDomReady(); + } else { + document.addEventListener("DOMContentLoaded", function() { + LifespanHandler_OnDomReady(); + }); + } + """) + + def _OnDomReady(self): + print("DOM is ready!") + self.browser.ExecuteFunction("alert", + "Message from Python: DOM is ready!") + + +if __name__ == '__main__': + main() diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index f78800d3..1024bdaf 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -83,6 +83,8 @@ NEW FEATURES + network_cookies.py + mouse_clicks.py + javascript_bindings.py + + javascript_errors.py + + ondomready.py + cef.GetDataUrl internal/cef_types.h From 7448372a26632092876e026a4a9f7711839bb83e Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Aug 2018 12:46:43 +0200 Subject: [PATCH 140/238] Add onpagecomplete.py snippet (#403) and others. Add tools/run_snippets.py. --- examples/README-examples.md | 2 ++ examples/snippets/ondomready.py | 18 +++++----- examples/snippets/onpagecomplete.py | 35 ++++++++++++++++++ src/cef_v59..v66_changes.txt | 1 + tools/common.py | 1 + tools/run_examples.py | 3 +- tools/run_snippets.py | 55 +++++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 examples/snippets/onpagecomplete.py create mode 100644 tools/run_snippets.py diff --git a/examples/README-examples.md b/examples/README-examples.md index 4ef36045..b877607a 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -61,6 +61,8 @@ See small code snippets that show various CEF features in the to execute custom code before browser window closes. - [ondomready.py](snippets/ondomready.py) - Execute custom Python code on a web page as soon as DOM is ready. +- [onpagecomplete.py](snippets/onpagecomplete.py) - Execute custom + Python code on a web page when page loading is complete. ### GUI frameworks diff --git a/examples/snippets/ondomready.py b/examples/snippets/ondomready.py index caeacc02..8775129c 100644 --- a/examples/snippets/ondomready.py +++ b/examples/snippets/ondomready.py @@ -1,6 +1,6 @@ """ Execute custom Python code on a web page as soon as DOM is ready. -Implements a custom "_OnDomReady" event in the LifespanHandler object. +Implements a custom "_OnDomReady" event in the LoadHandler object. """ from cefpython3 import cefpython as cef @@ -10,19 +10,19 @@ def main(): cef.Initialize() browser = cef.CreateBrowserSync(url="https://www.google.com/", window_title="_OnDomReady event") - lifespan_handler = LifespanHandler(browser) - browser.SetClientHandler(lifespan_handler) + load_handler = LoadHandler(browser) + browser.SetClientHandler(load_handler) bindings = cef.JavascriptBindings() - bindings.SetFunction("LifespanHandler_OnDomReady", - lifespan_handler["_OnDomReady"]) + bindings.SetFunction("LoadHandler_OnDomReady", + load_handler["_OnDomReady"]) browser.SetJavascriptBindings(bindings) cef.MessageLoop() - del lifespan_handler + del load_handler del browser cef.Shutdown() -class LifespanHandler(object): +class LoadHandler(object): def __init__(self, browser): self.browser = browser @@ -32,10 +32,10 @@ def __getitem__(self, key): def OnLoadStart(self, browser, **_): browser.ExecuteJavascript(""" if (document.readyState === "complete") { - LifespanHandler_OnDomReady(); + LoadHandler_OnDomReady(); } else { document.addEventListener("DOMContentLoaded", function() { - LifespanHandler_OnDomReady(); + LoadHandler_OnDomReady(); }); } """) diff --git a/examples/snippets/onpagecomplete.py b/examples/snippets/onpagecomplete.py new file mode 100644 index 00000000..e118e8e7 --- /dev/null +++ b/examples/snippets/onpagecomplete.py @@ -0,0 +1,35 @@ +""" +Execute custom Python code on a web page when page loading is complete. +Implements a custom "_OnPageComplete" event in the LoadHandler object. +""" + +from cefpython3 import cefpython as cef + + +def main(): + cef.Initialize() + browser = cef.CreateBrowserSync(url="https://www.google.com/", + window_title="_OnPageComplete event") + browser.SetClientHandler(LoadHandler()) + cef.MessageLoop() + del browser + cef.Shutdown() + + +class LoadHandler(object): + def OnLoadingStateChange(self, browser, is_loading, **_): + """For detecting if page loading has ended it is recommended + to use OnLoadingStateChange which is most reliable. The OnLoadEnd + callback also available in LoadHandler can sometimes fail in + some cases e.g. when image loading hangs.""" + if not is_loading: + self._OnPageComplete(browser) + + def _OnPageComplete(self, browser): + print("Page loading is complete!") + browser.ExecuteFunction("alert", "Message from Python: Page loading" + " is complete!") + + +if __name__ == '__main__': + main() diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 1024bdaf..9060ad14 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -85,6 +85,7 @@ NEW FEATURES + javascript_bindings.py + javascript_errors.py + ondomready.py + + onpagecomplete + cef.GetDataUrl internal/cef_types.h diff --git a/tools/common.py b/tools/common.py index 06ab942e..ec92b0fe 100644 --- a/tools/common.py +++ b/tools/common.py @@ -158,6 +158,7 @@ # -- end build directories EXAMPLES_DIR = os.path.join(ROOT_DIR, "examples") +SNIPPETS_DIR = os.path.join(EXAMPLES_DIR, "snippets") SRC_DIR = os.path.join(ROOT_DIR, "src") # Subdirectories in src/ diff --git a/tools/run_examples.py b/tools/run_examples.py index 87fe1296..bf70f045 100644 --- a/tools/run_examples.py +++ b/tools/run_examples.py @@ -3,7 +3,8 @@ # Project website: https://github.com/cztomczak/cefpython """ -Run all examples that can be run on current configuration. +Run all examples that can be run on current configuration +and display a summary at the end. Note on GTK 2 / GTK 3 on Windows: Installing both PyGTK and PyGI on Windows will cause errors. diff --git a/tools/run_snippets.py b/tools/run_snippets.py new file mode 100644 index 00000000..193d9558 --- /dev/null +++ b/tools/run_snippets.py @@ -0,0 +1,55 @@ +# Copyright (c) 2018 CEF Python, see the Authors file. +# All rights reserved. Licensed under BSD 3-clause license. +# Project website: https://github.com/cztomczak/cefpython + +""" +Run all snippets from the examples/snippets/ directory +and display a summary at the end. +""" + +from common import * + +import glob +import os +import subprocess +import sys + + +def main(): + # Iterate over all snippets + snippets_iter = glob.glob(os.path.join(SNIPPETS_DIR, "*.py")) + succeeded = [] + failed = [] + for snippet in snippets_iter: + print("[run_snippets.py] Running '{snippet}'..." + .format(snippet=os.path.basename(snippet))) + retcode = subprocess.call([sys.executable, snippet]) + if retcode == 0: + succeeded.append(os.path.basename(snippet)) + else: + print("[run_snippets.py] ERROR while running snippet: {snippet}" + .format(snippet=snippet)) + failed.append(os.path.basename(snippet)) + + # Print summary + summary = "" + for snippet in succeeded: + summary += " OK {snippet}{nl}"\ + .format(snippet=snippet, nl=os.linesep) + for snippet in failed: + summary += " ERROR {snippet}{nl}"\ + .format(snippet=snippet, nl=os.linesep) + summary = summary[:-(len(os.linesep))] + print("[run_snippets.py] SUMMARY:") + print(summary.format()) + if len(failed): + print("[run_snippets.py] ERRORS ({failed}) while running snippets" + .format(failed=len(failed))) + sys.exit(1) + else: + print("[run_snippets.py] OK ({succeeded})" + .format(succeeded=len(succeeded))) + + +if __name__ == "__main__": + main() From 9f3ba137d3d243711ee40e21b1b958907bf63abb Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Aug 2018 13:18:43 +0200 Subject: [PATCH 141/238] Update cefpython.md --- api/cefpython.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/cefpython.md b/api/cefpython.md index a876bd69..29720c48 100644 --- a/api/cefpython.md +++ b/api/cefpython.md @@ -66,7 +66,8 @@ any third party GUI framework for creation of top-level window. After the call to CreateBrowserSync() the page is not yet loaded, if you want your next lines of code to do some stuff on the -webpage you will have to implement LoadHandler.[OnLoadingStateChange]((LoadHandler.md#onloadingstatechange)) +webpage you will have to implement +LoadHandler.[OnLoadingStateChange](LoadHandler.md#onloadingstatechange) callback. From ef6febb7d3ca751ce86eed0061b11538f2379e64 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Aug 2018 14:30:14 +0200 Subject: [PATCH 142/238] Fix build_distrib.py tool on Windows (#403) --- tools/build_distrib.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/build_distrib.py b/tools/build_distrib.py index 65bfd5ee..fc8c9db3 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -593,15 +593,18 @@ def check_cpp_extension_dependencies_issue359(setup_dir, all_pythons): for python in all_pythons: if python["version2"] in ((3, 5), (3, 6), (3, 7)): checked_any = True - if not os.path.exists(os.path.join(setup_dir, "msvcp140.dll")): + if not os.path.exists(os.path.join(setup_dir, "cefpython3", + "msvcp140.dll")): raise Exception("C++ ext dependency missing: msvcp140.dll") elif python["version2"] == (3, 4): checked_any = True - if not os.path.exists(os.path.join(setup_dir, "msvcp100.dll")): + if not os.path.exists(os.path.join(setup_dir, "cefpython3", + "msvcp100.dll")): raise Exception("C++ ext dependency missing: msvcp100.dll") elif python["version2"] == (2, 7): - if not os.path.exists(os.path.join(setup_dir, "msvcp90.dll")): - raise Exception("C++ ext dependency missing: msvcp100.dll") + if not os.path.exists(os.path.join(setup_dir, "cefpython3", + "msvcp90.dll")): + raise Exception("C++ ext dependency missing: msvcp90.dll") checked_any = True assert checked_any From 209fe5ad81b89529c3e3e0282ae0917da1815103 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Aug 2018 19:51:17 +0200 Subject: [PATCH 143/238] CEF Python v66.0 release --- README.md | 136 ++++++++++++++-------------- api/AccessibilityHandler.md | 8 +- docs/Tutorial.md | 2 +- examples/README-examples.md | 2 +- examples/pywin32.py | 2 +- src/cef_v59..v66_changes.txt | 5 +- tools/installer/cefpython3.setup.py | 2 +- 7 files changed, 81 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 9ecad822..1e6697e8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Table of contents: * [Introduction](#introduction) * [Sponsors](#sponsors) -* [Funding for the v66 release](#funding-for-the-v66-release) + * [Thanks to Lampix for the v66 release](#thanks-to-lampix-for-the-v66-release) * [Install](#install) * [Tutorial](#tutorial) * [Examples](#examples) @@ -92,15 +92,15 @@ See the [Support development](#support-development) section for a list of all the individuals and companies supporting CEF Python. -## Funding for the v66 release +### Thanks to Lampix for the v66 release -I am happy to announce that Lampix is sponsoring the v66 release of cefpython. +Many Thanks to Lampix for sponsoring the [v66 release](../../releases) of CEF Python. Lampix is the first hardware and software solution that turns any surface into a smart, augmented reality or interactive surface. Please visit its -website here: https://lampix.com/ . See the [v66 milestone](../../milestone/13) -to see progress on the new release. +website here: https://lampix.com/ . + +[![lampix360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix360.png)](https://lampix.com/) -[![lampix600](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix600.png)](https://lampix.com/) ## Install @@ -110,9 +110,10 @@ also download packages for offline installation available on the [GitHub Releases](../../releases) pages. Command to install with pip: ``` -pip install cefpython3==57.0 +pip install cefpython3==66.0 ``` + ## Tutorial See the [Tutorial.md](docs/Tutorial.md) file. @@ -170,6 +171,7 @@ so your company logo and a website link will be visible to many Python developer The statistics are from Mar 9, 2018. Complete statistics are available in this topic on the Forum: [[ANN] Call for sponsors](https://groups.google.com/d/topic/cefpython/CjkZF2P4rMk/discussion). + ### Thanks * [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 @@ -254,66 +256,66 @@ Additional information for v31.2 release: - [Tutorial](docs/Tutorial.md) -### API categories - -#### Modules - - * [cefpython](api/cefpython.md#cefpython) module - - -#### Settings - - * [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary - * [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary - * [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary - - -#### Classes and objects - - * [Browser](api/Browser.md#browser-object) object - * [Callback](api/Callback.md#callback-object) object - * [Cookie](api/Cookie.md#cookie-class) class - * [CookieManager](api/CookieManager.md#cookiemanager-class) class - * [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) - * [DragData](api/DragData.md#dragdata-object) object - * [Frame](api/Frame.md#frame-object) object - * [Image](api/Image.md#image-object) object - * [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class - * [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object - * [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object - * [Request](api/Request.md#request-class) class - * [Response](api/Response.md#response-object) object - * [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object - * [WebRequest](api/WebRequest.md#webrequest-class) class - * [WindowInfo](api/WindowInfo.md#windowinfo-class) class - * [WindowUtils](api/WindowUtils.md#windowutils-class) class - - -#### Client handlers (interfaces) - - * [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) - * [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) - * [DownloadHandler](api/DownloadHandler.md#downloadhandler) - * [FocusHandler](api/FocusHandler.md#focushandler-interface) - * [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) - * [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) - * [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) - * [LoadHandler](api/LoadHandler.md#loadhandler-interface) - * [RenderHandler](api/RenderHandler.md#renderhandler-interface) - * [RequestHandler](api/RequestHandler.md#requesthandler-interface) - * [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) - * [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) - - -#### Other interfaces - - * [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface - * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface - * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface - - -### API index - +### API categories + +#### Modules + + * [cefpython](api/cefpython.md#cefpython) module + + +#### Settings + + * [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary + * [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary + * [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary + + +#### Classes and objects + + * [Browser](api/Browser.md#browser-object) object + * [Callback](api/Callback.md#callback-object) object + * [Cookie](api/Cookie.md#cookie-class) class + * [CookieManager](api/CookieManager.md#cookiemanager-class) class + * [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) + * [DragData](api/DragData.md#dragdata-object) object + * [Frame](api/Frame.md#frame-object) object + * [Image](api/Image.md#image-object) object + * [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class + * [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object + * [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object + * [Request](api/Request.md#request-class) class + * [Response](api/Response.md#response-object) object + * [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object + * [WebRequest](api/WebRequest.md#webrequest-class) class + * [WindowInfo](api/WindowInfo.md#windowinfo-class) class + * [WindowUtils](api/WindowUtils.md#windowutils-class) class + + +#### Client handlers (interfaces) + + * [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) + * [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) + * [DownloadHandler](api/DownloadHandler.md#downloadhandler) + * [FocusHandler](api/FocusHandler.md#focushandler-interface) + * [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) + * [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) + * [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) + * [LoadHandler](api/LoadHandler.md#loadhandler-interface) + * [RenderHandler](api/RenderHandler.md#renderhandler-interface) + * [RequestHandler](api/RequestHandler.md#requesthandler-interface) + * [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) + * [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) + + +#### Other interfaces + + * [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface + * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface + * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface + + +### API index + * [AccessibilityHandler (interface)](api/AccessibilityHandler.md#accessibilityhandler-interface) * [_OnAccessibilityTreeChange](api/AccessibilityHandler.md#_onaccessibilitytreechange) * [_OnAccessibilityLocationChange](api/AccessibilityHandler.md#_onaccessibilitylocationchange) diff --git a/api/AccessibilityHandler.md b/api/AccessibilityHandler.md index faea2605..3433e003 100644 --- a/api/AccessibilityHandler.md +++ b/api/AccessibilityHandler.md @@ -11,12 +11,12 @@ accessibility events have been registered. The methods of this class will be called on the UI thread. Callbacks in this interface are not associated with any specific browser, -thus you must call cefpython.[SetGlobalClientHandler] or -SetGlobalClientCallback() to use them. The callbacks names were prefixed +thus you must call +`cefpython`.[SetGlobalClientHandler](cefpython.md#setglobalclienthandler) +or [SetGlobalClientCallback](cefpython.md#setglobalclientcallback) +to use them. The callbacks names were prefixed with "`_`" to distinguish this special behavior. -For an example of how to implement handler see [cefpython](cefpython.md).CreateBrowser(). For a list of all handler interfaces see [API > Client handlers](API#Client_handlers). - Table of contents: * [Callbacks](#callbacks) diff --git a/docs/Tutorial.md b/docs/Tutorial.md index ea32cb42..d67b6204 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -40,7 +40,7 @@ Run the commands below to install the cefpython3 package, clone the repository and run the Hello World example: ```commandline -pip install cefpython3==57.0 +pip install cefpython3==66.0 git clone https://github.com/cztomczak/cefpython.git cd cefpython/examples/ python hello_world.py diff --git a/examples/README-examples.md b/examples/README-examples.md index b877607a..de756013 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -17,7 +17,7 @@ Instructions to install the cefpython3 package, clone the repository and run the hello_world.py example: ``` -pip install cefpython3==57.0 +pip install cefpython3==66.0 git clone https://github.com/cztomczak/cefpython.git cd cefpython/examples/ python hello_world.py diff --git a/examples/pywin32.py b/examples/pywin32.py index d18aa54e..bf8d2b9b 100644 --- a/examples/pywin32.py +++ b/examples/pywin32.py @@ -108,7 +108,7 @@ def check_versions(): pywin32_version = fp.read().strip() print("[pywin32.py] pywin32 {ver}".format(ver=pywin32_version)) - assert cef.__version__ >= "57.0", "CEF Python v57.0 required to run this" + assert cef.__version__ >= "57.0", "CEF Python v57.0+ required to run this" def create_browser(window_info, settings, url): diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 9060ad14..fab7e5e7 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -165,4 +165,7 @@ cef_v8.h - CreateArrayBuffer (does not own the buffer) - IsArrayBuffer - GetArrayBufferReleaseCallback - - NeuterArrayBuffer \ No newline at end of file + - NeuterArrayBuffer + +cef_urlrequest.h +- ResponseWasCached \ No newline at end of file diff --git a/tools/installer/cefpython3.setup.py b/tools/installer/cefpython3.setup.py index c8e52699..6814cbb7 100644 --- a/tools/installer/cefpython3.setup.py +++ b/tools/installer/cefpython3.setup.py @@ -129,7 +129,7 @@ def main(): "https://github.com/cztomczak/cefpython", license="BSD 3-clause", author="Czarek Tomczak", - author_email="czarek.tomczak2@@gmail.com", + author_email="czarek.tomczak@gmail.com", url="https://github.com/cztomczak/cefpython", download_url="https://github.com/cztomczak/cefpython/releases", platforms=["{{SYSCONFIG_PLATFORM}}"], From 2de75b7f884fe12266b701e1ed7cd531346754d3 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 21 Aug 2018 11:30:08 +0200 Subject: [PATCH 144/238] Update screenshot.py. Note on viewport size limits in Chromium. --- examples/screenshot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/screenshot.py b/examples/screenshot.py index c27e72d0..7392ed5b 100644 --- a/examples/screenshot.py +++ b/examples/screenshot.py @@ -24,6 +24,15 @@ Tested configurations: - CEF Python v57.0+ - Pillow 2.3.0 / 4.1.0 + +NOTE: There are limits in Chromium on viewport size. For some + websites with huge viewport size it won't work. In such + case it is required to reduce viewport size to an usual + size of a window and perform scrolling programmatically + using javascript while making a screenshot for each of + the scrolled region. Then at the end combine all the + screenshots into one. To force a paint event in OSR + mode call cef.Invalidate(). """ from cefpython3 import cefpython as cef From 774820848b37da3b01e0f2436354057b1c1faaad Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Wed, 22 Aug 2018 09:29:20 +0200 Subject: [PATCH 145/238] Update Tutorial.md ExceptHook update --- docs/Tutorial.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/Tutorial.md b/docs/Tutorial.md index d67b6204..b4533e34 100644 --- a/docs/Tutorial.md +++ b/docs/Tutorial.md @@ -69,10 +69,10 @@ Google website. Let's analyze the code from that example: 1. `from cefpython3 import cefpython as cef` - Import the cefpython module and make a short "cef" alias 2. `sys.excepthook = cef.ExceptHook` - Overwrite Python's default - exception handler so that all CEF sub-processes are terminated - when Python exception occurs. To understand this better read the - "Architecture" and "Handling Python exceptions" sections - further down in this Tutorial. + exception handler so that all CEF sub-processes are reliably + terminated when Python exception occurs. To understand this + better read the "Architecture" and "Handling Python exceptions" + sections further down in this Tutorial. 3. `cef.Initialize()` - Initialize CEF. This function must be called somewhere in the beginning of your code. It must be called before any application window is created. It must be called only once @@ -140,9 +140,9 @@ special handling. When Python exception occurs then main process is terminated. For CEF this means that the Browser process is terminated, however there may still be running CEF sub-processes like Renderer process, GPU process, etc. To terminate these -sub-processes cef.[Shutdown](../api/cefpython.md#shutdown) +sub-processes cleanly cef.[Shutdown](../api/cefpython.md#shutdown) must be called and if running CEF message loop then it must be -stopped first. In all CEF Python examples you can find such +stopped first. In most of CEF Python examples you can find such a line that overwrites the default exception handler in Python: ```python @@ -160,7 +160,8 @@ The cef.ExceptHook helper function does the following: which exits the process with status 1, without calling cleanup handlers, flushing stdio buffers, etc. -See CEF Python's ExceptHook source code in src/[helpers.pyx](../src/helpers.pyx). +If you would like to modify `ExceptHook` behavior, see its source code +in src/[helpers.pyx](../src/helpers.pyx) file. ## Settings From c160430867ab55a9dcee5e4855852da6f95d9a1a Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 11:26:24 +0200 Subject: [PATCH 146/238] Auto cleanup in the examples/ directory, so that build scripts do not include trash directories. See Issue #432. --- tools/common.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/common.py b/tools/common.py index ec92b0fe..4bee285f 100644 --- a/tools/common.py +++ b/tools/common.py @@ -175,6 +175,25 @@ UNITTESTS_DIR = os.path.abspath(os.path.join(ROOT_DIR, "unittests")) # ---------------------------------------------------------------------------- + +# Auto cleanup in the examples/ directory, so that build scripts +# do not include trash directories. See Issue #432. + +shutil.rmtree(os.path.join(EXAMPLES_DIR, "blob_storage"), + ignore_errors=True) +shutil.rmtree(os.path.join(EXAMPLES_DIR, "webrtc_event_logs"), + ignore_errors=True) +shutil.rmtree(os.path.join(EXAMPLES_DIR, "webcache"), + ignore_errors=True) + +shutil.rmtree(os.path.join(SNIPPETS_DIR, "blob_storage"), + ignore_errors=True) +shutil.rmtree(os.path.join(SNIPPETS_DIR, "webrtc_event_logs"), + ignore_errors=True) +shutil.rmtree(os.path.join(SNIPPETS_DIR, "webcache"), + ignore_errors=True) + + # cefpython API header file and a fixed copy of it CEFPYTHON_API_HFILE = os.path.join(BUILD_CEFPYTHON, "cefpython_py{pyver}.h" From 3364c8fbcf4b48b0e41446939d23ebe1892d0f63 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 11:37:40 +0200 Subject: [PATCH 147/238] Add window_size.py snippet --- examples/snippets/window_size.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/snippets/window_size.py diff --git a/examples/snippets/window_size.py b/examples/snippets/window_size.py new file mode 100644 index 00000000..6ae1ba54 --- /dev/null +++ b/examples/snippets/window_size.py @@ -0,0 +1,34 @@ +""" +Set initial size of window to 900px / 640px without using +any third party GUI framework. On Linux/Mac you can set +window size by calling WindowInfo.SetAsChild. On Windows +you can accomplish this by calling Windows native functions +using the ctypes module. +""" + +from cefpython3 import cefpython as cef +import platform + + +def main(): + cef.Initialize() + window_info = cef.WindowInfo() + window_info.SetAsChild(0, [0, 0, 900, 640]) + browser = cef.CreateBrowserSync(url="https://www.google.com/", + window_info=window_info, + window_title="Window size") + if platform.system() == "Windows": + pass + cef.MessageLoop() + del browser + cef.Shutdown() + + +class LifespanHandler(object): + def OnBeforeClose(self, browser): + print("Browser ID: {}".format(browser.GetIdentifier())) + print("Browser will close and app will exit") + + +if __name__ == '__main__': + main() From f6e7de20300bd33bc1dc2807f480c8efd5b9b689 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 11:54:44 +0200 Subject: [PATCH 148/238] Update window_size.py snippet. Works on Windows now. --- examples/README-examples.md | 2 ++ examples/snippets/window_size.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index de756013..c87eee07 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -63,6 +63,8 @@ See small code snippets that show various CEF features in the on a web page as soon as DOM is ready. - [onpagecomplete.py](snippets/onpagecomplete.py) - Execute custom Python code on a web page when page loading is complete. +- [window_size.py](snippets/window_size.py) - Set initial window size + without using any third party GUI framework. ### GUI frameworks diff --git a/examples/snippets/window_size.py b/examples/snippets/window_size.py index 6ae1ba54..48e99160 100644 --- a/examples/snippets/window_size.py +++ b/examples/snippets/window_size.py @@ -1,5 +1,5 @@ """ -Set initial size of window to 900px / 640px without using +Set initial window size to 900/600 pixels without using any third party GUI framework. On Linux/Mac you can set window size by calling WindowInfo.SetAsChild. On Windows you can accomplish this by calling Windows native functions @@ -7,18 +7,27 @@ """ from cefpython3 import cefpython as cef +import ctypes import platform def main(): cef.Initialize() window_info = cef.WindowInfo() - window_info.SetAsChild(0, [0, 0, 900, 640]) + parent_handle = 0 + # All rect coordinates are applied including X and Y parameters + window_info.SetAsChild(parent_handle, [0, 0, 900, 640]) browser = cef.CreateBrowserSync(url="https://www.google.com/", window_info=window_info, window_title="Window size") if platform.system() == "Windows": - pass + window_handle = browser.GetOuterWindowHandle() + # X and Y parameters are ignored by setting the SWP_NOMOVE flag + SWP_NOMOVE = 0x0002 + insert_after_handle = 0 + # noinspection PyUnresolvedReferences + ctypes.windll.user32.SetWindowPos(window_handle, insert_after_handle, + 0, 0, 900, 640, SWP_NOMOVE) cef.MessageLoop() del browser cef.Shutdown() From 39ca247b0c143b25326f9d1a4b173a22006a916e Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 11:59:49 +0200 Subject: [PATCH 149/238] Update window_size.py snippet --- examples/README-examples.md | 2 +- examples/snippets/window_size.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index c87eee07..c8943656 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -64,7 +64,7 @@ See small code snippets that show various CEF features in the - [onpagecomplete.py](snippets/onpagecomplete.py) - Execute custom Python code on a web page when page loading is complete. - [window_size.py](snippets/window_size.py) - Set initial window size - without using any third party GUI framework. + without use of any third party GUI framework. ### GUI frameworks diff --git a/examples/snippets/window_size.py b/examples/snippets/window_size.py index 48e99160..5a7b04d0 100644 --- a/examples/snippets/window_size.py +++ b/examples/snippets/window_size.py @@ -1,5 +1,5 @@ """ -Set initial window size to 900/600 pixels without using +Set initial window size to 900/640px without use of any third party GUI framework. On Linux/Mac you can set window size by calling WindowInfo.SetAsChild. On Windows you can accomplish this by calling Windows native functions @@ -15,16 +15,17 @@ def main(): cef.Initialize() window_info = cef.WindowInfo() parent_handle = 0 - # All rect coordinates are applied including X and Y parameters + # This call has effect only on Mac and Linux. + # All rect coordinates are applied including X and Y parameters. window_info.SetAsChild(parent_handle, [0, 0, 900, 640]) browser = cef.CreateBrowserSync(url="https://www.google.com/", window_info=window_info, window_title="Window size") if platform.system() == "Windows": window_handle = browser.GetOuterWindowHandle() + insert_after_handle = 0 # X and Y parameters are ignored by setting the SWP_NOMOVE flag SWP_NOMOVE = 0x0002 - insert_after_handle = 0 # noinspection PyUnresolvedReferences ctypes.windll.user32.SetWindowPos(window_handle, insert_after_handle, 0, 0, 900, 640, SWP_NOMOVE) @@ -33,11 +34,5 @@ def main(): cef.Shutdown() -class LifespanHandler(object): - def OnBeforeClose(self, browser): - print("Browser ID: {}".format(browser.GetIdentifier())) - print("Browser will close and app will exit") - - if __name__ == '__main__': main() From d61fd8b1114c440c298bf7a224f6f17bc19fc510 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 18:05:18 +0200 Subject: [PATCH 150/238] Add "setcookie.py" snippet --- examples/snippets/setcookie.py | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/snippets/setcookie.py diff --git a/examples/snippets/setcookie.py b/examples/snippets/setcookie.py new file mode 100644 index 00000000..04a99508 --- /dev/null +++ b/examples/snippets/setcookie.py @@ -0,0 +1,36 @@ +""" +Shows how to set a cookie. +""" + +from cefpython3 import cefpython as cef +import datetime + + +def main(): + cef.Initialize() + cef.CreateBrowserSync( + url="http://www.html-kit.com/tools/cookietester/", + window_title="Set a cookie") + manager = cef.CookieManager.GetGlobalManager() + cookie = cef.Cookie() + cookie.Set({ + "name": "my_cookie", + "value": "my_value", + # Make sure domain is a valid value otherwise it crashes + # app (Issue #459) + "domain": "www.html-kit.com", + "path": "/", + "secure": False, + "httpOnly": False, + "creation": datetime.datetime(2018, 8, 22), + "lastAccess": datetime.datetime(2018, 8, 22), + "hasExpires": True, + "expires": datetime.datetime(2028, 12, 31, 23, 59, 59), + }) + manager.SetCookie("http://www.html-kit.com/", cookie) + cef.MessageLoop() + cef.Shutdown() + + +if __name__ == '__main__': + main() From a1ddc14ca1650f84d85535eced76d36cbe806ab0 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Aug 2018 18:08:08 +0200 Subject: [PATCH 151/238] Update README-examples.md --- examples/README-examples.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/README-examples.md b/examples/README-examples.md index c8943656..ed104c39 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -63,6 +63,7 @@ See small code snippets that show various CEF features in the on a web page as soon as DOM is ready. - [onpagecomplete.py](snippets/onpagecomplete.py) - Execute custom Python code on a web page when page loading is complete. +- [setcookie.py](snippets/setcookie.py) - Shows how to set a cookie - [window_size.py](snippets/window_size.py) - Set initial window size without use of any third party GUI framework. From fa8737b3863f49a000656799559b66f69d4b2fae Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Thu, 23 Aug 2018 10:57:55 +0200 Subject: [PATCH 152/238] Update Knowledge-Base.md --- docs/Knowledge-Base.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/Knowledge-Base.md b/docs/Knowledge-Base.md index 91d5a516..fddb6a7d 100644 --- a/docs/Knowledge-Base.md +++ b/docs/Knowledge-Base.md @@ -34,15 +34,14 @@ To be notified on new commits subscribe to this [RSS/Atom feed](../../../commits CEF Python depends on CEF and API breaks are inevitable when updating to latest CEF. The [Migration Guide](Migration-guide.md) document -lists most notable breaking changes for each release. Other changes -that do not backwards compatibility can be seen on [GitHub Releases](../../../releases) -pages. +lists most notable breaking changes for each release. Full chanelogs +can be found on [GitHub Releases](../../../releases) pages. -Due to unavoidable changes in API it is recommended for your setup -scripts that use for example PIP to install the cefpython3 package, +Due to unavoidable changes in upstream API it is recommended for your setup +scripts, that for example use PIP to install the cefpython3 package, to hardcode the cefpython version string. If for example using PIP's -requirements.txt file then list the cefpython3 package in the -following format if using cefpython v57.0: `cefpython3 == 57.0`. +`requirements.txt` file then include the cefpython3 package in the +following format if using e.g. cefpython v57.0: `cefpython3 == 57.0`. ## Differences between Python 2 and Python 3 From 1ebc485ec499f15423802980936af5ac832b53cd Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 27 Aug 2018 20:05:36 +0200 Subject: [PATCH 153/238] Update README and Migration Guide dos - v49.0 release (#460, #462) --- README.md | 60 ++++++++- docs/Migration-guide.md | 291 ++++++++++++++++++++++++++-------------- 2 files changed, 241 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index 1e6697e8..2c4e38ab 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Table of contents: * [Introduction](#introduction) * [Sponsors](#sponsors) * [Thanks to Lampix for the v66 release](#thanks-to-lampix-for-the-v66-release) + * [Thanks to Fivestars for the v49 release (WinXP/Vista)](#thanks-to-fivestars-for-the-v49-release-winxpvista) * [Install](#install) * [Tutorial](#tutorial) * [Examples](#examples) @@ -11,6 +12,10 @@ Table of contents: * [Support development](#support-development) * [Thanks](#thanks) * [Releases](#releases) + * [Next release](#next-release) + * [Latest release](#latest-release) + * [v49 release (WinXP/Vista)](#v49-release-winxpvista) + * [v31 release (old systems)](#v31-release-old-systems) * [Other READMEs](#other-readmes) * [Quick links](#quick-links) @@ -43,6 +48,14 @@ or other kind of internet bots.

+ +
+ + + - -
+ +
@@ -94,7 +107,7 @@ all the individuals and companies supporting CEF Python. ### Thanks to Lampix for the v66 release -Many Thanks to Lampix for sponsoring the [v66 release](../../releases) of CEF Python. +Many Thanks to Lampix for sponsoring the [v66 release](../../releases/tag/v66.0) of CEF Python. Lampix is the first hardware and software solution that turns any surface into a smart, augmented reality or interactive surface. Please visit its website here: https://lampix.com/ . @@ -102,6 +115,17 @@ website here: https://lampix.com/ . [![lampix360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix360.png)](https://lampix.com/) +### Thanks to Fivestars for the v49 release (WinXP/Vista) + +Thanks to Fivestars Loyalty, Inc. for sponsoring the +[v49 release](../../releases/tag/v49.0) for legacy systems such +as Windows XP and Vista. Please visit its website: +https://www.fivestars.com/ . + +[![fivestars360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/fivestars360.png)](https://www.fivestars.com/) + + + ## Install You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3) @@ -201,7 +225,7 @@ Information on planned new and current releases, supported platforms, python versions, architectures and requirements. If you want to support old operating systems then choose the v31 release. -**Next release** +### Next release - To see planned new features or bugs to be fixed in the next release, see the @@ -212,7 +236,7 @@ support old operating systems then choose the v31 release. [next release 2](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release+2%22) label in the tracker -**Latest release** +### Latest release OS | Py2 | Py3 | 32bit | 64bit | Requirements --- | --- | --- | --- | --- | --- @@ -224,7 +248,31 @@ These platforms are not supported yet: - ARM - see [Issue #267](../../issues/267) - Android - see [Issue #307](../../issues/307) -**v31 release** + +### v49 release (WinXP/Vista) + +OS | Py2 | Py3 | 32bit | 64bit | Requirements +--- | --- | --- | --- | --- | --- +Windows | 2.7 | 3.4 | Yes | Yes | Windows XP+ + +- Install with command: `pip --no-cache-dir install cefpython3==49.0`. + - Please note that if you were previously installing cefpython3 + package it is required to use the `--no-cache-dir` flag, + otherwise pip will end up with error message + `No matching distribution found for cefpython3==49.0`. + This happens because 49.0 release occured after 57.0 and 66.0 + releases. +- Downloads are available on GitHub Releases tagged + [v49.0](../../releases/tag/v49.0). +- See [Migration guide](docs/Migration-guide.md) document for changes + in this release +- Documentation is available in the [docs/](../../tree/cefpython49-winxp/docs) + directory in the `cefpython49-winxp` branch +- API reference is available in the [api/](../../tree/cefpython49-winxp/api) + directory in the `cefpython49-winxp` branch + + +### v31 release (old systems) OS | Py2 | Py3 | 32bit | 64bit | Requirements --- | --- | --- | --- | --- | --- diff --git a/docs/Migration-guide.md b/docs/Migration-guide.md index 3063ada1..7567f0a8 100644 --- a/docs/Migration-guide.md +++ b/docs/Migration-guide.md @@ -15,25 +15,29 @@ in your application. Table of contents: -* [v50+ Distribution packages](#v50-distribution-packages) +* [v49+ Distribution packages](#v49-distribution-packages) +* [v49+ cefbuilds.com is deprected, use Spotify Automated CEF Builds](#v49-cefbuildscom-is-deprected-use-spotify-automated-cef-builds) +* [v49+ Build instructions and build tools](#v49-build-instructions-and-build-tools) +* [v49: GPU acceleration should be disabled on Windows XP](#v49-gpu-acceleration-should-be-disabled-on-windows-xp) +* [v49 (Win) Handlers' callbacks and other interfaces](#v49-win-handlers-callbacks-and-other-interfaces) +* [v49+ High DPI support on Windows](#v49-high-dpi-support-on-windows) +* [v49 (Win) Do not call the 'WindowUtils.OnSize' function](#v49-win-do-not-call-the-windowutilsonsize-function) +* [v49+ Notify CEF on move or resize events](#v49-notify-cef-on-move-or-resize-events) +* [v49+ Flash support](#v49-flash-support) +* [v49+ Off-screen-rendering: new option "windowless_rendering_enabled"](#v49-off-screen-rendering-new-option-windowless_rendering_enabled) +* [v49+ BrowserSettings options removed](#v49-browsersettings-options-removed) +* [v49+ cef.Request.Flags changed](#v49-cefrequestflags-changed) +* [v49+ Request.GetHeaderMap and SetHeaderMap change](#v49-requestgetheadermap-and-setheadermap-change) +* [v49+ (Win) HTTPS cache problems on pages with certificate errors](#v49-win-https-cache-problems-on-pages-with-certificate-errors) * [v50+ Importing the cefpython3 package on Linux](#v50-importing-the-cefpython3-package-on-linux) * [v50+ Install X11 error handlers on Linux](#v50-install-x11-error-handlers-on-linux) * [v50+ Set window bounds on Linux](#v50-set-window-bounds-on-linux) -* [v50+ Notify CEF on move or resize events](#v50-notify-cef-on-move-or-resize-events) * [v50+ Keyboard focus issues on Linux](#v50-keyboard-focus-issues-on-linux) * [v50+ Windows XP and Vista are no more supported](#v50-windows-xp-and-vista-are-no-more-supported) * [v50+ Mac 32-bit is no more supported](#v50-mac-32-bit-is-no-more-supported) -* [v50+ cefbuilds.com is deprected, use Spotify Automated CEF Builds](#v50-cefbuildscom-is-deprected-use-spotify-automated-cef-builds) -* [v50+ Build instructions and build tools](#v50-build-instructions-and-build-tools) -* [v51+ Off-screen-rendering: new option "windowless_rendering_enabled"](#v51-off-screen-rendering-new-option-windowless_rendering_enabled) * [v51+ Remove LifespanHandler.RunModal](#v51-remove-lifespanhandlerrunmodal) -* [v51+ BrowserSettings options removed](#v51-browsersettings-options-removed) -* [v51+ cef.Request.Flags changed](#v51-cefrequestflags-changed) -* [v51+ Request.GetHeaderMap and SetHeaderMap change](#v51-requestgetheadermap-and-setheadermap-change) -* [v54+ GTK 3 example doesn't work anymore on Linux](#v54-gtk-3-example-doesnt-work-anymore-on-linux) * [v54+ libcef.so library is stripped from symbols on Linux](#v54-libcefso-library-is-stripped-from-symbols-on-linux) -* [v55+ HTTPS cache problems on pages with certificate errors](#v55-https-cache-problems-on-pages-with-certificate-errors) -* [v55.3+ Handlers' callbacks and other interfaces are now called using keyword args](#v553-handlers-callbacks-and-other-interfaces-are-now-called-using-keyword-args) +* [v55.3+ Handlers' callbacks and other interfaces](#v553-handlers-callbacks-and-other-interfaces) * [v56+ MacOS 10.9+ required to run](#v56-macos-109-required-to-run) * [v57.1+ High DPI support on Windows](#v571-high-dpi-support-on-windows) * [v66+ Linux patch that fixed HTTPS cache problems on pages with certificate errors was disabled](#v66-linux-patch-that-fixed-https-cache-problems-on-pages-with-certificate-errors-was-disabled) @@ -46,10 +50,10 @@ Table of contents: * [v66+ cef.Request.Flags changed](#v66-cefrequestflags-changed) * [v66+ RequestHandler.GetCookieManager not getting called in some cases](#v66-requesthandlergetcookiemanager-not-getting-called-in-some-cases) * [v66+ Changes to Mac apps that integrate into existing message loop (Qt, wxPython)](#v66-changes-to-mac-apps-that-integrate-into-existing-message-loop-qt-wxpython) +* [v67+ Do not call the 'WindowUtils.OnSize' function](#v67-do-not-call-the-windowutilsonsize-function) - -## v50+ Distribution packages +## v49+ Distribution packages In latest CEF Python there is only one distribution package available: a wheel package. Wheel packages are distributed on @@ -77,120 +81,133 @@ in an automated manner, it might be reconsidered in the future to provide debian packages again. -## v50+ Importing the cefpython3 package on Linux +## v49+ cefbuilds.com is deprected, use Spotify Automated CEF Builds -In the past on Linux it was required for the cefpython3 package -to be imported before any other packages due to tcmalloc global -hook being loaded. This is not required anymore, tcmalloc is -disabled by default. +The cefbuilds.com site with CEF prebuilt binaries is now deprecated. +From now on download prebuilt CEF binaries from the Spotify Automated +CEF Builds: +http://opensource.spotify.com/cefbuilds/index.html -## v50+ Install X11 error handlers on Linux -It is required to install X11 error handlers on Linux, otherwise -you will see 'BadWindow' errors happening - sometimes randomly - -which will cause application to terminate. Since v56+ x11 error -handlers are installed automatically by default during the call -to cef.Initialize(). However sometimes that is not enough like -for example in the wxpython.py example which requires the x11 -error handlers to be installed manually after wx was initialized, -and that is because wx initialization had reset x11 error handlers -that were installed earlier during cef initialization (Issue [#334](../../../issues/334)). +## v49+ Build instructions and build tools -You can install X11 error handlers by calling: -``` -WindowUtils = cef.WindowUtils() -WindowUtils.InstallX11ErrorHandlers() -``` +There were many changes in regards to building CEF and CEF Python. +There are now new tools in the tools/ root directory that fully +automate building CEF and CEF Python. CEF Python now provides +upstream CEF prebuilt binaries and libraries on GitHub Releases +tagged eg. "v49-upstream". With these binaries you can build +CEF Python from sources in less than 10 minutes. See the new +[Build instructions](Build-instructions.md) document. -API ref: WindowUtils.[InstallX11ErrorHandlers()](../api/WindowUtils.md#installx11errorhandlers-linux) +## v49: GPU acceleration should be disabled on Windows XP -## v50+ Set window bounds on Linux +On XP you should disable GPU acceleration by setting the `--disable-gpu` +and `--disable-gpu-compositing` switches. These switches can +be passed programmatically to `cef.Initialize`, see +[api/Command Line Switches](../api/CommandLineSwitches.md). -It is now required to set window bounds during window "resize", -"move" and "configure" events on Linux. You can do so by calling: -``` -browser.SetBounds(x, y, width, height) -``` +## v49 (Win) Handlers' callbacks and other interfaces -API ref: Browser.[SetBounds()](../api/Browser.md#setbounds) +In v49.0 release for Windows all handlers' +callbacks and other interfaces such as +CookieVisitor, StringVisitor and WebRequestClient, are now called +using keyword arguments (Issue [#291](../../../issues/291)). +This will cause many of existing code to break. This is how you +should declare callbacks using the new style: + +``` +def OnLoadStart(self, browser, **_): + pass +def OnLoadStart(self, **kwargs): + browser = kwargs["browser"] +``` -## v50+ Notify CEF on move or resize events +In the first declaration you see that only one argument is +declared, the browser, the others unused will be in the "_" +variable (the name of the variable is so that PyCharm doesn't +warn about unused variable). -It is required to notify the browser on move or resize events -so that popup widgets (e.g. \) are displayed in the correct -location and dismissed when the window moves. Also so that -drag & drop areas are updated accordingly. +Even if you specify and use all arguments, always add the +unused kwargs (`**_`) at the end: ``` -browser.NotifyMoveOrResizeStarted() +def OnLoadStart(self, browser, frame, **_): + pass ``` -API ref: Browser.[NotifyMoveOrResizeStarted()](../api/Browser.md#notifymoveorresizestarted) - +This will be handy in the future, in a case when upstream CEF +adds a new argument to the API, your code won't break. When +an argument is removed in upstream CEF API, if it's possible +CEF Python will try to keep backward compatibility by +emulating behavior of the old argument. -## v50+ Keyboard focus issues on Linux +In case of OnLoadStart, when you've used "browser" and "frame" +names for the arguments, your code won't break. However in +many other callbacks, where you've used argument names that +differed from how they were named in API docs, your code will +break. Also argument names were changed from camelCase +to underscores. For example the OnLoadEnd callback has renamed +the `httpStatusCode` argument to `http_code`. So in this case +your code will definitely break, unless you've also used +"http_code" for argument name. -There several keyboard focus issues on Linux since CEF library -replaced GTK library with X11 library. Most of these issues are -fixed in examples by calling SetFocus in LoadHandler.OnLoadStart -during initial app loading and/or by calling SetFocus in -FocusHandler.OnGotFocus. This keyboard focus issues need to be -fixed in usptream CEF. For more details see Issue [#284](../../../issues/284). +## v49+ High DPI support on Windows -## v50+ Windows XP and Vista are no more supported +It is recommended to embed a DPI awareness manifest in both the main +process and the subprocesses (the subprocess.exe executable) instead +of calling `DpiAware`.[SetProcessDpiAware](../api/DpiAware.md#setprocessdpiaware) +which sets DPI awareness only for the main process. -CEF Python v31.2 was the last version to support Windows XP. -This is due to Chromium/CEF dropping XP support, last version -that supported XP was CEF v49. +The `ApplicationSettings`.[auto_zooming](../api/ApplicationSettings.md#auto_zooming) +option has a default value of an empty string now. Previously the +default was "system_dpi". When enabling High DPI support you should +set it to "system_dpi" explicitilly. +Note that `DpiAware`.[CalculateWindowSize](../api/DpiAware.md#calculatewindowsize) +does not handle all DPI settings (e.g. 132% on Windows 10). +In newer CEF Python there is available `DpiAware`[Scale](../api/DpiAware.md#scale) +which is more reliable and can handle all DPI resolutions. You can copy see +its implementation in `src/dpi_aware_win.pyx`. -## v50+ Mac 32-bit is no more supported -CEF Python v31.2 was the last version to support Mac 32-bit. -This is due to CEF/Chromium dropping 32-bit support, last version -that supported 32-bit was CEF v38. +## v49 (Win) Do not call the 'WindowUtils.OnSize' function +This function can sometimes cause app hanging during window resize. +Call instead the new `WindowUtils`.[UpdateBrowserSize](../api/WindowUtils.md#updatebrowsersize) +function. See [Issue #464](../../../issues/464) for more details. -## v50+ cefbuilds.com is deprected, use Spotify Automated CEF Builds -The cefbuilds.com site with CEF prebuilt binaries is now deprecated. -From now on download prebuilt CEF binaries from the Spotify Automated -CEF Builds: +## v49+ Notify CEF on move or resize events -http://opensource.spotify.com/cefbuilds/index.html +It is required to notify the browser on move or resize events +so that popup widgets (e.g. \) are displayed in the correct +location and dismissed when the window moves. Also so that +drag & drop areas are updated accordingly. Call +Browser.[NotifyMoveOrResizeStarted()](../api/Browser.md#notifymoveorresizestarted) +during a move or resize event in your app window. -## v50+ Build instructions and build tools +## v49+ Flash support -There were many changes in regards to building CEF and CEF Python. -There are now new tools in the tools/ root directory that fully -automate building CEF and CEF Python. CEF Python now provides -upstream CEF prebuilt binaries and libraries on GitHub Releases -tagged eg. "v56-upstream". With these binaries you can build -CEF Python from sources in less than 10 minutes. See the new -[Build instructions](Build-instructions.md) document. +See [Issue #235](../../../issues/235) ("Flash support in CEF v49+") +for instructions on how to enable Flash. -## v51+ Off-screen-rendering: new option "windowless_rendering_enabled" +## v49+ Off-screen-rendering: new option "windowless_rendering_enabled" When using off-screen-rendering you must set the ApplicationSettings "windowless_rendering_enabled" option to True. This applies to -examples such as: Kivy, Panda3D and screenshot example. +examples such as: Kivy, Panda3D, PySDL2 and screenshot example. API ref: ApplicationSettings.[windowless_rendering_enabled](../api/ApplicationSettings.md#windowless_rendering_enabled) -## v51+ Remove LifespanHandler.RunModal - -LifespanHandler.RunModal callback is no more available. - - -## v51+ BrowserSettings options removed +## v49+ BrowserSettings options removed The following options were removed from BrowserSettings: - user_style_sheet_location @@ -199,7 +216,7 @@ The following options were removed from BrowserSettings: - author_and_user_styles_disabled -## v51+ cef.Request.Flags changed +## v49+ cef.Request.Flags changed The following flags were removed from cef.Request.Flags: - AllowCookies @@ -209,7 +226,7 @@ The following flags were removed from cef.Request.Flags: API ref: Request.[GetFlags](../api/Request.md#getflags) -## v51+ Request.GetHeaderMap and SetHeaderMap change +## v49+ Request.GetHeaderMap and SetHeaderMap change GetHeaderMap() will not include the Referer value if any and SetHeaderMap() will ignore the Referer value. @@ -217,35 +234,93 @@ and SetHeaderMap() will ignore the Referer value. API ref: Request.[GetHeaderMap](../api/Request.md#getheadermap) -## v54+ GTK 3 example doesn't work anymore on Linux +## v49+ (Win) HTTPS cache problems on pages with certificate errors -Update: GTK 3 example is back working in v57+. +The fix for HTTPS cache problems on pages with certificate errors +(and that includes self-signed certificates) is no more applied +on Windows. -Currently GTK 3 example is broken on Linux. You can either -downgrade to an old cefpython v53 (available on GitHub release -page) or use GTK 2 example. For more details on the problem see -Issue [#261](../../../issues/261). +See Issue [#125](../../../issues/125) for more details. -## v54+ libcef.so library is stripped from symbols on Linux +## v50+ Importing the cefpython3 package on Linux -Symbols useful for debugging are no more available in libcef.so -shipped with distribution packages on Linux. This is explained -in details in Issue [#262](../../../issues/262). +In the past on Linux it was required for the cefpython3 package +to be imported before any other packages due to tcmalloc global +hook being loaded. This is not required anymore, tcmalloc is +disabled by default. -## v55+ HTTPS cache problems on pages with certificate errors +## v50+ Install X11 error handlers on Linux -The fix for HTTPS cache problems on pages with certificate errors -is no more applied on Windows. +It is required to install X11 error handlers on Linux, otherwise +you will see 'BadWindow' errors happening - sometimes randomly - +which will cause application to terminate. Since v56+ x11 error +handlers are installed automatically by default during the call +to cef.Initialize(). However sometimes that is not enough like +for example in the wxpython.py example which requires the x11 +error handlers to be installed manually after wx was initialized, +and that is because wx initialization had reset x11 error handlers +that were installed earlier during cef initialization (Issue [#334](../../../issues/334)). -Soon this will fix also won't be applied on Linux anymore when -cefpython starts using CEF prebuilt binaries from Spotify. +You can install X11 error handlers by calling: +``` +WindowUtils = cef.WindowUtils() +WindowUtils.InstallX11ErrorHandlers() +``` -See Issue [#125](../../../issues/125) for more details. +API ref: WindowUtils.[InstallX11ErrorHandlers()](../api/WindowUtils.md#installx11errorhandlers-linux) + + +## v50+ Set window bounds on Linux + +It is now required to set window bounds during window "resize", +"move" and "configure" events on Linux. You can do so by calling: + +``` +browser.SetBounds(x, y, width, height) +``` + +API ref: Browser.[SetBounds()](../api/Browser.md#setbounds) + + +## v50+ Keyboard focus issues on Linux + +There several keyboard focus issues on Linux since CEF library +replaced GTK library with X11 library. Most of these issues are +fixed in examples by calling SetFocus in LoadHandler.OnLoadStart +during initial app loading and/or by calling SetFocus in +FocusHandler.OnGotFocus. This keyboard focus issues need to be +fixed in usptream CEF. For more details see Issue [#284](../../../issues/284). -## v55.3+ Handlers' callbacks and other interfaces are now called using keyword args +## v50+ Windows XP and Vista are no more supported + +CEF Python v49.0 was the last version to support Windows XP. +This is due to Chromium/CEF dropping XP support, last version +that supported XP was CEF v49. + + +## v50+ Mac 32-bit is no more supported + +CEF Python v31.2 was the last version to support Mac 32-bit. +This is due to CEF/Chromium dropping 32-bit support, last version +that supported 32-bit was CEF v38. + + +## v51+ Remove LifespanHandler.RunModal + +LifespanHandler.RunModal callback is no more available. + + +## v54+ libcef.so library is stripped from symbols on Linux + +Symbols useful for debugging are no more available in libcef.so +shipped with distribution packages on Linux. This is explained +in details in Issue [#262](../../../issues/262). + + +## v55.3+ Handlers' callbacks and other interfaces Since v55.3 all handlers' callbacks and other interfaces such as CookieVisitor, StringVisitor and WebRequestClient, are now called @@ -407,3 +482,11 @@ with message loop freezing. Only basic testing was performed. It was not tested of how this change affects performance. See Issue [#442](../../../issues/442) for more details on the issues. + + +## v67+ Do not call the 'WindowUtils.OnSize' function + +This function can sometimes cause app hanging during window resize. +Call instead the new `WindowUtils`.[UpdateBrowserSize](../api/WindowUtils.md#updatebrowsersize) +function. See [Issue #464](../../../issues/464) for more details. + From 6cf7455179e7dd79f8a8e9c7fbbbe686c3682258 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 27 Aug 2018 20:07:56 +0200 Subject: [PATCH 154/238] Update README - style changes --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2c4e38ab..497d810f 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ Table of contents: * [Introduction](#introduction) * [Sponsors](#sponsors) - * [Thanks to Lampix for the v66 release](#thanks-to-lampix-for-the-v66-release) - * [Thanks to Fivestars for the v49 release (WinXP/Vista)](#thanks-to-fivestars-for-the-v49-release-winxpvista) * [Install](#install) * [Tutorial](#tutorial) * [Examples](#examples) @@ -105,7 +103,7 @@ See the [Support development](#support-development) section for a list of all the individuals and companies supporting CEF Python. -### Thanks to Lampix for the v66 release +**Thanks to Lampix for the v66 release** Many Thanks to Lampix for sponsoring the [v66 release](../../releases/tag/v66.0) of CEF Python. Lampix is the first hardware and software solution that turns any surface @@ -115,7 +113,7 @@ website here: https://lampix.com/ . [![lampix360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix360.png)](https://lampix.com/) -### Thanks to Fivestars for the v49 release (WinXP/Vista) +**Thanks to Fivestars for the v49 release (WinXP/Vista)** Thanks to Fivestars Loyalty, Inc. for sponsoring the [v49 release](../../releases/tag/v49.0) for legacy systems such From 263024423e22dfdcf720259d5c47aa2f48e949b5 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 27 Aug 2018 20:10:59 +0200 Subject: [PATCH 155/238] Update README, style changes again --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 497d810f..b6cc9eb4 100644 --- a/README.md +++ b/README.md @@ -110,8 +110,6 @@ Lampix is the first hardware and software solution that turns any surface into a smart, augmented reality or interactive surface. Please visit its website here: https://lampix.com/ . -[![lampix360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/lampix360.png)](https://lampix.com/) - **Thanks to Fivestars for the v49 release (WinXP/Vista)** @@ -120,9 +118,6 @@ Thanks to Fivestars Loyalty, Inc. for sponsoring the as Windows XP and Vista. Please visit its website: https://www.fivestars.com/ . -[![fivestars360](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/fivestars360.png)](https://www.fivestars.com/) - - ## Install From 3e6f421a2bdba024522092c91e9e2031a8dded10 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 27 Aug 2018 20:17:30 +0200 Subject: [PATCH 156/238] Disable GPU acceleration and add perf. enhancing switches in OSR (#463) --- examples/screenshot.py | 28 +++++++++++++++++++++++----- unittests/osr_test.py | 22 +++++++++++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/examples/screenshot.py b/examples/screenshot.py index 7392ed5b..d6dc661c 100644 --- a/examples/screenshot.py +++ b/examples/screenshot.py @@ -43,7 +43,7 @@ try: from PIL import Image, PILLOW_VERSION -except: +except ImportError: print("[screenshot.py] Error: PIL module not available. To install" " type: pip install Pillow") sys.exit(1) @@ -64,9 +64,26 @@ def main(): os.remove(SCREENSHOT_PATH) command_line_arguments() # Off-screen-rendering requires setting "windowless_rendering_enabled" - # option, so that RenderHandler callbacks are called. - cef.Initialize(settings={"windowless_rendering_enabled": True}) - create_browser() + # option. + settings = { + "windowless_rendering_enabled": True, + } + switches = { + # GPU acceleration is not supported in OSR mode, so must disable + # it using these Chromium switches (Issue #240 and #463) + "disable-gpu": "", + "disable-gpu-compositing": "", + # Tweaking OSR performance by setting the same Chromium flags + # as in upstream cefclient (Issue #240). + "enable-begin-frame-scheduling": "", + "disable-surfaces": "", # This is required for PDF ext to work + } + browser_settings = { + # Tweaking OSR performance (Issue #240) + "windowless_frame_rate": 30, # Default frame rate in CEF is 30 + } + cef.Initialize(settings=settings, switches=switches) + create_browser(browser_settings) cef.MessageLoop() cef.Shutdown() print("[screenshot.py] Opening screenshot with default application") @@ -108,7 +125,7 @@ def command_line_arguments(): sys.exit(1) -def create_browser(): +def create_browser(settings): # Create browser in off-screen-rendering mode (windowless mode) # by calling SetAsOffscreen method. In such mode parent window # handle can be NULL (0). @@ -120,6 +137,7 @@ def create_browser(): print("[screenshot.py] Loading url: {url}" .format(url=URL)) browser = cef.CreateBrowserSync(window_info=window_info, + settings=settings, url=URL) browser.SetClientHandler(LoadHandler()) browser.SetClientHandler(RenderHandler()) diff --git a/unittests/osr_test.py b/unittests/osr_test.py index 0e4191be..672e98fe 100644 --- a/unittests/osr_test.py +++ b/unittests/osr_test.py @@ -23,7 +23,7 @@ font-size: 11pt; } - + + + +""" + + +class RequestHandler: + def GetResourceHandler(self, browser, frame, request): + print(request.GetPostData()) + return None + +def main(): + sys.excepthook = cef.ExceptHook + cef.Initialize() + browser = cef.CreateBrowserSync(url=cef.GetDataUrl(html)) + browser.SetClientHandler(RequestHandler()) + cef.MessageLoop() + del browser + cef.Shutdown() + + +if __name__ == '__main__': + main() diff --git a/unittests/main_test.py b/unittests/main_test.py index b0c2200c..f3602c21 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -235,7 +235,7 @@ def test_main(self): req_file = os.path.dirname(os.path.abspath(__file__)) req_file = os.path.join(req_file, "main_test.py") if sys.version_info.major > 2: - req_file = req_file.encode() + req_file = req_file.encode("utf-8") req_data = [b"--key=value", b"@"+req_file] req.SetMethod("POST") req.SetPostData(req_data) From b7f25aa7eecf59569dbb0bd7513ff84cee669c00 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 12 Jan 2020 11:00:47 +0100 Subject: [PATCH 193/238] Fix tkinter focus issues on Windows (#535). --- examples/tkinter_.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/tkinter_.py b/examples/tkinter_.py index 58dc402e..f1e2c818 100644 --- a/examples/tkinter_.py +++ b/examples/tkinter_.py @@ -13,6 +13,8 @@ # Known issue on Linux: When typing url, mouse must be over url # entry widget otherwise keyboard focus is lost (Issue #255 # and Issue #284). +# Other focus issues discussed in Issue #535. + from cefpython3 import cefpython as cef import ctypes @@ -153,6 +155,7 @@ def __init__(self, master, navigation_bar=None): self.bind("", self.on_focus_in) self.bind("", self.on_focus_out) self.bind("", self.on_configure) + """For focus problems see Issue #255 and Issue #535. """ self.focus_set() def embed_browser(self): @@ -216,8 +219,6 @@ def on_focus_in(self, _): def on_focus_out(self, _): logger.debug("BrowserFrame.on_focus_out") - if self.browser: - self.browser.SetFocus(False) def on_root_close(self): if self.browser: @@ -242,6 +243,7 @@ def OnLoadStart(self, browser, **_): class FocusHandler(object): + """For focus problems see Issue #255 and Issue #535. """ def __init__(self, browser_frame): self.browser_frame = browser_frame @@ -253,13 +255,10 @@ def OnTakeFocus(self, next_component, **_): def OnSetFocus(self, source, **_): logger.debug("FocusHandler.OnSetFocus, source={source}" .format(source=source)) - return False + return True def OnGotFocus(self, **_): - """Fix CEF focus issues (#255). Call browser frame's focus_set - to get rid of type cursor in url entry widget.""" logger.debug("FocusHandler.OnGotFocus") - self.browser_frame.focus_set() class NavigationBar(tk.Frame): @@ -340,7 +339,7 @@ def on_load_url(self, _): self.master.get_browser().LoadUrl(self.url_entry.get()) def on_button1(self, _): - """Fix CEF focus issues (#255). See also FocusHandler.OnGotFocus.""" + """For focus problems see Issue #255 and Issue #535. """ logger.debug("NavigationBar.on_button1") self.master.master.focus_force() From 076b6a661246c5855233730c766ab1dfa58264a9 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 12 Jan 2020 11:12:15 +0100 Subject: [PATCH 194/238] Fix tkinter focus problems on Linux (#535). --- examples/tkinter_.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/tkinter_.py b/examples/tkinter_.py index f1e2c818..c823f3dc 100644 --- a/examples/tkinter_.py +++ b/examples/tkinter_.py @@ -219,6 +219,9 @@ def on_focus_in(self, _): def on_focus_out(self, _): logger.debug("BrowserFrame.on_focus_out") + """For focus problems see Issue #255 and Issue #535. """ + if LINUX and self.browser: + self.browser.SetFocus(False) def on_root_close(self): if self.browser: @@ -255,10 +258,15 @@ def OnTakeFocus(self, next_component, **_): def OnSetFocus(self, source, **_): logger.debug("FocusHandler.OnSetFocus, source={source}" .format(source=source)) - return True + if LINUX: + return False + else: + return True def OnGotFocus(self, **_): logger.debug("FocusHandler.OnGotFocus") + if LINUX: + self.browser_frame.focus_set() class NavigationBar(tk.Frame): From bddb859d52a6c4bc65d7a3400d1fed71d40e3d7c Mon Sep 17 00:00:00 2001 From: GiovanniL <13402461+GiovaLomba@users.noreply.github.com> Date: Sun, 12 Jan 2020 17:08:27 +0100 Subject: [PATCH 195/238] Fixed typo (#556) Original: The actual key code genenerated by the platform New: The actual key code generated by the platform --- api/KeyboardHandler.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/KeyboardHandler.md b/api/KeyboardHandler.md index f8082805..4735a88a 100644 --- a/api/KeyboardHandler.md +++ b/api/KeyboardHandler.md @@ -38,7 +38,7 @@ KeyEvent is a dictionary with the following keys: | type | KeyEventType | The type of keyboard event | | modifiers | KeyEventFlags | Bit flags describing any pressed modifier keys | | windows_key_code | int | The Windows key code for the key event. This value is used by the DOM specification. Sometimes it comes directly from the event (i.e. on Windows) and sometimes it's determined using a mapping function. See "chromium/KeyboardCodes.h" for a list of values. | -| native_key_code | int | The actual key code genenerated by the platform | +| native_key_code | int | The actual key code generated by the platform | | is_system_key | bool | Indicates whether the event is considered a "system key" event. For Windows see [WM_SYSKEYDOWN](http://msdn.microsoft.com/en-us/library/ms646286.aspx). This value will always be false on non-Windows platforms. | | character | wchar_t or unsigned short | The character generated by the keystroke | | unmodified_character | wchar_t or unsigned short | Same as 'character' but unmodified by any concurrently-held modifiers (except shift). This is useful for working out shortcut keys. | From d9587bc6e8198de84aaedf9dbbbc42b569384730 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Mon, 13 Jan 2020 11:36:30 +0100 Subject: [PATCH 196/238] Issue 554 (#557) * Do not link against libpython on Linux (#554). * Part 2. Do not link against libpython library on Linux (#554). --- tools/build.py | 2 +- tools/cython_setup.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/build.py b/tools/build.py index 66d1244e..5e578b94 100644 --- a/tools/build.py +++ b/tools/build.py @@ -238,7 +238,7 @@ def check_directories(): prebuilt_name = get_cef_binaries_libraries_basename(OS_POSTFIX2) print("[build.py] ERROR: Couldn't find CEF prebuilt binaries and" " libraries: 'build/{prebuilt_dir}/'. Download it" - " from GitHub released tagged eg. 'v50-upstream` or download" + " from GitHub released tagged eg. 'vXX-upstream` or download" " CEF binaries from Spotify Automated Builds and then run" "`automate.py --prebuilt-cef`." .format(prebuilt_dir=prebuilt_name)) diff --git a/tools/cython_setup.py b/tools/cython_setup.py index e033cf84..4f0cafc6 100644 --- a/tools/cython_setup.py +++ b/tools/cython_setup.py @@ -25,6 +25,7 @@ import sys import platform import Cython +import copy import os # Must monkey patch Cython's ModuleNode to inject custom C++ code @@ -65,6 +66,27 @@ def generate_extern_c_macro_definition(self, code): generate_extern_c_macro_definition) +# Issue #554: Shared libraries in manylinux1 wheel should not +# be linked against libpythonX.Y.so.1.0. +if LINUX: + get_libraries_old = (build_ext.get_libraries) + def get_libraries_new(self, ext): + libraries = get_libraries_old(self, ext) + libpython = ('python' + str(sys.version_info.major) + '.' + + str(sys.version_info.minor)) + for lib in copy.copy(libraries): + # Library name for Python versions before 3.8 may have + # an 'm' at the end. + if lib.startswith(libpython): + print("[cython_setup.py] Do not link against -l%s (Issue #554)" + % lib) + libraries.remove(lib) + return libraries + build_ext.get_libraries = ( + get_libraries_new + ) + + # Command line args FAST_FLAG = False ENABLE_PROFILING = False From fb2d94ca42c8ca54fe383a0ea55c9d3904fd5298 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 14 Jan 2020 16:02:46 +0100 Subject: [PATCH 197/238] Fix CefListValue "int index" params (#461). --- src/extern/cef/cef_values.pxd | 34 +++++++++++++++++----------------- src/process_message_utils.pyx | 8 ++++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/extern/cef/cef_values.pxd b/src/extern/cef/cef_values.pxd index ee0bf506..3210432b 100644 --- a/src/extern/cef/cef_values.pxd +++ b/src/extern/cef/cef_values.pxd @@ -72,20 +72,20 @@ cdef extern from "include/cef_values.h": cpp_bool SetSize(size_t size) size_t GetSize() cpp_bool Clear() - cpp_bool Remove(int index) - cef_value_type_t GetType(int index) - cpp_bool GetBool(int index) - int GetInt(int index) - double GetDouble(int index) - CefString GetString(int index) - CefRefPtr[CefBinaryValue] GetBinary(int index) - CefRefPtr[CefDictionaryValue] GetDictionary(int index) - CefRefPtr[CefListValue] GetList(int index) - cpp_bool SetNull(int index) - cpp_bool SetBool(int index, cpp_bool value) - cpp_bool SetInt(int index, int value) - cpp_bool SetDouble(int index, double value) - cpp_bool SetString(int index, const CefString& value) - cpp_bool SetBinary(int index, CefRefPtr[CefBinaryValue] value) - cpp_bool SetDictionary(int index, CefRefPtr[CefDictionaryValue] value) - cpp_bool SetList(int index, CefRefPtr[CefListValue] value) + cpp_bool Remove(size_t index) + cef_value_type_t GetType(size_t index) + cpp_bool GetBool(size_t index) + int GetInt(size_t index) + double GetDouble(size_t index) + CefString GetString(size_t index) + CefRefPtr[CefBinaryValue] GetBinary(size_t index) + CefRefPtr[CefDictionaryValue] GetDictionary(size_t index) + CefRefPtr[CefListValue] GetList(size_t index) + cpp_bool SetNull(size_t index) + cpp_bool SetBool(size_t index, cpp_bool value) + cpp_bool SetInt(size_t index, int value) + cpp_bool SetDouble(size_t index, double value) + cpp_bool SetString(size_t index, const CefString& value) + cpp_bool SetBinary(size_t index, CefRefPtr[CefBinaryValue] value) + cpp_bool SetDictionary(size_t index, CefRefPtr[CefDictionaryValue] value) + cpp_bool SetList(size_t index, CefRefPtr[CefListValue] value) diff --git a/src/process_message_utils.pyx b/src/process_message_utils.pyx index 464c8f6b..8ced3f6c 100644 --- a/src/process_message_utils.pyx +++ b/src/process_message_utils.pyx @@ -92,8 +92,8 @@ cdef list CefListValueToPyList( if nestingLevel > 8: raise Exception("CefListValueToPyList(): max nesting level (8)" " exceeded") - cdef int index - cdef int size = int(cefListValue.get().GetSize()) + cdef size_t index + cdef size_t size = cefListValue.get().GetSize() cdef cef_types.cef_value_type_t valueType cdef list ret = [] cdef CefRefPtr[CefBinaryValue] binaryValue @@ -230,7 +230,7 @@ cdef CefRefPtr[CefListValue] PyListToCefListValue( cdef type valueType cdef CefRefPtr[CefListValue] ret = CefListValue_Create() cdef CefRefPtr[CefBinaryValue] binaryValue - cdef int index + cdef size_t index for index_size_t, value in enumerate(pyList): index = int(index_size_t) valueType = type(value) @@ -289,7 +289,7 @@ cdef void PyListToExistingCefListValue( " exceeded") cdef type valueType cdef CefRefPtr[CefListValue] newCefListValue - cdef int index + cdef size_t index for index_size_t, value in enumerate(pyList): index = int(index_size_t) valueType = type(value) From 2c3681f633cd86024e0a4031a4efcea54570fb53 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 15 Jan 2020 14:32:49 +0100 Subject: [PATCH 198/238] Fix crash when setting a cookie with invalid domain (#459). --- src/cookie.pyx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cookie.pyx b/src/cookie.pyx index ce078c10..6d90144b 100644 --- a/src/cookie.pyx +++ b/src/cookie.pyx @@ -119,6 +119,19 @@ cdef class Cookie: return CefToPyString(cefString) cpdef py_void SetDomain(self, py_string domain): + pattern = re.compile(r"^(?:[a-z0-9](?:[a-z0-9-_]{0,61}[a-z0-9])?\.)" + r"+[a-z0-9][a-z0-9-_]{0,61}[a-z]$") + if PY_MAJOR_VERSION == 2: + assert isinstance(domain, bytes), "domain type is not bytes" + domain = domain.decode(g_applicationSettings["string_encoding"], + errors=BYTES_DECODE_ERRORS) + try: + if not pattern.match(domain.encode("idna").decode("ascii")): + raise Exception("Cookie.SetDomain() failed, invalid domain: {0}" + .format(domain)) + except UnicodeError: + raise Exception("Cookie.SetDomain() failed, invalid domain: {0}" + .format(domain)) cdef CefString cefString cefString.Attach(&self.cefCookie.domain, False) PyToCefString(domain, cefString) From a5d97f03e1762f79ac0d69ab446ade33b597ff5d Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 16 Jan 2020 11:56:45 +0100 Subject: [PATCH 199/238] Add GIL section to Contributing-code.md document (#102). --- docs/Contributing-code.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/Contributing-code.md b/docs/Contributing-code.md index bbcefc26..fb56e115 100644 --- a/docs/Contributing-code.md +++ b/docs/Contributing-code.md @@ -12,6 +12,7 @@ Table of contents: * [API docs](#api-docs) * [Unit tests](#unit-tests) * [Platforms](#platforms) +* [GIL](#gil) * [Authors](#authors) * [Updating CEF version](#updating-cef-version) @@ -123,6 +124,24 @@ In most cases new code should run fine on all platforms, but in some cases it might be required to test on all platforms before PR is merged. +## GIL + +In the pxd file, functions should be defined as "nogil" to avoid +deadlocks when calling CEF functions. In the pyx file the call must +use the "with nogil" statement. + +From [Cython's documentation](http://docs.cython.org/src/userguide/external_C_code.html#acquiring-and-releasing-the-gil): + +> Note that acquiring the GIL is a blocking thread-synchronising operation, +> and therefore potentially costly. It might not be worth releasing the GIL +> for minor calculations. Usually, I/O operations and substantial computations +> in parallel code will benefit from it. + +Revision [ec1ce78](https://github.com/cztomczak/cefpython/commit/ec1ce788373bb9e0fd2cedd71e900c3877e9185a) removes the GIL lock from the +following calls: Initialize(), Shutdown(), CreateBrowserSync(), +SetOsModalLoop(), QuitMessageLoop(), CefExecuteProcess(). There still +might be some more functions from which the GIL lock should be removed. + ## Authors In your pull request modify also the [Authors](../Authors) file From 11017dc68358b6adb4a3d822f53fa658ff4fa4f5 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 16 Jan 2020 12:31:08 +0100 Subject: [PATCH 200/238] Update LifespanHandler.md document. Info on OnBeforePopup and scripting between popup and parent window. (#171) --- api/LifespanHandler.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/LifespanHandler.md b/api/LifespanHandler.md index 2b929512..1794d62d 100644 --- a/api/LifespanHandler.md +++ b/api/LifespanHandler.md @@ -107,10 +107,6 @@ Description from upstream CEF: > browser is destroyed before the popup browser creation completes (indicated > by a call to OnAfterCreated for the popup browser). -Note that if you return True and create the popup window yourself, then -the popup window and parent window will not be able to script each other. -There will be no "window.opener" property available in the popup window. - `WindowOpenDisposition` constants in the cefpython module: * WOD_UNKNOWN, * WOD_CURRENT_TAB, @@ -122,3 +118,11 @@ There will be no "window.opener" property available in the popup window. * WOD_SAVE_TO_DISK, * WOD_OFF_THE_RECORD, * WOD_IGNORE_ACTION + +Note that if you return True and create the popup window yourself, then +the popup window and parent window will not be able to script each other. +There will be no "window.opener" property available in the popup window. +To avoid this issue create a hidden window when your application starts. +Parent the new popup browser to the hidden window in OnBeforePopup. After +the browser exists (OnAfterCreated) create the desired target window +and re-parent the browser to that target window. From 42924f5ee00ea4a5b97a099b0afb2ed9b877a71a Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 16 Jan 2020 15:52:10 +0100 Subject: [PATCH 201/238] Update README links for the old v31.2 release. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 24370549..0d0344ba 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,6 @@ See the [README-examples.md](examples/README-examples.md) and in the issue. See [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) sorted by reactions. -- Wiki pages are deprecated and for v31 only ## Releases @@ -196,10 +195,11 @@ Mac | 2.7 | No | Yes | Yes | MacOS 10.7+ Additional information for v31.2 release: - On Windows/Mac you can install with command: `pip install cefpython3==31.2` -- Downloads are available on [wiki pages](../../wiki#downloads) - and on GitHub Releases tagged [v31.2](../../releases/tag/v31.2). -- Documentation is on [wiki pages](../../wiki) +- Downloads are available on the GitHub Releases page tagged + [v31.2](../../releases/tag/v31.2). - API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api) +- Other documentation can be downloaded by cloning the + [cefpython.wiki.git](git@github.com:cztomczak/cefpython.wiki.git) repository. ## Support development From e9116faa2094de85ccebd403aee09c61e2c8b8f9 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 16 Jan 2020 15:54:30 +0100 Subject: [PATCH 202/238] Update README with cefpython.wiki git clone command. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d0344ba..9cef2431 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ Additional information for v31.2 release: [v31.2](../../releases/tag/v31.2). - API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api) - Other documentation can be downloaded by cloning the - [cefpython.wiki.git](git@github.com:cztomczak/cefpython.wiki.git) repository. + cefpython.wiki repository: `git clone git@github.com:cztomczak/cefpython.wiki.git` ## Support development From b03b78b64d0162eb186d05fb22452f934cd31152 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Fri, 17 Jan 2020 17:19:08 +0100 Subject: [PATCH 203/238] Fix V8ContextHandler.OnContextCreated and OnContextReleased (#484). These callbacks were never called previously. Rename --no-run-examples flag to --unittests in build scripts. --- api/V8ContextHandler.md | 4 +++- src/browser.pyx | 3 +++ tools/build.py | 23 +++++++++++++---------- tools/build_distrib.py | 23 ++++++++++++----------- unittests/_common.py | 5 +++-- unittests/main_test.py | 33 ++++++++++++++++++++++++++++++++- 6 files changed, 66 insertions(+), 25 deletions(-) diff --git a/api/V8ContextHandler.md b/api/V8ContextHandler.md index 9c6f6fbc..b88a8641 100644 --- a/api/V8ContextHandler.md +++ b/api/V8ContextHandler.md @@ -3,7 +3,9 @@ # V8ContextHandler (interface) -Implement this interface to handle javascript exceptions globally. +Implement this interface to handle render process callbacks. +Through inter-process messaging you are notified about these events +in the browser process. Table of contents: diff --git a/src/browser.pyx b/src/browser.pyx index d378ca22..8dfb7aed 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -267,6 +267,9 @@ cdef class PyBrowser: "OnScrollOffsetChanged", "StartDragging", "UpdateDragCursor", "OnTextSelectionChanged"] + # V8ContextHandler + self.allowedClientCallbacks += ["OnContextCreated", + "OnContextReleased"] # JavascriptDialogHandler self.allowedClientCallbacks += ["OnJavascriptDialog", "OnBeforeUnloadJavascriptDialog", diff --git a/tools/build.py b/tools/build.py index 5e578b94..522a9b08 100644 --- a/tools/build.py +++ b/tools/build.py @@ -18,12 +18,15 @@ from sources or use ready binaries from Spotify Automated Builds. Usage: - build.py VERSION [--rebuild-cpp] [--fast] [--clean] [--kivy] - [--hello-world] + build.py VERSION [--rebuild-cpp] [--unittests] [--fast] [--clean] [--kivy] + [--hello-world] [--enable-profiling] + [--enable-line-tracing] Options: VERSION Version number eg. 50.0 - --no-run-examples Do not run examples after build, only unit tests + --unittests Run only unit tests. Do not run examples while + building cefpython modules. Examples require + interaction such as closing window before proceeding. --fast Fast mode --clean Clean C++ projects build files on Linux/Mac --kivy Run only Kivy example @@ -79,7 +82,7 @@ # Command line args variables SYS_ARGV_ORIGINAL = None VERSION = "" -NO_RUN_EXAMPLES = False +UNITTESTS = False DEBUG_FLAG = False FAST_FLAG = False CLEAN_FLAG = False @@ -125,7 +128,7 @@ def main(): def command_line_args(): global DEBUG_FLAG, FAST_FLAG, CLEAN_FLAG, KIVY_FLAG, HELLO_WORLD_FLAG, \ - REBUILD_CPP, VERSION, NO_RUN_EXAMPLES + REBUILD_CPP, VERSION, UNITTESTS VERSION = get_version_from_command_line_args(__file__) # Other scripts called by this script expect that version number @@ -140,10 +143,10 @@ def command_line_args(): global SYS_ARGV_ORIGINAL SYS_ARGV_ORIGINAL = copy.copy(sys.argv) - if "--no-run-examples" in sys.argv: - NO_RUN_EXAMPLES = True - print("[build.py] Running examples disabled (--no-run-examples)") - sys.argv.remove("--no-run-examples") + if "--unittests" in sys.argv: + UNITTESTS = True + print("[build.py] Running examples disabled (--unittests)") + sys.argv.remove("--unittests") if "--debug" in sys.argv: DEBUG_FLAG = True @@ -913,7 +916,7 @@ def install_and_run(): sys.exit(1) # Run examples - if not NO_RUN_EXAMPLES: + if not UNITTESTS: print("[build.py] Run examples") os.chdir(EXAMPLES_DIR) flags = "" diff --git a/tools/build_distrib.py b/tools/build_distrib.py index 8ff5a6b8..e0a5bde1 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -7,13 +7,14 @@ python versions. Usage: - build_distrib.py VERSION [--no-run-examples] [--no-rebuild] + build_distrib.py VERSION [--unittests] [--no-rebuild] [--no-automate] + [--allow-partial] Options: VERSION Version number eg. 50.0 - --no-run-examples Do not run examples while building cefpython modules. - Examples require interaction, closing window before - proceeding. Only unit tests will be run in such case. + --unittests Run only unit tests. Do not run examples while building + cefpython modules. Examples require interaction such as + closing window before proceeding. --no-rebuild Do not rebuild cefpython modules. For internal use so that changes to packaging can be quickly tested. --no-automate Do not run automate.py --prebuilt-cef. This flag @@ -73,7 +74,7 @@ # Command line args VERSION = "" -NO_RUN_EXAMPLES = False +UNITTESTS = False NO_REBUILD = False NO_AUTOMATE = False ALLOW_PARTIAL = False @@ -152,15 +153,15 @@ def main(): def command_line_args(): - global VERSION, NO_RUN_EXAMPLES, NO_REBUILD, NO_AUTOMATE, ALLOW_PARTIAL + global VERSION, UNITTESTS, NO_REBUILD, NO_AUTOMATE, ALLOW_PARTIAL version = get_version_from_command_line_args(__file__) if not version or "--help" in sys.argv: print(__doc__) sys.exit(1) VERSION = version - if "--no-run-examples" in sys.argv: - NO_RUN_EXAMPLES = True - sys.argv.remove("--no-run-examples") + if "--unittests" in sys.argv: + UNITTESTS = True + sys.argv.remove("--unittests") if "--no-rebuild" in sys.argv: NO_REBUILD = True sys.argv.remove("--no-rebuild") @@ -488,8 +489,8 @@ def build_cefpython_modules(pythons, arch): print("[build_distrib.py] Build cefpython module for {python_name}" .format(python_name=python["name"])) flags = "" - if NO_RUN_EXAMPLES: - flags += " --no-run-examples" + if UNITTESTS: + flags += " --unittests" # On Linux/Mac Makefiles are used and must pass --clean flag command = ("\"{python}\" {build_py} {version} --clean {flags}" .format(python=python["executable"], diff --git a/unittests/_common.py b/unittests/_common.py index 684a27b1..fcd89917 100644 --- a/unittests/_common.py +++ b/unittests/_common.py @@ -82,7 +82,7 @@ def check_auto_asserts(test_case, objects): test_for_True = False # Test whether asserts are working correctly for key, value in obj.__dict__.items(): if key == "test_for_True": - test_for_True = True + test_for_True = value continue if "_True" in key: test_case.assertTrue(value, "Check assert: " + @@ -96,7 +96,8 @@ def check_auto_asserts(test_case, objects): subtest_message(obj.__class__.__name__ + "." + key.replace("_False", "") + " ok") - test_case.assertTrue(test_for_True) + if "test_for_True" in obj.__dict__.keys(): + test_case.assertTrue(test_for_True) class DisplayHandler(object): diff --git a/unittests/main_test.py b/unittests/main_test.py index f3602c21..99397da8 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -197,9 +197,11 @@ def test_main(self): # Client handlers display_handler2 = DisplayHandler2(self) + v8context_handler = V8ContextHandler(self) client_handlers = [LoadHandler(self, g_datauri), DisplayHandler(self), - display_handler2] + display_handler2, + v8context_handler] for handler in client_handlers: browser.SetClientHandler(handler) subtest_message("browser.SetClientHandler() ok") @@ -336,6 +338,35 @@ def OnLoadingProgressChange(self, progress, **_): self.OnLoadingProgressChange_Progress = progress +class V8ContextHandler(object): + def __init__(self, test_case): + self.test_case = test_case + self.OnContextCreatedFirstCall_True = False + self.OnContextCreatedSecondCall_True = False + self.OnContextReleased_True = False + + def OnContextCreated(self, browser, frame): + """CEF creates one context when creating browser and this one is + released immediately. Then when it loads url another context is + created.""" + if not self.OnContextCreatedFirstCall_True: + self.OnContextCreatedFirstCall_True = True + else: + self.test_case.assertFalse(self.OnContextCreatedSecondCall_True) + self.OnContextCreatedSecondCall_True = True + self.test_case.assertEqual(browser.GetIdentifier(), MAIN_BROWSER_ID) + self.test_case.assertEqual(frame.GetIdentifier(), 2) + + def OnContextReleased(self, browser, frame): + """This gets called only for the initial empty context, see comment + in OnContextCreated. This should never get called for the main frame + of the main browser, because it happens during app exit and there + isn't enough time for the IPC messages to go through.""" + self.test_case.assertFalse(self.OnContextReleased_True) + self.OnContextReleased_True = True + self.test_case.assertEqual(browser.GetIdentifier(), MAIN_BROWSER_ID) + self.test_case.assertEqual(frame.GetIdentifier(), 2) + class External(object): """Javascript 'window.external' object.""" From 6cc7f9c8058475ab9aadc04ff614b9904ce063b9 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 20 Jan 2020 14:35:29 +0100 Subject: [PATCH 204/238] Fix issues with urls containing special characters (#384). BC BREAK! Updated Migration-Guide.md document and other documentation. --- api/Browser.md | 9 +++++++- api/Frame.md | 9 +++++++- api/cefpython.md | 9 +++++++- docs/Migration-guide.md | 14 +++++++++++-- src/cefpython.pyx | 6 ------ src/frame.pyx | 1 - src/utils.pyx | 46 ----------------------------------------- 7 files changed, 36 insertions(+), 58 deletions(-) diff --git a/api/Browser.md b/api/Browser.md index 66272c0a..b34b90e2 100644 --- a/api/Browser.md +++ b/api/Browser.md @@ -376,7 +376,7 @@ Returns the focused [Frame](Frame.md) for the browser window. | name | string | | __Return__ | Frame | -Returns the [Frame](Frame.md) with the specified name, or NULL if not found. +Returns the [Frame](Frame.md) with the specified name, or NULL if not found. ### GetFrameByIdentifier @@ -697,6 +697,13 @@ Returns true if window rendering is disabled. Load url in the main frame. +If the url is a local path it needs to start with the `file://` prefix. +If the url contains special characters it may need proper handling. +Starting with v66.1+ it is required for the app code to encode the url +properly. You can use the `pathlib.PurePath.as_uri` in Python 3 +or `urllib.pathname2url` in Python 2 (`urllib.request.pathname2url` +in Python 3) depending on your case. + ### Navigate diff --git a/api/Frame.md b/api/Frame.md index 87dbc89c..05712912 100644 --- a/api/Frame.md +++ b/api/Frame.md @@ -228,9 +228,16 @@ Take also a look at a [custom resource handler](ResourceHandler.md). Load the contents of |value| with the specified dummy |url|. |url| should have a standard scheme (for example, http scheme) or behaviors like -link clicks and web security restrictions may not behave as expected. +link clicks and web security restrictions may not behave as expected. LoadString() can be called only after the Renderer process has been created. +If the url is a local path it needs to start with the `file://` prefix. +If the url contains special characters it may need proper handling. +Starting with v66.1+ it is required for the app code to encode the url +properly. You can use the `pathlib.PurePath.as_uri` in Python 3 +or `urllib.pathname2url` in Python 2 (`urllib.request.pathname2url` +in Python 3) depending on your case. + ### LoadUrl diff --git a/api/cefpython.md b/api/cefpython.md index 29720c48..ae7d255c 100644 --- a/api/cefpython.md +++ b/api/cefpython.md @@ -59,6 +59,13 @@ All parameters are optional. This function can only be called on the UI thread. +If the url is a local path it needs to start with the `file://` prefix. +If the url contains special characters it may need proper handling. +Starting with v66.1+ it is required for the app code to encode the url +properly. You can use the `pathlib.PurePath.as_uri` in Python 3 +or `urllib.pathname2url` in Python 2 (`urllib.request.pathname2url` +in Python 3) depending on your case. + The "window_title" parameter will be used only when parent window provided in window_info was set to 0. This is for use with hello_world.py and tutorial.py examples which don't use @@ -240,7 +247,7 @@ Description from upstream CEF: | __Return__ | void | Run the CEF message loop. Use this function instead of an application- -provided message loop to get the best balance between performance and +provided message loop to get the best balance between performance and CPU usage. This function should only be called on the main application thread (UI thread) and only if cefpython.Initialize() is called with a [ApplicationSettings](ApplicationSettings.md).multi_threaded_message_loop diff --git a/docs/Migration-guide.md b/docs/Migration-guide.md index 2359562c..5ad3d438 100644 --- a/docs/Migration-guide.md +++ b/docs/Migration-guide.md @@ -50,6 +50,7 @@ Table of contents: * [v66+ cef.Request.Flags changed](#v66-cefrequestflags-changed) * [v66+ RequestHandler.GetCookieManager not getting called in some cases](#v66-requesthandlergetcookiemanager-not-getting-called-in-some-cases) * [v66+ Changes to Mac apps that integrate into existing message loop (Qt, wxPython)](#v66-changes-to-mac-apps-that-integrate-into-existing-message-loop-qt-wxpython) +* [v66.1+ Navigation urls passed to CreateBrowserSync or LoadUrl methods need to be encoded by app code](#v661-navigation-urls-passed-to-createbrowsersync-or-loadurl-methods-need-to-be-encoded-by-app-code) * [v67+ Do not call the 'WindowUtils.OnSize' function](#v67-do-not-call-the-windowutilsonsize-function) @@ -487,6 +488,16 @@ tested of how this change affects performance. See Issue [#442](../../../issues/442) for more details on the issues. +## v66.1+ Navigation urls passed to CreateBrowserSync or LoadUrl methods need to be encoded by app code + +[Issue #384](../../../issues/384) fixes problems with browser failing to load +urls containing certain characters by not encoding the url anymore. From now +on it is required for the app code to encode the url properly. You can use +the `pathlib.PurePath.as_uri` in Python 3 or `urllib.pathname2url` in +Python 2 (`urllib.request.pathname2url` in Python 3) depending on your case. + +The `cef.GetNavigateUrl` function was removed from the cefpython3 module. + ## v67+ Do not call the 'WindowUtils.OnSize' function @@ -494,5 +505,4 @@ This function can sometimes cause app hanging during window resize. Call instead the new `WindowUtils`.[UpdateBrowserSize](../api/WindowUtils.md#updatebrowsersize) function. Except when you use the `pywin32.py` example, in such case `WindowUtils.OnSize` must be called. -See [Issue #464](../../../issues/464) for more details. - +See [Issue #464](../../../issues/464) for more details. \ No newline at end of file diff --git a/src/cefpython.pyx b/src/cefpython.pyx index aff190a0..c3b1e1a1 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -144,8 +144,6 @@ IF PY_MAJOR_VERSION == 2: # noinspection PyUnresolvedReferences import urlparse # noinspection PyUnresolvedReferences - from urllib import pathname2url as urllib_pathname2url - # noinspection PyUnresolvedReferences from urllib import urlencode as urllib_urlencode from urllib import quote as urlparse_quote ELSE: @@ -153,8 +151,6 @@ ELSE: from urllib import parse as urlparse from urllib.parse import quote as urlparse_quote # noinspection PyUnresolvedReferences - from urllib.request import pathname2url as urllib_pathname2url - # noinspection PyUnresolvedReferences from urllib.parse import urlencode as urllib_urlencode # noinspection PyUnresolvedReferences @@ -739,8 +735,6 @@ def CreateBrowserSync(windowInfo=None, cdef CefWindowInfo cefWindowInfo SetCefWindowInfo(cefWindowInfo, windowInfo) - navigateUrl = GetNavigateUrl(navigateUrl) - Debug("navigateUrl: %s" % navigateUrl) cdef CefString cefNavigateUrl PyToCefString(navigateUrl, cefNavigateUrl) diff --git a/src/frame.pyx b/src/frame.pyx index ec3ef8bc..812e4b3c 100644 --- a/src/frame.pyx +++ b/src/frame.pyx @@ -211,7 +211,6 @@ cdef class PyFrame: self.GetCefFrame().get().LoadString(cefValue, cefUrl) cpdef py_void LoadUrl(self, py_string url): - url = GetNavigateUrl(url) cdef CefString cefUrl PyToCefString(url, cefUrl) self.GetCefFrame().get().LoadURL(cefUrl) diff --git a/src/utils.pyx b/src/utils.pyx index 0e499554..3d1acd89 100644 --- a/src/utils.pyx +++ b/src/utils.pyx @@ -72,52 +72,6 @@ cpdef str GetSystemError(): ELSE: return "" -cpdef str GetNavigateUrl(py_string url): - # Encode local file paths so that CEF can load them correctly: - # | some.html, some/some.html, D:\, /var, file:// - if re.search(r"^file:", url, re.I) or \ - re.search(r"^[a-zA-Z]:", url) or \ - not re.search(r"^[\w-]+:", url): - - # Function pathname2url will complain if url starts with "file://". - # CEF may also change local urls to "file:///C:/" - three slashes. - is_file_protocol = False - file_prefix = "" - file_prefixes = ["file:///", "file://"] - for file_prefix in file_prefixes: - if url.startswith(file_prefix): - is_file_protocol = True - # Remove the file:// prefix - url = url[len(file_prefix):] - break - - # Need to encode chinese characters in local file paths, - # otherwise CEF will try to encode them by itself. But it - # will fail in doing so. CEF will return the following string: - # >> %EF%BF%97%EF%BF%80%EF%BF%83%EF%BF%A6 - # But it should be: - # >> %E6%A1%8C%E9%9D%A2 - url = urllib_pathname2url(url) - - if is_file_protocol: - url = "%s%s" % (file_prefix, url) - - # If it is C:\ then colon was encoded. Decode it back. - url = re.sub(r"^([a-zA-Z])%3A", r"\1:", url) - - # Allow hash when loading urls. The pathname2url function - # replaced hashes with "%23" (Issue #114). - url = url.replace("%23", "#") - - # Allow more special characters when loading urls. The pathname2url - # function encoded them and need to decode them back here - # Characters: ? & = (Issue #273). - url = url.replace("%3F", "?") - url = url.replace("%26", "&") - url = url.replace("%3D", "=") - - return str(url) - cpdef py_bool IsFunctionOrMethod(object valueType): if (valueType == types.FunctionType or valueType == types.MethodType From d97ba3d19e36c754792f004c4d0a01b2baad9a09 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 21 Jan 2020 12:37:50 +0100 Subject: [PATCH 205/238] Update Sponsors in README. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9cef2431..b2c06aad 100644 --- a/README.md +++ b/README.md @@ -246,10 +246,10 @@ priority.
@@ -278,7 +278,7 @@ priority. the v49 release for legacy systems (WinXP/Vista) * [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 release for all platforms -* [2017] Many thanks to [ClearChat Inc.](https://clearchat.com/) for sponsoring +* [2017] Many thanks to [HighSide Inc.](https://highside.io/) for sponsoring the v55/v56 releases for all platforms * [2016-2018] Thanks to JetBrains for providing an Open Source license for [PyCharm](https://www.jetbrains.com/pycharm/) From 99fb58a6badf905afde66903d5c87e39a5f32b38 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 21 Jan 2020 12:57:22 +0100 Subject: [PATCH 206/238] Restructure Sponsors section in README. --- README.md | 120 +++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index b2c06aad..747381bf 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Table of contents: * [Introduction](#introduction) -* [Sponsors](#sponsors) +* [Latest releases sponsored by](#latest-releases-sponsored-by) + * [Thanks to all sponsors](#thanks-to-all-sponsors) * [Install](#install) * [Tutorial](#tutorial) * [Examples](#examples) @@ -13,7 +14,6 @@ Table of contents: * [v49 release (WinXP/Vista)](#v49-release-winxpvista) * [v31 release (old systems)](#v31-release-old-systems) * [Support development](#support-development) - * [Thanks to sponsors](#thanks-to-sponsors) * [Thanks to all](#thanks-to-all) * [Seeking new sponsors](#seeking-new-sponsors) * [Other READMEs](#other-readmes) @@ -49,7 +49,7 @@ frameworks such as PyQt, wxPython, PyGTK, PyGObject, Tkinter, Kivy, Panda3D, PyGame, PyOpenGL, PyWin32, PySide and PySDL2. -## Sponsors +## Latest releases sponsored by
@@ -82,6 +82,63 @@ businesses with cutting edge marketing technology. Please visit their website:
+### Thanks to all sponsors + + + + + + + + + + + + +
+ + + + + +
+ + + + +
+ ## Install @@ -214,63 +271,6 @@ priority.

-### Thanks to sponsors - - - - - - - - - - - - -
- - - - - -
- - - - -
- ### Thanks to all From a314559af3270f2a0e48d085e23dc8cc76af7966 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Jan 2020 11:54:44 +0100 Subject: [PATCH 207/238] Fix focus issues in qt.py example (#404). --- examples/qt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/qt.py b/examples/qt.py index a272b80d..9b3e96b9 100644 --- a/examples/qt.py +++ b/examples/qt.py @@ -337,7 +337,11 @@ def __init__(self, cef_widget): self.cef_widget = cef_widget def OnSetFocus(self, **_): - pass + print("[qt.py] FocusHandler.OnSetFocus") + if LINUX: + return False + else: + return True def OnGotFocus(self, browser, **_): # Temporary fix no. 1 for focus issues on Linux (Issue #284) From 181588ce611ef4675b4948b71f9ed933a9519a98 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 22 Jan 2020 12:21:14 +0100 Subject: [PATCH 208/238] Fix QLineEdit focus issues in qt.py example on Windows (#404). Revert previous commit. --- examples/qt.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/qt.py b/examples/qt.py index 9b3e96b9..efb1b381 100644 --- a/examples/qt.py +++ b/examples/qt.py @@ -212,6 +212,8 @@ def __init__(self, parent=None): def focusInEvent(self, event): # This event seems to never get called on Linux, as CEF is # stealing all focus due to Issue #284. + if cef.GetAppSetting("debug"): + print("[qt.py] CefWidget.focusInEvent") if self.browser: if WINDOWS: WindowUtils.OnSetFocus(self.getHandle(), 0, 0, 0) @@ -220,6 +222,8 @@ def focusInEvent(self, event): def focusOutEvent(self, event): # This event seems to never get called on Linux, as CEF is # stealing all focus due to Issue #284. + if cef.GetAppSetting("debug"): + print("[qt.py] CefWidget.focusOutEvent") if self.browser: self.browser.SetFocus(False) @@ -336,18 +340,20 @@ class FocusHandler(object): def __init__(self, cef_widget): self.cef_widget = cef_widget + def OnTakeFocus(self, **_): + if cef.GetAppSetting("debug"): + print("[qt.py] FocusHandler.OnTakeFocus") + def OnSetFocus(self, **_): - print("[qt.py] FocusHandler.OnSetFocus") - if LINUX: - return False - else: - return True + if cef.GetAppSetting("debug"): + print("[qt.py] FocusHandler.OnSetFocus") def OnGotFocus(self, browser, **_): + if cef.GetAppSetting("debug"): + print("[qt.py] FocusHandler.OnGotFocus") + self.cef_widget.setFocus() # Temporary fix no. 1 for focus issues on Linux (Issue #284) if LINUX: - print("[qt.py] FocusHandler.OnGotFocus:" - " keyboard focus fix no. 1 (Issue #284)") browser.SetFocus(True) From 30439b659bf1974420c3ec7954f76f2fc93902e2 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Thu, 23 Jan 2020 16:32:52 +0100 Subject: [PATCH 209/238] Update utils.pyx. --- src/utils.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.pyx b/src/utils.pyx index 3d1acd89..7d855361 100644 --- a/src/utils.pyx +++ b/src/utils.pyx @@ -76,6 +76,7 @@ cpdef py_bool IsFunctionOrMethod(object valueType): if (valueType == types.FunctionType or valueType == types.MethodType or valueType == types.BuiltinFunctionType - or valueType == types.BuiltinMethodType): + or valueType == types.BuiltinMethodType + or valueType.__name__ == "cython_function_or_method"): return True return False From 042579dc0d7e0010dca4d23f0ccbbbaf2e72700e Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 25 Jan 2020 14:32:29 +0100 Subject: [PATCH 210/238] Allow for automatic conversion of string like objects to CEF strings. For example a QString passed to LoadUrl() method was causing error and now it's handled fine. --- src/string_utils.pyx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/string_utils.pyx b/src/string_utils.pyx index c5980b94..7b1c9a06 100644 --- a/src/string_utils.pyx +++ b/src/string_utils.pyx @@ -103,11 +103,17 @@ cdef void PyToCefString( CefString& cefString ) except *: if PY_MAJOR_VERSION < 3: + # Handle objects that may be converted to string e.g. QString + if not isinstance(pyString, str) and not isinstance(pyString, unicode): + pyString = str(pyString) if type(pyString) == unicode: pyString = (pyString.encode( g_applicationSettings["string_encoding"], errors=UNICODE_ENCODE_ERRORS)) else: + # Handle objects that may be converted to string e.g. QString + if not isinstance(pyString, str) and not isinstance(pyString, bytes): + pyString = str(pyString) # The unicode type is not defined in Python 3. if type(pyString) == str: pyString = (pyString.encode( From 28afa80a2f23fa2e6160926d0352b861466bf5a8 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sat, 25 Jan 2020 14:33:42 +0100 Subject: [PATCH 211/238] Pass proper parent window handle for DevTools window (#381). This still doesn't fix keyboard issues in wxpython.py example. --- src/browser.pyx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/browser.pyx b/src/browser.pyx index 8dfb7aed..c8cba03a 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -576,15 +576,8 @@ cdef class PyBrowser: cpdef py_void ShowDevTools(self): cdef CefWindowInfo window_info IF UNAME_SYSNAME == "Windows": - # On Windows with empty window_info structure the devtools - # window doesn't appear. - window_info.SetAsPopup( - # TODO: - # According to docs this returns NULL for non-popup - # windows, so looks like we shouldn't use that and - # either pass NULL or GetWindowHandle(). - self.GetOpenerWindowHandle(), - PyToCefStringValue("DevTools")) + window_info.SetAsPopup(self.GetWindowHandle(), + PyToCefStringValue("DevTools")) cdef CefBrowserSettings settings cdef CefPoint inspect_element_at self.GetCefBrowserHost().get().ShowDevTools( From 0da13937e50f389cba25533959c2b760403fb80f Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Mon, 20 Jul 2020 19:19:03 +0200 Subject: [PATCH 212/238] Fix Mac issues in Tkinter example (#309, #441) Still some issues on startup, see: https://github.com/cztomczak/cefpython/issues/583 --- examples/tkinter_.py | 73 +++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/examples/tkinter_.py b/examples/tkinter_.py index c823f3dc..327f171f 100644 --- a/examples/tkinter_.py +++ b/examples/tkinter_.py @@ -44,7 +44,7 @@ def main(): - logger.setLevel(_logging.INFO) + logger.setLevel(_logging.DEBUG) stream_handler = _logging.StreamHandler() formatter = _logging.Formatter("[%(filename)s] %(message)s") stream_handler.setFormatter(formatter) @@ -55,19 +55,23 @@ def main(): logger.info("Tk {ver}".format(ver=tk.Tcl().eval('info patchlevel'))) assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this" sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error + # Tk must be initialized before CEF otherwise fatal error (Issue #306) root = tk.Tk() app = MainFrame(root) - # Tk must be initialized before CEF otherwise fatal error (Issue #306) - cef.Initialize() + settings = {} + if MAC: + settings["external_message_pump"] = True + cef.Initialize(settings=settings) app.mainloop() + logger.debug("Main loop exited") cef.Shutdown() - class MainFrame(tk.Frame): def __init__(self, root): self.browser_frame = None self.navigation_bar = None + self.root = root # Root root.geometry("900x640") @@ -124,7 +128,9 @@ def on_focus_out(self, _): def on_close(self): if self.browser_frame: self.browser_frame.on_root_close() - self.master.destroy() + self.browser_frame = None + else: + self.master.destroy() def get_browser(self): if self.browser_frame: @@ -147,11 +153,12 @@ def setup_icon(self): class BrowserFrame(tk.Frame): - def __init__(self, master, navigation_bar=None): + def __init__(self, mainframe, navigation_bar=None): self.navigation_bar = navigation_bar self.closing = False self.browser = None - tk.Frame.__init__(self, master) + tk.Frame.__init__(self, mainframe) + self.mainframe = mainframe self.bind("", self.on_focus_in) self.bind("", self.on_focus_out) self.bind("", self.on_configure) @@ -165,27 +172,42 @@ def embed_browser(self): self.browser = cef.CreateBrowserSync(window_info, url="https://www.google.com/") assert self.browser + self.browser.SetClientHandler(LifespanHandler(self)) self.browser.SetClientHandler(LoadHandler(self)) self.browser.SetClientHandler(FocusHandler(self)) self.message_loop_work() def get_window_handle(self): - if self.winfo_id() > 0: - return self.winfo_id() - elif MAC: - # On Mac window id is an invalid negative value (Issue #308). - # This is kind of a dirty hack to get window handle using - # PyObjC package. If you change structure of windows then you + if MAC: + # Do not use self.winfo_id() on Mac, because of these issues: + # 1. Window id sometimes has an invalid negative value (Issue #308). + # 2. Even with valid window id it crashes during the call to NSView.setAutoresizingMask: + # https://github.com/cztomczak/cefpython/issues/309#issuecomment-661094466 + # + # To fix it using PyObjC package to obtain window handle. If you change structure of windows then you # need to do modifications here as well. + # + # There is still one issue with this solution. Sometimes there is more than one window, for example when application + # didn't close cleanly last time Python displays an NSAlert window asking whether to Reopen that window. In such + # case app will crash and you will see in console: + # > Fatal Python error: PyEval_RestoreThread: NULL tstate + # > zsh: abort python tkinter_.py + # Error messages related to this: https://github.com/cztomczak/cefpython/issues/441 + # + # There is yet another issue that might be related as well: + # https://github.com/cztomczak/cefpython/issues/583 + # noinspection PyUnresolvedReferences from AppKit import NSApp # noinspection PyUnresolvedReferences import objc - # Sometimes there is more than one window, when application - # didn't close cleanly last time Python displays an NSAlert - # window asking whether to Reopen that window. + logger.info("winfo_id={}".format(self.winfo_id())) # noinspection PyUnresolvedReferences - return objc.pyobjc_id(NSApp.windows()[-1].contentView()) + content_view = objc.pyobjc_id(NSApp.windows()[-1].contentView()) + logger.info("content_view={}".format(content_view)) + return content_view + elif self.winfo_id() > 0: + return self.winfo_id() else: raise Exception("Couldn't obtain window handle") @@ -224,10 +246,15 @@ def on_focus_out(self, _): self.browser.SetFocus(False) def on_root_close(self): + logger.info("BrowserFrame.on_root_close") if self.browser: + logger.debug("CloseBrowser") self.browser.CloseBrowser(True) self.clear_browser_references() - self.destroy() + else: + logger.debug("tk.Frame.destroy") + self.destroy() + def clear_browser_references(self): # Clear browser references that you keep anywhere in your @@ -235,6 +262,16 @@ def clear_browser_references(self): self.browser = None +class LifespanHandler(object): + + def __init__(self, tkFrame): + self.tkFrame = tkFrame + + def OnBeforeClose(self, browser, **_): + logger.debug("LifespanHandler.OnBeforeClose") + self.tkFrame.quit() + + class LoadHandler(object): def __init__(self, browser_frame): From 3cc7606101f2b1b8191b4db3648c264349ca4628 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Wed, 19 Aug 2020 11:14:04 +0200 Subject: [PATCH 213/238] Add keyboard handler snippet. --- examples/snippets/keyboard_handler.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/snippets/keyboard_handler.py diff --git a/examples/snippets/keyboard_handler.py b/examples/snippets/keyboard_handler.py new file mode 100644 index 00000000..9b8e40c8 --- /dev/null +++ b/examples/snippets/keyboard_handler.py @@ -0,0 +1,19 @@ +from cefpython3 import cefpython as cef + + +def main(): + cef.Initialize() + browser = cef.CreateBrowserSync(url="https://www.google.com/", + window_title="Keyboard Handler") + browser.SetClientHandler(KeyboardHandler()) + cef.MessageLoop() + del browser + cef.Shutdown() + + +class KeyboardHandler(object): + def OnKeyEvent(self, browser, event, event_handle, **_): + print("OnKeyEvent: "+str(event)) + +if __name__ == '__main__': + main() From 2fcf395f4e67e83e5c1dc06b3bfd6818d4e42602 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Fri, 9 Oct 2020 13:53:46 +0200 Subject: [PATCH 214/238] Update README.md Fix links. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 747381bf..546cd001 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Table of contents: ## Introduction CEF Python is an open source project founded by -[Czarek Tomczak](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view) +[Czarek Tomczak](https://www.linkedin.com/in/czarektomczak/) in 2012 to provide Python bindings for the [Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef) (CEF). The Chromium project focuses mainly on Google Chrome application @@ -317,7 +317,7 @@ notable are: If your company would like to sponsor CEF Python development efforts then please contact -[Czarek](https://drive.google.com/file/d/17xmoT5Z_zTHkVclqPzrs2aAV64Uiu7fh/view). +[Czarek](https://www.linkedin.com/in/czarektomczak/). Long term sponsorships are welcome and Czarek is open to ideas about the project. He would love to spend more time on developing this project, but he can't afford doing so in his free time. Currently there is no company From 019033d2919a4fab84cb832ec5b76aad12e39c40 Mon Sep 17 00:00:00 2001 From: Xianguang Zhou Date: Sun, 14 Feb 2021 22:44:22 +0800 Subject: [PATCH 215/238] Fix the bug of loading shared libraries. (#561) * Prepend the package directory path to the "LD_LIBRARY_PATH" environment variable. * Fix the bug of getting "LD_LIBRARY_PATH" environment variable. * Fix loading shared libraries on Linux. Co-authored-by: Czarek Tomczak --- tools/installer/cefpython3.__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/installer/cefpython3.__init__.py b/tools/installer/cefpython3.__init__.py index fc00000d..ef784f2c 100644 --- a/tools/installer/cefpython3.__init__.py +++ b/tools/installer/cefpython3.__init__.py @@ -26,9 +26,13 @@ package_dir = os.path.dirname(os.path.abspath(__file__)) -# This loads the libcef.so library for the subprocess executable. -# On Mac it works without setting library paths. -os.environ["LD_LIBRARY_PATH"] = package_dir +# This loads the libcef.so library for the subprocess executable on Linux. +# TODO: Use -Wl,-rpath=\$$ORIGIN in Makefile. +ld_library_path = os.environ.get("LD_LIBRARY_PATH") +if ld_library_path and ld_library_path.strip(): + os.environ["LD_LIBRARY_PATH"] = package_dir + os.pathsep + ld_library_path +else: + os.environ["LD_LIBRARY_PATH"] = package_dir # This env variable will be returned by cefpython.GetModuleDirectory(). os.environ["CEFPYTHON3_PATH"] = package_dir From 96f3b5ec1ef951a1959d378a5d4d87bf247b2c36 Mon Sep 17 00:00:00 2001 From: Martin Cejp Date: Sun, 14 Feb 2021 16:20:20 +0100 Subject: [PATCH 216/238] Fix pango library wrong include path (hb.h: No such file or directory) (#589) * Fix Fedora 32 build error (hb.h: No such file or directory) * Update client_handler/Makefile * Update client_handler/Makefile * Update cpp_utils/Makefile * Update subprocess/Makefile * Update subprocess/Makefile-libcefpythonapp * Update tools/cython_setup.py Co-authored-by: Czarek Tomczak --- src/client_handler/Makefile | 1 + src/cpp_utils/Makefile | 2 +- src/subprocess/Makefile | 1 + src/subprocess/Makefile-libcefpythonapp | 1 + tools/cython_setup.py | 2 ++ 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/client_handler/Makefile b/src/client_handler/Makefile index d217660e..25e645ff 100644 --- a/src/client_handler/Makefile +++ b/src/client_handler/Makefile @@ -37,6 +37,7 @@ INC = -I./../ -I./../common/ -I$(PYTHON_INCLUDE) \ -I/usr/include/glib-2.0 \ -I/usr/include/cairo \ -I/usr/include/pango-1.0 \ + -I/usr/include/harfbuzz \ -I/usr/include/gdk-pixbuf-2.0 \ -I/usr/include/atk-1.0 \ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include \ diff --git a/src/cpp_utils/Makefile b/src/cpp_utils/Makefile index 338fd960..e6a6a2fe 100644 --- a/src/cpp_utils/Makefile +++ b/src/cpp_utils/Makefile @@ -7,7 +7,7 @@ OUT = libcpp_utils.a INC = -I./../ -I/usr/include/gtk-2.0 \ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include \ -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/cairo \ - -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 \ + -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 \ -I/usr/include/atk-1.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include \ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include \ -I/usr/lib64/glib-2.0/include -I/usr/lib64/gtk-2.0/include \ diff --git a/src/subprocess/Makefile b/src/subprocess/Makefile index f52b72df..adc34fca 100644 --- a/src/subprocess/Makefile +++ b/src/subprocess/Makefile @@ -11,6 +11,7 @@ INC = -I./../ -I./../common/ -I$(PYTHON_INCLUDE) \ -I/usr/include/glib-2.0 \ -I/usr/include/cairo \ -I/usr/include/pango-1.0 \ + -I/usr/include/harfbuzz \ -I/usr/include/gdk-pixbuf-2.0 \ -I/usr/include/atk-1.0 \ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include \ diff --git a/src/subprocess/Makefile-libcefpythonapp b/src/subprocess/Makefile-libcefpythonapp index 23fbde39..e8a6b852 100644 --- a/src/subprocess/Makefile-libcefpythonapp +++ b/src/subprocess/Makefile-libcefpythonapp @@ -36,6 +36,7 @@ INC = -I./../ -I./../common/ -I$(PYTHON_INCLUDE) \ -I/usr/include/glib-2.0 \ -I/usr/include/cairo \ -I/usr/include/pango-1.0 \ + -I/usr/include/harfbuzz \ -I/usr/include/gdk-pixbuf-2.0 \ -I/usr/include/atk-1.0 \ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include \ diff --git a/tools/cython_setup.py b/tools/cython_setup.py index 4f0cafc6..52482cba 100644 --- a/tools/cython_setup.py +++ b/tools/cython_setup.py @@ -318,6 +318,7 @@ def get_include_dirs(): '/usr/include/gtk-unix-print-2.0', '/usr/include/cairo', '/usr/include/pango-1.0', + '/usr/include/harfbuzz', '/usr/include/gdk-pixbuf-2.0', '/usr/include/atk-1.0', # Fedora @@ -337,6 +338,7 @@ def get_include_dirs(): '/usr/include/gtk-unix-print-2.0', '/usr/include/cairo', '/usr/include/pango-1.0', + '/usr/include/harfbuzz', '/usr/include/gdk-pixbuf-2.0', '/usr/include/atk-1.0', # Ubuntu From 054ff3ca52106099d078f37b3f8986e5252c7733 Mon Sep 17 00:00:00 2001 From: Bryan Koroleski <44987192+bryan-koroleski-fivestars@users.noreply.github.com> Date: Sun, 14 Feb 2021 10:09:52 -0600 Subject: [PATCH 217/238] Update int range detection for Python 3 (#603) * Update int range detection for Python 3 Python 3 unified ints and longs into a single int type. The long type is still available in Cython as an alias to int. * Update javascript_bindings.pyx * Update process_message_utils.pyx Co-authored-by: Czarek Tomczak --- Authors | 1 + src/javascript_bindings.pyx | 2 ++ src/process_message_utils.pyx | 33 +++++++++------------------------ tools/cython_setup.py | 3 +++ 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Authors b/Authors index b4c55d20..b44b24e6 100644 --- a/Authors +++ b/Authors @@ -19,3 +19,4 @@ Contributors: Dónal McMullan nobodyguy Elliot Woods + Bryan Koroleski diff --git a/src/javascript_bindings.pyx b/src/javascript_bindings.pyx index 9043639e..31620a6d 100644 --- a/src/javascript_bindings.pyx +++ b/src/javascript_bindings.pyx @@ -140,6 +140,8 @@ cdef class JavascriptBindings: return True elif valueType == int: return True + elif valueType == long: + return True elif valueType == type(None): return True elif IsFunctionOrMethod(valueType): diff --git a/src/process_message_utils.pyx b/src/process_message_utils.pyx index 8ced3f6c..e2d55dab 100644 --- a/src/process_message_utils.pyx +++ b/src/process_message_utils.pyx @@ -238,14 +238,9 @@ cdef CefRefPtr[CefListValue] PyListToCefListValue( ret.get().SetNull(index) elif valueType == bool: ret.get().SetBool(index, bool(value)) - elif valueType == int: - ret.get().SetInt(index, int(value)) - elif valueType == long: - # Int32 range is -2147483648..2147483647, we've increased the - # minimum size by one as Cython was throwing a warning: - # "unary minus operator applied to unsigned type, result still - # unsigned". - if -2147483647 <= value <= 2147483647: + elif valueType == int or valueType == long: # In Py3 int and long types are the same type. + # Int32 range is -2147483648..2147483647 + if INT_MIN <= value <= INT_MAX: ret.get().SetInt(index, int(value)) else: # Long values become strings. @@ -297,14 +292,9 @@ cdef void PyListToExistingCefListValue( cefListValue.get().SetNull(index) elif valueType == bool: cefListValue.get().SetBool(index, bool(value)) - elif valueType == int: - cefListValue.get().SetInt(index, int(value)) - elif valueType == long: - # Int32 range is -2147483648..2147483647, we've increased the - # minimum size by one as Cython was throwing a warning: - # "unary minus operator applied to unsigned type, result still - # unsigned". - if -2147483647 <= value <= 2147483647: + elif valueType == int or valueType == long: # In Py3 int and long types are the same type. + # Int32 range is -2147483648..2147483647 + if INT_MIN <= value <= INT_MAX: cefListValue.get().SetInt(index, int(value)) else: # Long values become strings. @@ -357,14 +347,9 @@ cdef CefRefPtr[CefDictionaryValue] PyDictToCefDictionaryValue( ret.get().SetNull(cefKey) elif valueType == bool: ret.get().SetBool(cefKey, bool(value)) - elif valueType == int: - ret.get().SetInt(cefKey, int(value)) - elif valueType == long: - # Int32 range is -2147483648..2147483647, we've increased the - # minimum size by one as Cython was throwing a warning: - # "unary minus operator applied to unsigned type, result still - # unsigned". - if -2147483647 <= value <= 2147483647: + elif valueType == int or valueType == long: # In Py3 int and long types are the same type. + # Int32 range is -2147483648..2147483647 + if INT_MIN <= value <= INT_MAX: ret.get().SetInt(cefKey, int(value)) else: # Long values become strings. diff --git a/tools/cython_setup.py b/tools/cython_setup.py index 52482cba..5b3049db 100644 --- a/tools/cython_setup.py +++ b/tools/cython_setup.py @@ -470,6 +470,9 @@ def compile_time_constants(): # A way around Python 3.2 bug: UNAME_SYSNAME is not set contents += 'DEF UNAME_SYSNAME = "%s"\n' % platform.uname()[0] contents += 'DEF PY_MAJOR_VERSION = %s\n' % sys.version_info.major + contents += 'cdef extern from "limits.h":\n' + contents += ' cdef int INT_MIN\n' + contents += ' cdef int INT_MAX\n' fo.write(contents.encode("utf-8")) From 686d528b3eebbe5b84a770f5d266aea8dd185721 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sun, 14 Feb 2021 17:21:13 +0100 Subject: [PATCH 218/238] Fix pyinstaller hook for pyinstaller >= 4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Brénainn Woodsend (https://github.com/bwoodsend) for the fix. See also https://github.com/cztomczak/cefpython/pull/600 . --- examples/pyinstaller/hook-cefpython3.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/pyinstaller/hook-cefpython3.py b/examples/pyinstaller/hook-cefpython3.py index 7522b7be..9160f67f 100644 --- a/examples/pyinstaller/hook-cefpython3.py +++ b/examples/pyinstaller/hook-cefpython3.py @@ -14,8 +14,13 @@ import sys import PyInstaller from PyInstaller.utils.hooks import is_module_satisfies, get_package_paths -from PyInstaller.compat import is_win, is_darwin, is_linux, is_py2 +from PyInstaller.compat import is_win, is_darwin, is_linux from PyInstaller import log as logging +try: + # PyInstaller >= 4.0 doesn't support Python 2.7 + from PyInstaller.compat import is_py2 +except ImportError: + is_py2 = None # Constants CEFPYTHON_MIN_VERSION = "57.0" From 8e36e82a21a95574fbc2cc329be4f2d5e82f6d00 Mon Sep 17 00:00:00 2001 From: Holger Badorreck <6099617+hoba87@users.noreply.github.com> Date: Sun, 14 Feb 2021 17:30:11 +0100 Subject: [PATCH 219/238] update kivy example (#573) * update old print syntax * remove pygtk, gtk dependencies * restore kivy pygtk dependency for linux, add platform dependent conditional statements * kivy example macos keyboard working * external pump message only for macos * Update kivy_.py Co-authored-by: Czarek Tomczak --- src/linux/binaries_64bit/kivy_.py | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/linux/binaries_64bit/kivy_.py b/src/linux/binaries_64bit/kivy_.py index bdfb6d2c..49543bf9 100644 --- a/src/linux/binaries_64bit/kivy_.py +++ b/src/linux/binaries_64bit/kivy_.py @@ -8,11 +8,20 @@ from cefpython3 import cefpython as cef -import pygtk -import gtk import sys import os import time +if sys.platform == 'linux': + import pygtk + import gtk + pygtk.require('2.0') +elif sys.platform == 'darwin': + import gi + gi.require_version("Gtk", "3.0") + from gi.repository import Gtk +elif sys.platform == 'win32': + # no gtk needed on Windows + pass from kivy.app import App from kivy.uix.button import Button @@ -28,9 +37,6 @@ # Global variables g_switches = None -# PyGTK required -pygtk.require('2.0') - class BrowserLayout(BoxLayout): @@ -150,9 +156,6 @@ def start_cef(self): # Configure CEF settings = { - # This directories must be set on Linux - "locales_dir_path": cef.GetModuleDirectory()+"/locales", - "resources_dir_path": cef.GetModuleDirectory(), "browser_subprocess_path": "%s/%s" % ( cef.GetModuleDirectory(), "subprocess"), "windowless_rendering_enabled": True, @@ -161,7 +164,15 @@ def start_cef(self): "enabled": False, }, "external_message_pump": False, # See Issue #246 + "multi_threaded_message_loop": False, } + if sys.platform == 'linux': + # This directories must be set on Linux + settings["locales_dir_path"] = cef.GetModuleDirectory() + "/locales" + settings["resources_dir_path"] = cef.GetModuleDirectory() + if sys.platform == 'darwin': + settings["external_message_pump"] = True # Temporary fix for Issue #246 + switches = { # Tweaking OSR performance by setting the same Chromium flags # as in upstream cefclient (# Issue #240). @@ -190,18 +201,21 @@ def start_cef(self): # Start idle - CEF message loop work. Clock.schedule_once(self._message_loop_work, 0) + windowInfo = cef.WindowInfo() + # TODO: For printing to work in off-screen-rendering mode # it is enough to call gtk_init(). It is not required # to provide window handle when calling SetAsOffscreen(). # However it still needs to be tested whether providing # window handle is required for mouse context menu and # popup widgets to work. - gtkwin = gtk.Window() - gtkwin.realize() - # WindowInfo offscreen flag - windowInfo = cef.WindowInfo() - windowInfo.SetAsOffscreen(gtkwin.window.xid) + if sys.platform == 'linux': + gtkwin = gtk.Window() + gtkwin.realize() + windowInfo.SetAsOffscreen(gtkwin.window.xid) + elif sys.platform == 'darwin' or sys.platform == 'win32': + windowInfo.SetAsOffscreen(0) # Create Broswer and naviagte to empty page <= OnPaint won't get # called yet @@ -519,12 +533,12 @@ def get_windows_key_code(self, kivycode): def go_forward(self, *_): """Going to forward in browser history.""" - print "go forward" + print("go forward") self.browser.GoForward() def go_back(self, *_): """Going back in browser history.""" - print "go back" + print("go back") self.browser.GoBack() def reload(self, *_): @@ -864,7 +878,7 @@ def OnLoadingStateChange(self, is_loading, **_): def OnPaint(self, element_type, paint_buffer, **_): # print "OnPaint()" if element_type != cef.PET_VIEW: - print "Popups aren't implemented yet" + print("Popups aren't implemented yet") return # FPS meter ("fps" arg) From 55e63607afdce5d122f3d78884200a5e3f84938d Mon Sep 17 00:00:00 2001 From: gary Date: Sun, 14 Feb 2021 12:03:24 -0800 Subject: [PATCH 220/238] Add support for Python 3.8 and Upgrade Cython (#594) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/cztomczak/cefpython/issues/546 Had to include harfbuzz manually as newer Pango change this. See: https://github.com/eiskaltdcpp/eiskaltdcpp/issues/413 https://gitlab.gnome.org/GNOME/pango/-/issues/387 Also had to add `-Wno-deprecated-declarations` to get this to compile because of the following errors that didn't seem to be coming from this code directly: warning: ‘GTimeVal’ is deprecated: Use 'GDateTime' instead warning: ‘GTypeDebugFlags’ is deprecated --- README.md | 6 +++--- src/common/cefpython_public_api.h | 2 ++ tools/build.py | 2 +- tools/build_distrib.py | 2 +- tools/common.py | 2 ++ tools/installer/cefpython3.__init__.py | 3 +++ tools/installer/cefpython3.setup.py | 1 + tools/requirements.txt | 2 +- 8 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 546cd001..d4f4c493 100644 --- a/README.md +++ b/README.md @@ -210,9 +210,9 @@ support old operating systems then choose the v31 release. OS | Py2 | Py3 | 32bit | 64bit | Requirements --- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Windows 7+ -Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ -Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ +Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 | Yes | Yes | Windows 7+ +Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 3.8 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ +Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 | No | Yes | MacOS 10.9+ These platforms are not supported yet: - ARM - see [Issue #267](../../issues/267) diff --git a/src/common/cefpython_public_api.h b/src/common/cefpython_public_api.h index 53ad62c6..8e4ff60b 100644 --- a/src/common/cefpython_public_api.h +++ b/src/common/cefpython_public_api.h @@ -46,6 +46,8 @@ #include "../../build/build_cefpython/cefpython_py36_fixed.h" #elif PY_MINOR_VERSION == 7 #include "../../build/build_cefpython/cefpython_py37_fixed.h" +#elif PY_MINOR_VERSION == 8 +#include "../../build/build_cefpython/cefpython_py38_fixed.h" #endif // PY_MINOR_VERSION #endif // PY_MAJOR_VERSION diff --git a/tools/build.py b/tools/build.py index 522a9b08..b3bc9920 100644 --- a/tools/build.py +++ b/tools/build.py @@ -293,7 +293,7 @@ def setup_environ(): print("[build.py] PYTHON_INCLUDE: {python_include}" .format(python_include=os.environ["PYTHON_INCLUDE"])) - os.environ["CEF_CCFLAGS"] = "-std=gnu++11 -DNDEBUG -Wall -Werror" + os.environ["CEF_CCFLAGS"] = "-std=gnu++11 -DNDEBUG -Wall -Werror -Wno-deprecated-declarations" if FAST_FLAG: os.environ["CEF_CCFLAGS"] += " -O0" else: diff --git a/tools/build_distrib.py b/tools/build_distrib.py index e0a5bde1..f452bc0d 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -80,7 +80,7 @@ ALLOW_PARTIAL = False # Python versions -SUPPORTED_PYTHON_VERSIONS = [(2, 7), (3, 4), (3, 5), (3, 6), (3, 7)] +SUPPORTED_PYTHON_VERSIONS = [(2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] # Python search paths. It will use first Python found for specific version. # Supports replacement of one environment variable in path eg.: %ENV_KEY%. diff --git a/tools/common.py b/tools/common.py index 113bcd9e..226fd391 100644 --- a/tools/common.py +++ b/tools/common.py @@ -473,6 +473,8 @@ def get_msvs_for_python(vs_prefix=False): return "VS2015" if vs_prefix else "2015" elif sys.version_info[:2] == (3, 7): return "VS2015" if vs_prefix else "2015" + elif sys.version_info[:2] == (3, 8): + return "VS2015" if vs_prefix else "2015" else: print("ERROR: This version of Python is not supported") sys.exit(1) diff --git a/tools/installer/cefpython3.__init__.py b/tools/installer/cefpython3.__init__.py index ef784f2c..5f779a54 100644 --- a/tools/installer/cefpython3.__init__.py +++ b/tools/installer/cefpython3.__init__.py @@ -64,5 +64,8 @@ elif sys.version_info[:2] == (3, 7): # noinspection PyUnresolvedReferences from . import cefpython_py37 as cefpython +elif sys.version_info[:2] == (3, 8): + # noinspection PyUnresolvedReferences + from . import cefpython_py38 as cefpython else: raise Exception("Python version not supported: " + sys.version) diff --git a/tools/installer/cefpython3.setup.py b/tools/installer/cefpython3.setup.py index 6814cbb7..2a926913 100644 --- a/tools/installer/cefpython3.setup.py +++ b/tools/installer/cefpython3.setup.py @@ -148,6 +148,7 @@ def main(): "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Topic :: Desktop Environment", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP", diff --git a/tools/requirements.txt b/tools/requirements.txt index 81ebc0c5..4b083579 100644 --- a/tools/requirements.txt +++ b/tools/requirements.txt @@ -1,4 +1,4 @@ -Cython == 0.28.4 +Cython == 0.29.21 docopt >= 0.6.2 setuptools wheel From d6deaf8e2b87266d7b5fc4052fc05b5622056b17 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 14 Feb 2021 23:44:38 +0100 Subject: [PATCH 221/238] Support Python 3.8 and Python 3.9 (Issues #546 and #593). --- README.md | 6 +++--- docs/Build-instructions.md | 8 +++++--- examples/screenshot.py | 2 +- src/common/cefpython_public_api.h | 2 ++ src/compile_time_constants.pxi | 3 +++ src/subprocess/main_message_loop/util_win.cpp | 4 ++-- src/subprocess/main_message_loop/util_win.h | 2 +- tools/build.py | 2 +- tools/build_distrib.py | 5 +++-- tools/common.py | 6 ++++++ tools/cython_setup.py | 7 +++---- tools/installer/cefpython3.__init__.py | 3 +++ tools/installer/cefpython3.setup.py | 1 + tools/make_installer.py | 8 +++++--- 14 files changed, 39 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d4f4c493..48a9af4a 100644 --- a/README.md +++ b/README.md @@ -210,9 +210,9 @@ support old operating systems then choose the v31 release. OS | Py2 | Py3 | 32bit | 64bit | Requirements --- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 | Yes | Yes | Windows 7+ -Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 3.8 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ -Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 | No | Yes | MacOS 10.9+ +Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | Yes | Yes | Windows 7+ (Note that Python 3.9 supports Windows 8.1+) +Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ +Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ These platforms are not supported yet: - ARM - see [Issue #267](../../issues/267) diff --git a/docs/Build-instructions.md b/docs/Build-instructions.md index 5df63bec..9ca4d6e9 100644 --- a/docs/Build-instructions.md +++ b/docs/Build-instructions.md @@ -66,8 +66,9 @@ are named "cefpythonXX" where XX is Chromium version number. from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266) 5) For Python 2.7 and when using using "Visual C++ compiler for Python 2.7" - you have to install "Visual C++ 2008 Redistributable Package (x64)" - from [here](https://www.microsoft.com/en-us/download/details.aspx?id=15336) + you have to install "Visual C++ 2008 Redistributable Package" + from [here](https://www.microsoft.com/en-us/download/details.aspx?id=29) + and [here](https://www.microsoft.com/en-us/download/details.aspx?id=15336) 6) Clone cefpython, checkout for example "cefpython57" branch that includes Chromium v57, then create a build/ directory and enter it: @@ -164,7 +165,8 @@ requirements common for all platforms. * For Python 2.7 install "Microsoft Visual C++ Compiler for Python 2.7" from [here](https://www.microsoft.com/en-us/download/details.aspx?id=44266) * When using "Visual C++ compiler for Python 2.7" you have to install - "Microsoft Visual C++ 2008 Redistributable Package (x64)" from + "Microsoft Visual C++ 2008 Redistributable Package" from + [here](https://www.microsoft.com/en-us/download/details.aspx?id=29) and [here](https://www.microsoft.com/en-us/download/details.aspx?id=15336) * For Python 2.7 copy "cefpython/src/windows/py27/stdint.h" to "%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include\" diff --git a/examples/screenshot.py b/examples/screenshot.py index d6dc661c..976ba538 100644 --- a/examples/screenshot.py +++ b/examples/screenshot.py @@ -42,7 +42,7 @@ import sys try: - from PIL import Image, PILLOW_VERSION + from PIL import Image, __version__ as PILLOW_VERSION except ImportError: print("[screenshot.py] Error: PIL module not available. To install" " type: pip install Pillow") diff --git a/src/common/cefpython_public_api.h b/src/common/cefpython_public_api.h index 8e4ff60b..c796388e 100644 --- a/src/common/cefpython_public_api.h +++ b/src/common/cefpython_public_api.h @@ -48,6 +48,8 @@ #include "../../build/build_cefpython/cefpython_py37_fixed.h" #elif PY_MINOR_VERSION == 8 #include "../../build/build_cefpython/cefpython_py38_fixed.h" +#elif PY_MINOR_VERSION == 9 +#include "../../build/build_cefpython/cefpython_py39_fixed.h" #endif // PY_MINOR_VERSION #endif // PY_MAJOR_VERSION diff --git a/src/compile_time_constants.pxi b/src/compile_time_constants.pxi index 609470c1..bf130d6e 100644 --- a/src/compile_time_constants.pxi +++ b/src/compile_time_constants.pxi @@ -5,3 +5,6 @@ DEF UNAME_SYSNAME = "Windows" DEF PY_MAJOR_VERSION = 3 +cdef extern from "limits.h": + cdef int INT_MIN + cdef int INT_MAX diff --git a/src/subprocess/main_message_loop/util_win.cpp b/src/subprocess/main_message_loop/util_win.cpp index bc1f0965..834850e3 100644 --- a/src/subprocess/main_message_loop/util_win.cpp +++ b/src/subprocess/main_message_loop/util_win.cpp @@ -136,8 +136,8 @@ int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam) { return modifiers; } -bool IsKeyDown(WPARAM wparam) { - return (GetKeyState(wparam) & 0x8000) != 0; +bool IsKeyDown(int keycode) { + return (GetKeyState(keycode) & 0x8000) != 0; } float GetDeviceScaleFactor() { diff --git a/src/subprocess/main_message_loop/util_win.h b/src/subprocess/main_message_loop/util_win.h index 39870204..a716d938 100644 --- a/src/subprocess/main_message_loop/util_win.h +++ b/src/subprocess/main_message_loop/util_win.h @@ -31,7 +31,7 @@ WNDPROC SetWndProcPtr(HWND hWnd, WNDPROC wndProc); int GetCefMouseModifiers(WPARAM wparam); int GetCefKeyboardModifiers(WPARAM wparam, LPARAM lparam); -bool IsKeyDown(WPARAM wparam); +bool IsKeyDown(int keycode); // Returns the device scale factor. For example, 200% display scaling will // return 2.0. diff --git a/tools/build.py b/tools/build.py index b3bc9920..f3960283 100644 --- a/tools/build.py +++ b/tools/build.py @@ -809,7 +809,7 @@ def build_cefpython_module(): args = list() args.append("\"{python}\"".format(python=sys.executable)) args.append(os.path.join(TOOLS_DIR, os.path.basename(__file__))) - assert __file__ in sys.argv[0] + assert os.path.basename(__file__) in sys.argv[0] args.extend(SYS_ARGV_ORIGINAL[1:]) command = " ".join(args) print("[build.py] Running command: %s" % command) diff --git a/tools/build_distrib.py b/tools/build_distrib.py index f452bc0d..01ae66da 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -80,13 +80,14 @@ ALLOW_PARTIAL = False # Python versions -SUPPORTED_PYTHON_VERSIONS = [(2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] +SUPPORTED_PYTHON_VERSIONS = [(2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9)] # Python search paths. It will use first Python found for specific version. # Supports replacement of one environment variable in path eg.: %ENV_KEY%. PYTHON_SEARCH_PATHS = dict( WINDOWS=[ "C:\\Python*\\", + "C:\\Pythons\\Python*\\", "%LOCALAPPDATA%\\Programs\\Python\\Python*\\", "C:\\Program Files\\Python*\\", "C:\\Program Files (x86)\\Python*\\", @@ -614,7 +615,7 @@ def check_cpp_extension_dependencies_issue359(setup_dir, all_pythons): return checked_any = False for python in all_pythons: - if python["version2"] in ((3, 5), (3, 6), (3, 7)): + if python["version2"] in ((3, 5), (3, 6), (3, 7), (3, 8), (3, 9)): checked_any = True if not os.path.exists(os.path.join(setup_dir, "cefpython3", "msvcp140.dll")): diff --git a/tools/common.py b/tools/common.py index 226fd391..303ccb85 100644 --- a/tools/common.py +++ b/tools/common.py @@ -219,15 +219,19 @@ VS_PLATFORM_ARG = "x86" if ARCH32 else "amd64" +# Python 3.5 / 3.6 / 3.7 / 3.8 / 3.9 VS2015_VCVARS = ("C:\\Program Files (x86)\\Microsoft Visual Studio 14.0" "\\VC\\vcvarsall.bat") +# Required for building old CEF branches < 2704 VS2013_VCVARS = ("C:\\Program Files (x86)\\Microsoft Visual Studio 12.0" "\\VC\\vcvarsall.bat") +# Python 3.4 VS2010_VCVARS = ("C:\\Program Files (x86)\\Microsoft Visual Studio 10.0" "\\VC\\vcvarsall.bat") +# Python 2.7 VS2008_VCVARS = ("C:\\Program Files (x86)\\Microsoft Visual Studio 9.0" "\\VC\\vcvarsall.bat") @@ -475,6 +479,8 @@ def get_msvs_for_python(vs_prefix=False): return "VS2015" if vs_prefix else "2015" elif sys.version_info[:2] == (3, 8): return "VS2015" if vs_prefix else "2015" + elif sys.version_info[:2] == (3, 9): + return "VS2015" if vs_prefix else "2015" else: print("ERROR: This version of Python is not supported") sys.exit(1) diff --git a/tools/cython_setup.py b/tools/cython_setup.py index 5b3049db..436bcb2c 100644 --- a/tools/cython_setup.py +++ b/tools/cython_setup.py @@ -147,17 +147,15 @@ def get_winsdk_lib(): if WINDOWS: if ARCH32: winsdk_libs = [ + # Windows 7 SDKs. r"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib", r"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Lib", - # Visual Studio 2008 installation - r"C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Lib", ] elif ARCH64: winsdk_libs = [ + # Windows 7 SDKs. r"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64", r"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Lib\\x64", - # Visual Studio 2008 installation - r"C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Lib\\x64", ] else: raise Exception("Unknown architecture") @@ -433,6 +431,7 @@ def get_ext_modules(options): # > Unknown Extension options: 'cython_directives' warnings.warn(msg) cython_directives={ # Any conversion to unicode must be explicit using .decode(). + "language_level": 2, # Yes, Py2 for all python versions. "c_string_type": "bytes", "c_string_encoding": "utf-8", "profile": ENABLE_PROFILING, diff --git a/tools/installer/cefpython3.__init__.py b/tools/installer/cefpython3.__init__.py index 5f779a54..624a26e7 100644 --- a/tools/installer/cefpython3.__init__.py +++ b/tools/installer/cefpython3.__init__.py @@ -67,5 +67,8 @@ elif sys.version_info[:2] == (3, 8): # noinspection PyUnresolvedReferences from . import cefpython_py38 as cefpython +elif sys.version_info[:2] == (3, 9): + # noinspection PyUnresolvedReferences + from . import cefpython_py39 as cefpython else: raise Exception("Python version not supported: " + sys.version) diff --git a/tools/installer/cefpython3.setup.py b/tools/installer/cefpython3.setup.py index 2a926913..d14ee2ce 100644 --- a/tools/installer/cefpython3.setup.py +++ b/tools/installer/cefpython3.setup.py @@ -149,6 +149,7 @@ def main(): "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Desktop Environment", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP", diff --git a/tools/make_installer.py b/tools/make_installer.py index bc3b5cef..012e6657 100644 --- a/tools/make_installer.py +++ b/tools/make_installer.py @@ -338,7 +338,7 @@ def create_empty_log_file(log_file): def copy_cpp_extension_dependencies_issue359(pkg_dir): """CEF Python module is written in Cython and is a Python C++ - extension and depends on msvcpXX.dll. For Python 3.5 / 3.6 / 3.7 + extension and depends on msvcpXX.dll. For Python 3.5 / 3.6 / 3.7 / 3.8 / 3.9 msvcp140.dll is required. See Issue #359. For Python 2.7 msvcp90.dll is required. Etc. These dependencies are not included with Python binaries from Python.org.""" @@ -365,10 +365,12 @@ def copy_cpp_extension_dependencies_issue359(pkg_dir): # in the package. Thus if included, msvcpxx.dll dependency is # required as well. - # Python 3.5 / 3.6 / 3.7 + # Python 3.5 / 3.6 / 3.7 / 3.8 / 3.9 if os.path.exists(os.path.join(pkg_dir, "cefpython_py35.pyd")) \ or os.path.exists(os.path.join(pkg_dir, "cefpython_py36.pyd")) \ - or os.path.exists(os.path.join(pkg_dir, "cefpython_py37.pyd")): + or os.path.exists(os.path.join(pkg_dir, "cefpython_py37.pyd")) \ + or os.path.exists(os.path.join(pkg_dir, "cefpython_py38.pyd")) \ + or os.path.exists(os.path.join(pkg_dir, "cefpython_py39.pyd")): search_paths = [ # This is where Microsoft Visual C++ 2015 Update 3 installs # (14.00.24212). From 92aa6236268620105be0b3d5ce60412a8b5dbf5b Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 15 Feb 2021 19:01:48 +0100 Subject: [PATCH 222/238] Fix Python 3 error in build_distrib.py script (#546). --- tools/build_distrib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_distrib.py b/tools/build_distrib.py index 01ae66da..61560743 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -379,7 +379,7 @@ def uninstall_cefpython3_packages(pythons): .format(python=python["executable"])) try: output = subprocess.check_output(command, shell=True) - except subprocess.CalledProcessError, exc: + except subprocess.CalledProcessError as exc: # pip show returns error code when package is not installed output = exc.output if not len(output.strip()): From 3beaaf5dc39c80eea54a9bba6c4c35965764d628 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 15 Feb 2021 19:31:02 +0100 Subject: [PATCH 223/238] Fix build_distrib.py on Python 3 (Issue #546). --- tools/build_distrib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/build_distrib.py b/tools/build_distrib.py index 61560743..7adb535b 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -86,7 +86,7 @@ # Supports replacement of one environment variable in path eg.: %ENV_KEY%. PYTHON_SEARCH_PATHS = dict( WINDOWS=[ - "C:\\Python*\\", + "C:\\Python??*\\", "C:\\Pythons\\Python*\\", "%LOCALAPPDATA%\\Programs\\Python\\Python*\\", "C:\\Program Files\\Python*\\", @@ -277,6 +277,8 @@ def search_for_pythons(search_arch): version_str = subprocess.check_output([python, "-c", version_code]) version_str = version_str.strip() + if sys.version_info >= (3, 0): + version_str = version_str.decode("utf-8") match = re.search("^\((\d+), (\d+), (\d+)\)$", version_str) assert match, version_str major = match.group(1) @@ -288,6 +290,8 @@ def search_for_pythons(search_arch): "print(str(platform.architecture()[0]));") arch = subprocess.check_output([python, "-c", arch_code]) arch = arch.strip() + if sys.version_info >= (3, 0): + arch = arch.decode("utf-8") if version_tuple2 in SUPPORTED_PYTHON_VERSIONS \ and arch == search_arch: name = ("Python {major}.{minor}.{micro} {arch}" From 06d3b8c8e8164ea1a51caf00591b7eaedcbfc5ac Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 15 Feb 2021 23:26:45 +0100 Subject: [PATCH 224/238] Fix build_distrib.py script for Python 2.7 and Python 3.4 (latest pip versions are broken with these old Pythons). Fix screenshot.py example sometimes failing. When compiling for Python 3.4 you can encounter the the missing "ammintrin.h" header file error. Just copy it from the VS 2019 include/ directory. For Pythons 3.5 / 3.6 / 3.7 / 3.8 / 3.9 you can use the same VC++ 14.2 (VS 2019) compiler which is binary compatible with VC++ 14.1 (VS 2017) and VC++ 14.0 (VS 2015). Currently the subprocess.exe executable built by Python 3.4 (VC++ 10.0 compiler) gives the least amount of false-positives by AVs on virustotal.com . For comparison: Py34 (1/69), Py27 (2/69), Py39 (5/69). Results differ for 32bit and 64bit binaries. --- examples/screenshot.py | 9 ++++++--- tools/build_distrib.py | 28 ++++++++++++++++------------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/examples/screenshot.py b/examples/screenshot.py index 976ba538..5ca8d491 100644 --- a/examples/screenshot.py +++ b/examples/screenshot.py @@ -158,6 +158,8 @@ def save_screenshot(browser): "raw", "RGBA", 0, 1) image.save(SCREENSHOT_PATH, "PNG") print("[screenshot.py] Saved image: {path}".format(path=SCREENSHOT_PATH)) + # See comments in exit_app() why PostTask must be used + cef.PostTask(cef.TID_UI, exit_app, browser) def open_with_default_application(path): @@ -188,9 +190,10 @@ def OnLoadingStateChange(self, browser, is_loading, **_): # Loading is complete sys.stdout.write(os.linesep) print("[screenshot.py] Web page loading is complete") - save_screenshot(browser) - # See comments in exit_app() why PostTask must be used - cef.PostTask(cef.TID_UI, exit_app, browser) + print("[screenshot.py] Will save screenshot in 2 seconds") + # Give up to 2 seconds for the OnPaint call. Most of the time + # it is already called, but sometimes it may be called later. + cef.PostDelayedTask(cef.TID_UI, 2000, save_screenshot, browser) def OnLoadError(self, browser, frame, error_code, failed_url, **_): """Called when the resource load for a navigation fails diff --git a/tools/build_distrib.py b/tools/build_distrib.py index 7adb535b..051914f5 100644 --- a/tools/build_distrib.py +++ b/tools/build_distrib.py @@ -353,8 +353,14 @@ def install_upgrade_requirements(pythons): " for: {name}".format(name=python["name"])) # Upgrade pip - command = ("\"{python}\" -m pip install --upgrade pip" - .format(python=python["executable"])) + pip_version = "pip" + # Old Python versions require specific versions of pip, latest versions are broken with these. + if python["version2"] == (2, 7): + pip_version = "pip==20.3.4" + elif python["version2"] == (3, 4): + pip_version = "pip==19.1.1" + command = ("\"{python}\" -m pip install --upgrade {pip_version}" + .format(python=python["executable"], pip_version=pip_version)) command = sudo_command(command, python=python["executable"]) pcode = subprocess.call(command, shell=True) if pcode != 0: @@ -522,39 +528,37 @@ def build_cefpython_modules(pythons, arch): def backup_subprocess_executable_issue342(python): - """Use subprocess executable build by Python 2.7 to avoid - false-positives by AVs when building subprocess with Python 3. - Windows-only issue.""" + """Use subprocess executable built by Python 3.4 to have the least amount of + false-positives by AVs. Windows-only issue.""" if not WINDOWS: return if python["version2"] == (2, 7): print("[build_distrib.py] Backup subprocess executable built" - " with Python 2.7 (Issue #342)") + " with Python 3.4 (Issue #342)") cefpython_binary_basename = get_cefpython_binary_basename( get_os_postfix2_for_arch(python["arch"])) cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename) assert os.path.isdir(cefpython_binary) src = os.path.join(cefpython_binary, "subprocess.exe") dst = os.path.join(BUILD_CEFPYTHON, - "subprocess_py27_{arch}_issue342.exe" + "subprocess_py34_{arch}_issue342.exe" .format(arch=python["arch"])) shutil.copy(src, dst) def restore_subprocess_executable_issue342(arch): - """Use subprocess executable build by Python 2.7 to avoid - false-positives by AVs when building subprocess with Python 3. - Windows-only issue.""" + """Use subprocess executable built by Python 3.4 to have the least amount of + false-positives by AVs. Windows-only issue.""" if not WINDOWS: return print("[build_distrib.py] Restore subprocess executable built" - " with Python 2.7 (Issue #342)") + " with Python 3.4 (Issue #342)") cefpython_binary_basename = get_cefpython_binary_basename( get_os_postfix2_for_arch(arch)) cefpython_binary = os.path.join(BUILD_DIR, cefpython_binary_basename) assert os.path.isdir(cefpython_binary) src = os.path.join(BUILD_CEFPYTHON, - "subprocess_py27_{arch}_issue342.exe" + "subprocess_py34_{arch}_issue342.exe" .format(arch=arch)) assert os.path.isfile(src) dst = os.path.join(cefpython_binary, "subprocess.exe") From 0e2503c4675d683d2b853267ee0183e4e7fb5726 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 16 Feb 2021 19:18:02 +0100 Subject: [PATCH 225/238] Add JS bindings long integer test. Add comments on DPI awareness. --- examples/hello_world.py | 7 +++++++ unittests/main_test.py | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/examples/hello_world.py b/examples/hello_world.py index 478c7060..789f4666 100644 --- a/examples/hello_world.py +++ b/examples/hello_world.py @@ -1,5 +1,12 @@ # Hello world example. Doesn't depend on any third party GUI framework. # Tested with CEF Python v57.0+. +# +# ==== High DPI support on Windows ==== +# To enable DPI awareness on Windows you have to either embed DPI aware manifest +# in your executable created with pyinstaller or change python.exe properties manually: +# Compatibility > High DPI scaling override > Application. +# Setting DPI awareness programmatically via a call to cef.DpiAware.EnableHighDpiSupport +# is problematic in Python, may not work and can cause display glitches. from cefpython3 import cefpython as cef import platform diff --git a/unittests/main_test.py b/unittests/main_test.py index 99397da8..ce71af20 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -58,17 +58,18 @@ print("test_function() ok"); // Test binding property: test_property1 - if (test_property1 == "Test binding property to the 'window' object") { + if (test_property1 === "Test binding property to the 'window' object") { print("test_property_1 ok"); } else { throw new Error("test_property1 contains invalid string"); } // Test binding property: test_property2 - if (JSON.stringify(test_property2) == '{"key1":"Test binding property'+ - ' to the \\'window\\' object","key2":["Inside list",1,2]}') { + if (JSON.stringify(test_property2) === '{"key1":"Test binding property'+ + ' to the \\'window\\' object","key2":["Inside list",2147483647,"2147483648"]}') { print("test_property2 ok"); } else { + print("test_property2 invalid value: " + JSON.stringify(test_property2)); throw new Error("test_property2 contains invalid value"); } @@ -81,7 +82,7 @@ print("[TIMER] Call Python function and then js callback that was"+ " passed (Issue #277 test)"); external.test_callbacks(function(msg_from_python, py_callback){ - if (msg_from_python == "String sent from Python") { + if (msg_from_python === "String sent from Python") { print("test_callbacks() ok"); var execution_time = new Date().getTime() - start_time; print("[TIMER]: Elapsed = "+String(execution_time)+" ms"); @@ -163,15 +164,23 @@ def test_main(self): cef.LoadCrlSetsFile(crlset) subtest_message("cef.LoadCrlSetsFile ok") - # High DPI on Windows + # High DPI on Windows. + # Setting DPI awareness from Python is usually too late and should be done + # via manifest file. Alternatively change python.exe properties > Compatibility + # > High DPI scaling override > Application. + # Using cef.DpiAware.EnableHighDpiSupport is problematic, it can cause + # display glitches. if WINDOWS: self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple) window_size = cef.DpiAware.CalculateWindowSize(800, 600) self.assertIsInstance(window_size, tuple) self.assertGreater(window_size[0], 0) self.assertGreater(cef.DpiAware.Scale((800, 600))[0], 0) - cef.DpiAware.EnableHighDpiSupport() - self.assertTrue(cef.DpiAware.IsProcessDpiAware()) + + # OFF - see comments above. + # cef.DpiAware.EnableHighDpiSupport() + # self.assertTrue(cef.DpiAware.IsProcessDpiAware()) + # Make some calls again after DPI Aware was set self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple) self.assertGreater(cef.DpiAware.Scale([800, 600])[0], 0) @@ -374,9 +383,10 @@ def __init__(self, test_case): self.test_case = test_case # Test binding properties to the 'window' object. + # 2147483648 is out of INT_MAX limit and will be sent to JS as string value. self.test_property1 = "Test binding property to the 'window' object" self.test_property2 = {"key1": self.test_property1, - "key2": ["Inside list", 1, 2]} + "key2": ["Inside list", 2147483647, 2147483648]} # Asserts for True/False will be checked just before shutdown self.test_for_True = True # Test whether asserts are working correctly From d2c72528addad8ef41a2a460946f32fe425ed183 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Tue, 16 Feb 2021 19:31:32 +0100 Subject: [PATCH 226/238] Update the sponsors sections in README. --- README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 48a9af4a..e9175971 100644 --- a/README.md +++ b/README.md @@ -55,30 +55,29 @@ PyGame, PyOpenGL, PyWin32, PySide and PySDL2.

- - + +

-Many Thanks to Lampix for sponsoring the -[v66 release](../../releases/tag/v66.0). Lampix is the first hardware -and software solution that turns any surface into a smart, augmented reality -or interactive surface. Please visit their website: -Lampix.com +Thank you to Fivestars for sponsoring the [v66.1 release](../../releases/tag/v66.1) +with Python 3.8 / 3.9 support. Fivestars helps local communities thrive by empowering +small businesses with cutting edge marketing technology. Please visit their website: +Fivestars.com

- - + +

-Many thanks to Fivestars for sponsoring the -[v49 legacy release](../../releases/tag/v49.0). Fivestars helps local -communities thrive by empowering small -businesses with cutting edge marketing technology. Please visit their website: -Fivestars.com +Thank you to Lampix for sponsoring the +[v66 release](../../releases/tag/v66.0). Lampix is the first hardware +and software solution that turns any surface into a smart, augmented reality +or interactive surface. Please visit their website: +Lampix.com
@@ -274,6 +273,8 @@ priority. ### Thanks to all +* [2021] Thank you to [Fivestars](https://www.fivestars.com/) for sponsoring + the v66.1 release with Python 3.8 / 3.9 support * [2018] Thanks to [Fivestars](https://www.fivestars.com/) for sponsoring the v49 release for legacy systems (WinXP/Vista) * [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 From 431b9956db660d5552c31fb4a3a891f619ed84a8 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Tue, 13 Apr 2021 10:42:46 +0200 Subject: [PATCH 227/238] Fix Kivy example on Windows (#613). --- src/linux/binaries_64bit/kivy_.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/linux/binaries_64bit/kivy_.py b/src/linux/binaries_64bit/kivy_.py index 49543bf9..a9a1590b 100644 --- a/src/linux/binaries_64bit/kivy_.py +++ b/src/linux/binaries_64bit/kivy_.py @@ -1,7 +1,5 @@ -# An example of embedding CEF browser in the Kivy framework. -# The browser is embedded using off-screen rendering mode. - -# Tested using Kivy 1.7.2 stable, only on Linux. +# An example of embedding CEF browser with the Kivy framework +# by using off-screen rendering mode. # In this example kivy-lang is used to declare the layout which # contains two buttons (back, forward) and the browser view. @@ -44,7 +42,7 @@ def __init__(self, **kwargs): super(BrowserLayout, self).__init__(**kwargs) self.orientation = "vertical" - self.browser_widget = CefBrowser(id="browser") + self.browser_widget = CefBrowser() layout = BoxLayout() layout.size_hint_y = None From 80e6f3c9828fce40b103a4f51b8bc29d64c54b9c Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Wed, 21 Apr 2021 13:50:04 +0200 Subject: [PATCH 228/238] Fix link --- examples/README-examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README-examples.md b/examples/README-examples.md index ea5871c8..ec2f9bcd 100644 --- a/examples/README-examples.md +++ b/examples/README-examples.md @@ -107,7 +107,7 @@ yet ported to latest CEF. Some of them are externally maintained. for reading/modifying web requests: see the [wxpython-response.py](https://github.com/cztomczak/cefpython/blob/cefpython31/cefpython/cef3/linux/binaries_64bit/wxpython-response.py) example in the cefpython31 branch. - Example of using Python network library (urllib3/openssl) instead of Chromium's - network library - see [gist by Massimiliano Dal Cero](https://gist.github.com/yattamax/0252a3c5dc54a2f81650d5c0eafabf99) + network library - see [gist by Massimiliano Dal Cero](https://gist.github.com/cztomczak/83b77cbdda03ccef81e22e8bd36a51f6) - Example of passing exceptions from Python to Javascript and using await syntax to receive values from python return values - see [Managed python calls example by Elliot Woods](https://github.com/elliotwoods/cefpython-tests/tree/0180b22eac10a1bde08820ca192fdc30eb93f00d/6.%20Managed%20python%20calls) ## More examples to come From 5679f28cec18a57a56e298da2927aac8d8f83ad6 Mon Sep 17 00:00:00 2001 From: relyx <12107287+Reskayoi@users.noreply.github.com> Date: Fri, 14 May 2021 17:18:03 +0800 Subject: [PATCH 229/238] fix OnDownloadData decoding bug (#621) --- api/WebRequestClient.md | 2 +- src/web_request.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/WebRequestClient.md b/api/WebRequestClient.md index d8431cec..0c75a668 100644 --- a/api/WebRequestClient.md +++ b/api/WebRequestClient.md @@ -65,7 +65,7 @@ response (or -1 if not determined). | Parameter | Type | | --- | --- | | web_request | [WebRequest](WebRequest.md) | -| data | string | +| data | bytes | | __Return__ | void | Called when some part of the response is read. |data| contains the current diff --git a/src/web_request.pyx b/src/web_request.pyx index 9891dade..8e51fca1 100644 --- a/src/web_request.pyx +++ b/src/web_request.pyx @@ -176,7 +176,7 @@ cdef public void WebRequestClient_OnDownloadData( if userCallback: userCallback( web_request=webRequest, - data=VoidPtrToString(data, dataLength)) + data=VoidPtrToBytes(data, dataLength)) except: (exc_type, exc_value, exc_trace) = sys.exc_info() sys.excepthook(exc_type, exc_value, exc_trace) From b070673ba96572f49354b5507822528430525099 Mon Sep 17 00:00:00 2001 From: jonastieppo Date: Thu, 19 Dec 2024 14:41:39 -0300 Subject: [PATCH 230/238] Update README.md (#675) Just updating to the latest version (really minor change). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9175971..f9a76a57 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ also download packages for offline installation available on the [GitHub Releases](../../releases) pages. Command to install with pip: ``` -pip install cefpython3==66.0 +pip install cefpython3==66.1 ``` From 05586d5bd92b9b98f0d96f9d069f8c5b10223e9b Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:06:33 +0100 Subject: [PATCH 231/238] Update README.md --- README.md | 311 +++++++++++++----------------------------------------- 1 file changed, 71 insertions(+), 240 deletions(-) diff --git a/README.md b/README.md index f9a76a57..80bda463 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,12 @@ Table of contents: * [Introduction](#introduction) -* [Latest releases sponsored by](#latest-releases-sponsored-by) - * [Thanks to all sponsors](#thanks-to-all-sponsors) * [Install](#install) -* [Tutorial](#tutorial) * [Examples](#examples) * [Support](#support) -* [Releases](#releases) - * [Next release](#next-release) - * [Latest release](#latest-release) - * [v49 release (WinXP/Vista)](#v49-release-winxpvista) - * [v31 release (old systems)](#v31-release-old-systems) * [Support development](#support-development) - * [Thanks to all](#thanks-to-all) -* [Seeking new sponsors](#seeking-new-sponsors) -* [Other READMEs](#other-readmes) -* [Quick links](#quick-links) +* [Seeking sponsors](#seeking-sponsors) +* [API](#api) ## Introduction @@ -49,39 +39,82 @@ frameworks such as PyQt, wxPython, PyGTK, PyGObject, Tkinter, Kivy, Panda3D, PyGame, PyOpenGL, PyWin32, PySide and PySDL2. -## Latest releases sponsored by +## Install - -
+You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3) +package using pip tool. On Linux pip 8.1+ is required. You can +also download packages for offline installation available on the +[GitHub Releases](../../releases) pages. Command to install with pip: -

- - - -

+``` +pip install cefpython3==66.1 +``` -Thank you to Fivestars for sponsoring the [v66.1 release](../../releases/tag/v66.1) -with Python 3.8 / 3.9 support. Fivestars helps local communities thrive by empowering -small businesses with cutting edge marketing technology. Please visit their website: -Fivestars.com +Below is a table with supported platforms, python versions and architectures. -
+OS | Py2 | Py3 | 32bit | 64bit | Requirements +--- | --- | --- | --- | --- | --- +Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | Yes | Yes | Windows 7+ (Note that Python 3.9 supports Windows 8.1+) +Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ +Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ -

- - - -

-Thank you to Lampix for sponsoring the -[v66 release](../../releases/tag/v66.0). Lampix is the first hardware -and software solution that turns any surface into a smart, augmented reality -or interactive surface. Please visit their website: -Lampix.com +## Examples + +- [Tutorial](docs/Tutorial.md) +- [All examples](examples/README-examples.md). +- [Snippets](examples/snippets/README-snippets.md). +- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md). -
-### Thanks to all sponsors +## Support + +- Ask questions and report problems on the + [Forum](https://groups.google.com/group/cefpython) +- Supported examples are listed in the + [README-examples.md](examples/README-examples.md) file +- Documentation is in the [docs/](docs) directory: + - [Build instructions](docs/Build-instructions.md) + - [Contributing code](docs/Contributing-code.md) + - [Knowledge Base](docs/Knowledge-Base.md) + - [Migration guide](docs/Migration-guide.md) + - [Tutorial](docs/Tutorial.md) +- API reference is in the [api/](api) directory: + - [API categories](api/API-categories.md#api-categories) + - [API index](api/API-index.md#api-index) +- Additional documentation is available in + [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) +- To search documentation use GitHub "This repository" search + at the top. To narrow results to documentation only select + "Markdown" in the right pane. +- You can vote on issues in the tracker to let us know which issues are + important to you. To do that add a +1 thumb up reaction to the first post + in the issue. See + [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) + sorted by reactions. + + +## Support development + +If you would like to support general CEF Python development efforts +by making a donation then please click the Paypal Donate button below. + +
+ +

+ + +## Seeking sponsors + +CEF Python is seeking companies to sponsor development of this project. Most important +thing would be to have continuous monthly releases with updates to latest Chromium. There is +also lots of cool features and new settings that would be nice to implement. We have not yet +exposed all of upstream CEF APIs. If your company would like to sponsor CEF Python development efforts +then please contact [Czarek](https://www.linkedin.com/in/czarektomczak/). There are no active sponsors +at this moment. + + +### Previous sponsors @@ -139,209 +172,7 @@ or interactive surface. Please visit their website:
-## Install - -You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3) -package using pip tool. On Linux pip 8.1+ is required. You can -also download packages for offline installation available on the -[GitHub Releases](../../releases) pages. Command to install with pip: - -``` -pip install cefpython3==66.1 -``` - - -## Tutorial - -See the [Tutorial.md](docs/Tutorial.md) document. - - -## Examples - -See the [README-examples.md](examples/README-examples.md) and -[README-snippets.md](examples/snippets/README-snippets.md) documents. - - -## Support - -- Ask questions and report problems on the - [Forum](https://groups.google.com/group/cefpython) -- Supported examples are listed in the - [README-examples.md](examples/README-examples.md) file -- Documentation is in the [docs/](docs) directory: - - [Build instructions](docs/Build-instructions.md) - - [Contributing code](docs/Contributing-code.md) - - [Knowledge Base](docs/Knowledge-Base.md) - - [Migration guide](docs/Migration-guide.md) - - [Tutorial](docs/Tutorial.md) -- API reference is in the [api/](api) directory: - - [API categories](api/API-categories.md#api-categories) - - [API index](api/API-index.md#api-index) -- Additional documentation is available in - [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) -- To search documentation use GitHub "This repository" search - at the top. To narrow results to documentation only select - "Markdown" in the right pane. -- You can vote on issues in the tracker to let us know which issues are - important to you. To do that add a +1 thumb up reaction to the first post - in the issue. See - [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) - sorted by reactions. - - -## Releases - -Information on planned new and current releases, supported platforms, -python versions, architectures and requirements. If you want to -support old operating systems then choose the v31 release. - -### Next release - -- To see planned new features or bugs to be fixed in the near future in one of - next releases, see the - [next release](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release%22) - label in the tracker -- To see planned new features or bugs to be fixed in further future, see the - [next release 2](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release+2%22) - label in the tracker - -### Latest release - -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | Yes | Yes | Windows 7+ (Note that Python 3.9 supports Windows 8.1+) -Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ -Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ - -These platforms are not supported yet: -- ARM - see [Issue #267](../../issues/267) -- Android - see [Issue #307](../../issues/307) - - -### v49 release (WinXP/Vista) - -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 | Yes | Yes | Windows XP+ - -- Install with command: `pip --no-cache-dir install cefpython3==49.0`. - - Please note that if you were previously installing cefpython3 - package it is required to use the `--no-cache-dir` flag, - otherwise pip will end up with error message - `No matching distribution found for cefpython3==49.0`. - This happens because 49.0 release occured after 57.0 and 66.0 - releases. -- Downloads are available on GitHub Releases tagged - [v49.0](../../releases/tag/v49.0). -- See [Migration guide](docs/Migration-guide.md) document for changes - in this release -- Documentation is available in the [docs/](../../tree/cefpython49-winxp/docs) - directory in the `cefpython49-winxp` branch -- API reference is available in the [api/](../../tree/cefpython49-winxp/api) - directory in the `cefpython49-winxp` branch - - -### v31 release (old systems) - -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | No | Yes | Yes | Windows XP+ -Linux | 2.7 | No | Yes | Yes | Debian 7+ / Ubuntu 12.04+ -Mac | 2.7 | No | Yes | Yes | MacOS 10.7+ - -Additional information for v31.2 release: -- On Windows/Mac you can install with command: `pip install cefpython3==31.2` -- Downloads are available on the GitHub Releases page tagged - [v31.2](../../releases/tag/v31.2). -- API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api) -- Other documentation can be downloaded by cloning the - cefpython.wiki repository: `git clone git@github.com:cztomczak/cefpython.wiki.git` - - -## Support development - -If you would like to support general CEF Python development efforts -by making a donation then please click the Paypal Donate button below. -If you would like to see a specific feature implemented then you can make -a comment about that when making a donation and that will give it a higher -priority. - - - -

- - -### Thanks to all - -* [2021] Thank you to [Fivestars](https://www.fivestars.com/) for sponsoring - the v66.1 release with Python 3.8 / 3.9 support -* [2018] Thanks to [Fivestars](https://www.fivestars.com/) for sponsoring - the v49 release for legacy systems (WinXP/Vista) -* [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 - release for all platforms -* [2017] Many thanks to [HighSide Inc.](https://highside.io/) for sponsoring - the v55/v56 releases for all platforms -* [2016-2018] Thanks to JetBrains for providing an Open Source license for - [PyCharm](https://www.jetbrains.com/pycharm/) -* [2014] Thanks to Adam Duston for donating a Macbook to aid the development - of Mac port -* [2013-2015] Lots of thanks goes to [Cyan Inc.](http://www.blueplanet.com/) - for sponsoring this project for a long time, making CEF Python 3 mature -* [2013] Thanks to [Rentouch GmbH](http://www.rentouch.ch/) for sponsoring the - development of the off-screen rendering support -* [2013] Thanks to Thomas Wusatiuk for sponsoring the development of the web - response reading features -* [2012-2018] Thanks to those who have made a Paypal donation: - [Rentouch GmbH](http://www.rentouch.ch/), Walter Purvis, Rokas Stupuras, - Alex Rattray, Greg Kacy, Paul Korzhyk, Tomasz Tomanek. -* [2012-2017] Thanks to those who have donated their time through code - contributions, they are listed in the [Authors](Authors) file - - -## Seeking new sponsors - -CEF Python is seeking companies to sponsor further development of the project. -There are many proposals for new features submitted in the issue tracker. Most -notable are: - -* Monthly releases with latest Chromium -* An automated build system similar to upstream CEF Spotify Automated Builds -* ARM and Android support -* Multi-threaded support for increased performance -* Proprietary codecs support in build tools: H264, H265,AC3, EAC3, MPEG-4 -* More CEF API exposed, only about 50% is exposed so far -* Hundreds of new settings and Chromium preferences not yet exposed -* Easier integration with popular GUI toolkits in just a few lines of code - and support for more third party GUI frameworks -* More examples of implementing various advanced features and more snippets - as well - -If your company would like to sponsor CEF Python development efforts then -please contact -[Czarek](https://www.linkedin.com/in/czarektomczak/). -Long term sponsorships are welcome and Czarek is open to ideas about -the project. He would love to spend more time on developing this project, -but he can't afford doing so in his free time. Currently there is no company -supporting this project actively on a daily basis. - - -## Other READMEs - -- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md) - - - -## Quick links - -### Docs - -- [Build instructions](docs/Build-instructions.md) -- [Knowledge Base](docs/Knowledge-Base.md) -- [Migration guide](docs/Migration-guide.md) -- [Tutorial](docs/Tutorial.md) - - -### API categories +## API #### Modules From 811fa74c8ef413d5b82371d6d74166e7d5eab47b Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:07:19 +0100 Subject: [PATCH 232/238] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 80bda463..35127ab7 100644 --- a/README.md +++ b/README.md @@ -62,9 +62,9 @@ Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ ## Examples - [Tutorial](docs/Tutorial.md) -- [All examples](examples/README-examples.md). -- [Snippets](examples/snippets/README-snippets.md). -- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md). +- [All examples](examples/README-examples.md) +- [Snippets](examples/snippets/README-snippets.md) +- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md) ## Support From 6c72dc3d093d3eebbee3ff0b79dc58b762f10846 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:11:02 +0100 Subject: [PATCH 233/238] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 35127ab7..2e127e63 100644 --- a/README.md +++ b/README.md @@ -86,13 +86,7 @@ Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) - To search documentation use GitHub "This repository" search at the top. To narrow results to documentation only select - "Markdown" in the right pane. -- You can vote on issues in the tracker to let us know which issues are - important to you. To do that add a +1 thumb up reaction to the first post - in the issue. See - [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) - sorted by reactions. - + "Markdown" in the side pane. ## Support development From 0d3295e05212333f14155f416cc483bd2b2f3e3f Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:12:07 +0100 Subject: [PATCH 234/238] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e127e63..06d3a4e3 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ by making a donation then please click the Paypal Donate button below. -

+
## Seeking sponsors From a6f5def34270b8d64a733597146b98633a7e7dd3 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:17:13 +0100 Subject: [PATCH 235/238] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 06d3a4e3..b6fe4539 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,7 @@ Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ ## Support development -If you would like to support general CEF Python development efforts -by making a donation then please click the Paypal Donate button below. +To support general CEF Python development efforts please make a donation using PayPal button below: From de22be237b20b504eb6bdc385eae436eb12d225b Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:18:30 +0100 Subject: [PATCH 236/238] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6fe4539..755d6299 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ ## Support development -To support general CEF Python development efforts please make a donation using PayPal button below: +To support general CEF Python development efforts you can make a donation using PayPal button below: From 5217c04feaa6b8a4abbcb18bba34ad586e3cecd1 Mon Sep 17 00:00:00 2001 From: Czarek Tomczak Date: Sat, 8 Feb 2025 01:23:50 +0100 Subject: [PATCH 237/238] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 755d6299..4ff688b0 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,16 @@ PyGame, PyOpenGL, PyWin32, PySide and PySDL2. ## Install -You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3) -package using pip tool. On Linux pip 8.1+ is required. You can -also download packages for offline installation available on the -[GitHub Releases](../../releases) pages. Command to install with pip: +Command to install with pip: ``` pip install cefpython3==66.1 ``` +Hosted at [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3). On Linux pip 8.1+ is required. + +You can also download packages for offline installation available on the [GitHub Releases](../../releases) pages. + Below is a table with supported platforms, python versions and architectures. OS | Py2 | Py3 | 32bit | 64bit | Requirements From 3d6f6c19992cb112d6de8ff856bce443bdf3bbea Mon Sep 17 00:00:00 2001 From: Mandru-JashwanthKumar Date: Wed, 26 Nov 2025 10:17:23 +0530 Subject: [PATCH 238/238] Fix formatting of README.md documentation section --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ff688b0..b85f34c6 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) - To search documentation use GitHub "This repository" search at the top. To narrow results to documentation only select - "Markdown" in the side pane. + "Markdown" in the side pane ## Support development