A: ICefView Proc

This commit is contained in:
杨红岩 2023-07-02 22:06:51 +08:00
parent d262364959
commit 7eb11561b8
6 changed files with 102 additions and 9 deletions

View File

@ -107,23 +107,23 @@ func init() {
}
switch fn.(type) {
case BrowserViewComponentOnBrowserCreated:
browserView := &ICefBrowserView{instance: getPtr(1)}
browserView := &ICefBrowserView{&ICefView{instance: getPtr(1)}}
browser := &ICefBrowser{instance: getPtr(2)}
fn.(BrowserViewComponentOnBrowserCreated)(lcl.AsObject(getPtr(0)), browserView, browser)
case BrowserViewComponentOnBrowserDestroyed:
browserView := &ICefBrowserView{instance: getPtr(1)}
browserView := &ICefBrowserView{&ICefView{instance: getPtr(1)}}
browser := &ICefBrowser{instance: getPtr(2)}
fn.(BrowserViewComponentOnBrowserDestroyed)(lcl.AsObject(getPtr(0)), browserView, browser)
case BrowserViewComponentOnGetDelegateForPopupBrowserView:
browserView := &ICefBrowserView{instance: getPtr(1)}
browserView := &ICefBrowserView{&ICefView{instance: getPtr(1)}}
browserSettingsPtr := (*tCefBrowserSettingsPtr)(getPtr(2))
browserSettings := browserSettingsPtr.Convert()
client := &ICefClient{instance: getPtr(3)}
result := &ICefBrowserViewDelegate{instance: getPtr(5)}
fn.(BrowserViewComponentOnGetDelegateForPopupBrowserView)(lcl.AsObject(getPtr(0)), browserView, browserSettings, client, api.GoBool(getVal(4)), result)
case BrowserViewComponentOnPopupBrowserViewCreated:
browserView := &ICefBrowserView{instance: getPtr(1)}
popupBrowserView := &ICefBrowserView{instance: getPtr(2)}
browserView := &ICefBrowserView{&ICefView{instance: getPtr(1)}}
popupBrowserView := &ICefBrowserView{&ICefView{instance: getPtr(2)}}
fn.(BrowserViewComponentOnPopupBrowserViewCreated)(lcl.AsObject(getPtr(0)), browserView, popupBrowserView, api.GoBool(getVal(3)), (*bool)(getPtr(4)))
case BrowserViewComponentOnGetChromeToolbarType:
fn.(BrowserViewComponentOnGetChromeToolbarType)(lcl.AsObject(getPtr(0)), (*consts.TCefChromeToolbarType)(getPtr(1)))

View File

@ -14,5 +14,28 @@ import "unsafe"
// ICefBrowserViewDelegate TODO 未实现
type ICefBrowserViewDelegate struct {
base TCefBaseRefCounted
instance unsafe.Pointer
}
// Instance 实例
func (m *ICefBrowserViewDelegate) Instance() uintptr {
if m == nil {
return 0
}
return uintptr(m.instance)
}
func (m *ICefBrowserViewDelegate) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return m.instance != nil
}
func (m *ICefBrowserViewDelegate) Free() {
if m.instance != nil {
m.base.Free(m.Instance())
m.instance = nil
}
}

View File

@ -19,11 +19,28 @@ import (
"unsafe"
)
func (m *ICefBrowserView) Instance() uintptr {
if m == nil {
return 0
// BrowserViewRef -> ICefBrowserView
var BrowserViewRef browserView
type browserView uintptr
func (*browserView) New(client *ICefClient, url string, browserSettings *TCefBrowserSettings, extraInfo *ICefDictionaryValue, requestContext *ICefRequestContext, delegate *ICefBrowserViewDelegate) *ICefBrowserView {
var browserSettingsPtr = browserSettings.ToPtr()
var result uintptr
imports.Proc(def.CefBrowserViewRef_Create).Call(client.Instance(), api.PascalStr(url), uintptr(unsafe.Pointer(&browserSettingsPtr)), extraInfo.Instance(), requestContext.Instance(), delegate.Instance(), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefBrowserView{&ICefView{instance: unsafe.Pointer(result)}}
}
return uintptr(m.instance)
return nil
}
func (*browserView) GetForBrowser(browser *ICefBrowser) *ICefBrowserView {
var result uintptr
imports.Proc(def.CefBrowserViewRef_GetForBrowser).Call(browser.Instance(), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefBrowserView{&ICefView{instance: unsafe.Pointer(result)}}
}
return nil
}
func (m *ICefBrowserView) Browser() *ICefBrowser {

View File

@ -642,6 +642,10 @@ const (
CEFBrowser_GetRequestContext
CEFBrowserRef_UnWrap
// ICefRequestContext
RequestContextRef_Global
RequestContextRef_New
RequestContextRef_NewTwo
RequestContextRef_Shared
RequestContext_HasPreference
RequestContext_GetPreference
RequestContext_GetAllPreferences
@ -1503,6 +1507,8 @@ const (
CefDownloadItemCallback_Resume
CefDownloadItemCallbackRef_Pause
// ICefBrowserView
CefBrowserViewRef_Create
CefBrowserViewRef_GetForBrowser
CefBrowserView_Browser
CefBrowserView_ChromeToolbar
CefBrowserView_SetPreferAccelerators

View File

@ -642,6 +642,10 @@ func init() {
dllimports.NewEnergyImport("CEFBrowser_GetRequestContext", 0),
dllimports.NewEnergyImport("CEFBrowserRef_UnWrap", 0),
// ICefRequestContext
dllimports.NewEnergyImport("RequestContextRef_Global", 0),
dllimports.NewEnergyImport("RequestContextRef_New", 0),
dllimports.NewEnergyImport("RequestContextRef_NewTwo", 0),
dllimports.NewEnergyImport("RequestContextRef_Shared", 0),
dllimports.NewEnergyImport("RequestContext_HasPreference", 0),
dllimports.NewEnergyImport("RequestContext_GetPreference", 0),
dllimports.NewEnergyImport("RequestContext_GetAllPreferences", 0),
@ -1503,6 +1507,8 @@ func init() {
dllimports.NewEnergyImport("CefDownloadItemCallback_Resume", 0),
dllimports.NewEnergyImport("CefDownloadItemCallbackRef_Pause", 0),
//ICefBrowserView
dllimports.NewEnergyImport("CefBrowserViewRef_Create", 0),
dllimports.NewEnergyImport("CefBrowserViewRef_GetForBrowser", 0),
dllimports.NewEnergyImport("CefBrowserView_Browser", 0),
dllimports.NewEnergyImport("CefBrowserView_ChromeToolbar", 0),
dllimports.NewEnergyImport("CefBrowserView_SetPreferAccelerators", 0),

View File

@ -18,6 +18,47 @@ import (
"unsafe"
)
var RequestContextRef requestContext
type requestContext uintptr
func (*requestContext) Global() *ICefRequestContext {
var result uintptr
imports.Proc(def.RequestContextRef_Global).Call(uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefRequestContext{instance: getInstance(result)}
}
return nil
}
func (*requestContext) New(requestContextSettings *TCefRequestContextSettings, handler *ICefRequestContextHandler) *ICefRequestContext {
requestContextSettingsPtr := requestContextSettings.ToPtr()
var result uintptr
imports.Proc(def.RequestContextRef_New).Call(uintptr(unsafe.Pointer(&requestContextSettingsPtr)), handler.Instance(), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefRequestContext{instance: getInstance(result)}
}
return nil
}
func (*requestContext) NewTwo(cache, acceptLanguageList, cookieableSchemesList string, cookieableSchemesExcludeDefaults, persistSessionCookies, persistUserPreferences bool, handler *ICefRequestContextHandler) *ICefRequestContext {
var result uintptr
imports.Proc(def.RequestContextRef_NewTwo).Call(api.PascalStr(cache), api.PascalStr(acceptLanguageList), api.PascalStr(cookieableSchemesList), api.PascalBool(cookieableSchemesExcludeDefaults), api.PascalBool(persistSessionCookies), api.PascalBool(persistUserPreferences), handler.Instance(), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefRequestContext{instance: getInstance(result)}
}
return nil
}
func (*requestContext) Shared(other *ICefRequestContext, handler *ICefRequestContextHandler) *ICefRequestContext {
var result uintptr
imports.Proc(def.RequestContextRef_Shared).Call(other.Instance(), handler.Instance(), uintptr(unsafe.Pointer(&result)))
if result != 0 {
return &ICefRequestContext{instance: getInstance(result)}
}
return nil
}
// Instance 实例
func (m *ICefRequestContext) Instance() uintptr {
if m == nil {