mirror of
https://github.com/tauri-apps/web-view.git
synced 2026-02-04 02:11:18 +01:00
Remove webview_check_url
It was not needed, simple null check is enough. Webview on macOS, Linux, and Windows correctly display empty webpage is content is empty, no need to display empty html document. With this, Linux gtk backend is now fully in Rust, no c compiler needed.
This commit is contained in:
@@ -42,8 +42,6 @@ fn main() {
|
||||
.atleast_version("2.8")
|
||||
.probe("webkit2gtk-4.0")
|
||||
.unwrap();
|
||||
|
||||
build.file("webview_gtk.c");
|
||||
} else if target.contains("apple") {
|
||||
build
|
||||
.file("webview_cocoa.c")
|
||||
|
||||
@@ -126,7 +126,14 @@ unsafe extern "C" fn webview_new(
|
||||
|
||||
let webview = webkit_web_view_new_with_user_content_manager(m);
|
||||
(*w).webview = webview;
|
||||
webkit_web_view_load_uri(mem::transmute(webview), webview_check_url(url));
|
||||
webkit_web_view_load_uri(
|
||||
mem::transmute(webview),
|
||||
if url.is_null() {
|
||||
b"\0".as_ptr() as *const i8
|
||||
} else {
|
||||
url
|
||||
},
|
||||
);
|
||||
g_signal_connect_data(
|
||||
mem::transmute(webview),
|
||||
CStr::from_bytes_with_nul_unchecked(b"load-changed\0").as_ptr(),
|
||||
@@ -178,10 +185,6 @@ unsafe extern "C" fn webview_new(
|
||||
w
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn webview_check_url(url: *const c_char) -> *const c_char;
|
||||
}
|
||||
|
||||
extern "C" fn webview_context_menu_cb(
|
||||
_webview: *mut WebKitWebView,
|
||||
_default_menu: *mut GtkWidget,
|
||||
|
||||
@@ -46,21 +46,6 @@ struct webview_dispatch_arg {
|
||||
void *arg;
|
||||
};
|
||||
|
||||
#define DEFAULT_URL \
|
||||
"data:text/" \
|
||||
"html,%3C%21DOCTYPE%20html%3E%0A%3Chtml%20lang=%22en%22%3E%0A%3Chead%3E%" \
|
||||
"3Cmeta%20charset=%22utf-8%22%3E%3Cmeta%20http-equiv=%22X-UA-Compatible%22%" \
|
||||
"20content=%22IE=edge%22%3E%3C%2Fhead%3E%0A%3Cbody%3E%3Cdiv%20id=%22app%22%" \
|
||||
"3E%3C%2Fdiv%3E%3Cscript%20type=%22text%2Fjavascript%22%3E%3C%2Fscript%3E%" \
|
||||
"3C%2Fbody%3E%0A%3C%2Fhtml%3E"
|
||||
|
||||
const char *webview_check_url(const char *url) {
|
||||
if (url == NULL || strlen(url) == 0) {
|
||||
return DEFAULT_URL;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
// Convert ASCII hex digit to a nibble (four bits, 0 - 15).
|
||||
//
|
||||
// Use unsigned to avoid signed overflow UB.
|
||||
|
||||
@@ -438,7 +438,7 @@ WEBVIEW_API int webview_init(webview_t w) {
|
||||
|
||||
id nsURL = objc_msgSend((id)objc_getClass("NSURL"),
|
||||
sel_registerName("URLWithString:"),
|
||||
get_nsstring(webview_check_url(wv->url)));
|
||||
get_nsstring(wv->url == NULL ? "" : wv->url));
|
||||
|
||||
objc_msgSend(wv->priv.webview, sel_registerName("loadRequest:"),
|
||||
objc_msgSend((id)objc_getClass("NSURLRequest"),
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "webview.h"
|
||||
@@ -840,7 +840,7 @@ static int DisplayHTMLPage(struct mshtml_webview *wv) {
|
||||
VARIANT *pVar;
|
||||
browserObject = *wv->browser;
|
||||
int isDataURL = 0;
|
||||
const char *webview_url = webview_check_url(wv->url);
|
||||
const char *webview_url = wv->url == NULL ? "" : wv->url;
|
||||
if (!browserObject->lpVtbl->QueryInterface(
|
||||
browserObject, iid_unref(&IID_IWebBrowser2), (void **)&webBrowser2)) {
|
||||
LPCSTR webPageName;
|
||||
|
||||
Reference in New Issue
Block a user