Title: [213841] releases/WebKitGTK/webkit-2.16/Tools
Revision
213841
Author
[email protected]
Date
2017-03-13 06:24:51 -0700 (Mon, 13 Mar 2017)

Log Message

Merge r213789 - MiniBrowser: a tab closed from _javascript_ always closes the window
https://bugs.webkit.org/show_bug.cgi?id=169415

Reviewed by Michael Catanzaro.

When I implemented tabs support in MiniBrowser I forgot about web view close. We connect to the signal (only for
the active tab) and close the window. That worked when we didn't have tabs, but now we should close the tab, or
the window if it's the last tab.

* MiniBrowser/gtk/BrowserWindow.c:
(webViewClose): Destroy the window if therte's only one tab, otherwise search for the tab corresponding to the web
view and destroy it.
(browserWindowSwitchTab): Re-connect to close signal, we want to handle close on all tabs.

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.16/Tools/ChangeLog (213840 => 213841)


--- releases/WebKitGTK/webkit-2.16/Tools/ChangeLog	2017-03-13 13:24:02 UTC (rev 213840)
+++ releases/WebKitGTK/webkit-2.16/Tools/ChangeLog	2017-03-13 13:24:51 UTC (rev 213841)
@@ -1,3 +1,19 @@
+2017-03-13  Carlos Garcia Campos  <[email protected]>
+
+        MiniBrowser: a tab closed from _javascript_ always closes the window
+        https://bugs.webkit.org/show_bug.cgi?id=169415
+
+        Reviewed by Michael Catanzaro.
+
+        When I implemented tabs support in MiniBrowser I forgot about web view close. We connect to the signal (only for
+        the active tab) and close the window. That worked when we didn't have tabs, but now we should close the tab, or
+        the window if it's the last tab.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (webViewClose): Destroy the window if therte's only one tab, otherwise search for the tab corresponding to the web
+        view and destroy it.
+        (browserWindowSwitchTab): Re-connect to close signal, we want to handle close on all tabs.
+
 2017-03-07  Alex Christensen  <[email protected]>
 
         [URLParser] Fix file URLs that are just file:// and a Windows drive letter

Modified: releases/WebKitGTK/webkit-2.16/Tools/MiniBrowser/gtk/BrowserWindow.c (213840 => 213841)


--- releases/WebKitGTK/webkit-2.16/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-03-13 13:24:02 UTC (rev 213840)
+++ releases/WebKitGTK/webkit-2.16/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-03-13 13:24:51 UTC (rev 213841)
@@ -259,7 +259,20 @@
 
 static void webViewClose(WebKitWebView *webView, BrowserWindow *window)
 {
-    gtk_widget_destroy(GTK_WIDGET(window));
+    int tabsCount = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook));
+    if (tabsCount == 1) {
+        gtk_widget_destroy(GTK_WIDGET(window));
+        return;
+    }
+
+    int i;
+    for (i = 0; i < tabsCount; ++i) {
+        BrowserTab *tab = (BrowserTab *)gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->notebook), i);
+        if (browser_tab_get_web_view(tab) == webView) {
+            gtk_widget_destroy(GTK_WIDGET(tab));
+            return;
+        }
+    }
 }
 
 static void webViewRunAsModal(WebKitWebView *webView, BrowserWindow *window)
@@ -800,6 +813,9 @@
         WebKitWebView *webView = browser_tab_get_web_view(window->activeTab);
         g_signal_handlers_disconnect_by_data(webView, window);
 
+        /* We always want close to be connected even for not active tabs */
+        g_signal_connect(webView, "close", G_CALLBACK(webViewClose), window);
+
         WebKitBackForwardList *backForwadlist = webkit_web_view_get_back_forward_list(webView);
         g_signal_handlers_disconnect_by_data(backForwadlist, window);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to