Skip to content

Commit 34ebd4d

Browse files
committed
Fixed CEF 3 compilation, updated CEF 3 examples to
work after recent API changes. Updated dummy API script. cefpython.SingleMessageLoop() is deprecated, use cefpython.MessageLoopWork() instead.
1 parent 1dad020 commit 34ebd4d

20 files changed

Lines changed: 423 additions & 209 deletions

File tree

cefpython/browser.pyx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# License: New BSD License.
33
# Website: http://code.google.com/p/cefpython/
44

5-
# cef_key_type_t, SendKeyEvent().
6-
KEYTYPE_KEYUP = cef_types.KT_KEYUP
7-
KEYTYPE_KEYDOWN = cef_types.KT_KEYDOWN
8-
KEYTYPE_CHAR = cef_types.KT_CHAR
5+
IF CEF_VERSION == 1:
6+
# cef_key_type_t, SendKeyEvent().
7+
KEYTYPE_KEYUP = cef_types.KT_KEYUP
8+
KEYTYPE_KEYDOWN = cef_types.KT_KEYDOWN
9+
KEYTYPE_CHAR = cef_types.KT_CHAR
910

10-
# cef_mouse_button_type_t, SendMouseClickEvent().
11-
MOUSEBUTTON_LEFT = cef_types.MBT_LEFT
12-
MOUSEBUTTON_MIDDLE = cef_types.MBT_MIDDLE
13-
MOUSEBUTTON_RIGHT = cef_types.MBT_RIGHT
11+
# cef_mouse_button_type_t, SendMouseClickEvent().
12+
MOUSEBUTTON_LEFT = cef_types.MBT_LEFT
13+
MOUSEBUTTON_MIDDLE = cef_types.MBT_MIDDLE
14+
MOUSEBUTTON_RIGHT = cef_types.MBT_RIGHT
1415

1516
# If you try to keep PyBrowser() objects inside cpp_vector you will
1617
# get segmentation faults, as they will be garbage collected.
@@ -56,7 +57,8 @@ cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser):
5657

5758
cdef WindowHandle openerHandle
5859
cdef dict clientCallbacks
59-
cdef JavascriptBindings javascriptBindings
60+
IF CEF_VERSION == 1:
61+
cdef JavascriptBindings javascriptBindings
6062

6163
if pyBrowser.IsPopup() and (
6264
not pyBrowser.GetUserData("__outerWindowHandle")):
@@ -66,9 +68,10 @@ cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser):
6668
clientCallbacks = tempPyBrowser.GetClientCallbacksDict()
6769
if clientCallbacks:
6870
pyBrowser.SetClientCallbacksDict(clientCallbacks)
69-
javascriptBindings = tempPyBrowser.GetJavascriptBindings()
70-
if javascriptBindings.GetBindToPopups():
71-
pyBrowser.SetJavascriptBindings(javascriptBindings)
71+
IF CEF_VERSION == 1:
72+
javascriptBindings = tempPyBrowser.GetJavascriptBindings()
73+
if javascriptBindings.GetBindToPopups():
74+
pyBrowser.SetJavascriptBindings(javascriptBindings)
7275

7376
return pyBrowser
7477

cefpython/cef1/windows/binaries/cefadvanced.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def ExceptHook(type, value, traceObject):
8080
os._exit(1)
8181

8282
def InitDebugging():
83-
# Whether to print & log debug messages, log file is "debug.log".
83+
# Whether to print & log debug messages
8484
if DEBUG:
8585
cefpython.g_debug = True
8686
cefpython.g_debugFile = GetApplicationPath("debug.log")
512 Bytes
Binary file not shown.

cefpython/cef1/windows/binaries/cefwxpanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _createTimer(self):
9494

9595
def _onTimer(self, event):
9696
"""Service CEF message loop"""
97-
cefpython.SingleMessageLoop()
97+
cefpython.MessageLoopWork()
9898

9999
def OnSetFocus(self, event):
100100
cefpython.WindowUtils.OnSetFocus(self.GetHandle(), 0, 0, 0)

cefpython/cef1/windows/binaries/panda3d_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def onMouseWheelDown(self):
306306
self.browser.SendMouseWheelEvent(x, y, deltaX=0, deltaY=-120)
307307

308308
def messageLoop(self, task):
309-
cefpython.SingleMessageLoop()
309+
cefpython.MessageLoopWork()
310310
return Task.cont
311311

312312
def spinCameraTask(self, task):

cefpython/cef1/windows/binaries/pygtk_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def OnTimer(self):
134134

135135
if self.exiting:
136136
return False
137-
cefpython.SingleMessageLoop()
137+
cefpython.MessageLoopWork()
138138
return True
139139

140140
def OnFocusIn(self, widget, data):

cefpython/cef1/windows/binaries/pyqt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ def createTimer(self):
111111
def onTimer(self):
112112
# The proper way of doing message loop should be:
113113
# 1. In createTimer() call self.timer.start(0)
114-
# 2. In onTimer() call SingleMessageLoop() only when
114+
# 2. In onTimer() call MessageLoopWork() only when
115115
# QtGui.QApplication.instance()->hasPendingEvents() returns False.
116116
# But... there is a bug in Qt, hasPendingEvents() returns always true.
117-
cefpython.SingleMessageLoop()
117+
cefpython.MessageLoopWork()
118118

119119
def stopTimer(self):
120-
# Stop the timer after Qt message loop ended, calls to SingleMessageLoop()
120+
# Stop the timer after Qt message loop ended, calls to MessageLoopWork()
121121
# should not happen anymore.
122122
self.timer.stop()
123123

cefpython/cef1/windows/binaries/pyside.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ def createTimer(self):
128128
def onTimer(self):
129129
# The proper way of doing message loop should be:
130130
# 1. In createTimer() call self.timer.start(0)
131-
# 2. In onTimer() call SingleMessageLoop() only when
131+
# 2. In onTimer() call MessageLoopWork() only when
132132
# QtGui.QApplication.instance()->hasPendingEvents() returns False.
133133
# But... there is a bug in Qt, hasPendingEvents() returns always true.
134-
cefpython.SingleMessageLoop()
134+
cefpython.MessageLoopWork()
135135

136136
def stopTimer(self):
137-
# Stop the timer after Qt message loop ended, calls to SingleMessageLoop()
137+
# Stop the timer after Qt message loop ended, calls to MessageLoopWork()
138138
# should not happen anymore.
139139
self.timer.stop()
140140

cefpython/cef1/windows/binaries/wxpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def OnClose(self, event):
9393
self.Destroy()
9494

9595
def OnIdle(self, event):
96-
cefpython.SingleMessageLoop()
96+
cefpython.MessageLoopWork()
9797

9898
class MyApp(wx.App):
9999

cefpython/cef1_api.py

Lines changed: 94 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
def CreateBrowserSync(windowInfo, browserSettings, navigateUrl):
1515
return Browser()
1616

17-
def ExceptHook(type, value, traceObject):
18-
return None
19-
2017
def FormatJavascriptStackTrace(stackTrace):
2118
return ""
2219

@@ -26,9 +23,6 @@ def GetBrowserByWindowHandle(windowHandle):
2623
def GetJavascriptStackTrace(frameLimit=100):
2724
return []
2825

29-
def GetRealPath(file=None, encodeUrl=False):
30-
return ""
31-
3226
def Initialize(applicationSettings={}):
3327
return None
3428

@@ -38,7 +32,7 @@ def IsKeyModifier(key, modifiers):
3832
def MessageLoop():
3933
return None
4034

41-
def SingleMessageLoop():
35+
def MessageLoopWork():
4236
return None
4337

4438
def QuitMessageLoop():
@@ -62,7 +56,7 @@ def Shutdown():
6256
"locale": "",
6357
"locales_dir_path": "",
6458
"log_file": "",
65-
"log_severity": LOGSEVERITY_VERBOSE,
59+
"log_severity": LOGSEVERITY_INFO,
6660
"release_dcheck_enabled": False,
6761
"multi_threaded_message_loop": False,
6862
"pack_loading_disabled": False,
@@ -183,6 +177,12 @@ def GetFrame(self):
183177
def GetFrameNames(self):
184178
return ["", ""]
185179

180+
def GetIdentifier(self):
181+
return 0
182+
183+
def GetImage(self, paintElementType, width, height):
184+
return PaintBuffer()
185+
186186
def GetJavascriptBindings(self):
187187
return JavascriptBindings()
188188

@@ -195,6 +195,9 @@ def GetOpenerWindowHandle(self):
195195
def GetOuterWindowHandle(self):
196196
return 0
197197

198+
def GetSize(self, paintElementType):
199+
return (0,0,)
200+
198201
def GetUserData(self, key):
199202
return None
200203

@@ -219,6 +222,9 @@ def HasDocument(self):
219222
def HidePopup(self):
220223
return None
221224

225+
def Invalidate(self, dirtyRect):
226+
return None
227+
222228
def IsFullscreen(self):
223229
return False
224230

@@ -237,6 +243,24 @@ def Reload(self):
237243
def ReloadIgnoreCache(self):
238244
return None
239245

246+
def SendKeyEvent(self, keyType, keyInfo, modifiers):
247+
return None
248+
249+
def SendMouseClickEvent(self, x, y, mouseButtonType, mouseUp, clickCount):
250+
return None
251+
252+
def SendMouseMoveEvent(self, x, y, mouseLeave):
253+
return None
254+
255+
def SendMouseWheelEvent(self, x, y, deltaX, deltaY):
256+
return None
257+
258+
def SendFocusEvent(self, setFocus):
259+
return None
260+
261+
def SendCaptureLostEvent(self):
262+
return None
263+
240264
def SetClientCallback(self, name, callback):
241265
return None
242266

@@ -249,6 +273,9 @@ def SetFocus(self, enable):
249273
def SetJavascriptBindings(self, javascriptBindings):
250274
return None
251275

276+
def SetSize(self, paintElementType, width, height):
277+
return None
278+
252279
def SetZoomLevel(self, zoomLevel):
253280
return None
254281

@@ -371,9 +398,13 @@ def SetHeaderMap(self, headerMap={}):
371398
def SetHeaderMultimap(self, headerMultimap=[]):
372399
return None
373400

374-
#
375-
# JavascriptBindings class.
376-
#
401+
class PaintBuffer:
402+
403+
def GetIntPointer(self):
404+
return 0
405+
406+
def GetString(self, mode="bgra", origin="top-left"):
407+
return ""
377408

378409
class JavascriptBindings:
379410

@@ -395,10 +426,6 @@ def SetObject(self, name, obj):
395426
def SetProperty(self, name, value):
396427
return None
397428

398-
#
399-
# JavascriptCallback object.
400-
#
401-
402429
class JavascriptCallback:
403430

404431
def Call(self, param1, param2, param3_etc):
@@ -407,6 +434,28 @@ def Call(self, param1, param2, param3_etc):
407434
def GetName(self):
408435
return name
409436

437+
class WindowUtils:
438+
439+
@staticmethod
440+
def OnSetFocus(windowID, msg, wparam, lparam):
441+
return 0
442+
443+
@staticmethod
444+
def OnSize(windowID, msg, wparam, lparam):
445+
return 0
446+
447+
@staticmethod
448+
def OnEraseBackground(windowID, msg, wparam, lparam):
449+
return 0
450+
451+
@staticmethod
452+
def SetTitle(pyBrowser, pyTitle):
453+
return None
454+
455+
@staticmethod
456+
def SetIcon(pyBrowser, icon="inherit"):
457+
return None
458+
410459
#
411460
# DisplayHandler.
412461
#
@@ -726,26 +775,39 @@ def LifespanHandler_OnBeforeClose(browser):
726775
def LifespanHandler_RunModal(browser):
727776
return False
728777

729-
# WindowUtils class.
778+
#
779+
# RenderHandler
780+
#
730781

731-
class WindowUtils:
782+
PET_VIEW = 0
783+
PET_POPUP = 0
732784

733-
@staticmethod
734-
def OnSetFocus(windowID, msg, wparam, lparam):
735-
return 0
785+
KEYTYPE_KEYUP = 0
786+
KEYTYPE_KEYDOWN = 0
787+
KEYTYPE_CHAR = 0
736788

737-
@staticmethod
738-
def OnSize(windowID, msg, wparam, lparam):
739-
return 0
789+
MOUSEBUTTON_LEFT = 0
790+
MOUSEBUTTON_MIDDLE = 0
791+
MOUSEBUTTON_RIGHT = 0
740792

741-
@staticmethod
742-
def OnEraseBackground(windowID, msg, wparam, lparam):
743-
return 0
793+
def RenderHandler_GetViewRect(browser, out_rect):
794+
return False
744795

745-
@staticmethod
746-
def SetTitle(pyBrowser, pyTitle):
747-
return None
796+
def RenderHandler_GetScreenRect(browser, out_rect):
797+
return False
748798

749-
@staticmethod
750-
def SetIcon(pyBrowser, icon="inherit"):
751-
return None
799+
def RenderHandler_GetScreenPoint(browser, viewX, viewY, out_screenCoordinates):
800+
return False
801+
802+
def RenderHandler_OnPopupShow(browser, show):
803+
return None
804+
805+
def RenderHandler_OnPopupSize(browser, rect):
806+
return None
807+
808+
def RenderHandler_OnPaint(browser, paintElementType, out_dirtyRects,
809+
paintBuffer):
810+
return None
811+
812+
def RenderHandler_OnCursorChange(browser, cursor):
813+
return None

0 commit comments

Comments
 (0)