X Tutup
Skip to content

Commit 62c8c48

Browse files
committed
Code and documentation cleanup PART 3. Added patches/ and version/ dirs.
1 parent c8fdf96 commit 62c8c48

File tree

13 files changed

+213
-2
lines changed

13 files changed

+213
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
__Notes__:
22
* Repository rewritten on 2016-02-15 to reduce its size.
3-
Please clone it again. Issue #103.
3+
Please clone it again.
44
* There is an ongoing big refactoring with code and documentation
55
cleanup. The last stable code is in the cefpython31 branch.
6-
Issue #208.
6+
Use documentation from the Wiki tab, the docs/ directory is still
7+
under works.
78

89
# CEF Python
910

cefpython/base.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2016 The CEF Python authors. All rights reserved.
2+
3+
#pragma once
4+
5+
#define STR_(x) #x
6+
#define STR(x) STR_(x)
7+
8+
#if defined(_WIN32)
9+
#define OS_WIN 1
10+
#define OS_LINUX 0
11+
#define OS_MAC 0
12+
#define OS_POSTFIX "win"
13+
#elif defined(__linux__)
14+
#define OS_WIN 0
15+
#define OS_LINUX 1
16+
#define OS_MAC 0
17+
#define OS_POSTFIX "linux"
18+
#elif defined(__APPLE__)
19+
#define OS_WIN 0
20+
#define OS_LINUX 0
21+
#define OS_MAC 1
22+
#define OS_POSTFIX "mac"
23+
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2016 The CEF Python authors. All rights reserved.
2+
3+
// The cef_version_win.h and other platform dependent headers
4+
// come from CEF binary distributions. These header files are
5+
// generated by CEF during builds.
6+
7+
#pragma once
8+
9+
#include "base.h"
10+
#include "cef_version_" OS_POSTFIX ".h"
11+
12+
#define CEFPYTHON_VERSION_MAJOR 47
13+
#define CEFPYTHON_VERSION_MINOR 0
14+
#define CEFPYTHON_VERSION \
15+
STR(CEFPYTHON_VERSION_MAJOR) "." \
16+
STR(CEFPYTHON_VERSION_MINOR)
17+
18+
// @todo: overwrite during build
19+
// Possible values: "stable", "rc", "alpha"
20+
#define CEFPYTHON_RELEASE_TYPE
21+
22+
// @todo: overwrite during build
23+
#define CEFPYTHON_COMMIT_NUMBER
24+
#define CEFPYTHON_COMMIT_HASH
25+
#define CEFPYTHON_COMMIT_SHORT
26+
27+
#define CHROME_VERSION \
28+
STR(CHROME_VERSION_MAJOR) "." \
29+
STR(CHROME_VERSION_MINOR) "." \
30+
STR(CHROME_VERSION_BUILD) "." \
31+
STR(CHROME_VERSION_PATCH)
32+
#define CHROMIUM_VERSION CHROME_VERSION

patches/Build-CEF-with-patches.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Build CEF with the cefpython patches applied
2+
3+
CEF Python official binaries come with custom CEF binaries
4+
with a few patches applied for our use case.
5+
6+
On Linux before running any CEF tools apply the issue73 patch
7+
first.
8+
9+
To build CEF follow the instructions on the Branches and
10+
Building CEF wiki page:
11+
https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
12+
13+
Use the automate-git.py tool, for example:
14+
```
15+
mkdir chromium && cd chromium
16+
python automate-git.py --download-dir=./ --branch=2526 --no-debug-build --verbose-build --build-log-file
17+
```
18+
19+
After it is built apply patches and rebuild:
20+
```
21+
cd chromium/src
22+
ninja -v -j2 -Cout\Release cefclient
23+
```
24+
25+
## How to patch
26+
27+
Create a patch from unstaged changes in current directory:
28+
```
29+
cd chromium/src/cef/
30+
git diff > cef.gyp.patch
31+
```
32+
33+
Apply a patch in current directory:
34+
```
35+
cd chromium/src/cef/
36+
git apply cef.gyp.patch
37+
```
38+
39+
## Ninja build slowing down computer
40+
41+
If ninja slows down your computer too much, build manually with
42+
this command (where -j2 means to run 2 jobs in parallel)
43+
```
44+
cd chromium/src
45+
ninja -v -j2 -Cout\Release cefclient
46+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Patch to fix HTTPS cache problems on pages with certificate errors:
2+
https://github.com/cztomczak/cefpython/issues/125
3+
4+
Apply the patch in the "chromium/src/" directory.
5+
Modifications are made to the HttpCache::Transaction::
6+
WriteResponseInfoToEntry function.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Index: net/http/http_cache_transaction.cc
2+
===================================================================
3+
--- http_cache_transaction.cc (revision 241641)
4+
+++ http_cache_transaction.cc (working copy)
5+
@@ -2240,7 +2240,8 @@
6+
// reverse-map the cert status to a net error and replay the net error.
7+
if ((cache_->mode() != RECORD &&
8+
response_.headers->HasHeaderValue("cache-control", "no-store")) ||
9+
- net::IsCertStatusError(response_.ssl_info.cert_status)) {
10+
+ (!cache_->GetSession()->params().ignore_certificate_errors &&
11+
+ net::IsCertStatusError(response_.ssl_info.cert_status))) {
12+
DoneWritingToEntry(false);
13+
ReportCacheActionFinish();
14+
if (net_log_.IsLoggingAllEvents())

patches/issue218_linux/PATCH.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fixes to the CEF GTK implementation on Linux:
2+
https://github.com/cztomczak/cefpython/issues/218
3+
4+
Apply the patch in the `~/chromium/src/cef/` directory.
5+
6+
Modifications are made to the CefBrowserHostImpl::
7+
PlatformCreateWindow function.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Index: libcef/browser/browser_host_impl_gtk.cc
2+
===================================================================
3+
--- browser_host_impl_gtk.cc (revision 1639)
4+
+++ browser_host_impl_gtk.cc (working copy)
5+
@@ -273,8 +273,43 @@
6+
7+
// Parent the TabContents to the browser window.
8+
window_info_.widget = web_contents_->GetView()->GetNativeView();
9+
- gtk_container_add(GTK_CONTAINER(window_info_.parent_widget),
10+
- window_info_.widget);
11+
+ if (GTK_IS_BOX(window_info_.parent_widget)) {
12+
+ gtk_box_pack_start(GTK_BOX(window_info_.parent_widget),
13+
+ window_info_.widget, TRUE, TRUE, 0);
14+
+ } else {
15+
+ // Parent view shouldn't contain any children, but in wxWidgets library
16+
+ // there will be GtkPizza widget for Panel or any other control.
17+
+ GList *children, *iter;
18+
+ children = gtk_container_get_children(GTK_CONTAINER(
19+
+ window_info_.parent_widget));
20+
+ GtkWidget* child = NULL;
21+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
22+
+ for (iter = children; iter != NULL; iter = g_list_next(iter)) {
23+
+ child = GTK_WIDGET(iter->data);
24+
+ // We will have to keep a reference to that child that we remove,
25+
+ // otherwise we will get lots of warnings like "invalid unclassed
26+
+ // pointer in cast to `GtkPizza'". First we increase a reference,
27+
+ // we need to do this for a moment before we add this child to the
28+
+ // vbox, then we will decrease that reference.
29+
+ g_object_ref(G_OBJECT(child));
30+
+ gtk_container_remove(GTK_CONTAINER(window_info_.parent_widget), child);
31+
+ }
32+
+ g_list_free(children);
33+
+ gtk_box_pack_start(GTK_BOX(vbox), window_info_.widget, TRUE, TRUE, 0);
34+
+ if (child != NULL) {
35+
+ // This child is packed to the box only so that its reference lives,
36+
+ // as it might be referenced from other code thus resulting in errors.
37+
+ gtk_box_pack_end(GTK_BOX(vbox), child, FALSE, FALSE, 0);
38+
+ gtk_widget_hide(GTK_WIDGET(child));
39+
+ g_object_unref(G_OBJECT(child));
40+
+ }
41+
+ gtk_widget_show(GTK_WIDGET(vbox));
42+
+ if (GTK_IS_SCROLLED_WINDOW(window_info_.parent_widget))
43+
+ gtk_scrolled_window_add_with_viewport(
44+
+ GTK_SCROLLED_WINDOW(window_info_.parent_widget), vbox);
45+
+ else
46+
+ gtk_container_add(GTK_CONTAINER(window_info_.parent_widget), vbox);
47+
+ }
48+
49+
g_signal_connect(G_OBJECT(window_info_.widget), "destroy",
50+
G_CALLBACK(browser_destroy), this);
51+
@@ -293,6 +328,8 @@
52+
prefs->inactive_selection_bg_color = SkColorSetRGB(200, 200, 200);
53+
prefs->inactive_selection_fg_color = SkColorSetRGB(50, 50, 50);
54+
55+
+ gtk_widget_show_all(GTK_WIDGET(window_info_.widget));
56+
+
57+
return true;
58+
}

patches/issue73_linux/PATCH.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Patch to fix tcmalloc issue on Linux:
2+
https://github.com/cztomczak/cefpython/issues/73
3+
4+
You have two options:
5+
1. Copy `include.gypi` to `~/.gyp/`.
6+
2. Or run the `use_allocator_none.sh` script - this will set
7+
the GYP_DEFINES env variable, but it will last only for
8+
current session.

patches/issue73_linux/include.gypi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
'variables': {
3+
'use_allocator': 'none',
4+
},
5+
}

0 commit comments

Comments
 (0)
X Tutup