GNOME Bugzilla – Bug 761870
calling gtk_style_context_save on a menuitem style child of a menubar makes it not render
Last modified: 2018-04-15 00:28:03 UTC
Created attachment 320898 [details] [review] adds a menubar example to gtk-demo which reproduces a gtk_style_context_save problem Which sounds like bug 758442, but this is with today's gtk master from git which claims to have that fixed. Attached is a patch against gtk-demo to add a menubar example which reproduces this problem (this is probably the reason firefox in current f24 has no box-shadow in its menus anymore)
To be clear: the fix was to the foreigndrawing example. So for it to help in firefox, the Firefox copy of the code needs to be updated. Thanks for the example/test case anyway, I will have a look.
Quick initial analysis: style_context_save() creates a subnode of the context's node, by copying it. So you end up with a tree that looks like this: menubar > menuitem:hover > menuitem:hover Unfortunately, Adwaita only styles menubar > menuitem:hover, which we don't match anymore. So, using save() can have unintended side-effects. We're still discussing if there's a good way to fix this.
This would be a good one to "fix" somehow. This explains several strange problems I never solved when attempting to use the foreign drawing API. I think Benjamin mentioned months ago possibly using some bit to track whether a node was created by save()?
There's no way to track that inside CSS though. And you don't want to match any menuitem that's a descenant of a menubar, because those aren't just menuitems inside menuitems (your extra save()) but also menuitems inside menus popped up by the menubar. And this code is written to explicitly not style the second case.
the fix is to not use gtk_style_context_save
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new