v0.0.46 - Release: target=_blank links open in new tab instead of new window
This commit is contained in:
+21
-18
@@ -1082,8 +1082,15 @@ static gboolean on_decide_policy(WebKitWebView *webview,
|
||||
|
||||
/* ── New webview creation (target="_blank") ────────────────────────── *
|
||||
* When a page requests a new window (target="_blank", window.open()),
|
||||
* WebKit fires the "create" signal on the webview. We create a new tab
|
||||
* with the requested URI and return its webview.
|
||||
* WebKit fires the "create" signal on the webview. We open the requested
|
||||
* URI in a new tab in the current window (matching the behavior of other
|
||||
* tabbed browsers like Brave/Firefox) and return the new tab's webview.
|
||||
*
|
||||
* The new webview is created with webkit_web_view_new_with_related_view()
|
||||
* (via the g_target_related_view mechanism in tab_create) so it shares the
|
||||
* parent's WebProcess and window features — this avoids the
|
||||
* std::optional<WindowFeatures> assertion crash that occurs with
|
||||
* webkit_web_view_new_with_context() for target="_blank" requests.
|
||||
*/
|
||||
|
||||
static GtkWidget *on_create_webview(WebKitWebView *webview,
|
||||
@@ -1094,24 +1101,20 @@ static GtkWidget *on_create_webview(WebKitWebView *webview,
|
||||
WebKitURIRequest *request = webkit_navigation_action_get_request(action);
|
||||
const char *uri = webkit_uri_request_get_uri(request);
|
||||
|
||||
/* When a page requests a new window (target="_blank", window.open()),
|
||||
* WebKit fires the "create" signal. We create a real GtkWindow with
|
||||
* its own webview (created with webkit_web_view_new_with_related_view
|
||||
* so it shares the parent's WebProcess) and return that webview.
|
||||
*
|
||||
* Using webkit_web_view_new_with_related_view() shares the WebProcess
|
||||
* and the related view's window features, which avoids the previous
|
||||
* std::optional<WindowFeatures> assertion crash that occurred when
|
||||
* returning a webview created with webkit_web_view_new_with_context().
|
||||
*
|
||||
* If new window creation fails, fall back to opening a tab. */
|
||||
if (uri && uri[0]) {
|
||||
GtkWidget *new_wv = tab_manager_new_window(uri, webview);
|
||||
if (new_wv != NULL) {
|
||||
return new_wv;
|
||||
/* Set the related view so tab_create() uses
|
||||
* webkit_web_view_new_with_related_view() — shares the parent's
|
||||
* WebProcess and avoids the WindowFeatures assertion crash. */
|
||||
g_target_related_view = webview;
|
||||
int idx = tab_manager_new_tab(uri);
|
||||
g_target_related_view = NULL;
|
||||
|
||||
if (idx >= 0) {
|
||||
tab_info_t *tab = tab_manager_get(idx);
|
||||
if (tab && tab->webview) {
|
||||
return GTK_WIDGET(tab->webview);
|
||||
}
|
||||
}
|
||||
/* Fallback: open in a new tab in the main window. */
|
||||
tab_manager_new_tab(uri);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
+2
-2
@@ -11,9 +11,9 @@
|
||||
#ifndef SOVEREIGN_BROWSER_VERSION_H
|
||||
#define SOVEREIGN_BROWSER_VERSION_H
|
||||
|
||||
#define SB_VERSION "v0.0.45"
|
||||
#define SB_VERSION "v0.0.46"
|
||||
#define SB_VERSION_MAJOR 0
|
||||
#define SB_VERSION_MINOR 0
|
||||
#define SB_VERSION_PATCH 45
|
||||
#define SB_VERSION_PATCH 46
|
||||
|
||||
#endif /* SOVEREIGN_BROWSER_VERSION_H */
|
||||
|
||||
Reference in New Issue
Block a user