Skip to content

Commit ef401b3

Browse files
committed
Create patches/ and tools/ directories - moved from pycef
1 parent 349db55 commit ef401b3

13 files changed

+2011
-0
lines changed

patches/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+
}

patches/issue125_win_mac_linux

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Patch to Chromium. Fixes HTTPS cache problems on sites with certificate errors:
2+
https://github.com/cztomczak/cefpython/issues/125
3+
4+
Apply the patch in the "chromium/src/net/http/" directory. It modifies
5+
the WriteResponseInfoToEntry() method.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git http_cache_transaction.cc http_cache_transaction.cc
2+
index 9dd8458..e61f1f0 100644
3+
--- http_cache_transaction.cc
4+
+++ http_cache_transaction.cc
5+
@@ -2661,7 +2661,8 @@ int HttpCache::Transaction::WriteResponseInfoToEntry(bool truncated) {
6+
// blocking page is shown. An alternative would be to reverse-map the cert
7+
// status to a net error and replay the net error.
8+
if ((response_.headers->HasHeaderValue("cache-control", "no-store")) ||
9+
- IsCertStatusError(response_.ssl_info.cert_status)) {
10+
+ (!cache_->GetSession()->params().ignore_certificate_errors &&
11+
+ IsCertStatusError(response_.ssl_info.cert_status))) {
12+
DoneWritingToEntry(false);
13+
if (net_log_.IsCapturing())
14+
net_log_.EndEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO);

patches/issue218_linux

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Patch to CEF. Fixes GTK/wxPython issues on Linux:
2+
https://github.com/cztomczak/cefpython/issues/218
3+
4+
Apply the patch in the `cef/libcef/browser/` directory. It modifies
5+
the PlatformCreateWindow() method.

patches/issue218_linux.patch

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Patch to CEF. Fixes tcmalloc issue on Linux:
2+
https://github.com/cztomczak/cefpython/issues/73
3+
4+
Copy the "include.gypi" file to the ~/.gyp/ directory.

patches/patch.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# CEF Python patches to Chromium and CEF.
2+
# See upstream cef/patch/patch.cfg for how patching works in CEF.
3+
# Current working directory is cef_build_dir/chromium/cef/ .
4+
# See also docs/Build-instructions.md and tools/automate.py .
5+
6+
import platform
7+
8+
OS_POSTFIX = ("win" if platform.system() == "Windows" else
9+
"linux" if platform.system() == "Linux" else
10+
"mac" if platform.system() == "Darwin" else "unknown")
11+
12+
patches.append(
13+
{
14+
# Fixes HTTPS cache problems on sites with certificate errors
15+
'name': 'issue125_win_mac_linux',
16+
'path': '../net/http/',
17+
},
18+
)

tools/apidocs.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2016 CEF Python, see the Authors file. All rights reserved.
2+
3+
"""Generate API docs from sources.
4+
5+
The pycef package must be first built and installed before running
6+
this tool. It inspects both Cython sources and the dynamic module.
7+
8+
TODO:
9+
- generate api/ docs from Cython sources
10+
- generate API-index.md, a list of all modules/functions/classes/methods
11+
and constants/global module variables
12+
- generate API-categories.md: objects, handlers, settings, types
13+
(eg. TerminationStatus, KeyEvent, KeyEventFlags)
14+
"""
15+
16+
import os
17+
import sys
18+
import glob
19+
import re
20+
21+
# Constants
22+
API_DIR = os.path.join(
23+
os.path.dirname(os.path.dirname(__file__)),
24+
"api"
25+
)
26+
27+
28+
def main():
29+
"""Main entry point."""
30+
api_index()
31+
32+
33+
def api_index():
34+
"""Generate API-index.md file with all modules/classes/funcs/methods."""
35+
files = glob.glob(os.path.join(API_DIR, "*.md"))
36+
contents = ("[API categories](API-categories.md) | " +
37+
"[API index](API-index.md)\n\n" +
38+
"# API index\n\n")
39+
for file_ in files:
40+
if "API-" in file_:
41+
continue
42+
with open(file_, "rb") as fo:
43+
raw_mdcontents = fo.read()
44+
45+
parsable_mdcontents = re.sub(r"```[\s\S]+?```", "", raw_mdcontents)
46+
allmatches = re.findall(r"^(#|###)\s+(.*)", parsable_mdcontents,
47+
re.MULTILINE)
48+
for allmatch in allmatches:
49+
hlevel = allmatch[0].strip()
50+
title = allmatch[1].strip()
51+
title = title.strip()
52+
if hlevel == "#":
53+
indent = ""
54+
link = os.path.basename(file_)
55+
elif hlevel == "###":
56+
indent = " "
57+
link = os.path.basename(file_) + "#" + headinghash(title)
58+
# hash generation needs complete title. Now we can strip some.
59+
title = re.sub(r"\(.*", r"", title)
60+
else:
61+
assert False, "Heading level unsupported"
62+
contents += (indent + "* " + "[%s](%s)\n" % (title, link))
63+
indexfile = os.path.join(API_DIR, "API-index.md")
64+
with open(indexfile, "wb") as fo:
65+
fo.write(contents)
66+
print("Created %s in %s" % (os.path.basename(indexfile), API_DIR))
67+
print("Done")
68+
69+
70+
def headinghash(title):
71+
"""Get a link hash for a heading H1,H2,H3."""
72+
hash_ = title.lower()
73+
hash_ = re.sub(r"[^a-z0-9_\- ]+", r"", hash_)
74+
hash_ = hash_.replace(" ", "-")
75+
hash_ = re.sub(r"[-]+", r"-", hash_)
76+
hash_ = re.sub(r"-$", r"", hash_)
77+
return hash_
78+
79+
80+
if __name__ == "__main__":
81+
main()

0 commit comments

Comments
 (0)