Bug 2037016

Summary: WebKit horizontal scrollbar not correctly displayed if theme enables steppers
Product: Red Hat Enterprise Linux 9 Reporter: Simeon Andreev <simeon.andreev>
Component: webkit2gtk3Assignee: Michael Catanzaro <mcatanza>
Status: CLOSED ERRATA QA Contact: Michal Odehnal <modehnal>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.0CC: loskutov, sbarcomb, tpelka, tpopela, vrajput
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: webkit2gtk3-2.34.6-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 12:34:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Screenshot of the reproducer snippet, with enabled scrollbar steppers and disabled overlay scrollbars.
none
Recording of the reproduction snippet, if scrollbar steppers and overlay scrollbars are enabled. none

Description Simeon Andreev 2022-01-04 16:28:48 UTC
Created attachment 1848883 [details]
Screenshot of the reproducer snippet, with enabled scrollbar steppers and disabled overlay scrollbars.

Description of problem:

The following theme code breaks WebKit horizontal scrollbars:

* { -GtkScrollbar-has-backward-stepper: true; -GtkScrollbar-has-forward-stepper: true; }


Version-Release number of selected component (if applicable):

Red Hat Enterprise Linux release 9.0 Beta (Plow)
gtk3-3.24.30-3.el9.x86_64
webkit2gtk3-2.32.3-2.el9.x86_64

How reproducible:

Run snippet provided below.

Steps to Reproduce:
1. Adjust the user .css to enable scrollbar steppers (create a backup beforehand if user .css already exists):

echo "* { -GtkScrollbar-has-backward-stepper: true; -GtkScrollbar-has-forward-stepper: true; }" > ~/.config/gtk-3.0/gtk.css

2. Create an .html file to display "overlay_scroll.html", with contents:

<!DOCTYPE html>
<html>
<head>
    <style>     
    div.scroll {
        margin: 4px, 4px;
        padding: 4px;
        width: 500px;
        overflow: scroll;
    }
    </style>
</head>
<body>
        <div class="scroll">
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
        </div>
</body>
</html>

3. Create the GTK3 snippet "browser.cpp" with contents:

#include <gtk/gtk.h>
#include <webkit2/webkit2.h>


static void destroyWindowCb(GtkWidget* widget, GtkWidget* window);
static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window);

// gcc -g browser.cpp  `pkg-config --cflags --libs  webkit2gtk-4.0 gtk+-3.0` -o BrowserExample && ./BrowserExample

int main(int argc, char* argv[])
{
    // Initialize GTK+
    gtk_init(&argc, &argv);

    // Create a window that will contain the browser instance
    GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(main_window), 300, 200);

    // Create a browser instance
    WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());

    // Put the browser area into the main window
    gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(webView));

    // Set up callbacks so that if either the main window or the browser instance is
    // closed, the program will exit
    g_signal_connect(main_window, "destroy", G_CALLBACK(destroyWindowCb), NULL);
    g_signal_connect(webView, "close", G_CALLBACK(closeWebViewCb), main_window);

    // Load a web page into the browser instance
    webkit_web_view_load_uri(webView, "file:///home/sandreev/overlay_scroll.html");

    // Make sure that when the browser area becomes visible, it will get mouse
    // and keyboard events
    gtk_widget_grab_focus(GTK_WIDGET(webView));

    // Make sure the main window and all its contents are visible
    gtk_widget_show_all(main_window);

    // Run the main GTK+ event loop
    gtk_main();

    return 0;
}


static void destroyWindowCb(GtkWidget* widget, GtkWidget* window)
{
    gtk_main_quit();
}

static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window)
{
    gtk_widget_destroy(window);
    return TRUE;
}


4. Run the snippet with command line:

gcc -g browser.cpp  `pkg-config --cflags --libs  webkit2gtk-4.0 gtk+-3.0` -o BrowserExample && ./BrowserExample


Actual results:

The horizontal scrollbar is not displayed correctly.

When overlay scrollbars are disabled, the horizontal scrollbar is undersized/misplaced, and a thick black bar is displayed above it.

When overlay scrollbars are enabled, the horizontal scrollbar is undersized/misplaced.

It looks like the horizontal scrollbar is drawn too low, but its hard to tell.

Expected results:

The horizontal scrollbar is displayed correctly.

Additional info:

Found while investigating Eclipse bug for JavaDoc/debugging hovers with GTK3: https://bugs.eclipse.org/bugs/show_bug.cgi?id=546961

Comment 1 Simeon Andreev 2022-01-04 16:30:48 UTC
Created attachment 1848884 [details]
Recording of the reproduction snippet, if scrollbar steppers and overlay scrollbars are enabled.

Comment 2 Michael Catanzaro 2022-01-04 17:24:40 UTC
Ack, thanks for the detailed report.

If you have a WebKit Bugzilla account, I'm going to request that you report this upstream as well. If not, I can forward it.

Comment 3 Simeon Andreev 2022-01-05 07:25:25 UTC
(In reply to Michael Catanzaro from comment #2)
> Ack, thanks for the detailed report.
> 
> If you have a WebKit Bugzilla account, I'm going to request that you report
> this upstream as well. If not, I can forward it.

I don't have an account. What is the WebKit bugzilla?

Is anyone able to register, if so I'll create an account. If not, please forward the bug.

Comment 4 Tomas Popela 2022-01-05 07:40:04 UTC
(In reply to Simeon Andreev from comment #3)
> (In reply to Michael Catanzaro from comment #2)
> > Ack, thanks for the detailed report.
> > 
> > If you have a WebKit Bugzilla account, I'm going to request that you report
> > this upstream as well. If not, I can forward it.
> 
> I don't have an account. What is the WebKit bugzilla?

https://bugs.webkit.org/

> Is anyone able to register, if so I'll create an account.

Yes, everyone is able to register there.

Comment 5 Simeon Andreev 2022-01-05 07:55:02 UTC
OK, I opened a ticket: https://bugs.webkit.org/show_bug.cgi?id=234871

Comment 6 Michael Catanzaro 2022-02-04 20:05:51 UTC
Hi, since we found a workaround in the upstream ticket, is it OK to close this issue? It certainly is a valid bug, but I don't think it's high enough priority to track downstream if you are content with the workaround.

Comment 7 Simeon Andreev 2022-02-07 15:44:13 UTC
(In reply to Michael Catanzaro from comment #6)
> Hi, since we found a workaround in the upstream ticket, is it OK to close
> this issue? It certainly is a valid bug, but I don't think it's high enough
> priority to track downstream if you are content with the workaround.

I discussed with Andrey (the colleague responsible for Eclipse maintenance at Advantest). We cannot add the suggested workaround to Eclipse, as it would affect the Eclipse UI for all themes, in particular it will also affect Adwaita. Maybe with a switch, which we enable in some way...

If there is an option to set an ENV variable, so that we can set it in our environment (that uses a theme with steppers) and so affect every WebKit based application, that would be preferable. Though I assume there isn't one? Or maybe something in the theme can be set to affect WebKit?

Comment 8 Michael Catanzaro 2022-02-07 17:45:48 UTC
OK, I'll add this back to my TODO list then. It should be fixable.

Just remember that the suggested workaround will be mandatory with GTK 4, as there it's impossible to draw system scrollbars.

Comment 12 errata-xmlrpc 2022-05-17 12:34:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: webkit2gtk3), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2349

Comment 13 Simeon Andreev 2022-06-08 08:39:41 UTC
I validated on RHEL 9 with webkit2gtk3-2.34.6-1.el9.x86_64, the problem is gone. Thanks!