[epiphany/mcatanzaro/#960] web-view: fix white flash when opening tabs in dark mode
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/#960] web-view: fix white flash when opening tabs in dark mode
- Date: Thu, 30 Jan 2020 10:47:34 +0000 (UTC)
commit 87f2a382c020fc3a069a506e51ffb3fcaad05f06
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Jan 30 04:46:03 2020 -0600
web-view: fix white flash when opening tabs in dark mode
It's OK to use a custom background color when opening new tabs, but we
have to be careful to reset it back to white when loading anything
that's not an internal Epiphany webpage.
Fixes #960
embed/ephy-web-view.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index a81a1711e..841baab17 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1359,6 +1359,15 @@ update_ucm_ads_state (WebKitWebView *web_view,
ephy_filters_manager_set_ucm_forbids_ads (ephy_embed_shell_get_filters_manager (shell), ucm, enable);
}
+static void
+reset_background_color (WebKitWebView *web_view)
+{
+ GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
+
+ /* https://bugs.webkit.org/show_bug.cgi?id=206953#c2 */
+ webkit_web_view_set_background_color (web_view, &white);
+}
+
static void
load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
@@ -1447,6 +1456,12 @@ load_changed_cb (WebKitWebView *web_view,
if (!view->reader_active)
g_clear_pointer (&view->reader_content, g_free);
+ /* We have to reset the background color here because we set a
+ * nonwhite background in constructed.
+ */
+ if (!g_str_has_prefix (uri, EPHY_ABOUT_SCHEME))
+ reset_background_color (web_view);
+
break;
}
case WEBKIT_LOAD_FINISHED:
@@ -3488,6 +3503,8 @@ static void
ephy_web_view_constructed (GObject *object)
{
EphyWebView *web_view = EPHY_WEB_VIEW (object);
+ GtkStyleContext *context;
+ GdkRGBA color;
G_OBJECT_CLASS (ephy_web_view_parent_class)->constructed (object);
@@ -3497,6 +3514,14 @@ ephy_web_view_constructed (GObject *object)
G_CALLBACK (process_terminated_cb), NULL);
g_signal_connect_swapped (webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view)),
"changed", G_CALLBACK (update_navigation_flags), web_view);
+
+ /* Avoid flashing a white background when loading the overview in
+ * dark mode. Note that we have to later reset this to white before
+ * loading any non-Epiphany page.
+ */
+ context = gtk_widget_get_style_context (GTK_WIDGET (web_view));
+ if (gtk_style_context_lookup_color (context, "theme_base_color", &color))
+ webkit_web_view_set_background_color (WEBKIT_WEB_VIEW (web_view), &color);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]