types.go 26.9 KB
Newer Older
yanghye's avatar
yanghye 已提交
1 2 3 4
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
yanghye's avatar
yanghye 已提交
5 6 7
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
yanghye's avatar
yanghye 已提交
8 9 10
//
//----------------------------------------

yanghye's avatar
yanghye 已提交
11 12 13 14
// cef -> energy 所有结构类型定义
// 每个结构对象创建 XXXRef.New() 创建并返回CEF对象, 创建后的对象是
// 引用CEF指针在不使用时,使用Free函数合理的释放掉该对象

yanghye's avatar
yanghye 已提交
15 16 17
package cef

import (
18
	"github.com/energye/energy/v2/common"
yanghye's avatar
yanghye 已提交
19 20
	. "github.com/energye/energy/v2/consts"
	. "github.com/energye/energy/v2/types"
yanghye's avatar
yanghye 已提交
21
	"github.com/energye/golcl/lcl"
yanghye's avatar
yanghye 已提交
22
	"github.com/energye/golcl/lcl/api"
yanghye's avatar
yanghye 已提交
23 24 25 26
	"time"
	"unsafe"
)

yanghye's avatar
yanghye 已提交
27
// ICefCookie CEF Cookie
yanghye's avatar
yanghye 已提交
28 29 30 31 32 33 34 35 36 37 38 39
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
}

yanghye's avatar
yanghye 已提交
40
// TCefKeyEvent CEF 键盘事件
yanghye's avatar
yanghye 已提交
41 42 43
type TCefKeyEvent struct {
	Kind                 TCefKeyEventType // called 'type' in the original CEF source code
	Modifiers            TCefEventFlags
yanghye's avatar
yanghye 已提交
44 45 46 47 48 49
	WindowsKeyCode       Int32
	NativeKeyCode        Int32
	IsSystemKey          Int32
	Character            UInt16
	UnmodifiedCharacter  UInt16
	FocusOnEditableField Int32
yanghye's avatar
yanghye 已提交
50 51
}

yanghye's avatar
yanghye 已提交
52
// TCefRequestContextSettings CEF 请求上下文配置
yanghye's avatar
yanghye 已提交
53
type TCefRequestContextSettings struct {
yanghye's avatar
yanghye 已提交
54
	Size                             UInt32
yanghye's avatar
yanghye 已提交
55
	CachePath                        TCefString
yanghye's avatar
yanghye 已提交
56 57
	PersistSessionCookies            Int32
	PersistUserPreferences           Int32
yanghye's avatar
yanghye 已提交
58 59
	AcceptLanguageList               TCefString
	CookieableSchemesList            TCefString
yanghye's avatar
yanghye 已提交
60 61 62 63 64
	CookieableSchemesExcludeDefaults Int32
}

func (m *TCefRequestContextSettings) ToPtr() *tCefRequestContextSettingsPtr {
	return &tCefRequestContextSettingsPtr{
yanghye's avatar
yanghye 已提交
65 66 67 68 69 70 71
		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),
yanghye's avatar
yanghye 已提交
72
	}
yanghye's avatar
yanghye 已提交
73 74
}

yanghye's avatar
yanghye 已提交
75
// TCefBrowserSettings CEF Browser配置
yanghye's avatar
yanghye 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
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
yanghye's avatar
yanghye 已提交
105 106
}

yanghye's avatar
yanghye 已提交
107
// TCefCommandLine 进程启动命令行参数设置
yanghye's avatar
yanghye 已提交
108 109
type TCefCommandLine struct {
	commandLines map[string]string
yanghye's avatar
yanghye 已提交
110 111
}

yanghye's avatar
yanghye 已提交
112 113 114 115 116 117
// ICefCommandLine
type ICefCommandLine struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
118
// TCefProxy 代理配置
yanghye's avatar
yanghye 已提交
119 120 121 122 123 124 125 126 127 128 129 130
type TCefProxy struct {
	ProxyType              TCefProxyType
	ProxyScheme            TCefProxyScheme
	ProxyServer            string
	ProxyPort              int32
	ProxyUsername          string
	ProxyPassword          string
	ProxyScriptURL         string
	ProxyByPassList        string
	MaxConnectionsPerProxy int32
}

yanghye's avatar
yanghye 已提交
131
// TCefTouchEvent 触摸事件
yanghye's avatar
yanghye 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144
type TCefTouchEvent struct {
	Id            int32
	X             float32
	Y             float32
	RadiusX       float32
	RadiusY       float32
	RotationAngle float32
	Pressure      float32
	Type          TCefTouchEeventType
	Modifiers     TCefEventFlags
	PointerType   TCefPointerType
}

yanghye's avatar
yanghye 已提交
145
// TCustomHeader 自定义请求头
146 147 148 149 150
type TCustomHeader struct {
	CustomHeaderName  string
	CustomHeaderValue string
}

yanghye's avatar
yanghye 已提交
151
// TCefMouseEvent 鼠标事件
yanghye's avatar
yanghye 已提交
152 153 154 155 156 157
type TCefMouseEvent struct {
	X         int32
	Y         int32
	Modifiers TCefEventFlags
}

yanghye's avatar
yanghye 已提交
158
// BeforePopupInfo 弹出子窗口信息
yanghye's avatar
yanghye 已提交
159 160 161 162 163 164 165
type BeforePopupInfo struct {
	TargetUrl         string
	TargetFrameName   string
	TargetDisposition TCefWindowOpenDisposition
	UserGesture       bool
}

yanghye's avatar
yanghye 已提交
166 167
// TCefRect
//  /include/internal/cef_types_geometry.h (cef_rect_t)
yanghye's avatar
yanghye 已提交
168 169 170 171 172 173 174
type TCefRect struct {
	X      int32
	Y      int32
	Width  int32
	Height int32
}

175 176 177 178 179 180
type TCefRectArray struct {
	ptr    uintptr
	sizeOf uintptr
	count  uint32
}

yanghye's avatar
yanghye 已提交
181 182 183 184 185 186 187
type TRGBQuad struct {
	RgbBlue     byte
	RgbGreen    byte
	RgbRed      byte
	RgbReserved byte
}

188 189 190 191 192 193 194 195 196 197
// NewTCefRectArray
//  TCefRect 动态数组结构, 通过指针引用取值
func NewTCefRectArray(ptr uintptr, count uint32) *TCefRectArray {
	return &TCefRectArray{
		ptr:    ptr,
		sizeOf: unsafe.Sizeof(TCefRect{}),
		count:  count,
	}
}

yanghye's avatar
yanghye 已提交
198 199
func (m *TCefRectArray) Count() int {
	return int(m.count)
200 201 202 203 204 205 206 207 208
}

func (m *TCefRectArray) Get(index int) *TCefRect {
	if m.count == 0 || index < 0 || index >= int(m.count) {
		return nil
	}
	return (*TCefRect)(common.GetParamPtr(m.ptr, index*int(m.sizeOf)))
}

yanghye's avatar
yanghye 已提交
209 210
// TCefSize
//  /include/internal/cef_types_geometry.h (cef_size_t)
211 212 213 214 215
type TCefSize struct {
	Width  int32
	Height int32
}

yanghye's avatar
yanghye 已提交
216 217
// TCefPoint
//  /include/internal/cef_types_geometry.h (cef_point_t)
yanghye's avatar
yanghye 已提交
218 219 220 221 222
type TCefPoint struct {
	X int32
	Y int32
}

yanghye's avatar
yanghye 已提交
223 224 225 226 227 228 229 230 231
// TCefCursorInfo
//  /include/internal/cef_types.h (cef_cursor_info_t)
type TCefCursorInfo struct {
	Hotspot          TCefPoint
	ImageScaleFactor Single
	Buffer           uintptr
	Size             TCefSize
}

yanghye's avatar
yanghye 已提交
232 233 234 235 236
// TCefSchemeRegistrarRef
type TCefSchemeRegistrarRef struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
237 238
// TCefBaseRefCounted
type TCefBaseRefCounted struct {
yanghye's avatar
yanghye 已提交
239 240 241
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
// ICefRequestContext
type ICefRequestContext struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefCookieManager
type ICefCookieManager struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefCookieVisitor
type ICefCookieVisitor struct {
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
257
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
258 259
}

yanghye's avatar
yanghye 已提交
260
// ICefBrowser
yanghye's avatar
yanghye 已提交
261
type ICefBrowser struct {
yanghye's avatar
yanghye 已提交
262 263 264 265 266 267
	base           TCefBaseRefCounted
	instance       unsafe.Pointer
	mainFrame      *ICefFrame
	requestContext *ICefRequestContext
	idFrames       map[int64]*ICefFrame
	nameFrames     map[string]*ICefFrame
yanghye's avatar
yanghye 已提交
268 269 270 271 272
}

// ICefFrame
// Html <iframe></iframe>
type ICefFrame struct {
yanghye's avatar
yanghye 已提交
273
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
274 275 276
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
277 278
// ICefImage
type ICefImage struct {
yanghye's avatar
yanghye 已提交
279
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
280 281 282
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
283
// TCefDraggableRegions 拖拽区域集合
284
type TCefDraggableRegions struct {
285
	regions      []TCefDraggableRegion
286
	regionsCount int
287 288
}

yanghye's avatar
yanghye 已提交
289
// TCefDraggableRegion 拖拽区域集
yanghye's avatar
yanghye 已提交
290 291
type TCefDraggableRegion struct {
	Bounds    TCefRect
292
	Draggable bool
yanghye's avatar
yanghye 已提交
293 294
}

295 296
// ICefProcessMessage
type ICefProcessMessage struct {
yanghye's avatar
yanghye 已提交
297
	base         TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
298 299
	instance     unsafe.Pointer
	argumentList *ICefListValue
yanghye's avatar
yanghye 已提交
300
	name         string
301 302
}

yanghye's avatar
yanghye 已提交
303 304 305 306 307 308 309 310
// TCefBinaryValueArray
//  []ICefBinaryValue
type TCefBinaryValueArray struct {
	instance     unsafe.Pointer
	binaryValues []*ICefBinaryValue
	count        uint32
}

yanghye's avatar
yanghye 已提交
311 312
// ICefBinaryValue -> ArgumentList
type ICefBinaryValue struct {
yanghye's avatar
yanghye 已提交
313
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
314 315 316
	instance unsafe.Pointer
}

317 318
// ICefValue -> ArgumentList
type ICefValue struct {
yanghye's avatar
yanghye 已提交
319
	base            TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
320 321 322 323
	instance        unsafe.Pointer
	binaryValue     *ICefBinaryValue
	dictionaryValue *ICefDictionaryValue
	listValue       *ICefListValue
324 325 326 327
}

// ICefListValue -> ArgumentList
type ICefListValue struct {
yanghye's avatar
yanghye 已提交
328
	base             TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
329 330 331 332 333
	instance         unsafe.Pointer
	values           map[int]*ICefValue
	binaryValues     map[int]*ICefBinaryValue
	dictionaryValues map[int]*ICefDictionaryValue
	listValues       map[int]*ICefListValue
334 335 336 337
}

// ICefDictionaryValue -> ArgumentList
type ICefDictionaryValue struct {
yanghye's avatar
yanghye 已提交
338
	base             TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
339 340 341 342 343
	instance         unsafe.Pointer
	values           map[string]*ICefValue
	binaryValues     map[string]*ICefBinaryValue
	dictionaryValues map[string]*ICefDictionaryValue
	listValues       map[string]*ICefListValue
344 345
}

yanghye's avatar
yanghye 已提交
346
// ICefDisplay
yanghye's avatar
yanghye 已提交
347
type ICefDisplay struct {
yanghye's avatar
yanghye 已提交
348
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
349 350 351
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
352
// ICefWindow
yanghye's avatar
yanghye 已提交
353
type ICefWindow struct {
yanghye's avatar
yanghye 已提交
354
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
355 356 357
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
358 359 360 361 362 363 364 365 366 367
// ICefExtensionHandler
type ICefExtensionHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// TCustomExtensionHandler
type TCustomExtensionHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
368
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
}

// ICefExtension
type ICefExtension struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefSchemeHandlerFactory
//  /include/capi/cef_scheme_capi.h (cef_scheme_handler_factory_t)
type ICefSchemeHandlerFactory struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// TCefResourceHandlerClass
type TCefResourceHandlerClass uintptr

yanghye's avatar
yanghye 已提交
387 388
// ICefRequest
type ICefRequest struct {
yanghye's avatar
yanghye 已提交
389 390 391 392 393
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefResponse
yanghye's avatar
yanghye 已提交
394
type ICefResponse struct {
yanghye's avatar
yanghye 已提交
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefDomVisitor
type ICefDomVisitor struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefDomDocument
type ICefDomDocument struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// TCefScreenInfo
//  /include/internal/cef_types.h (cef_screen_info_t)
type TCefScreenInfo struct {
414
	DeviceScaleFactor Single
yanghye's avatar
yanghye 已提交
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
	Depth             int32
	DepthPerComponent int32
	IsMonochrome      int32
	Rect              TCefRect
	AvailableRect     TCefRect
}

// TCefTouchHandleState
//  /include/internal/cef_types.h (cef_touch_handle_state_t)
type TCefTouchHandleState struct {
	TouchHandleId    int32
	Flags            uint32
	Enabled          int32
	Orientation      TCefHorizontalAlignment
	MirrorVertical   int32
	MirrorHorizontal int32
	Origin           TCefPoint
	Alpha            float32
}

// ICefRequestContextHandler
type ICefRequestContextHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
439
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
440
}
yanghye's avatar
yanghye 已提交
441 442 443 444 445 446 447

// ICefMenuModel 菜单
type ICefMenuModel struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
	CefMis   *keyEventAccelerator
}
yanghye's avatar
yanghye 已提交
448

yanghye's avatar
yanghye 已提交
449 450 451 452 453 454 455
// ICefMenuModelDelegate
// /include/capi/cef_menu_model_delegate_capi.h (cef_menu_model_delegate_t)
type ICefMenuModelDelegate struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
456 457 458 459 460
// ICefStringMultiMap 实例
type ICefStringMultiMap struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
461 462 463 464 465
// ICefPostData
type ICefPostData struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
466 467 468 469 470 471 472 473 474 475 476 477
// ICefPostDataElement
type ICefPostDataElement struct {
	instance unsafe.Pointer
}

// TCefPostDataElementArray
type TCefPostDataElementArray struct {
	instance              unsafe.Pointer
	postDataElement       uintptr
	postDataElementLength uint32
}

yanghye's avatar
yanghye 已提交
478
// ICefBrowserView
yanghye's avatar
yanghye 已提交
479
// /include/capi/views/cef_browser_view_capi.h (cef_browser_view_t)
yanghye's avatar
yanghye 已提交
480
type ICefBrowserView struct {
yanghye's avatar
yanghye 已提交
481 482 483 484 485 486 487 488 489
	*ICefView
}

// ICefButton
// /include/capi/views/cef_button_capi.h (cef_button_t)
type ICefButton struct {
	*ICefView
}

yanghye's avatar
yanghye 已提交
490 491 492 493 494 495
// ICefLabelButton
// /include/capi/views/cef_label_button_capi.h (cef_label_button_t)
type ICefLabelButton struct {
	*ICefButton
}

yanghye's avatar
yanghye 已提交
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
// ICefPanel
// /include/capi/views/cef_panel_capi.h (cef_panel_t)
type ICefPanel struct {
	*ICefView
}

// ICefScrollView
// /include/capi/views/cef_scroll_view_capi.h (cef_scroll_view_t)
type ICefScrollView struct {
	*ICefView
}

// ICefTextfield
// /include/capi/views/cef_textfield_capi.h (cef_textfield_t)
type ICefTextfield struct {
	*ICefView
yanghye's avatar
yanghye 已提交
512 513
}

yanghye's avatar
yanghye 已提交
514
// ICefView
yanghye's avatar
yanghye 已提交
515
// /include/capi/views/cef_view_capi.h (cef_view_t)
516
type ICefView struct {
yanghye's avatar
yanghye 已提交
517 518 519 520 521 522 523 524
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefViewDelegate
// /include/capi/views/cef_view_delegate_capi.h (cef_view_delegate_t)
type ICefViewDelegate struct {
	base     TCefBaseRefCounted
525
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
526 527 528 529 530 531
	ct       CefCreateType
}

// ICefBrowserViewDelegate
type ICefBrowserViewDelegate struct {
	*ICefViewDelegate
532 533
}

yanghye's avatar
yanghye 已提交
534 535 536 537 538
// ICefButtonDelegate
type ICefButtonDelegate struct {
	*ICefViewDelegate
}

yanghye's avatar
yanghye 已提交
539 540 541 542 543
// TCEFViewComponent
type TCEFViewComponent struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
544 545 546 547 548
// TCEFButtonComponent
type TCEFButtonComponent struct {
	*TCEFViewComponent
}

yanghye's avatar
yanghye 已提交
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577
// TCefX509CertificateArray
// []ICefX509Certificate
type TCefX509CertificateArray struct {
	instance     unsafe.Pointer
	certificates []*ICefX509Certificate
	count        uint32
}

// ICefX509Certificate
//  /include/capi/cef_x509_certificate_capi.h (cef_x509certificate_t)
type ICefX509Certificate struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefX509CertPrincipal
// /include/capi/cef_x509_certificate_capi.h (cef_x509cert_principal_t)
type ICefX509CertPrincipal struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefSslInfo
//  /include/capi/cef_ssl_info_capi.h (cef_sslinfo_t)
type ICefSslInfo struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
578
// ICefClient
yanghye's avatar
yanghye 已提交
579
type ICefClient struct {
yanghye's avatar
yanghye 已提交
580 581
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
582
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710
}

// ICefAudioHandler
type ICefAudioHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefCommandHandler
type ICefCommandHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefContextMenuHandler
type ICefContextMenuHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefDialogHandler
type ICefDialogHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefDisplayHandler
type ICefDisplayHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefDownloadHandler
type ICefDownloadHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefDownloadItem 下载项
type ICefDownloadItem struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefDragHandler
type ICefDragHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefFindHandler
type ICefFindHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefFocusHandler
type ICefFocusHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefFrameHandler
type ICefFrameHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefPermissionHandler
type ICefPermissionHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefJsDialogHandler
type ICefJsDialogHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefKeyboardHandler
type ICefKeyboardHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefLifeSpanHandler
type ICefLifeSpanHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefLoadHandler
type ICefLoadHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefPrintHandler
type ICefPrintHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefRenderHandler
type ICefRenderHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

//ICefRequestHandler
type ICefRequestHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefAccessibilityHandler
//  /include/capi/cef_accessibility_handler_capi.h (cef_accessibility_handler_t)
type ICefAccessibilityHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefResourceRequestHandler
//  /include/capi/cef_resource_request_handler_capi.h (cef_resource_request_handler_t)
type ICefResourceRequestHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
711
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
712 713 714 715 716 717 718
}

// ICefCookieAccessFilter
//  /include/capi/cef_resource_request_handler_capi.h (cef_cookie_access_filter_t)
type ICefCookieAccessFilter struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
719
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
720 721 722 723 724 725 726 727 728 729 730 731 732
}

// ICefResourceHandler
//  /include/capi/cef_resource_handler_capi.h (cef_resource_handler_t)
type ICefResourceHandler struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefResponseFilter
//  /include/capi/cef_response_filter_capi.h (cef_response_filter_t)
type ICefResponseFilter struct {
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
733 734 735
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
736
// ICefDragData
737
type ICefDragData struct {
yanghye's avatar
yanghye 已提交
738
	base     TCefBaseRefCounted
739 740 741
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
742 743 744 745 746
// ICefV8Exception
type ICefV8Exception struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
747 748 749 750 751 752
// ICefStreamWriter
//  /include/capi/cef_stream_capi.h (cef_stream_writer_t)
type ICefStreamWriter struct {
	*TCefBaseRefCounted
}

yanghye's avatar
yanghye 已提交
753
// ICefV8Context
yanghye's avatar
yanghye 已提交
754 755 756 757 758 759
//
// v8上下文对象
//
// 生命周期
//   1. 在回调函数中有效
//   2. 回调函数外使用 cef.V8ContextRef.Current() 获取上下文对象
yanghye's avatar
yanghye 已提交
760
type ICefV8Context struct {
yanghye's avatar
yanghye 已提交
761
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
762
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
763 764 765
	browser  *ICefBrowser
	frame    *ICefFrame
	global   *ICefV8Value
yanghye's avatar
yanghye 已提交
766 767 768 769
}

// ICefV8Value
type ICefV8Value struct {
yanghye's avatar
yanghye 已提交
770 771 772 773 774
	base         TCefBaseRefCounted
	instance     unsafe.Pointer
	valueType    V8ValueType
	valueByIndex []*ICefV8Value
	valueByKeys  map[string]*ICefV8Value
yanghye's avatar
yanghye 已提交
775
	cantFree     bool
yanghye's avatar
yanghye 已提交
776 777
}

yanghye's avatar
yanghye 已提交
778 779
// ICefV8ValueKeys
type ICefV8ValueKeys struct {
yanghye's avatar
yanghye 已提交
780 781 782
	keys     *lcl.TStrings
	count    int
	keyArray []string
yanghye's avatar
yanghye 已提交
783 784
}

yanghye's avatar
yanghye 已提交
785 786
// TCefV8ValueArray ICefV8Value 数组的替代结构
type TCefV8ValueArray struct {
yanghye's avatar
yanghye 已提交
787 788 789 790
	instance         unsafe.Pointer
	arguments        uintptr
	argumentsLength  int
	argumentsCollect []*ICefV8Value
yanghye's avatar
yanghye 已提交
791 792
}

yanghye's avatar
yanghye 已提交
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807
// ICefV8Handler
type ICefV8Handler struct {
	instance unsafe.Pointer
}

//ICefV8Interceptor
type ICefV8Interceptor struct {
	instance unsafe.Pointer
}

//ICefV8Accessor
type ICefV8Accessor struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
// ICefStreamReader
type ICefStreamReader struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefPrintSettings
type ICefPrintSettings struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefSelectClientCertificateCallback
//  /include/capi/cef_request_handler_capi.h (cef_select_client_certificate_callback_t)
type ICefSelectClientCertificateCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefResourceReadCallback
//  /include/capi/cef_resource_handler_capi.h (cef_resource_read_callback_t)
type ICefResourceReadCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefResourceSkipCallback
//  /include/capi/cef_resource_handler_capi.h (cef_resource_skip_callback_t)
type ICefResourceSkipCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefDeleteCookiesCallback
type ICefDeleteCookiesCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
845
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
846 847 848 849 850 851
}

// ICefSetCookieCallback
type ICefSetCookieCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
yanghye's avatar
yanghye 已提交
852
	ct       CefCreateType
yanghye's avatar
yanghye 已提交
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
}

// ICefPrintDialogCallback
type ICefPrintDialogCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefPrintJobCallback
type ICefPrintJobCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefCallback
type ICefCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefAuthCallback 授权回调
type ICefAuthCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
879 880 881 882 883
//ICefV8ArrayBufferReleaseCallback
type ICefV8ArrayBufferReleaseCallback struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
884 885
// ICefGetExtensionResourceCallback
type ICefGetExtensionResourceCallback struct {
yanghye's avatar
yanghye 已提交
886
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
887 888 889 890 891 892 893
	instance unsafe.Pointer
}

// ICefDownloadItemCallback
//
// 下载中回调
type ICefDownloadItemCallback struct {
yanghye's avatar
yanghye 已提交
894
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
895 896 897 898 899 900 901
	instance unsafe.Pointer
}

// ICefBeforeDownloadCallback
//
// 下载之前回调
type ICefBeforeDownloadCallback struct {
yanghye's avatar
yanghye 已提交
902
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
903 904 905
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
906 907
// ICefPdfPrintCallback
type ICefPdfPrintCallback struct {
yanghye's avatar
yanghye 已提交
908
	base     TCefBaseRefCounted
yanghye's avatar
yanghye 已提交
909 910 911
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938
// ICefCompletionCallback
type ICefCompletionCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefRunContextMenuCallback
//  /include/capi/cef_context_menu_handler_capi.h (cef_run_context_menu_callback_t)
type ICefRunContextMenuCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefRunQuickMenuCallback
//  /include/capi/cef_context_menu_handler_capi.h (cef_run_quick_menu_callback_t)
type ICefRunQuickMenuCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefFileDialogCallback
//  /include/capi/cef_dialog_handler_capi.h (cef_file_dialog_callback_t)
type ICefFileDialogCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
939 940 941 942 943 944 945
// TCefRunFileDialogCallback
// /include/capi/cef_browser_capi.h (cef_run_file_dialog_callback_t)
type ICefRunFileDialogCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
946 947 948 949 950 951 952
// TCefDownloadImageCallback
// /include/capi/cef_browser_capi.h (cef_download_image_callback_t)
type ICefDownloadImageCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
// ICefMediaAccessCallback
//  This interface is declared twice with almost identical parameters. "allowed_permissions" is defined as int and uint32.
//  /include/capi/cef_media_access_handler_capi.h (cef_media_access_callback_t)
//  /include/capi/cef_permission_handler_capi.h (cef_media_access_callback_t)
type ICefMediaAccessCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefPermissionPromptCallback
//  /include/capi/cef_permission_handler_capi.h (cef_permission_prompt_callback_t)
type ICefPermissionPromptCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefJsDialogCallback
//  /include/capi/cef_jsdialog_handler_capi.h (cef_jsdialog_callback_t)
type ICefJsDialogCallback struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
976 977
// ICefV8StackTrace
type ICefV8StackTrace struct {
yanghye's avatar
yanghye 已提交
978 979 980 981
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
982 983 984 985 986 987
// ICefContextMenuParams 菜单显示时参数,当前鼠标右键的frame & html元素参数
type ICefContextMenuParams struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
988 989 990 991 992 993
// ICefDomNode
type ICefDomNode struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
// TCefMediaRouteArray
//  []ICefMediaRoute
type TCefMediaRouteArray struct {
	instance   unsafe.Pointer
	mediaRoute []*ICefMediaRoute
	count      uint32
}

// ICefMediaRoute
//  /include/capi/cef_media_router_capi.h (cef_media_observer_t)
type ICefMediaRoute struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// TCefMediaSinkArray
//  []ICefMediaSink
type TCefMediaSinkArray struct {
	instance  unsafe.Pointer
	mediaSink []*ICefMediaSink
	count     uint32
}

// ICefMediaSink
//  /include/capi/cef_media_router_capi.h (cef_media_sink_t)
type ICefMediaSink struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

// ICefNavigationEntry
//  /include/capi/cef_navigation_entry_capi.h (cef_navigation_entry_t)
type ICefNavigationEntry struct {
	base     TCefBaseRefCounted
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
1031 1032 1033 1034 1035
// TCefPreferenceRegistrarRef
type TCefPreferenceRegistrarRef struct {
	instance unsafe.Pointer
}

yanghye's avatar
yanghye 已提交
1036 1037 1038 1039 1040 1041 1042
// TCefRange
//  /include/internal/cef_types_geometry.h (cef_range_t)
type TCefRange struct {
	From int32
	To   int32
}

yanghye's avatar
yanghye 已提交
1043 1044 1045 1046 1047 1048 1049 1050
// /include/internal/cef_types_geometry.h (cef_insets_t)
type TCefInsets struct {
	Top    int32
	Left   int32
	Bottom int32
	Right  int32
}

yanghye's avatar
yanghye 已提交
1051 1052 1053 1054 1055 1056 1057 1058
// TCefAudioParameters
// /include/internal/cef_types.h (cef_audio_parameters_t)
type TCefAudioParameters struct {
	channelLayout   TCefChannelLayout
	sampleRate      int32
	framesPerBuffer int32
}

yanghye's avatar
yanghye 已提交
1059
type CefPdfPrintSettings struct {
yanghye's avatar
yanghye 已提交
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
	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
yanghye's avatar
yanghye 已提交
1075 1076
}

yanghye's avatar
yanghye 已提交
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
// /include/internal/cef_types.h (cef_popup_features_t)
type TCefPopupFeatures struct {
	X                 int32
	XSet              int32
	Y                 int32
	YSet              int32
	Width             int32
	WidthSet          int32
	Height            int32
	HeightSet         int32
	MenuBarVisible    int32
	StatusBarVisible  int32
	ToolBarVisible    int32
	ScrollbarsVisible int32
}

yanghye's avatar
yanghye 已提交
1093 1094 1095 1096 1097 1098 1099 1100 1101
// /include/internal/cef_types.h (cef_composition_underline_t)
type TCefCompositionUnderline struct {
	Range           TCefRange
	Color           Cardinal
	BackgroundColor Cardinal
	Thick           int32
	Style           TCefCompositionUnderlineStyle
}

yanghye's avatar
yanghye 已提交
1102 1103 1104 1105 1106
// ResultString 字符串返回值
type ResultString struct {
	value string
}

yanghye's avatar
yanghye 已提交
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125
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
	backgroundColor            TCefColor
	acceptLanguageList         String
	windowlessFrameRate        Integer
	chromeStatusBubble         TCefState
}

yanghye's avatar
yanghye 已提交
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
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
yanghye's avatar
yanghye 已提交
1150 1151
}

yanghye's avatar
yanghye 已提交
1152 1153
func (m *ResultBytes) SetValue(value []byte) {
	m.value = value
yanghye's avatar
yanghye 已提交
1154 1155
}

yanghye's avatar
yanghye 已提交
1156 1157
func (m *ResultBytes) Value() []byte {
	return m.value
yanghye's avatar
yanghye 已提交
1158 1159
}

yanghye's avatar
yanghye 已提交
1160
// NewCefRect
1161 1162 1163 1164 1165 1166 1167 1168 1169
func NewCefRect(x, y, width, height int32) *TCefRect {
	return &TCefRect{
		X:      x,
		Y:      y,
		Width:  width,
		Height: height,
	}
}

yanghye's avatar
yanghye 已提交
1170
// NewCefSize
yanghye's avatar
yanghye 已提交
1171 1172 1173 1174 1175 1176 1177
func NewCefSize(width, height int32) *TCefSize {
	return &TCefSize{
		Width:  width,
		Height: height,
	}
}

yanghye's avatar
yanghye 已提交
1178
// NewCefPoint
1179 1180 1181 1182 1183 1184 1185
func NewCefPoint(x, y int32) *TCefPoint {
	return &TCefPoint{
		X: x,
		Y: y,
	}
}

yanghye's avatar
yanghye 已提交
1186 1187 1188 1189 1190 1191 1192
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
}