summaryrefslogtreecommitdiffstatshomepage
path: root/webview_idochostuihandler.go
blob: 1525382406e4f9545a6444e98453c4d7351b0305 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright 2010 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build windows

package walk

import (
	"syscall"
	"unsafe"
)

import (
	"github.com/lxn/win"
)

var webViewIDocHostUIHandlerVtbl *win.IDocHostUIHandlerVtbl

func init() {
	webViewIDocHostUIHandlerVtbl = &win.IDocHostUIHandlerVtbl{
		syscall.NewCallback(webView_IDocHostUIHandler_QueryInterface),
		syscall.NewCallback(webView_IDocHostUIHandler_AddRef),
		syscall.NewCallback(webView_IDocHostUIHandler_Release),
		syscall.NewCallback(webView_IDocHostUIHandler_ShowContextMenu),
		syscall.NewCallback(webView_IDocHostUIHandler_GetHostInfo),
		syscall.NewCallback(webView_IDocHostUIHandler_ShowUI),
		syscall.NewCallback(webView_IDocHostUIHandler_HideUI),
		syscall.NewCallback(webView_IDocHostUIHandler_UpdateUI),
		syscall.NewCallback(webView_IDocHostUIHandler_EnableModeless),
		syscall.NewCallback(webView_IDocHostUIHandler_OnDocWindowActivate),
		syscall.NewCallback(webView_IDocHostUIHandler_OnFrameWindowActivate),
		syscall.NewCallback(webView_IDocHostUIHandler_ResizeBorder),
		syscall.NewCallback(webView_IDocHostUIHandler_TranslateAccelerator),
		syscall.NewCallback(webView_IDocHostUIHandler_GetOptionKeyPath),
		syscall.NewCallback(webView_IDocHostUIHandler_GetDropTarget),
		syscall.NewCallback(webView_IDocHostUIHandler_GetExternal),
		syscall.NewCallback(webView_IDocHostUIHandler_TranslateUrl),
		syscall.NewCallback(webView_IDocHostUIHandler_FilterDataObject),
	}
}

type webViewIDocHostUIHandler struct {
	win.IDocHostUIHandler
}

func webView_IDocHostUIHandler_QueryInterface(docHostUIHandler *webViewIDocHostUIHandler, riid win.REFIID, ppvObject *unsafe.Pointer) uintptr {
	// Just reuse the QueryInterface implementation we have for IOleClientSite.
	// We need to adjust object, which initially points at our
	// webViewIDocHostUIHandler, so it refers to the containing
	// webViewIOleClientSite for the call.
	var clientSite win.IOleClientSite
	var webViewInPlaceSite webViewIOleInPlaceSite

	ptr := uintptr(unsafe.Pointer(docHostUIHandler)) - uintptr(unsafe.Sizeof(clientSite)) -
		uintptr(unsafe.Sizeof(webViewInPlaceSite))

	return webView_IOleClientSite_QueryInterface((*webViewIOleClientSite)(unsafe.Pointer(ptr)), riid, ppvObject)
}

func webView_IDocHostUIHandler_AddRef(docHostUIHandler *webViewIDocHostUIHandler) uintptr {
	return 1
}

func webView_IDocHostUIHandler_Release(docHostUIHandler *webViewIDocHostUIHandler) uintptr {
	return 1
}

func webView_IDocHostUIHandler_ShowContextMenu(docHostUIHandler *webViewIDocHostUIHandler, dwID uint32, ppt *win.POINT, pcmdtReserved *win.IUnknown, pdispReserved uintptr) uintptr {
	var webViewInPlaceSite webViewIOleInPlaceSite
	var iOleClientSite win.IOleClientSite
	var wb WidgetBase
	ptr := uintptr(unsafe.Pointer(docHostUIHandler)) -
		uintptr(unsafe.Sizeof(webViewInPlaceSite)) -
		uintptr(unsafe.Sizeof(iOleClientSite)) -
		uintptr(unsafe.Sizeof(wb))
	webView := (*WebView)(unsafe.Pointer(ptr))

	// show context menu
	if webView.NativeContextMenuEnabled() {
		return win.S_FALSE
	}

	return win.S_OK
}

func webView_IDocHostUIHandler_GetHostInfo(docHostUIHandler *webViewIDocHostUIHandler, pInfo *win.DOCHOSTUIINFO) uintptr {
	pInfo.CbSize = uint32(unsafe.Sizeof(*pInfo))
	pInfo.DwFlags = win.DOCHOSTUIFLAG_NO3DBORDER
	pInfo.DwDoubleClick = win.DOCHOSTUIDBLCLK_DEFAULT

	return win.S_OK
}

func webView_IDocHostUIHandler_ShowUI(docHostUIHandler *webViewIDocHostUIHandler, dwID uint32, pActiveObject uintptr, pCommandTarget uintptr, pFrame *win.IOleInPlaceFrame, pDoc uintptr) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_HideUI(docHostUIHandler *webViewIDocHostUIHandler) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_UpdateUI(docHostUIHandler *webViewIDocHostUIHandler) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_EnableModeless(docHostUIHandler *webViewIDocHostUIHandler, fEnable win.BOOL) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_OnDocWindowActivate(docHostUIHandler *webViewIDocHostUIHandler, fActivate win.BOOL) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_OnFrameWindowActivate(docHostUIHandler *webViewIDocHostUIHandler, fActivate win.BOOL) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_ResizeBorder(docHostUIHandler *webViewIDocHostUIHandler, prcBorder *win.RECT, pUIWindow uintptr, fRameWindow win.BOOL) uintptr {
	return win.S_OK
}

func webView_IDocHostUIHandler_TranslateAccelerator(docHostUIHandler *webViewIDocHostUIHandler, lpMsg *win.MSG, pguidCmdGroup *syscall.GUID, nCmdID uint) uintptr {
	return win.S_FALSE
}

func webView_IDocHostUIHandler_GetOptionKeyPath(docHostUIHandler *webViewIDocHostUIHandler, pchKey *uint16, dw uint) uintptr {
	return win.S_FALSE
}

func webView_IDocHostUIHandler_GetDropTarget(docHostUIHandler *webViewIDocHostUIHandler, pDropTarget uintptr, ppDropTarget *uintptr) uintptr {
	return win.S_FALSE
}

func webView_IDocHostUIHandler_GetExternal(docHostUIHandler *webViewIDocHostUIHandler, ppDispatch *uintptr) uintptr {
	*ppDispatch = 0

	return win.S_FALSE
}

func webView_IDocHostUIHandler_TranslateUrl(docHostUIHandler *webViewIDocHostUIHandler, dwTranslate uint32, pchURLIn *uint16, ppchURLOut **uint16) uintptr {
	*ppchURLOut = nil

	return win.S_FALSE
}

func webView_IDocHostUIHandler_FilterDataObject(docHostUIHandler *webViewIDocHostUIHandler, pDO uintptr, ppDORet *uintptr) uintptr {
	*ppDORet = 0

	return win.S_FALSE
}