U: 增加部分CEF49不支持的API条件判断

This commit is contained in:
杨红岩 2024-01-03 19:01:01 +08:00
parent 599b40d1ed
commit 3a66f948ae
4 changed files with 37 additions and 11 deletions

View File

@ -200,12 +200,17 @@ func (m *TCEFApplication) SetMultiThreadedMessageLoop(value bool) {
}
func (m *TCEFApplication) ExternalMessagePump() bool {
r1, _, _ := imports.Proc(def.CEFAppConfig_ExternalMessagePump).Call()
return api.GoBool(r1)
if !m.IsSpecVer49() {
r1, _, _ := imports.Proc(def.CEFAppConfig_ExternalMessagePump).Call()
return api.GoBool(r1)
}
return false
}
func (m *TCEFApplication) SetExternalMessagePump(value bool) {
imports.Proc(def.CEFAppConfig_SetExternalMessagePump).Call(api.PascalBool(value))
if !m.IsSpecVer49() {
imports.Proc(def.CEFAppConfig_SetExternalMessagePump).Call(api.PascalBool(value))
}
}
func (m *TCEFApplication) WindowlessRenderingEnabled() bool {
@ -705,7 +710,9 @@ func (m *TCEFApplication) EnablePrintPreview() bool {
}
func (m *TCEFApplication) SetEnablePrintPreview(value bool) {
imports.Proc(def.CEFAppConfig_SetEnablePrintPreview).Call(api.PascalBool(value))
if !m.IsSpecVer49() {
imports.Proc(def.CEFAppConfig_SetEnablePrintPreview).Call(api.PascalBool(value))
}
}
func (m *TCEFApplication) DefaultEncoding() string {

View File

@ -61,22 +61,38 @@ func (m *BrowserWindow) OnFormCreate(sender lcl.IObject) {
// 3. 触发后将canClose设置为true, 发送消息到主窗口关闭,触发 m.SetOnCloseQuery
m.chromium.SetOnBeforeClose(m.chromiumBeforeClose)
m.chromium.SetOnBeforePopup(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, beforePopupInfo *cef.BeforePopupInfo, popupFeatures *cef.TCefPopupFeatures, windowInfo *cef.TCefWindowInfo, client *cef.ICefClient, browserSettings *cef.TCefBrowserSettings, resultExtraInfo *cef.ICefDictionaryValue, noJavascriptAccess *bool) bool {
m.chromium.SetOnBeforePopup(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, beforePopupInfo *cef.BeforePopupInfo,
popupFeatures *cef.TCefPopupFeatures, windowInfo *cef.TCefWindowInfo, client *cef.ICefClient, browserSettings *cef.TCefBrowserSettings,
resultExtraInfo *cef.ICefDictionaryValue, noJavascriptAccess *bool) bool {
fmt.Println("beforePopupInfo:", beforePopupInfo.TargetUrl, beforePopupInfo.TargetDisposition, beforePopupInfo.TargetFrameName, beforePopupInfo.UserGesture)
fmt.Println(*noJavascriptAccess)
fmt.Println(browser.BrowserId(), frame.Identifier(), frame.Url(), frame.V8Context().Frame().Url())
fmt.Printf("windowInfo: %+v\n", windowInfo)
fmt.Printf("browserSettings: %+v\n", browserSettings)
fmt.Printf("popupFeatures: %+v\n", popupFeatures)
extraInfo := cef.DictionaryValueRef.New()
*resultExtraInfo = *extraInfo
wp := cef.NewWindowProperty()
wp.Url = "https://www.baidu.com"
//window := cef.NewLCLWindow(wp)
//window.Show()
return true
})
//m.chromium.SetOnRenderCompMsg(func(sender lcl.IObject, message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
// fmt.Println("SetOnRenderCompMsg", *lResult, *aHandled)
// //*aHandled = true
//})
m.chromium.SetOnRenderCompMsg(func(sender lcl.IObject, message *types.TMessage, lResult *types.LRESULT, aHandled *bool) {
fmt.Println("SetOnRenderCompMsg", *lResult, *aHandled)
//*aHandled = true
})
m.chromium.SetOnBeforeContextMenu(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, params *cef.ICefContextMenuParams, model *cef.ICefMenuModel) {
fmt.Println("SetOnBeforeContextMenu")
})
m.chromium.SetOnContextMenuCommand(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, params *cef.ICefContextMenuParams, commandId consts.MenuId, eventFlags uint32) bool {
fmt.Println("SetOnContextMenuCommand")
return false
})
m.chromium.SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *cef.ICefBrowser, frame *cef.ICefFrame, request *cef.ICefRequest, callback *cef.ICefCallback, result *consts.TCefReturnValue) {
fmt.Println("SetOnBeforeResourceLoad", frame.Url())
})
}
func (m *BrowserWindow) show(sender lcl.IObject) {

1
go.mod
View File

@ -13,6 +13,7 @@ require (
github.com/godbus/dbus/v5 v5.1.0
github.com/jessevdk/go-flags v1.5.0
github.com/json-iterator/go v1.1.12
github.com/kenshaw/snaker v0.2.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8
github.com/mattn/go-pointer v0.0.1
github.com/pterm/pterm v0.12.66

2
go.sum
View File

@ -53,6 +53,8 @@ github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kenshaw/snaker v0.2.0 h1:DPlxCtAv9mw1wSsvIN1khUAPJUIbFJUckMIDWSQ7TC8=
github.com/kenshaw/snaker v0.2.0/go.mod h1:DNyRUqHMZ18/zioxr6R7m4kSxxf2+QmB0BXoORsXRaY=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=