Bug 196912

Summary: [GTK] fix gtk_style_context_set_background deprecation
Product: WebKit Reporter: Ludovico de Nittis <ludovico.denittis>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, bugs-noreply, cgarcia, commit-queue, ews-watchlist, gustavo, mcatanzaro, pnormand
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=197156
Attachments:
Description Flags
Patch
none
Patch none

Description Ludovico de Nittis 2019-04-15 08:24:54 PDT
Since gtk 3.18 gtk_style_context_set_background has been deprecated[1].
gtk_render_background should be used instead.

gtk_style_context_set_background is still used in "Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp".

In a few minutes I'm going to attach a patch to this issue.


[1] https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-set-background
Comment 1 Ludovico de Nittis 2019-04-15 08:31:52 PDT
Created attachment 367416 [details]
Patch
Comment 2 EWS Watchlist 2019-04-15 08:33:20 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Michael Catanzaro 2019-04-15 10:48:15 PDT
Comment on attachment 367416 [details]
Patch

This looks correct to me. Could you test webkit_web_view_set_background_color(), please? Especially with transparent background.
Comment 4 Ludovico de Nittis 2019-04-16 00:25:20 PDT
I tried to launch it with the bg-color option, e.g. `/Tools/Scripts/webkit-flatpak --gtk --bg-color="rgba(200,10,10,0)"`

I was not sure how to test it though.
In the fraction of a second before the webpage was loaded I saw that the background was indeed transparent.
Then I tried to increase the alpha value and I got a colored background.
Comment 5 Philippe Normand 2019-04-16 08:00:58 PDT
Can you try with Tools/Scripts/run-minibrowser --gtk --bg-color=rgba(....) ?
run-minibrowser should invoke the built MiniBrowser in the Flatpak environment.
Comment 6 Ludovico de Nittis 2019-04-16 08:25:55 PDT
Philippe, yes I'm able to open the MiniBrowser even with webkit-flatpak.
What I meant when I said that I wasn't sure how to test my changes, is that the chosen background color is visible only for a few ms before the webpage gets loaded on top of it. And I was unable to find another place where I could see the chosen background color. For example a blank you tab is always white.

Is that how it is supposed to be?
Comment 7 Ludovico de Nittis 2019-04-16 23:32:59 PDT
s/blank you tab/blank new tab
Comment 8 Carlos Garcia Campos 2019-04-22 03:53:32 PDT
Comment on attachment 367416 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=367416&action=review

> Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp:-387
> -    gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
> -

Actually, I think this is no longer needed since we don't render backgrounds in the UI process. I think we can simply remove this without adding the render_background.
Comment 9 Carlos Garcia Campos 2019-04-22 03:55:51 PDT
(In reply to Ludovico de Nittis from comment #4)
> I tried to launch it with the bg-color option, e.g.
> `/Tools/Scripts/webkit-flatpak --gtk --bg-color="rgba(200,10,10,0)"`
> 
> I was not sure how to test it though.
> In the fraction of a second before the webpage was loaded I saw that the
> background was indeed transparent.
> Then I tried to increase the alpha value and I got a colored background.

You can use the MiniBrowser editor mode (-e) to try it out. You can also try with any page not setting a background color in the css, as simple as <html></html> for example. But you have to load MiniBrowser without arguments and then load the test page (for some reason I don't remember the background color is not set when MiniBrowser receives arguments).
Comment 10 Ludovico de Nittis 2019-04-22 05:18:59 PDT
Created attachment 367936 [details]
Patch
Comment 11 Ludovico de Nittis 2019-04-22 05:21:32 PDT
Carlos I tested it again and you are right, the background is available even without the gtk_render_background.
So I uploaded a new patch, this time that just removes gtk_style_context_set_background.
Comment 12 WebKit Commit Bot 2019-04-22 09:31:46 PDT
Comment on attachment 367936 [details]
Patch

Clearing flags on attachment: 367936

Committed r244500: <https://trac.webkit.org/changeset/244500>
Comment 13 WebKit Commit Bot 2019-04-22 09:31:48 PDT
All reviewed patches have been landed.  Closing bug.