Title: [244583] trunk/Tools
Revision
244583
Author
carlo...@webkit.org
Date
2019-04-24 00:53:58 -0700 (Wed, 24 Apr 2019)

Log Message

[GTK] MiniBrowser: also set the passed bg-color when receiving arguments
https://bugs.webkit.org/show_bug.cgi?id=197156

Reviewed by Michael Catanzaro.

The background color is only set when MiniBrowser is launched without arguments. This regressed when tabs
support was added.

* MiniBrowser/gtk/BrowserTab.c:
(browser_tab_set_background_color): Set the passed in color as web view background color.
* MiniBrowser/gtk/BrowserTab.h:
* MiniBrowser/gtk/BrowserWindow.c:
(browser_window_init): Initialize backgroundColor.
(browser_window_append_view): Call browser_tab_set_background_color().
(browser_window_set_background_color): Save the passed in color. This function should now be called before tabs
are added.
* MiniBrowser/gtk/main.c:
(main): Call browser_window_set_background_color() before creating the tabs.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (244582 => 244583)


--- trunk/Tools/ChangeLog	2019-04-24 07:46:08 UTC (rev 244582)
+++ trunk/Tools/ChangeLog	2019-04-24 07:53:58 UTC (rev 244583)
@@ -1,3 +1,24 @@
+2019-04-24  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] MiniBrowser: also set the passed bg-color when receiving arguments
+        https://bugs.webkit.org/show_bug.cgi?id=197156
+
+        Reviewed by Michael Catanzaro.
+
+        The background color is only set when MiniBrowser is launched without arguments. This regressed when tabs
+        support was added.
+
+        * MiniBrowser/gtk/BrowserTab.c:
+        (browser_tab_set_background_color): Set the passed in color as web view background color.
+        * MiniBrowser/gtk/BrowserTab.h:
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (browser_window_init): Initialize backgroundColor.
+        (browser_window_append_view): Call browser_tab_set_background_color().
+        (browser_window_set_background_color): Save the passed in color. This function should now be called before tabs
+        are added.
+        * MiniBrowser/gtk/main.c:
+        (main): Call browser_window_set_background_color() before creating the tabs.
+
 2019-04-23  John Wilander  <wilan...@apple.com>
 
         Move Ad Click Attribution from internal feature to experimental feature

Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.c (244582 => 244583)


--- trunk/Tools/MiniBrowser/gtk/BrowserTab.c	2019-04-24 07:46:08 UTC (rev 244582)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.c	2019-04-24 07:53:58 UTC (rev 244583)
@@ -603,3 +603,16 @@
         gtk_window_set_focus(window, focusWidget);
     }
 }
+
+void browser_tab_set_background_color(BrowserTab *tab, GdkRGBA *rgba)
+{
+    g_return_if_fail(BROWSER_IS_TAB(tab));
+    g_return_if_fail(rgba);
+
+    GdkRGBA viewRGBA;
+    webkit_web_view_get_background_color(tab->webView, &viewRGBA);
+    if (gdk_rgba_equal(rgba, &viewRGBA))
+        return;
+
+    webkit_web_view_set_background_color(tab->webView, rgba);
+}

Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.h (244582 => 244583)


--- trunk/Tools/MiniBrowser/gtk/BrowserTab.h	2019-04-24 07:46:08 UTC (rev 244582)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.h	2019-04-24 07:53:58 UTC (rev 244583)
@@ -54,6 +54,7 @@
 void browser_tab_add_accelerators(BrowserTab*, GtkAccelGroup*);
 void browser_tab_enter_fullscreen(BrowserTab*);
 void browser_tab_leave_fullscreen(BrowserTab*);
+void browser_tab_set_background_color(BrowserTab*, GdkRGBA*);
 
 G_END_DECLS
 

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (244582 => 244583)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2019-04-24 07:46:08 UTC (rev 244582)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2019-04-24 07:53:58 UTC (rev 244583)
@@ -65,6 +65,7 @@
     GtkWindow *parentWindow;
     guint resetEntryProgressTimeoutId;
     gchar *sessionFile;
+    GdkRGBA backgroundColor;
 };
 
 struct _BrowserWindowClass {
@@ -917,6 +918,9 @@
 {
     windowList = g_list_append(windowList, window);
 
+    window->backgroundColor.red = window->backgroundColor.green = window->backgroundColor.blue = 255;
+    window->backgroundColor.alpha = 1;
+
     gtk_window_set_title(GTK_WINDOW(window), defaultWindowTitle);
     gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
 
@@ -1155,6 +1159,8 @@
     }
 
     GtkWidget *tab = browser_tab_new(webView);
+    if (gtk_widget_get_app_paintable(GTK_WIDGET(window)))
+        browser_tab_set_background_color(BROWSER_TAB(tab), &window->backgroundColor);
     browser_tab_add_accelerators(BROWSER_TAB(tab), window->accelGroup);
     gtk_notebook_append_page(GTK_NOTEBOOK(window->notebook), tab, browser_tab_get_title_widget(BROWSER_TAB(tab)));
     gtk_container_child_set(GTK_CONTAINER(window->notebook), tab, "tab-expand", TRUE, NULL);
@@ -1203,12 +1209,13 @@
     g_return_if_fail(BROWSER_IS_WINDOW(window));
     g_return_if_fail(rgba);
 
-    WebKitWebView *webView = browser_tab_get_web_view(window->activeTab);
-    GdkRGBA viewRGBA;
-    webkit_web_view_get_background_color(webView, &viewRGBA);
-    if (gdk_rgba_equal(rgba, &viewRGBA))
+    g_assert(!window->activeTab);
+
+    if (gdk_rgba_equal(rgba, &window->backgroundColor))
         return;
 
+    window->backgroundColor = *rgba;
+
     GdkVisual *rgbaVisual = gdk_screen_get_rgba_visual(gtk_window_get_screen(GTK_WINDOW(window)));
     if (!rgbaVisual)
         return;
@@ -1215,8 +1222,6 @@
 
     gtk_widget_set_visual(GTK_WIDGET(window), rgbaVisual);
     gtk_widget_set_app_paintable(GTK_WIDGET(window), TRUE);
-
-    webkit_web_view_set_background_color(webView, rgba);
 }
 
 WebKitWebView *browser_window_get_or_create_web_view_for_automation(void)

Modified: trunk/Tools/MiniBrowser/gtk/main.c (244582 => 244583)


--- trunk/Tools/MiniBrowser/gtk/main.c	2019-04-24 07:46:08 UTC (rev 244582)
+++ trunk/Tools/MiniBrowser/gtk/main.c	2019-04-24 07:53:58 UTC (rev 244583)
@@ -589,6 +589,9 @@
     else if (geometry)
         gtk_window_parse_geometry(GTK_WINDOW(mainWindow), geometry);
 
+    if (backgroundColor)
+        browser_window_set_background_color(mainWindow, backgroundColor);
+
     GtkWidget *firstTab = NULL;
     if (uriArguments) {
         int i;
@@ -605,9 +608,6 @@
         WebKitWebView *webView = createBrowserTab(mainWindow, webkitSettings, userContentManager);
         firstTab = GTK_WIDGET(webView);
 
-        if (backgroundColor)
-            browser_window_set_background_color(mainWindow, backgroundColor);
-
         if (!editorMode) {
             if (sessionFile)
                 browser_window_load_session(mainWindow, sessionFile);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to