Skip to content

Commit

Permalink
update pkgs/miniblink
Browse files Browse the repository at this point in the history
  • Loading branch information
ying32 committed Jun 21, 2021
1 parent ba21abb commit 9fdafa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 59 deletions.
12 changes: 0 additions & 12 deletions pkgs/miniblink/init.go
@@ -1,15 +1,3 @@
// +build windows

package miniblink

import "github.com/ying32/govcl/vcl/rtl"

var (
isLcl bool
)

func init() {
isLcl = rtl.LcLLoaded()
//Initialize()

}
30 changes: 5 additions & 25 deletions pkgs/miniblink/wke.go
Expand Up @@ -21,27 +21,15 @@ func (w WkeWebView) SetTransparent(val bool) {
}

func (w WkeWebView) LoadURL(url string) {
if isLcl {
wkeLoadURL(w, url)
} else {
wkeLoadURLW(w, url)
}
wkeLoadURL(w, url)
}

func (w WkeWebView) LoadHTML(html string) {
if isLcl {
wkeLoadHTML(w, html)
} else {
wkeLoadHTMLW(w, html)
}
wkeLoadHTML(w, html)
}

func (w WkeWebView) LoadFile(html string) {
if isLcl {
wkeLoadFile(w, html)
} else {
wkeLoadFileW(w, html)
}
wkeLoadFile(w, html)
}

func (w WkeWebView) URL() string {
Expand Down Expand Up @@ -73,11 +61,7 @@ func (w WkeWebView) Reload() {
}

func (w WkeWebView) Title() string {
if isLcl {
return wkeTitle(w)
} else {
return wkeTitleW(w)
}
return wkeTitle(w)
}

func (w WkeWebView) Resize(width, height int) {
Expand Down Expand Up @@ -217,11 +201,7 @@ func (w WkeWebView) KillFocus() {
}

func (w WkeWebView) RunJS(script string) JsValue {
if isLcl {
return wkeRunJS(w, script)
} else {
return wkeRunJSW(w, script)
}
return wkeRunJS(w, script)
}

func (w WkeWebView) GlobalExec() JsExecState {
Expand Down
28 changes: 6 additions & 22 deletions pkgs/miniblink/wkecallback.go
Expand Up @@ -16,7 +16,7 @@ var (
_wkeDocumentReadyCallback = syscall.NewCallbackCDecl(fnwkeDocumentReadyCallback)
)

type TOnCreateViewEvent func(sender *TMiniBlinkWebview, navigationType WkeNavigationType, url WkeString, windowFeatures *WkeWindowFeatures, result *WkeWebView)
type TOnCreateViewEvent func(sender *TMiniBlinkWebview, navigationType WkeNavigationType, url string, windowFeatures *WkeWindowFeatures, result *WkeWebView)
type TOnTitleChangedEvent func(sender *TMiniBlinkWebview, title string)
type TOnURLChangedEvent func(sender *TMiniBlinkWebview, url string)
type TOnNavigationEvent func(sender *TMiniBlinkWebview, navigationType WkeNavigationType, url string)
Expand All @@ -34,7 +34,7 @@ func fnwkeCreateViewCallback(webView WkeWebView, param uintptr, navigationType W
obj := getObj(param)
proc := obj.OnCreateView
if proc != nil {
proc(obj, navigationType, url, windowFeatures, &ret)
proc(obj, navigationType, wkeGetString(url), windowFeatures, &ret)
}
}
return ret
Expand All @@ -48,11 +48,7 @@ func fnwkeTitleChangedCallback(webView unsafe.Pointer, param unsafe.Pointer, tit
obj := getObj(uintptr(param))
proc := obj.OnTitleChanged
if proc != nil {
if isLcl {
proc(obj, wkeGetString(WkeString(title)))
} else {
proc(obj, wkeGetStringW(WkeString(title)))
}
proc(obj, wkeGetString(WkeString(title)))
}
}
return 0
Expand All @@ -64,11 +60,7 @@ func fnwkeURLChangedCallback(view WkeWebView, param uintptr, url WkeString) uint
obj := getObj(param)
proc := obj.OnURLChanged
if proc != nil {
if isLcl {
proc(obj, wkeGetString(url))
} else {
proc(obj, wkeGetStringW(url))
}
proc(obj, wkeGetString(url))
}
}
return 1
Expand All @@ -80,11 +72,7 @@ func fnwkeNavigationCallback(view WkeWebView, param uintptr, navigationType WkeN
obj := getObj(param)
proc := obj.OnNavigation
if proc != nil {
if isLcl {
proc(obj, navigationType, wkeGetString(url))
} else {
proc(obj, navigationType, wkeGetStringW(url))
}
proc(obj, navigationType, wkeGetString(url))
}
}
return 1
Expand All @@ -96,11 +84,7 @@ func fnwkeLoadingFinishCallback(view WkeWebView, param uintptr, url WkeString, r
obj := getObj(param)
proc := obj.OnLoadingFinish
if proc != nil {
if isLcl {
proc(obj, wkeGetString(url), result, wkeGetString(failedReason))
} else {
proc(obj, wkeGetStringW(url), result, wkeGetStringW(failedReason))
}
proc(obj, wkeGetString(url), result, wkeGetString(failedReason))
}
}
return 1
Expand Down

0 comments on commit 9fdafa8

Please sign in to comment.