//---------------------------------------- // // Copyright © yanghy. All Rights Reserved. // // Licensed under Apache License Version 2.0, January 2004 // // https://www.apache.org/licenses/LICENSE-2.0 // //---------------------------------------- // cef -> energy 结构类型定义 package cef import ( "fmt" "github.com/energye/energy/common" . "github.com/energye/energy/consts" . "github.com/energye/energy/types" "github.com/energye/golcl/lcl" "github.com/energye/golcl/lcl/api" "time" "unsafe" ) // TCefCloseBrowsesAction 浏览器关闭控制 type TCefCloseBrowsesAction = CBS // ICefCookie CEF Cookie type ICefCookie struct { Url, Name, Value, Domain, Path string Secure, Httponly, HasExpires bool Creation, LastAccess, Expires time.Time Count, Total, ID int32 SameSite TCefCookieSameSite Priority TCefCookiePriority SetImmediately bool DeleteCookie bool Result bool } // TCefKeyEvent CEF 键盘事件 type TCefKeyEvent struct { Kind TCefKeyEventType // called 'type' in the original CEF source code Modifiers TCefEventFlags WindowsKeyCode Int32 NativeKeyCode Int32 IsSystemKey Int32 Character UInt16 UnmodifiedCharacter UInt16 FocusOnEditableField Int32 } // TCefRequestContextSettings CEF 请求上下文配置 type TCefRequestContextSettings struct { Size UInt32 CachePath TCefString PersistSessionCookies Int32 PersistUserPreferences Int32 AcceptLanguageList TCefString CookieableSchemesList TCefString CookieableSchemesExcludeDefaults Int32 } func (m *TCefRequestContextSettings) ToPtr() *tCefRequestContextSettingsPtr { return &tCefRequestContextSettingsPtr{ Size: uintptr(m.Size), CachePath: api.PascalStr(string(m.CachePath)), PersistSessionCookies: uintptr(m.PersistSessionCookies), PersistUserPreferences: uintptr(m.PersistUserPreferences), AcceptLanguageList: api.PascalStr(string(m.AcceptLanguageList)), CookieableSchemesList: api.PascalStr(string(m.CookieableSchemesList)), CookieableSchemesExcludeDefaults: uintptr(m.CookieableSchemesExcludeDefaults), } } // TCefBrowserSettings CEF Browser配置 type TCefBrowserSettings struct { Size NativeUInt WindowlessFrameRate Integer StandardFontFamily TCefString FixedFontFamily TCefString SerifFontFamily TCefString SansSerifFontFamily TCefString CursiveFontFamily TCefString FantasyFontFamily TCefString DefaultFontSize Integer DefaultFixedFontSize Integer 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 BackgroundColor TCefColor AcceptLanguageList TCefString ChromeStatusBubble TCefState } // TCefCommandLine 进程启动命令行参数设置 type TCefCommandLine struct { commandLines map[string]string } // ICefCommandLine type ICefCommandLine struct { base TCefBaseRefCounted instance unsafe.Pointer } // TCefProxy 代理配置 type TCefProxy struct { ProxyType TCefProxyType ProxyScheme TCefProxyScheme ProxyServer string ProxyPort int32 ProxyUsername string ProxyPassword string ProxyScriptURL string ProxyByPassList string MaxConnectionsPerProxy int32 } // TCefTouchEvent 触摸事件 type TCefTouchEvent struct { Id int32 X float32 Y float32 RadiusX float32 RadiusY float32 RotationAngle float32 Pressure float32 Type TCefTouchEeventType Modifiers TCefEventFlags PointerType TCefPointerType } // TCustomHeader 自定义请求头 type TCustomHeader struct { CustomHeaderName string CustomHeaderValue string } // TCefMouseEvent 鼠标事件 type TCefMouseEvent struct { X int32 Y int32 Modifiers TCefEventFlags } // BeforePopupInfo 弹出子窗口信息 type BeforePopupInfo struct { TargetUrl string TargetFrameName string TargetDisposition TCefWindowOpenDisposition UserGesture bool } // TCefRect 矩形 type TCefRect struct { X int32 Y int32 Width int32 Height int32 } // TCefSize 大小 type TCefSize struct { Width int32 Height int32 } // TCefPoint 位置 type TCefPoint struct { X int32 Y int32 } // TCefSchemeRegistrarRef type TCefSchemeRegistrarRef struct { instance unsafe.Pointer } // ICefCallback type ICefCallback struct { instance unsafe.Pointer } // TCefBaseRefCounted type TCefBaseRefCounted struct { instance unsafe.Pointer } // ICefBrowser main type ICefBrowser struct { base TCefBaseRefCounted instance unsafe.Pointer mainFrame *ICefFrame } // ICefFrame // Html type ICefFrame struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefImage type ICefImage struct { instance unsafe.Pointer } // TCefDraggableRegions 拖拽区域集合 type TCefDraggableRegions struct { regions []TCefDraggableRegion regionsCount int } // TCefDraggableRegion 拖拽区域集 type TCefDraggableRegion struct { Bounds TCefRect Draggable bool } // ICefProcessMessage type ICefProcessMessage struct { base TCefBaseRefCounted instance unsafe.Pointer argumentList *ICefListValue name string } // ICefBinaryValue -> ArgumentList type ICefBinaryValue struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefValue -> ArgumentList type ICefValue struct { base TCefBaseRefCounted instance unsafe.Pointer binaryValue *ICefBinaryValue dictionaryValue *ICefDictionaryValue listValue *ICefListValue } // ICefListValue -> ArgumentList type ICefListValue struct { base TCefBaseRefCounted instance unsafe.Pointer values map[int]*ICefValue binaryValues map[int]*ICefBinaryValue dictionaryValues map[int]*ICefDictionaryValue listValues map[int]*ICefListValue } // ICefDictionaryValue -> ArgumentList type ICefDictionaryValue struct { base TCefBaseRefCounted instance unsafe.Pointer values map[string]*ICefValue binaryValues map[string]*ICefBinaryValue dictionaryValues map[string]*ICefDictionaryValue listValues map[string]*ICefListValue } // ICefDisplay type ICefDisplay struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefWindow type ICefWindow struct { instance unsafe.Pointer } // ICefRequest type ICefRequest struct { base TCefBaseRefCounted instance unsafe.Pointer Url string Method string ReferrerUrl string ReferrerPolicy TCefReferrerPolicy Flags TCefUrlRequestFlags FirstPartyForCookies string ResourceType TCefResourceType TransitionType TCefTransitionType Identifier uint64 } // ICefResponse 实例 type ICefResponse struct { base TCefBaseRefCounted instance unsafe.Pointer Status int32 StatusText string MimeType string Charset string Error TCefErrorCode URL string } // ICefMenuModel 菜单 type ICefMenuModel struct { base TCefBaseRefCounted instance unsafe.Pointer CefMis *keyEventAccelerator } // ICefStringMultiMap 实例 type ICefStringMultiMap struct { instance unsafe.Pointer } // ICefPostData type ICefPostData struct { instance unsafe.Pointer } // ICefPostDataElement type ICefPostDataElement struct { instance unsafe.Pointer } // TCefPostDataElementArray type TCefPostDataElementArray struct { instance unsafe.Pointer postDataElement uintptr postDataElementLength uint32 } // ICefBrowserView type ICefBrowserView struct { instance unsafe.Pointer } // ICefView type ICefView struct { instance unsafe.Pointer } // ICefClient type ICefClient struct { instance unsafe.Pointer } // ICefDragData type ICefDragData struct { instance unsafe.Pointer } // ICefV8Exception type ICefV8Exception struct { instance unsafe.Pointer } // ICefV8Context // // v8上下文对象 // // 生命周期 // 1. 在回调函数中有效 // 2. 回调函数外使用 cef.V8ContextRef.Current() 获取上下文对象 type ICefV8Context struct { base TCefBaseRefCounted instance unsafe.Pointer browser *ICefBrowser frame *ICefFrame global *ICefV8Value } // ICefV8Value type ICefV8Value struct { base TCefBaseRefCounted instance unsafe.Pointer valueType V8ValueType valueByIndex []*ICefV8Value valueByKeys map[string]*ICefV8Value } // ICefV8ValueKeys type ICefV8ValueKeys struct { keys *lcl.TStrings count int keyArray []string } // TCefV8ValueArray ICefV8Value 数组的替代结构 type TCefV8ValueArray struct { instance unsafe.Pointer arguments uintptr argumentsLength int argumentsCollect []*ICefV8Value } // ICefV8Handler type ICefV8Handler struct { instance unsafe.Pointer } //ICefV8Interceptor type ICefV8Interceptor struct { instance unsafe.Pointer } //ICefV8Accessor type ICefV8Accessor struct { instance unsafe.Pointer } //ICefV8ArrayBufferReleaseCallback type ICefV8ArrayBufferReleaseCallback struct { instance unsafe.Pointer } // ICefDownloadItem 下载项 type ICefDownloadItem struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefDownloadItemCallback // // 下载中回调 type ICefDownloadItemCallback struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefBeforeDownloadCallback // // 下载之前回调 type ICefBeforeDownloadCallback struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefPdfPrintCallback type ICefPdfPrintCallback struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefV8StackTrace type ICefV8StackTrace struct { base TCefBaseRefCounted instance unsafe.Pointer } // ICefDomNode type ICefDomNode struct { base TCefBaseRefCounted instance unsafe.Pointer } // TCefPreferenceRegistrarRef type TCefPreferenceRegistrarRef struct { instance unsafe.Pointer } 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 } // ResultString 字符串返回值 type ResultString struct { value string } func (m *ResultString) SetValue(value string) { m.value = value } func (m *ResultString) Value() string { return m.value } // ResultBool bool返回值 type ResultBool struct { value bool } func (m *ResultBool) SetValue(value bool) { m.value = value } func (m *ResultBool) Value() bool { return m.value } // ResultBytes []byte返回值 type ResultBytes struct { value []byte } func (m *ResultBytes) SetValue(value []byte) { m.value = value } func (m *ResultBytes) Value() []byte { return m.value } // NewCefRect func NewCefRect(x, y, width, height int32) *TCefRect { return &TCefRect{ X: x, Y: y, Width: width, Height: height, } } // NewCefSize func NewCefSize(width, height int32) *TCefSize { return &TCefSize{ Width: width, Height: height, } } // NewCefPoint func NewCefPoint(x, y int32) *TCefPoint { return &TCefPoint{ X: x, Y: y, } } func (m *ICefClient) SetClient(client *ICefClient) { m.instance = client.instance } func (m *TCefKeyEvent) KeyDown() bool { return m.Kind == KEYEVENT_RAW_KEYDOWN || m.Kind == KEYEVENT_KEYDOWN } func (m *TCefKeyEvent) KeyUp() bool { return m.Kind == KEYEVENT_KEYUP } func (m *VT) ToString() string { gov := common.FuncParamGoTypeStr(m.Gov) jsv := common.FuncParamJsTypeStr(m.Jsv) return fmt.Sprintf("GO=%s JS=%s", gov, jsv) } // IsGoIntAuto 判断Go 所有 int 类型 func (m *VT) IsGoIntAuto() bool { switch m.Gov { case GO_VALUE_INT, GO_VALUE_INT8, GO_VALUE_INT16, GO_VALUE_INT32, GO_VALUE_INT64, GO_VALUE_UINT, GO_VALUE_UINT8, GO_VALUE_UINT16, GO_VALUE_UINT32, GO_VALUE_UINT64: return true } return false } // IsGoFloatAuto 判断Go 所有 float 类型 func (m *VT) IsGoFloatAuto() bool { switch m.Gov { case GO_VALUE_FLOAT32, GO_VALUE_FLOAT64: return true } return false }