Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
llcc01 committed Dec 29, 2022
1 parent c39e8d6 commit 576f6ed
Show file tree
Hide file tree
Showing 539 changed files with 87,948 additions and 15,438 deletions.
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:/Program Files/Python311/include/**",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.22621.0",
"cStandard": "c17",
"cppStandard": "c++17"
}
],
"version": 4
}
117 changes: 117 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"files.associations": {
"memory": "cpp",
"__config": "cpp",
"cstddef": "cpp",
"algorithm": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"exception": "cpp",
"filesystem": "cpp",
"format": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory_resource": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"random": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"regex": "cpp",
"scoped_allocator": "cpp",
"set": "cpp",
"span": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"strstream": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"utility": "cpp",
"valarray": "cpp",
"variant": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"__bit_reference": "cpp",
"__bits": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp",
"propagate_const": "cpp",
"string_view": "cpp",
"*.tcc": "cpp",
"cfenv": "cpp"
}
}
4 changes: 2 additions & 2 deletions examples/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
def main():
check_versions()
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
# To change user agent use either "product_version"
# To change user agent use either "user_agent_product"
# or "user_agent" options. Explained in Tutorial in
# "Change user agent string" section.
settings = {
# "product_version": "MyProduct/10.00",
# "user_agent_product": "MyProduct/10.00",
# "user_agent": "MyAgent/20.00 MyProduct/10.00",
}
cef.Initialize(settings=settings)
Expand Down
82 changes: 42 additions & 40 deletions src/browser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser,
provided."""

global g_pyBrowsers

if <void*>cefBrowser == NULL or not cefBrowser.get():
#lc void*
if not cefBrowser.get():
raise Exception("{caller}: CefBrowser reference is NULL"
.format(caller=callerIdStr))

Expand Down Expand Up @@ -148,7 +148,7 @@ cdef void RemovePyBrowser(int browserId) except *:
# noinspection PyUnresolvedReferences
Debug("del g_pyBrowsers[%s]" % browserId)
pyBrowser = g_pyBrowsers[browserId]
pyBrowser.cefBrowser.Assign(NULL)
pyBrowser.cefBrowser.Assign(nullptr)
del pyBrowser
del g_pyBrowsers[browserId]
g_unreferenced_browsers.append(browserId)
Expand Down Expand Up @@ -207,15 +207,17 @@ cdef class PyBrowser:
cdef void* imageBuffer

cdef CefRefPtr[CefBrowser] GetCefBrowser(self) except *:
if <void*>self.cefBrowser != NULL and self.cefBrowser.get():
#lc void*
if self.cefBrowser.get():
return self.cefBrowser
raise Exception("PyBrowser.GetCefBrowser() failed: CefBrowser "
"was destroyed")

cdef CefRefPtr[CefBrowserHost] GetCefBrowserHost(self) except *:
cdef CefRefPtr[CefBrowserHost] cefBrowserHost = (
self.GetCefBrowser().get().GetHost())
if <void*>cefBrowserHost != NULL and cefBrowserHost.get():
#lc void*
if cefBrowserHost.get():
return cefBrowserHost
raise Exception("PyBrowser.GetCefBrowserHost() failed: this "
"method can only be called in the browser "
Expand Down Expand Up @@ -394,9 +396,9 @@ cdef class PyBrowser:
# If using GetCookieManager to implement custom cookie managers
# then flushing of cookies would need to be handled manually.
self.GetCefBrowserHost().get().GetRequestContext().get() \
.GetDefaultCookieManager(
<CefRefPtr[CefCompletionCallback]?>NULL) \
.get().FlushStore(<CefRefPtr[CefCompletionCallback]?>NULL)
.GetCookieManager(
<CefRefPtr[CefCompletionCallback]?>nullptr) \
.get().FlushStore(<CefRefPtr[CefCompletionCallback]?>nullptr)

cdef int browserId = self.GetCefBrowser().get().GetIdentifier()
self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose))
Expand All @@ -413,12 +415,12 @@ cdef class PyBrowser:
py_string scriptUrl="", int startLine=1):
self.GetMainFrame().ExecuteJavascript(jsCode, scriptUrl, startLine)

cpdef py_void Find(self, int searchId, py_string searchText,
cpdef py_void Find(self, py_string searchText,
py_bool forward, py_bool matchCase,
py_bool findNext):
cdef CefString cefSearchText
PyToCefString(searchText, cefSearchText)
self.GetCefBrowserHost().get().Find(searchId, cefSearchText,
self.GetCefBrowserHost().get().Find(cefSearchText,
bool(forward), bool(matchCase), bool(findNext))

cpdef PyFrame GetFocusedFrame(self):
Expand Down Expand Up @@ -581,7 +583,7 @@ cdef class PyBrowser:
cdef CefBrowserSettings settings
cdef CefPoint inspect_element_at
self.GetCefBrowserHost().get().ShowDevTools(
window_info, <CefRefPtr[CefClient]?>NULL, settings,
window_info, <CefRefPtr[CefClient]?>nullptr, settings,
inspect_element_at)

cpdef py_void StopLoad(self):
Expand Down Expand Up @@ -728,8 +730,8 @@ cdef class PyBrowser:
self.GetCefBrowserHost().get().SendMouseWheelEvent(mouseEvent,
deltaX, deltaY)

cpdef py_void SendFocusEvent(self, py_bool setFocus):
self.GetCefBrowserHost().get().SendFocusEvent(bool(setFocus))
# cpdef py_void SendFocusEvent(self, py_bool setFocus):
# self.GetCefBrowserHost().get().SendFocusEvent(bool(setFocus))

cpdef py_void SendCaptureLostEvent(self):
self.GetCefBrowserHost().get().SendCaptureLostEvent()
Expand All @@ -738,12 +740,12 @@ cdef class PyBrowser:
self.GetCefBrowserHost().get().StartDownload(PyToCefStringValue(
url))

cpdef py_void SetMouseCursorChangeDisabled(self, py_bool disabled):
self.GetCefBrowserHost().get().SetMouseCursorChangeDisabled(
bool(disabled))
# cpdef py_void SetMouseCursorChangeDisabled(self, py_bool disabled):
# self.GetCefBrowserHost().get().SetMouseCursorChangeDisabled(
# bool(disabled))

cpdef py_bool IsMouseCursorChangeDisabled(self):
return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled()
# cpdef py_bool IsMouseCursorChangeDisabled(self):
# return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled()

cpdef py_bool TryCloseBrowser(self):
return self.GetCefBrowserHost().get().TryCloseBrowser()
Expand All @@ -757,28 +759,28 @@ cdef class PyBrowser:
cpdef py_void NotifyScreenInfoChanged(self):
self.GetCefBrowserHost().get().NotifyScreenInfoChanged()

cdef void SendProcessMessage(self, cef_process_id_t targetProcess,
object frameId, py_string messageName, list pyArguments
) except *:
cdef CefRefPtr[CefProcessMessage] message = \
CefProcessMessage_Create(PyToCefStringValue(messageName))
# This does not work, no idea why, the CEF implementation
# seems not to allow it, both Assign() and swap() do not work:
# | message.get().GetArgumentList().Assign(arguments.get())
# | message.get().GetArgumentList().swap(arguments)
cdef CefRefPtr[CefListValue] messageArguments = \
message.get().GetArgumentList()
PyListToExistingCefListValue(self.GetIdentifier(), frameId,
pyArguments, messageArguments)
Debug("SendProcessMessage(): message=%s, arguments size=%d" % (
messageName,
message.get().GetArgumentList().get().GetSize()))
cdef cpp_bool success = \
self.GetCefBrowser().get().SendProcessMessage(
targetProcess, message)
if not success:
raise Exception("Browser.SendProcessMessage() failed: "\
"messageName=%s" % messageName)
# cdef void SendProcessMessage(self, cef_process_id_t targetProcess,
# object frameId, py_string messageName, list pyArguments
# ) except *:
# cdef CefRefPtr[CefProcessMessage] message = \
# CefProcessMessage_Create(PyToCefStringValue(messageName))
# # This does not work, no idea why, the CEF implementation
# # seems not to allow it, both Assign() and swap() do not work:
# # | message.get().GetArgumentList().Assign(arguments.get())
# # | message.get().GetArgumentList().swap(arguments)
# cdef CefRefPtr[CefListValue] messageArguments = \
# message.get().GetArgumentList()
# PyListToExistingCefListValue(self.GetIdentifier(), frameId,
# pyArguments, messageArguments)
# Debug("SendProcessMessage(): message=%s, arguments size=%d" % (
# messageName,
# message.get().GetArgumentList().get().GetSize()))
# cdef cpp_bool success = \
# self.GetCefBrowser().get().SendProcessMessage(
# targetProcess, message)
# if not success:
# raise Exception("Browser.SendProcessMessage() failed: "\
# "messageName=%s" % messageName)

# -------------------------------------------------------------------------
# OSR drag & drop
Expand Down
Loading

0 comments on commit 576f6ed

Please sign in to comment.