Title: [213789] trunk/Tools
Revision
213789
Author
[email protected]
Date
2017-03-13 02:15:51 -0700 (Mon, 13 Mar 2017)

Log Message

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: trunk/Tools/ChangeLog (213788 => 213789)


--- trunk/Tools/ChangeLog	2017-03-13 09:10:29 UTC (rev 213788)
+++ trunk/Tools/ChangeLog	2017-03-13 09:15:51 UTC (rev 213789)
@@ -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-11  Said Abou-Hallawa  <[email protected]>
 
         Enable async image decoding for large images

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (213788 => 213789)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-03-13 09:10:29 UTC (rev 213788)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2017-03-13 09:15:51 UTC (rev 213789)
@@ -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