forked from lxn/walk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webview_ioleinplacesite.go
126 lines (99 loc) · 4.3 KB
/
webview_ioleinplacesite.go
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
// 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.
package walk
import (
"syscall"
"unsafe"
)
import (
"github.com/lxn/win"
)
var webViewIOleInPlaceSiteVtbl *win.IOleInPlaceSiteVtbl
func init() {
webViewIOleInPlaceSiteVtbl = &win.IOleInPlaceSiteVtbl{
syscall.NewCallback(webView_IOleInPlaceSite_QueryInterface),
syscall.NewCallback(webView_IOleInPlaceSite_AddRef),
syscall.NewCallback(webView_IOleInPlaceSite_Release),
syscall.NewCallback(webView_IOleInPlaceSite_GetWindow),
syscall.NewCallback(webView_IOleInPlaceSite_ContextSensitiveHelp),
syscall.NewCallback(webView_IOleInPlaceSite_CanInPlaceActivate),
syscall.NewCallback(webView_IOleInPlaceSite_OnInPlaceActivate),
syscall.NewCallback(webView_IOleInPlaceSite_OnUIActivate),
syscall.NewCallback(webView_IOleInPlaceSite_GetWindowContext),
syscall.NewCallback(webView_IOleInPlaceSite_Scroll),
syscall.NewCallback(webView_IOleInPlaceSite_OnUIDeactivate),
syscall.NewCallback(webView_IOleInPlaceSite_OnInPlaceDeactivate),
syscall.NewCallback(webView_IOleInPlaceSite_DiscardUndoState),
syscall.NewCallback(webView_IOleInPlaceSite_DeactivateAndUndo),
syscall.NewCallback(webView_IOleInPlaceSite_OnPosRectChange),
}
}
type webViewIOleInPlaceSite struct {
win.IOleInPlaceSite
inPlaceFrame webViewIOleInPlaceFrame
}
func webView_IOleInPlaceSite_QueryInterface(inPlaceSite *webViewIOleInPlaceSite, riid win.REFIID, ppvObject *unsafe.Pointer) uintptr {
// Just reuse the QueryInterface implementation we have for IOleClientSite.
// We need to adjust object from the webViewIDocHostUIHandler to the
// containing webViewIOleInPlaceSite.
var clientSite win.IOleClientSite
ptr := uintptr(unsafe.Pointer(inPlaceSite)) - uintptr(unsafe.Sizeof(clientSite))
return webView_IOleClientSite_QueryInterface((*webViewIOleClientSite)(unsafe.Pointer(ptr)), riid, ppvObject)
}
func webView_IOleInPlaceSite_AddRef(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return 1
}
func webView_IOleInPlaceSite_Release(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return 1
}
func webView_IOleInPlaceSite_GetWindow(inPlaceSite *webViewIOleInPlaceSite, lphwnd *win.HWND) uintptr {
*lphwnd = inPlaceSite.inPlaceFrame.webView.hWnd
return win.S_OK
}
func webView_IOleInPlaceSite_ContextSensitiveHelp(inPlaceSite *webViewIOleInPlaceSite, fEnterMode win.BOOL) uintptr {
return win.E_NOTIMPL
}
func webView_IOleInPlaceSite_CanInPlaceActivate(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.S_OK
}
func webView_IOleInPlaceSite_OnInPlaceActivate(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.S_OK
}
func webView_IOleInPlaceSite_OnUIActivate(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.S_OK
}
func webView_IOleInPlaceSite_GetWindowContext(inPlaceSite *webViewIOleInPlaceSite, lplpFrame **webViewIOleInPlaceFrame, lplpDoc *uintptr, lprcPosRect, lprcClipRect *win.RECT, lpFrameInfo *win.OLEINPLACEFRAMEINFO) uintptr {
*lplpFrame = &inPlaceSite.inPlaceFrame
*lplpDoc = 0
lpFrameInfo.FMDIApp = win.FALSE
lpFrameInfo.HwndFrame = inPlaceSite.inPlaceFrame.webView.hWnd
lpFrameInfo.Haccel = 0
lpFrameInfo.CAccelEntries = 0
return win.S_OK
}
func webView_IOleInPlaceSite_Scroll(inPlaceSite *webViewIOleInPlaceSite, scrollExtentX, scrollExtentY int32) uintptr {
return win.E_NOTIMPL
}
func webView_IOleInPlaceSite_OnUIDeactivate(inPlaceSite *webViewIOleInPlaceSite, fUndoable win.BOOL) uintptr {
return win.S_OK
}
func webView_IOleInPlaceSite_OnInPlaceDeactivate(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.S_OK
}
func webView_IOleInPlaceSite_DiscardUndoState(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.E_NOTIMPL
}
func webView_IOleInPlaceSite_DeactivateAndUndo(inPlaceSite *webViewIOleInPlaceSite) uintptr {
return win.E_NOTIMPL
}
func webView_IOleInPlaceSite_OnPosRectChange(inPlaceSite *webViewIOleInPlaceSite, lprcPosRect *win.RECT) uintptr {
browserObject := inPlaceSite.inPlaceFrame.webView.browserObject
var inPlaceObjectPtr unsafe.Pointer
if hr := browserObject.QueryInterface(&win.IID_IOleInPlaceObject, &inPlaceObjectPtr); win.FAILED(hr) {
return uintptr(hr)
}
inPlaceObject := (*win.IOleInPlaceObject)(inPlaceObjectPtr)
defer inPlaceObject.Release()
return uintptr(inPlaceObject.SetObjectRects(lprcPosRect, lprcPosRect))
}