mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 03:37:48 +08:00
U: 修改CEFFrame返回字符串API使用TString
修改OnBeforePopup回调函数browserSettings结构引用 调整TString增加As函数
This commit is contained in:
parent
28b493bcd9
commit
462bc4a52a
@ -46,7 +46,7 @@ func (m *ICefBrowser) createBrowserViewSource() {
|
||||
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
|
||||
})
|
||||
}
|
||||
viewSourceWindow.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool {
|
||||
viewSourceWindow.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, settings *TCefBrowserSettings, noJavascriptAccess *bool) bool {
|
||||
wp := NewWindowProperty()
|
||||
wp.Url = beforePopupInfo.TargetUrl
|
||||
wp.Title = beforePopupInfo.TargetUrl
|
||||
|
@ -566,7 +566,9 @@ func (m *LCLBrowserWindow) ChromiumCreate(config *TCefChromiumConfig, defaultUrl
|
||||
config = NewChromiumConfig()
|
||||
}
|
||||
m.chromiumBrowser = NewChromiumBrowser(m, config)
|
||||
m.Chromium().SetEnableMultiBrowserMode(true)
|
||||
if !application.IsSpecVer49() {
|
||||
m.Chromium().SetEnableMultiBrowserMode(true)
|
||||
}
|
||||
|
||||
if defaultUrl != "" {
|
||||
m.Chromium().SetDefaultURL(defaultUrl)
|
||||
@ -1015,7 +1017,7 @@ func (m *LCLBrowserWindow) registerPopupEvent() {
|
||||
}
|
||||
return false
|
||||
})
|
||||
m.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool {
|
||||
m.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, settings *TCefBrowserSettings, noJavascriptAccess *bool) bool {
|
||||
if !m.Chromium().Config().EnableWindowPopup() {
|
||||
return true
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ func (m *ViewsFrameworkBrowserWindow) registerPopupEvent(isMain bool) {
|
||||
}
|
||||
return false
|
||||
})
|
||||
m.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool {
|
||||
m.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, settings *TCefBrowserSettings, noJavascriptAccess *bool) bool {
|
||||
if !m.Chromium().Config().EnableWindowPopup() {
|
||||
return true
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ package cef
|
||||
|
||||
import (
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
)
|
||||
|
||||
// ICEFChromiumBrowser
|
||||
@ -47,6 +48,9 @@ func NewChromiumBrowser(owner lcl.IWinControl, config *TCefChromiumConfig) ICEFC
|
||||
m.windowParent = NewCEFWindowParent(owner)
|
||||
m.windowParent.SetParent(owner)
|
||||
m.windowParent.SetChromium(m.chromium, 0)
|
||||
m.windowParent.SetWidth(100)
|
||||
m.windowParent.SetHeight(100)
|
||||
m.windowParent.SetAlign(types.AlNone)
|
||||
m.createTimer = lcl.NewTimer(owner)
|
||||
m.createTimer.SetInterval(200)
|
||||
m.createTimer.SetOnTimer(m.checkAndCreateBrowser)
|
||||
|
@ -876,14 +876,15 @@ func init() {
|
||||
var (
|
||||
//windowInfo = getPtr(4) // not use
|
||||
//resultClientPtr = (*uintptr)(getPtr(5))
|
||||
client = &ICefClient{instance: getPtr(5)}
|
||||
//setting = getPtr(6)
|
||||
//extra_info = getPtr(7)
|
||||
client = &ICefClient{instance: getPtr(5)}
|
||||
browserSettingsPtr = (*tCefBrowserSettingsPtr)(getPtr(6))
|
||||
//extra_info = getPtr(7) // CEF49 = nil
|
||||
noJavascriptAccess = (*bool)(getPtr(8))
|
||||
result = (*bool)(getPtr(9))
|
||||
)
|
||||
//callback
|
||||
*result = fn.(chromiumEventOnBeforePopup)(lcl.AsObject(sender), browse, frame, beforePopupInfo, client, noJavascriptAccess)
|
||||
browserSettings := browserSettingsPtr.Convert()
|
||||
*result = fn.(chromiumEventOnBeforePopup)(lcl.AsObject(sender), browse, frame, beforePopupInfo, client, browserSettings, noJavascriptAccess)
|
||||
browserSettings.SetInstanceValue()
|
||||
case chromiumEventOnOpenUrlFromTab:
|
||||
sender := getPtr(0)
|
||||
browse := &ICefBrowser{instance: getPtr(1)}
|
||||
|
@ -166,7 +166,7 @@ type chromiumEventOnFrameCreated func(sender lcl.IObject, browser *ICefBrowser,
|
||||
type chromiumEventOnFrameDetached func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame)
|
||||
type chromiumEventOnMainFrameChanged func(sender lcl.IObject, browser *ICefBrowser, oldFrame *ICefFrame, newFrame *ICefFrame)
|
||||
type chromiumEventOnMainFrameChangedEx func(sender lcl.IObject, browser *ICefBrowser, oldFrame *ICefFrame, newFrame *ICefFrame, window IBrowserWindow)
|
||||
type chromiumEventOnBeforePopup func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, noJavascriptAccess *bool) bool
|
||||
type chromiumEventOnBeforePopup func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, client *ICefClient, settings *TCefBrowserSettings, noJavascriptAccess *bool) bool
|
||||
type chromiumEventOnBeforePopupEx func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, popupWindow IBrowserWindow, noJavascriptAccess *bool) bool
|
||||
type chromiumEventOnOpenUrlFromTab func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, targetUrl string, targetDisposition consts.TCefWindowOpenDisposition, userGesture bool) bool
|
||||
type chromiumEventOnDragEnter func(sender lcl.IObject, browser *ICefBrowser, dragData *ICefDragData, mask consts.TCefDragOperations, result *bool)
|
||||
|
@ -8,8 +8,8 @@
|
||||
//
|
||||
//----------------------------------------
|
||||
|
||||
// energy => pascal string
|
||||
// 字符串引用, 用于在取string时字节指针失效
|
||||
// energy go string => pascal string
|
||||
// 字符串引用, 用于读取string值
|
||||
|
||||
package cef
|
||||
|
||||
@ -26,7 +26,8 @@ type TString struct {
|
||||
}
|
||||
|
||||
// IsValid
|
||||
// return true if created
|
||||
//
|
||||
// return true if created
|
||||
func (m *TString) IsValid() bool {
|
||||
if m == nil || m.instance == nil {
|
||||
return false
|
||||
@ -35,8 +36,9 @@ func (m *TString) IsValid() bool {
|
||||
}
|
||||
|
||||
// Value
|
||||
// get string pointer, string length
|
||||
// bytes copy
|
||||
//
|
||||
// get string pointer, string length
|
||||
// bytes copy
|
||||
func (m *TString) Value() string {
|
||||
if !m.IsValid() {
|
||||
return ""
|
||||
@ -54,7 +56,8 @@ func (m *TString) Value() string {
|
||||
}
|
||||
|
||||
// Free
|
||||
// Destroy this reference
|
||||
//
|
||||
// Destroy this reference
|
||||
func (m *TString) Free() {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
@ -65,15 +68,28 @@ func (m *TString) Free() {
|
||||
}
|
||||
|
||||
// Instance
|
||||
// return string value pointer
|
||||
//
|
||||
// return string value pointer
|
||||
func (m *TString) Instance() uintptr {
|
||||
return uintptr(m.instance)
|
||||
}
|
||||
|
||||
// NewTString
|
||||
// 创建一个 TString pointer reference
|
||||
//
|
||||
// Create TString pointer reference
|
||||
func NewTString() *TString {
|
||||
var result uintptr
|
||||
imports.Proc(def.TString_Create).Call(uintptr(unsafe.Pointer(&result)))
|
||||
return &TString{instance: unsafe.Pointer(result)}
|
||||
}
|
||||
|
||||
// AsTString
|
||||
//
|
||||
// Convert TString
|
||||
// instance must string(TString) pointer
|
||||
func AsTString(instance uintptr) *TString {
|
||||
if instance == 0 {
|
||||
return nil
|
||||
}
|
||||
return &TString{instance: unsafe.Pointer(instance)}
|
||||
}
|
||||
|
137
cef/types.go
137
cef/types.go
@ -16,7 +16,7 @@ package cef
|
||||
|
||||
import (
|
||||
"github.com/energye/energy/v2/common"
|
||||
. "github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
. "github.com/energye/energy/v2/types"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
@ -31,8 +31,8 @@ type ICefCookie struct {
|
||||
Secure, Httponly, HasExpires bool
|
||||
Creation, LastAccess, Expires time.Time
|
||||
Count, Total, ID int32
|
||||
SameSite TCefCookieSameSite
|
||||
Priority TCefCookiePriority
|
||||
SameSite consts.TCefCookieSameSite
|
||||
Priority consts.TCefCookiePriority
|
||||
SetImmediately bool
|
||||
DeleteCookie bool
|
||||
Result bool
|
||||
@ -40,8 +40,8 @@ type ICefCookie struct {
|
||||
|
||||
// TCefKeyEvent CEF 键盘事件
|
||||
type TCefKeyEvent struct {
|
||||
Kind TCefKeyEventType // called 'type' in the original CEF source code
|
||||
Modifiers TCefEventFlags
|
||||
Kind consts.TCefKeyEventType // called 'type' in the original CEF source code
|
||||
Modifiers consts.TCefEventFlags
|
||||
WindowsKeyCode Int32
|
||||
NativeKeyCode Int32
|
||||
IsSystemKey Int32
|
||||
@ -75,6 +75,7 @@ func (m *TCefRequestContextSettings) ToPtr() *tCefRequestContextSettingsPtr {
|
||||
|
||||
// TCefBrowserSettings CEF Browser配置
|
||||
type TCefBrowserSettings struct {
|
||||
instance *tCefBrowserSettingsPtr
|
||||
Size NativeUInt
|
||||
WindowlessFrameRate Integer
|
||||
StandardFontFamily TCefString
|
||||
@ -88,21 +89,21 @@ type TCefBrowserSettings struct {
|
||||
MinimumFontSize Integer
|
||||
MinimumLogicalFontSize Integer
|
||||
DefaultEncoding TCefString
|
||||
RemoteFonts TCefState
|
||||
Javascript TCefState
|
||||
JavascriptCloseWindows TCefState
|
||||
JavascriptAccessClipboard TCefState
|
||||
JavascriptDomPaste TCefState
|
||||
ImageLoading TCefState
|
||||
ImageShrinkStandaLonetoFit TCefState
|
||||
TextAreaResize TCefState
|
||||
TabToLinks TCefState
|
||||
LocalStorage TCefState
|
||||
Databases TCefState
|
||||
Webgl TCefState
|
||||
RemoteFonts consts.TCefState
|
||||
Javascript consts.TCefState
|
||||
JavascriptCloseWindows consts.TCefState
|
||||
JavascriptAccessClipboard consts.TCefState
|
||||
JavascriptDomPaste consts.TCefState
|
||||
ImageLoading consts.TCefState
|
||||
ImageShrinkStandaLonetoFit consts.TCefState
|
||||
TextAreaResize consts.TCefState
|
||||
TabToLinks consts.TCefState
|
||||
LocalStorage consts.TCefState
|
||||
Databases consts.TCefState
|
||||
Webgl consts.TCefState
|
||||
BackgroundColor TCefColor
|
||||
AcceptLanguageList TCefString // Remove CEF 118
|
||||
ChromeStatusBubble TCefState
|
||||
ChromeStatusBubble consts.TCefState
|
||||
}
|
||||
|
||||
// TCefCommandLine 进程启动命令行参数设置
|
||||
@ -118,8 +119,8 @@ type ICefCommandLine struct {
|
||||
|
||||
// TCefProxy 代理配置
|
||||
type TCefProxy struct {
|
||||
ProxyType TCefProxyType
|
||||
ProxyScheme TCefProxyScheme
|
||||
ProxyType consts.TCefProxyType
|
||||
ProxyScheme consts.TCefProxyScheme
|
||||
ProxyServer string
|
||||
ProxyPort int32
|
||||
ProxyUsername string
|
||||
@ -138,9 +139,9 @@ type TCefTouchEvent struct {
|
||||
RadiusY float32
|
||||
RotationAngle float32
|
||||
Pressure float32
|
||||
Type TCefTouchEeventType
|
||||
Modifiers TCefEventFlags
|
||||
PointerType TCefPointerType
|
||||
Type consts.TCefTouchEeventType
|
||||
Modifiers consts.TCefEventFlags
|
||||
PointerType consts.TCefPointerType
|
||||
}
|
||||
|
||||
// TCustomHeader 自定义请求头
|
||||
@ -153,14 +154,14 @@ type TCustomHeader struct {
|
||||
type TCefMouseEvent struct {
|
||||
X int32
|
||||
Y int32
|
||||
Modifiers TCefEventFlags
|
||||
Modifiers consts.TCefEventFlags
|
||||
}
|
||||
|
||||
// BeforePopupInfo 弹出子窗口信息
|
||||
type BeforePopupInfo struct {
|
||||
TargetUrl string
|
||||
TargetFrameName string
|
||||
TargetDisposition TCefWindowOpenDisposition
|
||||
TargetDisposition consts.TCefWindowOpenDisposition
|
||||
UserGesture bool
|
||||
}
|
||||
|
||||
@ -382,7 +383,7 @@ type ICefExtensionHandler struct {
|
||||
type TCustomExtensionHandler struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefExtension
|
||||
@ -445,7 +446,7 @@ type TCefTouchHandleState struct {
|
||||
TouchHandleId int32
|
||||
Flags uint32
|
||||
Enabled int32
|
||||
Orientation TCefHorizontalAlignment
|
||||
Orientation consts.TCefHorizontalAlignment
|
||||
MirrorVertical int32
|
||||
MirrorHorizontal int32
|
||||
Origin TCefPoint
|
||||
@ -456,7 +457,7 @@ type TCefTouchHandleState struct {
|
||||
type ICefRequestContextHandler struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefMenuModel 菜单
|
||||
@ -590,7 +591,7 @@ type ICefView struct {
|
||||
type ICefViewDelegate struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefOverlayController TODO 未实现
|
||||
@ -730,7 +731,7 @@ type ICefSslInfo struct {
|
||||
type ICefClient struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefAudioHandler
|
||||
@ -861,7 +862,7 @@ type ICefAccessibilityHandler struct {
|
||||
type ICefResourceRequestHandler struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefCookieAccessFilter
|
||||
@ -870,7 +871,7 @@ type ICefResourceRequestHandler struct {
|
||||
type ICefCookieAccessFilter struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefResourceHandler
|
||||
@ -928,7 +929,7 @@ type ICefV8Context struct {
|
||||
type ICefV8Value struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
valueType V8ValueType // 值类型
|
||||
valueType consts.V8ValueType // 值类型
|
||||
valueByIndex []*ICefV8Value // 当前对象的所有数组集合
|
||||
valueByKeys map[string]*ICefV8Value // 当前对象的所有key=value子集合
|
||||
cantNotFree bool // 是否允许释放, false时允许释放
|
||||
@ -1004,14 +1005,14 @@ type ICefResourceSkipCallback struct {
|
||||
type ICefDeleteCookiesCallback struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefSetCookieCallback
|
||||
type ICefSetCookieCallback struct {
|
||||
base TCefBaseRefCounted
|
||||
instance unsafe.Pointer
|
||||
ct CefCreateType
|
||||
ct consts.CefCreateType
|
||||
}
|
||||
|
||||
// ICefPrintDialogCallback
|
||||
@ -1232,27 +1233,27 @@ type TCefInsets struct {
|
||||
// TCefAudioParameters
|
||||
// /include/internal/cef_types.h (cef_audio_parameters_t)
|
||||
type TCefAudioParameters struct {
|
||||
channelLayout TCefChannelLayout
|
||||
channelLayout consts.TCefChannelLayout
|
||||
sampleRate int32
|
||||
framesPerBuffer int32
|
||||
}
|
||||
|
||||
type CefPdfPrintSettings struct {
|
||||
Landscape int32 // Integer
|
||||
PrintBackground int32 // Integer
|
||||
Scale float64 // double
|
||||
PaperWidth float64 // double
|
||||
PaperHeight float64 // double
|
||||
PreferCssPageSize int32 // Integer
|
||||
MarginType TCefPdfPrintMarginType // TCefPdfPrintMarginType
|
||||
MarginTop float64 // double
|
||||
MarginRight float64 // double
|
||||
MarginBottom float64 // double
|
||||
MarginLeft float64 // double
|
||||
PageRanges string // TCefString
|
||||
DisplayHeaderFooter int32 // Integer
|
||||
HeaderTemplate string // TCefString
|
||||
FooterTemplate string // TCefString
|
||||
Landscape int32 // Integer
|
||||
PrintBackground int32 // Integer
|
||||
Scale float64 // double
|
||||
PaperWidth float64 // double
|
||||
PaperHeight float64 // double
|
||||
PreferCssPageSize int32 // Integer
|
||||
MarginType consts.TCefPdfPrintMarginType // TCefPdfPrintMarginType
|
||||
MarginTop float64 // double
|
||||
MarginRight float64 // double
|
||||
MarginBottom float64 // double
|
||||
MarginLeft float64 // double
|
||||
PageRanges string // TCefString
|
||||
DisplayHeaderFooter int32 // Integer
|
||||
HeaderTemplate string // TCefString
|
||||
FooterTemplate string // TCefString
|
||||
}
|
||||
|
||||
// /include/internal/cef_types.h (cef_popup_features_t)
|
||||
@ -1278,7 +1279,7 @@ type TCefCompositionUnderline struct {
|
||||
Color TCefColor
|
||||
BackgroundColor TCefColor
|
||||
Thick int32
|
||||
Style TCefCompositionUnderlineStyle
|
||||
Style consts.TCefCompositionUnderlineStyle
|
||||
}
|
||||
|
||||
type TCefCompositionUnderlineArray struct {
|
||||
@ -1294,8 +1295,8 @@ type TCefBoxLayoutSettings struct {
|
||||
InsideBorderVerticalSpacing Integer
|
||||
InsideBorderInsets TCefInsets
|
||||
BetweenChildSpacing Integer
|
||||
MainAxisAlignment TCefMainAxisAlignment
|
||||
CrossAxisAlignment TCefCrossAxisAlignment
|
||||
MainAxisAlignment consts.TCefMainAxisAlignment
|
||||
CrossAxisAlignment consts.TCefCrossAxisAlignment
|
||||
MinimumCrossAxisSize Integer
|
||||
DefaultFlex Integer
|
||||
}
|
||||
@ -1307,21 +1308,21 @@ type ResultString struct {
|
||||
|
||||
type TChromiumOptions struct {
|
||||
Chromium IChromium
|
||||
javascript TCefState
|
||||
javascriptCloseWindows TCefState
|
||||
javascriptAccessClipboard TCefState
|
||||
javascriptDomPaste TCefState
|
||||
imageLoading TCefState
|
||||
imageShrinkStandaloneToFit TCefState
|
||||
textAreaResize TCefState
|
||||
tabToLinks TCefState
|
||||
localStorage TCefState
|
||||
databases TCefState
|
||||
webgl TCefState
|
||||
javascript consts.TCefState
|
||||
javascriptCloseWindows consts.TCefState
|
||||
javascriptAccessClipboard consts.TCefState
|
||||
javascriptDomPaste consts.TCefState
|
||||
imageLoading consts.TCefState
|
||||
imageShrinkStandaloneToFit consts.TCefState
|
||||
textAreaResize consts.TCefState
|
||||
tabToLinks consts.TCefState
|
||||
localStorage consts.TCefState
|
||||
databases consts.TCefState
|
||||
webgl consts.TCefState
|
||||
backgroundColor TCefColor
|
||||
acceptLanguageList String // Remove CEF 118
|
||||
windowlessFrameRate Integer
|
||||
chromeStatusBubble TCefState
|
||||
chromeStatusBubble consts.TCefState
|
||||
}
|
||||
|
||||
func (m *TCefCompositionUnderlineArray) Count() int {
|
||||
@ -1396,9 +1397,9 @@ func NewCefPoint(x, y int32) *TCefPoint {
|
||||
}
|
||||
|
||||
func (m *TCefKeyEvent) KeyDown() bool {
|
||||
return m.Kind == KEYEVENT_RAW_KEYDOWN || m.Kind == KEYEVENT_KEYDOWN
|
||||
return m.Kind == consts.KEYEVENT_RAW_KEYDOWN || m.Kind == consts.KEYEVENT_KEYDOWN
|
||||
}
|
||||
|
||||
func (m *TCefKeyEvent) KeyUp() bool {
|
||||
return m.Kind == KEYEVENT_KEYUP
|
||||
return m.Kind == consts.KEYEVENT_KEYUP
|
||||
}
|
||||
|
@ -145,7 +145,8 @@ func (m *TCEFBrowserViewComponent) SetOnGetChromeToolbarType(fn BrowserViewCompo
|
||||
}
|
||||
|
||||
// SetOnUseFramelessWindowForPictureInPicture
|
||||
// CEF 113 ~
|
||||
//
|
||||
// CEF 113 ~
|
||||
func (m *TCEFBrowserViewComponent) SetOnUseFramelessWindowForPictureInPicture(fn BrowserViewComponentOnUseFramelessWindowForPictureInPicture) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
@ -154,7 +155,8 @@ func (m *TCEFBrowserViewComponent) SetOnUseFramelessWindowForPictureInPicture(fn
|
||||
}
|
||||
|
||||
// SetOnGestureCommand
|
||||
// CEF 113 ~
|
||||
//
|
||||
// CEF 113 ~
|
||||
func (m *TCEFBrowserViewComponent) SetOnGestureCommand(fn BrowserViewComponentOnGestureCommand) {
|
||||
if !m.IsValid() {
|
||||
return
|
||||
|
@ -226,20 +226,26 @@ func (m *ICefFrame) Identifier() (result int64) {
|
||||
return result
|
||||
}
|
||||
|
||||
func (m *ICefFrame) Name() string {
|
||||
func (m *ICefFrame) Name() (value string) {
|
||||
if !m.IsValid() {
|
||||
return ""
|
||||
}
|
||||
r1, _, _ := imports.Proc(def.CEFFrame_Name).Call(m.Instance())
|
||||
return api.GoStr(r1)
|
||||
val := NewTString()
|
||||
imports.Proc(def.CEFFrame_Name).Call(m.Instance(), val.Instance())
|
||||
value = val.Value()
|
||||
val.Free()
|
||||
return
|
||||
}
|
||||
|
||||
func (m *ICefFrame) Url() string {
|
||||
func (m *ICefFrame) Url() (value string) {
|
||||
if !m.IsValid() {
|
||||
return ""
|
||||
}
|
||||
r1, _, _ := imports.Proc(def.CEFFrame_Url).Call(m.Instance())
|
||||
return api.GoStr(r1)
|
||||
val := NewTString()
|
||||
imports.Proc(def.CEFFrame_Url).Call(m.Instance(), val.Instance())
|
||||
value = val.Value()
|
||||
val.Free()
|
||||
return
|
||||
}
|
||||
|
||||
func (m *ICefFrame) Parent() *ICefFrame {
|
||||
|
218
cef/types_ptr.go
218
cef/types_ptr.go
@ -11,7 +11,7 @@
|
||||
package cef
|
||||
|
||||
import (
|
||||
. "github.com/energye/energy/v2/consts"
|
||||
"github.com/energye/energy/v2/consts"
|
||||
. "github.com/energye/energy/v2/types"
|
||||
"github.com/energye/golcl/lcl/api"
|
||||
"unsafe"
|
||||
@ -40,34 +40,34 @@ type tCefRequestContextSettingsPtr struct {
|
||||
}
|
||||
|
||||
type tCefBrowserSettingsPtr struct {
|
||||
Size uintptr //NativeUInt
|
||||
WindowlessFrameRate uintptr //Integer
|
||||
StandardFontFamily uintptr //TCefString
|
||||
FixedFontFamily uintptr //TCefString
|
||||
SerifFontFamily uintptr //TCefString
|
||||
SansSerifFontFamily uintptr //TCefString
|
||||
CursiveFontFamily uintptr //TCefString
|
||||
FantasyFontFamily uintptr //TCefString
|
||||
DefaultFontSize uintptr //Integer
|
||||
DefaultFixedFontSize uintptr //Integer
|
||||
MinimumFontSize uintptr //Integer
|
||||
MinimumLogicalFontSize uintptr //Integer
|
||||
DefaultEncoding uintptr //TCefString
|
||||
RemoteFonts uintptr //TCefState
|
||||
Javascript uintptr //TCefState
|
||||
JavascriptCloseWindows uintptr //TCefState
|
||||
JavascriptAccessClipboard uintptr //TCefState
|
||||
JavascriptDomPaste uintptr //TCefState
|
||||
ImageLoading uintptr //TCefState
|
||||
ImageShrinkStandaLonetoFit uintptr //TCefState
|
||||
TextAreaResize uintptr //TCefState
|
||||
TabToLinks uintptr //TCefState
|
||||
LocalStorage uintptr //TCefState
|
||||
Databases uintptr //TCefState
|
||||
Webgl uintptr //TCefState
|
||||
BackgroundColor uintptr //TCefColor
|
||||
AcceptLanguageList uintptr //TCefString Remove CEF 118
|
||||
ChromeStatusBubble uintptr //TCefState
|
||||
Size UIntptr //NativeUInt
|
||||
WindowlessFrameRate UIntptr //Integer
|
||||
StandardFontFamily UIntptr //TCefString
|
||||
FixedFontFamily UIntptr //TCefString
|
||||
SerifFontFamily UIntptr //TCefString
|
||||
SansSerifFontFamily UIntptr //TCefString
|
||||
CursiveFontFamily UIntptr //TCefString
|
||||
FantasyFontFamily UIntptr //TCefString
|
||||
DefaultFontSize UIntptr //Integer
|
||||
DefaultFixedFontSize UIntptr //Integer
|
||||
MinimumFontSize UIntptr //Integer
|
||||
MinimumLogicalFontSize UIntptr //Integer
|
||||
DefaultEncoding UIntptr //TCefString
|
||||
RemoteFonts UIntptr //TCefState
|
||||
Javascript UIntptr //TCefState
|
||||
JavascriptCloseWindows UIntptr //TCefState
|
||||
JavascriptAccessClipboard UIntptr //TCefState
|
||||
JavascriptDomPaste UIntptr //TCefState
|
||||
ImageLoading UIntptr //TCefState
|
||||
ImageShrinkStandaLonetoFit UIntptr //TCefState
|
||||
TextAreaResize UIntptr //TCefState
|
||||
TabToLinks UIntptr //TCefState
|
||||
LocalStorage UIntptr //TCefState
|
||||
Databases UIntptr //TCefState
|
||||
Webgl UIntptr //TCefState
|
||||
BackgroundColor UIntptr //TCefColor
|
||||
AcceptLanguageList UIntptr //TCefString Remove CEF 118
|
||||
ChromeStatusBubble UIntptr //TCefState
|
||||
}
|
||||
|
||||
type tCefCompositionUnderlinePtr struct {
|
||||
@ -78,74 +78,122 @@ type tCefCompositionUnderlinePtr struct {
|
||||
Style uintptr //TCefCompositionUnderlineStyle
|
||||
}
|
||||
|
||||
// SetInstanceValue 为实例指针设置值
|
||||
func (m *TCefBrowserSettings) SetInstanceValue() {
|
||||
if m.instance == nil {
|
||||
return
|
||||
}
|
||||
// 字段指针引用赋值, 如果是字符串类型需直接赋值
|
||||
// TODO 需要全部修改
|
||||
m.instance.Size.SetValue(uint32(m.Size))
|
||||
m.instance.WindowlessFrameRate.SetValue(int32(m.WindowlessFrameRate))
|
||||
m.instance.StandardFontFamily = UIntptr(m.StandardFontFamily.ToPtr()) // 字符串赋值
|
||||
m.instance.FixedFontFamily = UIntptr(m.FixedFontFamily.ToPtr())
|
||||
//m.instance.SerifFontFamily = m.SerifFontFamily.ToPtr()
|
||||
//m.instance.SansSerifFontFamily = m.SansSerifFontFamily.ToPtr()
|
||||
//m.instance.CursiveFontFamily = m.CursiveFontFamily.ToPtr()
|
||||
//m.instance.FantasyFontFamily = m.FantasyFontFamily.ToPtr()
|
||||
//m.instance.DefaultFontSize = m.DefaultFontSize.ToPtr()
|
||||
//m.instance.DefaultFixedFontSize = m.DefaultFixedFontSize.ToPtr()
|
||||
//m.instance.MinimumFontSize = m.MinimumFontSize.ToPtr()
|
||||
//m.instance.MinimumLogicalFontSize = m.MinimumLogicalFontSize.ToPtr()
|
||||
//m.instance.DefaultEncoding = m.DefaultEncoding.ToPtr()
|
||||
//m.instance.RemoteFonts = m.RemoteFonts.ToPtr()
|
||||
//m.instance.Javascript = m.Javascript.ToPtr()
|
||||
//m.instance.JavascriptCloseWindows = m.JavascriptCloseWindows.ToPtr()
|
||||
//m.instance.JavascriptAccessClipboard = m.JavascriptAccessClipboard.ToPtr()
|
||||
//m.instance.JavascriptDomPaste = m.JavascriptDomPaste.ToPtr()
|
||||
//m.instance.ImageLoading = m.ImageLoading.ToPtr()
|
||||
//m.instance.ImageShrinkStandaLonetoFit = m.ImageShrinkStandaLonetoFit.ToPtr()
|
||||
//m.instance.TextAreaResize = m.TextAreaResize.ToPtr()
|
||||
//m.instance.TabToLinks = m.TabToLinks.ToPtr()
|
||||
//m.instance.LocalStorage = m.LocalStorage.ToPtr()
|
||||
//m.instance.Databases = m.Databases.ToPtr()
|
||||
//m.instance.Webgl = m.Webgl.ToPtr()
|
||||
//m.instance.BackgroundColor = m.BackgroundColor.ToPtr()
|
||||
//m.instance.AcceptLanguageList = m.AcceptLanguageList.ToPtr() // Remove CEF 118
|
||||
//m.instance.ChromeStatusBubble = m.ChromeStatusBubble.ToPtr()
|
||||
}
|
||||
|
||||
// ToPtr 转换为指针
|
||||
func (m *TCefBrowserSettings) ToPtr() *tCefBrowserSettingsPtr {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
return &tCefBrowserSettingsPtr{
|
||||
Size: m.Size.ToPtr(),
|
||||
WindowlessFrameRate: m.WindowlessFrameRate.ToPtr(),
|
||||
StandardFontFamily: m.StandardFontFamily.ToPtr(),
|
||||
FixedFontFamily: m.FixedFontFamily.ToPtr(),
|
||||
SerifFontFamily: m.SerifFontFamily.ToPtr(),
|
||||
SansSerifFontFamily: m.SansSerifFontFamily.ToPtr(),
|
||||
CursiveFontFamily: m.CursiveFontFamily.ToPtr(),
|
||||
FantasyFontFamily: m.FantasyFontFamily.ToPtr(),
|
||||
DefaultFontSize: m.DefaultFontSize.ToPtr(),
|
||||
DefaultFixedFontSize: m.DefaultFixedFontSize.ToPtr(),
|
||||
MinimumFontSize: m.MinimumFontSize.ToPtr(),
|
||||
MinimumLogicalFontSize: m.MinimumLogicalFontSize.ToPtr(),
|
||||
DefaultEncoding: m.DefaultEncoding.ToPtr(),
|
||||
RemoteFonts: m.RemoteFonts.ToPtr(),
|
||||
Javascript: m.Javascript.ToPtr(),
|
||||
JavascriptCloseWindows: m.JavascriptCloseWindows.ToPtr(),
|
||||
JavascriptAccessClipboard: m.JavascriptAccessClipboard.ToPtr(),
|
||||
JavascriptDomPaste: m.JavascriptDomPaste.ToPtr(),
|
||||
ImageLoading: m.ImageLoading.ToPtr(),
|
||||
ImageShrinkStandaLonetoFit: m.ImageShrinkStandaLonetoFit.ToPtr(),
|
||||
TextAreaResize: m.TextAreaResize.ToPtr(),
|
||||
TabToLinks: m.TabToLinks.ToPtr(),
|
||||
LocalStorage: m.LocalStorage.ToPtr(),
|
||||
Databases: m.Databases.ToPtr(),
|
||||
Webgl: m.Webgl.ToPtr(),
|
||||
BackgroundColor: m.BackgroundColor.ToPtr(),
|
||||
AcceptLanguageList: m.AcceptLanguageList.ToPtr(), // Remove CEF 118
|
||||
ChromeStatusBubble: m.ChromeStatusBubble.ToPtr(),
|
||||
Size: UIntptr(m.Size.ToPtr()),
|
||||
WindowlessFrameRate: UIntptr(m.WindowlessFrameRate.ToPtr()),
|
||||
StandardFontFamily: UIntptr(m.StandardFontFamily.ToPtr()),
|
||||
FixedFontFamily: UIntptr(m.FixedFontFamily.ToPtr()),
|
||||
SerifFontFamily: UIntptr(m.SerifFontFamily.ToPtr()),
|
||||
SansSerifFontFamily: UIntptr(m.SansSerifFontFamily.ToPtr()),
|
||||
CursiveFontFamily: UIntptr(m.CursiveFontFamily.ToPtr()),
|
||||
FantasyFontFamily: UIntptr(m.FantasyFontFamily.ToPtr()),
|
||||
DefaultFontSize: UIntptr(m.DefaultFontSize.ToPtr()),
|
||||
DefaultFixedFontSize: UIntptr(m.DefaultFixedFontSize.ToPtr()),
|
||||
MinimumFontSize: UIntptr(m.MinimumFontSize.ToPtr()),
|
||||
MinimumLogicalFontSize: UIntptr(m.MinimumLogicalFontSize.ToPtr()),
|
||||
DefaultEncoding: UIntptr(m.DefaultEncoding.ToPtr()),
|
||||
RemoteFonts: UIntptr(m.RemoteFonts.ToPtr()),
|
||||
Javascript: UIntptr(m.Javascript.ToPtr()),
|
||||
JavascriptCloseWindows: UIntptr(m.JavascriptCloseWindows.ToPtr()),
|
||||
JavascriptAccessClipboard: UIntptr(m.JavascriptAccessClipboard.ToPtr()),
|
||||
JavascriptDomPaste: UIntptr(m.JavascriptDomPaste.ToPtr()),
|
||||
ImageLoading: UIntptr(m.ImageLoading.ToPtr()),
|
||||
ImageShrinkStandaLonetoFit: UIntptr(m.ImageShrinkStandaLonetoFit.ToPtr()),
|
||||
TextAreaResize: UIntptr(m.TextAreaResize.ToPtr()),
|
||||
TabToLinks: UIntptr(m.TabToLinks.ToPtr()),
|
||||
LocalStorage: UIntptr(m.LocalStorage.ToPtr()),
|
||||
Databases: UIntptr(m.Databases.ToPtr()),
|
||||
Webgl: UIntptr(m.Webgl.ToPtr()),
|
||||
BackgroundColor: UIntptr(m.BackgroundColor.ToPtr()),
|
||||
AcceptLanguageList: UIntptr(m.AcceptLanguageList.ToPtr()), // Remove CEF 118
|
||||
ChromeStatusBubble: UIntptr(m.ChromeStatusBubble.ToPtr()),
|
||||
}
|
||||
}
|
||||
|
||||
// Convert 转换为结构
|
||||
func (m *tCefBrowserSettingsPtr) Convert() *TCefBrowserSettings {
|
||||
getPtr := func(ptr uintptr) unsafe.Pointer {
|
||||
return unsafe.Pointer(ptr)
|
||||
}
|
||||
getCefState := func(ptr uintptr) consts.TCefState {
|
||||
// 可以确保字段不为空
|
||||
if ptr == 0 {
|
||||
return 0
|
||||
}
|
||||
return *(*consts.TCefState)(getPtr(ptr))
|
||||
}
|
||||
return &TCefBrowserSettings{
|
||||
Size: NativeUInt(m.Size),
|
||||
WindowlessFrameRate: Integer(m.WindowlessFrameRate),
|
||||
StandardFontFamily: TCefString(api.GoStr(m.StandardFontFamily)),
|
||||
FixedFontFamily: TCefString(api.GoStr(m.FixedFontFamily)),
|
||||
SerifFontFamily: TCefString(api.GoStr(m.SerifFontFamily)),
|
||||
SansSerifFontFamily: TCefString(api.GoStr(m.SansSerifFontFamily)),
|
||||
CursiveFontFamily: TCefString(api.GoStr(m.CursiveFontFamily)),
|
||||
FantasyFontFamily: TCefString(api.GoStr(m.FantasyFontFamily)),
|
||||
DefaultFontSize: Integer(m.DefaultFontSize),
|
||||
DefaultFixedFontSize: Integer(m.DefaultFixedFontSize),
|
||||
MinimumFontSize: Integer(m.MinimumFontSize),
|
||||
MinimumLogicalFontSize: Integer(m.MinimumLogicalFontSize),
|
||||
DefaultEncoding: TCefString(api.GoStr(m.DefaultEncoding)),
|
||||
RemoteFonts: TCefState(m.RemoteFonts),
|
||||
Javascript: TCefState(m.Javascript),
|
||||
JavascriptCloseWindows: TCefState(m.JavascriptCloseWindows),
|
||||
JavascriptAccessClipboard: TCefState(m.JavascriptAccessClipboard),
|
||||
JavascriptDomPaste: TCefState(m.JavascriptDomPaste),
|
||||
ImageLoading: TCefState(m.ImageLoading),
|
||||
ImageShrinkStandaLonetoFit: TCefState(m.ImageShrinkStandaLonetoFit),
|
||||
TextAreaResize: TCefState(m.TextAreaResize),
|
||||
TabToLinks: TCefState(m.TabToLinks),
|
||||
LocalStorage: TCefState(m.LocalStorage),
|
||||
Databases: TCefState(m.Databases),
|
||||
Webgl: TCefState(m.Webgl),
|
||||
BackgroundColor: TCefColor(m.BackgroundColor),
|
||||
AcceptLanguageList: TCefString(api.GoStr(m.AcceptLanguageList)), // Remove CEF 118
|
||||
ChromeStatusBubble: TCefState(m.ChromeStatusBubble),
|
||||
instance: m,
|
||||
Size: *(*NativeUInt)(getPtr(m.Size.ToPtr())),
|
||||
WindowlessFrameRate: *(*Integer)(getPtr(m.WindowlessFrameRate.ToPtr())),
|
||||
StandardFontFamily: TCefString(api.GoStr(m.StandardFontFamily.ToPtr())),
|
||||
FixedFontFamily: TCefString(api.GoStr(m.FixedFontFamily.ToPtr())),
|
||||
SerifFontFamily: TCefString(api.GoStr(m.SerifFontFamily.ToPtr())),
|
||||
SansSerifFontFamily: TCefString(api.GoStr(m.SansSerifFontFamily.ToPtr())),
|
||||
CursiveFontFamily: TCefString(api.GoStr(m.CursiveFontFamily.ToPtr())),
|
||||
FantasyFontFamily: TCefString(api.GoStr(m.FantasyFontFamily.ToPtr())),
|
||||
DefaultFontSize: *(*Integer)(getPtr(m.DefaultFontSize.ToPtr())),
|
||||
DefaultFixedFontSize: *(*Integer)(getPtr(m.DefaultFixedFontSize.ToPtr())),
|
||||
MinimumFontSize: *(*Integer)(getPtr(m.MinimumFontSize.ToPtr())),
|
||||
MinimumLogicalFontSize: *(*Integer)(getPtr(m.MinimumLogicalFontSize.ToPtr())),
|
||||
DefaultEncoding: TCefString(api.GoStr(m.DefaultEncoding.ToPtr())),
|
||||
RemoteFonts: getCefState(m.RemoteFonts.ToPtr()),
|
||||
Javascript: getCefState(m.Javascript.ToPtr()),
|
||||
JavascriptCloseWindows: getCefState(m.JavascriptCloseWindows.ToPtr()),
|
||||
JavascriptAccessClipboard: getCefState(m.JavascriptAccessClipboard.ToPtr()),
|
||||
JavascriptDomPaste: getCefState(m.JavascriptDomPaste.ToPtr()),
|
||||
ImageLoading: getCefState(m.ImageLoading.ToPtr()),
|
||||
ImageShrinkStandaLonetoFit: getCefState(m.ImageShrinkStandaLonetoFit.ToPtr()),
|
||||
TextAreaResize: getCefState(m.TextAreaResize.ToPtr()),
|
||||
TabToLinks: getCefState(m.TabToLinks.ToPtr()),
|
||||
LocalStorage: getCefState(m.LocalStorage.ToPtr()),
|
||||
Databases: getCefState(m.Databases.ToPtr()),
|
||||
Webgl: getCefState(m.Webgl.ToPtr()),
|
||||
BackgroundColor: *(*TCefColor)(getPtr(m.BackgroundColor.ToPtr())),
|
||||
AcceptLanguageList: TCefString(api.GoStr(m.AcceptLanguageList.ToPtr())), // Remove CEF 118
|
||||
ChromeStatusBubble: getCefState(m.ChromeStatusBubble.ToPtr()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,6 +377,46 @@ func (m UIntptr) ToPtr() uintptr {
|
||||
return uintptr(m)
|
||||
}
|
||||
|
||||
// SetValue
|
||||
//
|
||||
// 给指针设置值, 仅基础类型, 字符串需直接赋值
|
||||
func (m UIntptr) SetValue(value interface{}) {
|
||||
switch value.(type) {
|
||||
case uintptr:
|
||||
*(*uintptr)(unsafe.Pointer(m)) = value.(uintptr)
|
||||
case int:
|
||||
*(*int)(unsafe.Pointer(m)) = value.(int)
|
||||
case int8:
|
||||
*(*int8)(unsafe.Pointer(m)) = value.(int8)
|
||||
case int16:
|
||||
*(*int16)(unsafe.Pointer(m)) = value.(int16)
|
||||
case int32:
|
||||
*(*int32)(unsafe.Pointer(m)) = value.(int32)
|
||||
case int64:
|
||||
*(*int64)(unsafe.Pointer(m)) = value.(int64)
|
||||
case uint:
|
||||
*(*uint)(unsafe.Pointer(m)) = value.(uint)
|
||||
case uint8:
|
||||
*(*uint8)(unsafe.Pointer(m)) = value.(uint8)
|
||||
case uint16:
|
||||
*(*uint16)(unsafe.Pointer(m)) = value.(uint16)
|
||||
case uint32:
|
||||
*(*uint32)(unsafe.Pointer(m)) = value.(uint32)
|
||||
case uint64:
|
||||
*(*uint64)(unsafe.Pointer(m)) = value.(uint64)
|
||||
case float32:
|
||||
//*(*float32)(unsafe.Pointer(uintptr(unsafe.Pointer(&m)))) = value.(float32)
|
||||
*(*float32)(unsafe.Pointer(m)) = value.(float32)
|
||||
case float64:
|
||||
//*(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&m)))) = value.(float64)
|
||||
*(*float64)(unsafe.Pointer(m)) = value.(float64)
|
||||
case bool:
|
||||
*(*bool)(unsafe.Pointer(m)) = value.(bool)
|
||||
case string:
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (m String) ToPtr() uintptr {
|
||||
return api.PascalStr(string(m))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user