Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ tasks:
- git add .
- git commit -m "Updated mappings"

gofmt:
dir: pkg/webview2
cmds:
- go fmt

test:
cmds:
- go test ./...
Expand All @@ -22,7 +17,6 @@ tasks:
dir: scripts
cmds:
- go run update_version_mapping.go
- task: gofmt
- go fmt update_version_mapping.go
- task: test
- task: commit
Expand All @@ -31,7 +25,6 @@ tasks:
dir: scripts
cmds:
- go run update_version_mapping.go -forced
- task: gofmt
- go fmt update_version_mapping.go
- task: test
- task: commit
8 changes: 4 additions & 4 deletions pkg/webview2/COREWEBVIEW2_PHYSICAL_KEY_STATUS.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package webview2
type COREWEBVIEW2_PHYSICAL_KEY_STATUS struct {
RepeatCount uint32
ScanCode uint32
IsExtendedKey bool
IsMenuKeyDown bool
WasKeyDown bool
IsKeyReleased bool
IsExtendedKey int32
IsMenuKeyDown int32
WasKeyDown int32
IsKeyReleased int32
}
49 changes: 31 additions & 18 deletions pkg/webview2/ICoreWebView2.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ func (i *ICoreWebView2) AddRef() uintptr {
return refCounter
}

// Release drops one reference and returns the new count.
//
// AddRef was generated for all 252 interfaces and Release for none, which left every caller of a
// Get<Interface>() accessor leaking: QueryInterface AddRefs on success and there was no matching
// call to make, short of reaching through the embedded IUnknownVtbl for CallRelease. Additive, so
// no existing caller changes.
//
// Not generated for handler interfaces: those are objects WE implement and hand to WebView2, so
// their lifetime is the Go object's, and calling through the vtable would re-enter our own impl.
func (i *ICoreWebView2) Release() uint32 {
return i.Vtbl.CallRelease(unsafe.Pointer(i))
}

func (i *ICoreWebView2) GetSettings() (*ICoreWebView2Settings, error) {

var settings *ICoreWebView2Settings
Expand All @@ -99,7 +112,7 @@ func (i *ICoreWebView2) GetSource() (string, error) {

hr, _, _ := i.Vtbl.GetSource.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_uri)),
uintptr(unsafe.Pointer(&_uri)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
Expand Down Expand Up @@ -165,7 +178,7 @@ func (i *ICoreWebView2) RemoveNavigationStarting(token EventRegistrationToken) e

hr, _, _ := i.Vtbl.RemoveNavigationStarting.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -192,7 +205,7 @@ func (i *ICoreWebView2) RemoveContentLoading(token EventRegistrationToken) error

hr, _, _ := i.Vtbl.RemoveContentLoading.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -219,7 +232,7 @@ func (i *ICoreWebView2) RemoveSourceChanged(token EventRegistrationToken) error

hr, _, _ := i.Vtbl.RemoveSourceChanged.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -246,7 +259,7 @@ func (i *ICoreWebView2) RemoveHistoryChanged(token EventRegistrationToken) error

hr, _, _ := i.Vtbl.RemoveHistoryChanged.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -273,7 +286,7 @@ func (i *ICoreWebView2) RemoveNavigationCompleted(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemoveNavigationCompleted.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -300,7 +313,7 @@ func (i *ICoreWebView2) RemoveFrameNavigationStarting(token EventRegistrationTok

hr, _, _ := i.Vtbl.RemoveFrameNavigationStarting.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -327,7 +340,7 @@ func (i *ICoreWebView2) RemoveFrameNavigationCompleted(token EventRegistrationTo

hr, _, _ := i.Vtbl.RemoveFrameNavigationCompleted.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -354,7 +367,7 @@ func (i *ICoreWebView2) RemoveScriptDialogOpening(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemoveScriptDialogOpening.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -381,7 +394,7 @@ func (i *ICoreWebView2) RemovePermissionRequested(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemovePermissionRequested.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -408,7 +421,7 @@ func (i *ICoreWebView2) RemoveProcessFailed(token EventRegistrationToken) error

hr, _, _ := i.Vtbl.RemoveProcessFailed.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down Expand Up @@ -552,7 +565,7 @@ func (i *ICoreWebView2) RemoveWebMessageReceived(token EventRegistrationToken) e

hr, _, _ := i.Vtbl.RemoveWebMessageReceived.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down Expand Up @@ -703,7 +716,7 @@ func (i *ICoreWebView2) RemoveNewWindowRequested(token EventRegistrationToken) e

hr, _, _ := i.Vtbl.RemoveNewWindowRequested.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -730,7 +743,7 @@ func (i *ICoreWebView2) RemoveDocumentTitleChanged(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemoveDocumentTitleChanged.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand All @@ -744,7 +757,7 @@ func (i *ICoreWebView2) GetDocumentTitle() (string, error) {

hr, _, _ := i.Vtbl.GetDocumentTitle.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_title)),
uintptr(unsafe.Pointer(&_title)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
Expand Down Expand Up @@ -822,7 +835,7 @@ func (i *ICoreWebView2) RemoveContainsFullScreenElementChanged(token EventRegist

hr, _, _ := i.Vtbl.RemoveContainsFullScreenElementChanged.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down Expand Up @@ -865,7 +878,7 @@ func (i *ICoreWebView2) RemoveWebResourceRequested(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemoveWebResourceRequested.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down Expand Up @@ -930,7 +943,7 @@ func (i *ICoreWebView2) RemoveWindowCloseRequested(token EventRegistrationToken)

hr, _, _ := i.Vtbl.RemoveWindowCloseRequested.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&token)),
uintptr(*(*uint64)(unsafe.Pointer(&token))),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down
23 changes: 18 additions & 5 deletions pkg/webview2/ICoreWebView2AcceleratorKeyPressedEventArgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) AddRef() uintptr {
return refCounter
}

// Release drops one reference and returns the new count.
//
// AddRef was generated for all 252 interfaces and Release for none, which left every caller of a
// Get<Interface>() accessor leaking: QueryInterface AddRefs on success and there was no matching
// call to make, short of reaching through the embedded IUnknownVtbl for CallRelease. Additive, so
// no existing caller changes.
//
// Not generated for handler interfaces: those are objects WE implement and hand to WebView2, so
// their lifetime is the Go object's, and calling through the vtable would re-enter our own impl.
func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) Release() uint32 {
return i.Vtbl.CallRelease(unsafe.Pointer(i))
}

func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetKeyEventKind() (COREWEBVIEW2_KEY_EVENT_KIND, error) {

var keyEventKind COREWEBVIEW2_KEY_EVENT_KIND
Expand All @@ -41,9 +54,9 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetKeyEventKind() (COREWEB
return keyEventKind, nil
}

func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetVirtualKey() (uint, error) {
func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetVirtualKey() (uint32, error) {

var virtualKey uint
var virtualKey uint32

hr, _, _ := i.Vtbl.GetVirtualKey.Call(
uintptr(unsafe.Pointer(i)),
Expand All @@ -55,9 +68,9 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetVirtualKey() (uint, err
return virtualKey, nil
}

func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetKeyEventLParam() (int, error) {
func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetKeyEventLParam() (int32, error) {

var lParam int
var lParam int32

hr, _, _ := i.Vtbl.GetKeyEventLParam.Call(
uintptr(unsafe.Pointer(i)),
Expand Down Expand Up @@ -103,7 +116,7 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) PutHandled(handled bool) e

hr, _, _ := i.Vtbl.PutHandled.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&handled)),
boolToUintptr(handled),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down
26 changes: 23 additions & 3 deletions pkg/webview2/ICoreWebView2AcceleratorKeyPressedEventArgs2.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type ICoreWebView2AcceleratorKeyPressedEventArgs2Vtbl struct {
IUnknownVtbl
ICoreWebView2AcceleratorKeyPressedEventArgsVtbl
GetIsBrowserAcceleratorKeyEnabled ComProc
PutIsBrowserAcceleratorKeyEnabled ComProc
}
Expand All @@ -23,10 +23,30 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs2) AddRef() uintptr {
return refCounter
}

func (i *ICoreWebView2) GetICoreWebView2AcceleratorKeyPressedEventArgs2() *ICoreWebView2AcceleratorKeyPressedEventArgs2 {
// Release drops one reference and returns the new count.
//
// AddRef was generated for all 252 interfaces and Release for none, which left every caller of a
// Get<Interface>() accessor leaking: QueryInterface AddRefs on success and there was no matching
// call to make, short of reaching through the embedded IUnknownVtbl for CallRelease. Additive, so
// no existing caller changes.
//
// Not generated for handler interfaces: those are objects WE implement and hand to WebView2, so
// their lifetime is the Go object's, and calling through the vtable would re-enter our own impl.
func (i *ICoreWebView2AcceleratorKeyPressedEventArgs2) Release() uint32 {
return i.Vtbl.CallRelease(unsafe.Pointer(i))
}

func (i *ICoreWebView2AcceleratorKeyPressedEventArgs) GetICoreWebView2AcceleratorKeyPressedEventArgs2() *ICoreWebView2AcceleratorKeyPressedEventArgs2 {
var result *ICoreWebView2AcceleratorKeyPressedEventArgs2

iidICoreWebView2AcceleratorKeyPressedEventArgs2 := NewGUID("{03b2c8c8-7799-4e34-bd66-ed26aa85f2bf}")
// The HRESULT is deliberately not returned, because changing the signature of all 82 of these
// accessors is an API break. It is E_NOINTERFACE whenever the installed WebView2 Runtime is
// older than this interface, which is the normal case rather than an exotic one -- and then
// result stays nil and the CALLER's next method call dereferences it. Callers must nil-check.
//
// This also leaks a reference on success: QueryInterface AddRefs, and no Release is generated.
// Use Vtbl.CallRelease(unsafe.Pointer(x)) via the embedded IUnknownVtbl when finished.
_, _, _ = i.Vtbl.QueryInterface.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(iidICoreWebView2AcceleratorKeyPressedEventArgs2)),
Expand Down Expand Up @@ -55,7 +75,7 @@ func (i *ICoreWebView2AcceleratorKeyPressedEventArgs2) PutIsBrowserAcceleratorKe

hr, _, _ := i.Vtbl.PutIsBrowserAcceleratorKeyEnabled.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&value)),
boolToUintptr(value),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerIUnknownRel
return this.impl.Release()
}

func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerInvoke(this *ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler, errorCode uintptr, result string) uintptr {
func ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerInvoke(this *ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler, errorCode uintptr, result *uint16) uintptr {
return this.impl.AddScriptToExecuteOnDocumentCreatedCompleted(errorCode, result)
}

type ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerImpl interface {
IUnknownImpl
AddScriptToExecuteOnDocumentCreatedCompleted(errorCode uintptr, result string) uintptr
AddScriptToExecuteOnDocumentCreatedCompleted(errorCode uintptr, result *uint16) uintptr
}

var ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerFn = ICoreWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandlerVtbl{
Expand Down
19 changes: 16 additions & 3 deletions pkg/webview2/ICoreWebView2BasicAuthenticationRequestedEventArgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ func (i *ICoreWebView2BasicAuthenticationRequestedEventArgs) AddRef() uintptr {
return refCounter
}

// Release drops one reference and returns the new count.
//
// AddRef was generated for all 252 interfaces and Release for none, which left every caller of a
// Get<Interface>() accessor leaking: QueryInterface AddRefs on success and there was no matching
// call to make, short of reaching through the embedded IUnknownVtbl for CallRelease. Additive, so
// no existing caller changes.
//
// Not generated for handler interfaces: those are objects WE implement and hand to WebView2, so
// their lifetime is the Go object's, and calling through the vtable would re-enter our own impl.
func (i *ICoreWebView2BasicAuthenticationRequestedEventArgs) Release() uint32 {
return i.Vtbl.CallRelease(unsafe.Pointer(i))
}

func (i *ICoreWebView2BasicAuthenticationRequestedEventArgs) GetUri() (string, error) {
// Create *uint16 to hold result
var _value *uint16

hr, _, _ := i.Vtbl.GetUri.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_value)),
uintptr(unsafe.Pointer(&_value)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
Expand All @@ -50,7 +63,7 @@ func (i *ICoreWebView2BasicAuthenticationRequestedEventArgs) GetChallenge() (str

hr, _, _ := i.Vtbl.GetChallenge.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(_challenge)),
uintptr(unsafe.Pointer(&_challenge)),
)
if windows.Handle(hr) != windows.S_OK {
return "", syscall.Errno(hr)
Expand Down Expand Up @@ -95,7 +108,7 @@ func (i *ICoreWebView2BasicAuthenticationRequestedEventArgs) PutCancel(cancel bo

hr, _, _ := i.Vtbl.PutCancel.Call(
uintptr(unsafe.Pointer(i)),
uintptr(unsafe.Pointer(&cancel)),
boolToUintptr(cancel),
)
if windows.Handle(hr) != windows.S_OK {
return syscall.Errno(hr)
Expand Down
Loading