After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 649798 - Css selection problems
Css selection problems
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.0.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2011-05-09 14:37 UTC by Alexander Larsson
Modified: 2014-05-22 00:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (1.91 KB, text/plain)
2011-05-09 14:37 UTC, Alexander Larsson
Details

Description Alexander Larsson 2011-05-09 14:37:05 UTC
Created attachment 187511 [details]
Test case

I'm playing around with CSS, and i have found two problems:

1) A single element matcher: "Foo { }" matches all Foo widgets and all the widgets inside it. This isn't what you expect from css, which only matches the element, and lets you use "Foo, Foo * {}" for the above behaviour. 

This is problematic because it means there is no way to only select the Foo

2) widget name selectors don't seem to work at all.

Attaching a testcase
Comment 1 Alexander Larsson 2011-05-09 14:41:34 UTC
Ahh, the name selector works, i was just using it wrong ("GtkLabel #name" instead of "GtkLabel#name").
Comment 2 Carlos Garnacho 2011-05-16 12:00:24 UTC
As for 1), it was rather considered a "feature", since GtkCssProvider considers all properties to be inherited by default so, given a label within a button, these 3 selectors are ordered by priority:

GtkButton GtkLabel { ... }
GtkLabel { ... }
GtkButton { ... }

With the parent objects' rules yielding less priority, these properties serve as a fallback to more specific rules within the same GtkStyleProvider.

However, I know Benjamin was rewriting the parser so it's more CSS3 compliant, not sure if he has plans about having inheritance to be figured out per property there.
Comment 3 Benjamin Otte (Company) 2011-05-16 13:06:39 UTC
Yeah, inherit by default was "ok", but there's problems with it:
1) You don't want inherit almost all of the time - see http://www.w3.org/TR/CSS21/propidx.html - for our code I think we just want inherit for color and font properties.
2) I think the parser didn't get the priorities right, so it could happen that a parent's rule would overwrite a rule applying to the child directly
Comment 4 Matthias Clasen 2014-05-22 00:29:42 UTC
we have more spec-compliant inheritance now