Skip to content

Commit 62cc77a

Browse files
committed
Code and documentation cleanup PART 1.
1 parent f239f52 commit 62cc77a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+5753
-95
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ svn-win32-1.8.5
33
cefpython.wiki
44
.tags*
55
/cython-version.*
6+
.idea/
File renamed without changes.

README.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# CEF Python
22

33
Table of contents:
4-
* [Introduction](#introduction)
5-
* [Supported Python versions and platforms](#supported-python-versions-and-platforms)
6-
* [Downloads](#downloads)
7-
* [Help and documentation](#help-and-documentation)
8-
* [Support development](#support-development)
9-
* [Thanks](#thanks)
4+
* [Introduction](#introduction)
5+
* [Supported Python versions and platforms](#supported-python-versions-and-platforms)
6+
* [Downloads](#downloads)
7+
* [Help and documentation](#help-and-documentation)
8+
* [Support development](#support-development)
9+
* [Thanks](#thanks)
1010

1111
## Introduction
1212

@@ -34,25 +34,17 @@ Some use cases for CEF:
3434

3535
* See the [Help and search](../../wiki/Help-and-search) wiki page
3636
* Documentation and API is available on [Wiki Pages](../../wiki)
37-
* Please do not use the [Issue Tracker](../../issues) for asking questions
37+
* Please do not use the Issue Tracker for asking questions. Use the
38+
[Forum](https://groups.google.com/group/cefpython).
3839

3940
## Support development
4041

41-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=95W9VHNSFWRUN"><img align="right" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif"></img></a> If you are interested in donating time to help with the CEF Python development please see the [Internal development](../../wiki/InternalDevelopment) wiki page. If you would like to support general CEF Python development efforts by making a donation please click the Paypal "Donate" button to the right. At this time CEF Python is unable to accept donations that sponsor the development of specific features. If you are interested in sponsorship opportunities please contact Czarek directly.
42-
43-
### Thanks
44-
45-
* Thanks to the numerous individuals that made a Paypal donation: Walter Purvis, Rokas Stupuras, Alex Rattray, Greg Kacy, Paul Korzhyk.
46-
* Thanks to those that have donated their time through code contributions: see the [AUTHORS.txt](../master/cefpython/AUTHORS.txt) file. Patches can be attached in the issue tracker.
47-
* <a href="http://www.cyaninc.com/"><img align="right" width="200" height="42" src="https://raw.githubusercontent.com/cztomczak/cefpython/master/cefpython/var/cyan_new_logo.png"></img></a>Many thanks to [Cyan Inc.](http://www.cyaninc.com/) for sponsoring this project, making CEF Python 3 more mature. Lots of new features were added, including javascript bindings and Linux support.
48-
* Thanks to [Rentouch GmbH](http://www.rentouch.ch/) for sponsoring the development of the off-screen rendering support in CEF Python 3.
49-
* Thanks to Thomas Wusatiuk for sponsoring the development of the web response reading features in CEF Python 3.
50-
* Thanks to Adam Duston for donating a Macbook to aid the development of the Mac port.
42+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=95W9VHNSFWRUN"><img align="right" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif"></img></a> If you are interested in donating time to help with the CEF Python development please see the [Internal development](../../wiki/InternalDevelopment) wiki page. If you would like to support general CEF Python development efforts by making a donation see the [Donations](docs/Donations.md) page. At this time CEF Python is unable to accept donations that sponsor the development of specific features. If you are interested in sponsorship opportunities please contact Czarek directly.
5143

5244
## Built a cool app?
5345

5446
Built a cool app using CEF Python and would like to share info with the community? Talk about it on the [CEF Python Forum](https://groups.google.com/group/cefpython).
5547

56-
## Familiar with PHP or Go?
48+
## CEF bindings for other languages
5749

5850
The author of CEF Python is also working on CEF bindings for other languages such as PHP and Go. For PHP take a look at the [PHP Desktop](https://github.com/cztomczak/phpdesktop) project. For Go see the [CEF2go](https://github.com/cztomczak/cef2go) project on GitHub.

cefpython/cefpython.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
# CEF threading, see topic at cython-users for more details:
2929
# https://groups.google.com/d/msg/cython-users/CRxWoX57dnM/aufW3gXMhOUJ.
3030
#
31+
# - Note that acquiring the GIL is a blocking thread-synchronising operation,
32+
# and therefore potentially costly. It might not be worth releasing the GIL
33+
# for minor calculations. Usually, I/O operations and substantial
34+
# computations in parallel code will benefit from it.
35+
#
36+
# - In regards to GIL locks see Issue #102 "Remove GIL to avoid deadlocks when
37+
# calling CEF functions".
38+
#
3139
# - CTags requires all functions/methods imported in .pxd files to be preceded with "cdef",
3240
# otherwise they are not indexed.
3341
#

cefpython/frame.pyx

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ cdef class PyFrame:
7777
self.browserId = browserId
7878
self.frameId = frameId
7979

80-
IF CEF_VERSION == 3:
81-
cpdef py_bool IsValid(self):
82-
if <void*>self.cefFrame != NULL and self.cefFrame.get() \
83-
and self.cefFrame.get().IsValid():
84-
return True
85-
return False
80+
cpdef py_bool IsValid(self):
81+
if <void*>self.cefFrame != NULL and self.cefFrame.get() \
82+
and self.cefFrame.get().IsValid():
83+
return True
84+
return False
8685

8786
def CallFunction(self, *args):
8887
# DEPRECATED - keep for backwards compatibility.
@@ -97,13 +96,12 @@ cdef class PyFrame:
9796
cpdef py_void Delete(self):
9897
self.GetCefFrame().get().Delete()
9998

100-
def ExecuteFunction(self, *args):
99+
def ExecuteFunction(self, funcName, *args):
101100
# No need to enter V8 context as we're calling javascript
102101
# asynchronously using ExecuteJavascript() function.
103-
funcName = args[0]
104102
code = funcName+"("
105-
for i in range(1, len(args)):
106-
if i != 1:
103+
for i in range(0, len(args)):
104+
if i != 0:
107105
code += ", "
108106
code += json.dumps(args[i])
109107
code += ")"
@@ -122,55 +120,33 @@ cdef class PyFrame:
122120
# may or may not include GetIdentifier() method, but let's be sure.
123121
return self.frameId
124122

123+
cpdef PyFrame GetParent(self):
124+
return GetPyFrame(self.GetCefFrame().get().GetParent())
125+
126+
cpdef PyBrowser GetBrowser(self):
127+
return GetPyBrowser(self.GetCefFrame().get().GetBrowser())
128+
125129
cpdef int GetBrowserIdentifier(self) except *:
126130
return self.browserId
127131

128132
cpdef str GetName(self):
129133
return CefToPyString(self.GetCefFrame().get().GetName())
130134

131-
IF CEF_VERSION == 1:
132-
cpdef object GetProperty(self, py_string name):
133-
assert IsThread(TID_UI), (
134-
"Frame.GetProperty() may only be called on the UI thread")
135-
cdef CefRefPtr[CefV8Context] v8Context = self.GetCefFrame().get().GetV8Context()
136-
cdef CefRefPtr[CefV8Value] window = v8Context.get().GetGlobal()
137-
cdef CefString cefPropertyName
138-
PyToCefString(name, cefPropertyName)
139-
cdef CefRefPtr[CefV8Value] v8Value = window.get().GetValue(cefPropertyName)
140-
return V8ToPyValue(v8Value, v8Context)
141-
142-
cpdef str GetSource(self):
143-
assert IsThread(TID_UI), (
144-
"Frame.GetSource() may only be called on the UI thread")
145-
return CefToPyString(self.GetCefFrame().get().GetSource())
146-
147-
cpdef str GetText(self):
148-
assert IsThread(TID_UI), (
149-
"Frame.GetText() may only be called on the UI thread")
150-
return CefToPyString(self.GetCefFrame().get().GetText())
151-
152-
IF CEF_VERSION == 3:
153-
cpdef py_void GetSource(self, object userStringVisitor):
154-
self.GetCefFrame().get().GetSource(CreateStringVisitor(userStringVisitor))
155-
156-
cpdef py_void GetText(self, object userStringVisitor):
157-
self.GetCefFrame().get().GetText(CreateStringVisitor(userStringVisitor))
135+
cpdef py_void GetSource(self, object visitor):
136+
self.GetCefFrame().get().GetSource(CreateStringVisitor(visitor))
137+
138+
cpdef py_void GetText(self, object visitor):
139+
self.GetCefFrame().get().GetText(CreateStringVisitor(visitor))
158140

159141
cpdef str GetUrl(self):
160142
return CefToPyString(self.GetCefFrame().get().GetURL())
161143

162144
cpdef py_bool IsFocused(self):
163-
IF CEF_VERSION == 1:
164-
assert IsThread(TID_UI), (
165-
"Frame.IsFocused() may only be called on the UI thread")
166145
return self.GetCefFrame().get().IsFocused()
167146

168147
cpdef py_bool IsMain(self):
169148
return self.GetCefFrame().get().IsMain()
170149

171-
cpdef py_void LoadRequest(self):
172-
pass
173-
174150
cpdef py_void LoadString(self, py_string value, py_string url):
175151
cdef CefString cefValue
176152
cdef CefString cefUrl
@@ -187,48 +163,14 @@ cdef class PyFrame:
187163
cpdef py_void Paste(self):
188164
self.GetCefFrame().get().Paste()
189165

190-
IF CEF_VERSION == 1:
191-
cpdef py_void Print(self):
192-
self.GetCefFrame().get().Print()
193-
194166
cpdef py_void Redo(self):
195167
self.GetCefFrame().get().Redo()
196168

197169
cpdef py_void SelectAll(self):
198170
self.GetCefFrame().get().SelectAll()
199171

200-
IF CEF_VERSION == 1:
201-
cpdef py_void SetProperty(self, py_string name, object value):
202-
assert IsThread(TID_UI), (
203-
"Frame.SetProperty() may only be called on the UI thread")
204-
if not JavascriptBindings.IsValueAllowed(value):
205-
valueType = JavascriptBindings.__IsValueAllowed(value)
206-
raise Exception("Frame.SetProperty() failed: name=%s, "
207-
"not allowed type: %s (this may be a type of a nested value)"
208-
% (name, valueType))
209-
cdef CefRefPtr[CefV8Context] v8Context = self.GetCefFrame().get().GetV8Context()
210-
cdef CefRefPtr[CefV8Value] window = v8Context.get().GetGlobal()
211-
cdef CefString cefPropertyName
212-
PyToCefString(name, cefPropertyName)
213-
cdef cpp_bool sameContext = v8Context.get().IsSame(cef_v8_static.GetCurrentContext())
214-
if not sameContext:
215-
Debug("Frame.SetProperty(): inside a different context, calling v8Context.Enter()")
216-
assert v8Context.get().Enter(), "v8Context.Enter() failed"
217-
window.get().SetValue(
218-
cefPropertyName,
219-
PyToV8Value(value, v8Context),
220-
V8_PROPERTY_ATTRIBUTE_NONE)
221-
if not sameContext:
222-
assert v8Context.get().Exit(), "v8Context.Exit() failed"
223-
224172
cpdef py_void Undo(self):
225173
self.GetCefFrame().get().Undo()
226174

227175
cpdef py_void ViewSource(self):
228176
self.GetCefFrame().get().ViewSource()
229-
230-
cpdef PyFrame GetParent(self):
231-
return GetPyFrame(self.GetCefFrame().get().GetParent())
232-
233-
cpdef PyBrowser GetBrowser(self):
234-
return GetPyBrowser(self.GetCefFrame().get().GetBrowser())

docs/API.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# API
2+
3+
### Settings
4+
5+
* [ApplicationSettings](ApplicationSettings) dictionary
6+
* [BrowserSettings](BrowserSettings) dictionary
7+
* [CommandLineSwitches](CommandLineSwitches) dictionary
8+
9+
### Objects
10+
11+
* [Browser](Browser) object
12+
* [Callback](Callback) object
13+
* [ContentFilter](ContentFilter) object
14+
* [Cookie](Cookie) class
15+
* [CookieManager](CookieManager) class
16+
* [DpiAware](DpiAware) class (Win)
17+
* [DragData](DragData) object
18+
* [Frame](Frame) object
19+
* [JavascriptBindings](JavascriptBindings) class
20+
* [JavascriptCallback](JavascriptCallback) object
21+
* [PaintBuffer](PaintBuffer) object
22+
* [Request](Request) class
23+
* [Response](Response) object
24+
* [StreamReader](StreamReader) object
25+
* [WebPluginInfo](WebPluginInfo) object
26+
* [WebRequest](WebRequest) class
27+
* [WindowInfo](WindowInfo) class
28+
* [WindowUtils](WindowUtils) class
29+
30+
### Handlers
31+
32+
* [DisplayHandler](DisplayHandler)
33+
* [DownloadHandler](DownloadHandler)
34+
* [DragHandler](DragHandler)
35+
* [JavascriptContextHandler](JavascriptContextHandler)
36+
* [JavascriptDialogHandler](JavascriptDialogHandler)
37+
* [KeyboardHandler](KeyboardHandler)
38+
* [LifespanHandler](LifespanHandler)
39+
* [LoadHandler](LoadHandler)
40+
* [RenderHandler](RenderHandler)
41+
* [RequestHandler](RequestHandler)
42+
* [ResourceHandler](ResourceHandler)
43+
44+
### Modules
45+
46+
* [cefpython](cefpython) module

docs/Audio-and-Video.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Audio and Video support
2+
3+
### Preface
4+
5+
CEF supports WebM & Ogg Theora video codecs. MPEG-4 & H.264
6+
are proprietary codecs and are not included in Chromium builds,
7+
as there are [licensing issues](https://bitbucket.org/chromiumembedded/cef/issues/371/cannot-play-proprietary-audio-or-video):
8+
9+
> Codecs like MP3 and AAC are included in Google Chrome releases but
10+
> not Chromium builds. This is because these formats are not open and
11+
> require licensing. Distributing these codecs with your application
12+
> without a licensing agreement may violate the law in certain countries.
13+
> You should discuss with a lawyer if appropriate.
14+
15+
### Audio support
16+
17+
Open [html5test.com](http://html5test.com/) and see the Audio section. Results as of CEF v47:
18+
19+
```
20+
audio element Yes ✔
21+
Loop audio Yes ✔
22+
Preload in the background Yes ✔
23+
Web Audio API Yes ✔
24+
Speech Recognition Prefixed ✔
25+
Speech Synthesis Yes ✔
26+
PCM audio support Yes ✔
27+
AAC support No ✘
28+
MP3 support No ✘
29+
Ogg Vorbis support Yes ✔
30+
Ogg Opus support Yes ✔
31+
WebM with Vorbis support Yes ✔
32+
WebM with Opus support Yes ✔
33+
```
34+
35+
### Video support
36+
37+
Open [html5test.com](http://html5test.com/) and see the Video section. Results as of CEF v47:
38+
```
39+
video element Yes ✔
40+
Subtitles Yes ✔
41+
Audio track selection No ✘
42+
Video track selection No ✘
43+
Poster images Yes ✔
44+
Codec detection Yes ✔
45+
DRM support Yes ✔
46+
Media Source extensions Yes ✔
47+
MPEG-4 ASP support No ✘
48+
H.264 support No ✘
49+
Ogg Theora support Yes ✔
50+
WebM with VP8 support Yes ✔
51+
WebM with VP9 support Yes ✔
52+
```

docs/Donations.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Donations
2+
3+
CEF Python is an open source project founded by [Czarek Tomczak](http://www.linkedin.com/in/czarektomczak) in 2012 to provide python bindings for the [Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef). If you would like to support general CEF Python development efforts by making a donation please click the Paypal "Donate" button below:
4+
5+
<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=95W9VHNSFWRUN'><img src='https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif' /></a>
6+
7+
At this time CEF Python is unable to accept donations that sponsor the development of specific features. If you are interested in sponsorship opportunities please contact Czarek directly.
8+
9+
## Thanks
10+
11+
* Thanks to the numerous individuals that made a Paypal donation:
12+
Walter Purvis, Rokas Stupuras, Alex Rattray, Greg Kacy, Paul Korzhyk.
13+
* Thanks to those that have donated their time through code contributions.
14+
See the [AUTHORS.txt](../AUTHORS.txt) file.
15+
* <a href="http://www.cyaninc.com/"><img align="right" width="200" height="42" src="https://raw.githubusercontent.com/cztomczak/cefpython/master/cefpython/var/cyan_new_logo.png"></img></a>Many thanks to [Cyan Inc.](http://www.cyaninc.com/) for sponsoring this project, making CEF Python 3 more mature. Lots of new features were added, including javascript bindings and Linux support.
16+
* Thanks to [Rentouch GmbH](http://www.rentouch.ch/) for sponsoring the
17+
development of the off-screen rendering support in CEF Python 3.
18+
* Thanks to Thomas Wusatiuk for sponsoring the development of the web
19+
response reading features in CEF Python 3.
20+
* Thanks to Adam Duston for donating a Macbook to aid the development
21+
of the Mac port.

docs/Help-and-search.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Documentation and API is available on [Wiki Pages](../wiki).
2+
3+
### Questions and problems
4+
5+
Ask questions and report problems on the ![CEF Python Forum](https://www.google.com/images/icons/material/product/1x/groups_24dp.png)
6+
[CEF Python Forum](https://groups.google.com/d/forum/cefpython).
7+
8+
See also the <img src="https://cdn.sstatic.net/stackoverflow/img/favicon.ico" width="24" height="24"> [cefpython](http://stackoverflow.com/questions/tagged/cefpython) tag on StackOverflow.
9+
10+
Before creating an issue in the tracker it is best to discuss it first on the Forum. When creating issue include information like: OS, Python version, library version (wxPython etc), cefpython version and say which example you're running (try to reproduce your issue with one of official cefpython examples).
11+
12+
### Search
13+
14+
Search through wiki pages with the ![Github](https://www.google.com/images/icons/product/chrome_web_store-24.png) [Github Wiki Search](https://github.com/linyows/github-wiki-search) plugin.
15+
16+
You can find many useful information on the ![CEF Python Forum](https://www.google.com/images/icons/material/product/1x/groups_24dp.png) [CEF Python Forum](https://groups.google.com/d/forum/cefpython).
17+
18+
Try searching in <img alt="CEF Python issues" src="https://github.com/favicon.ico" width="24" height="24"> [All Issues](https://github.com/cztomczak/cefpython/issues?utf8=%E2%9C%93&q=is%3Aissue).
19+
20+
Another option for wiki search is to use <img src="https://www.google.com/images/icons/product/search-32.png" width="24" height="24"> Google: [**site**:github.com/cztomczak/cefpython/wiki/](https://www.google.com/search?q=site%3Agithub.com%2Fcztomczak%2Fcefpython%2Fwiki%2F&hl=en&gfe_rd=cr&gws_rd=cr).
21+
22+
Try also searching upstream ![CEF Forum](https://www.google.com/images/icons/product/chrome-24.png) [CEF Forum](http://magpcss.org/ceforum/) - a valuable resource of information.
23+
24+
You can search upstream <img alt="CEF Issues" src="https://bitbucket.org/favicon.ico" width="24" height="24"> [CEF Issues](https://bitbucket.org/chromiumembedded/cef/issues) as well.
25+
26+
## Knowledge Base
27+
28+
See the [Knowledge Base](KnowledgeBase) wiki page.
29+
30+
## Contributing
31+
32+
Not looking for help, but instead want to help? Great, read further.
33+
34+
1. Subscribe to [Forum](https://groups.google.com/d/forum/cefpython) updates by setting membership settings to send Daily summaries via email - help other users solve problems.
35+
36+
2. Subscribe to be notified of new [cefpython](http://stackoverflow.com/questions/tagged/cefpython) tagged questions on StackOverflow through [RSS feed](http://stackoverflow.com/feeds/tag/cefpython) or by enabling email subscritpion through [Tag Sets](http://blog.stackoverflow.com/2010/11/tag-sets-on-stack-exchange/).
37+
38+
3. Anyone can edit Wiki Pages - help us improve documentation. Besides the built-in online editor you can also clone wiki locally (use git clone for [this url](https://github.com/cztomczak/cefpython.wiki.git)) and easily edit markdown pages with [Atom editor](https://atom.io/) and the [markdown-preview](https://atom.io/packages/markdown-preview) plugin (ctrl+shift+m to preview, also set live preview and split pane in settings).
39+
40+
Want to do some more? Read On!
41+
42+
4. See the [good first issue](https://github.com/cztomczak/cefpython/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) and [help wanted](https://github.com/cztomczak/cefpython/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) labeled issues. These are Good First Issues for anyone who knows any of: Python, Git, Unit testing, CI builds or just plain English (documentation help). No need to know obfuscated languages like Cython/C/C++ and you still can help.
43+
44+
5. If you are interested in donating time to help with the CEF Python development (Cython/C/C++ skills) please see the [Internal development](InternalDevelopment) wiki page.

0 commit comments

Comments
 (0)