Commit Graph

488 Commits

Author SHA1 Message Date
Benjamin Otte
8355ee3053 stylecontext: Don't emit state warning for transient nodes
It's fine to call set_state() on those.

https://bugzilla.gnome.org/show_bug.cgi?id=758930
2015-12-02 00:29:36 +01:00
Benjamin Otte
4b2ea59dd1 stylecontext: Treat empty path like no path
This way, we don't do weird stuff when an empty path is set.
2015-11-21 02:22:22 +01:00
Benjamin Otte
6eb89fb6a3 stylecontext: Copy name when setting widget path
Imitate what we do for the type. This way we don't lose the name on
save/restore.

https://bugzilla.gnome.org/show_bug.cgi?id=758442
2015-11-21 02:21:12 +01:00
Benjamin Otte
a9814fea7d stylecontext: Always warn on style mismatch
For now, always warn when
gtk_style_context_get()/get_padding()/get_margin()/get_border()
get called with the wrong state.

We used to hide this behind an env var because the warnings were
too frequent, but with the recent refactorings, this warning has become
rather important for detecting bugs.

If it's still problematic, we might want to revert this patch before
3.20.
2015-11-06 18:59:15 +01:00
Benjamin Otte
c075c14bf4 stylecontext: Add gtk_style_context_save_to_node()
To be used instead of gtk_style_context_save() with persistent nodes.
2015-10-22 16:35:14 +02:00
Benjamin Otte
72615a1b16 stylecontext: Add gtk_style_context_add_named()
This is an intermediate step for cssnode introduction. It gives a name
for the node created by saving the style context.
2015-10-22 16:35:14 +02:00
Benjamin Otte
bddc524cd8 stylecontext: Make sure style is valid when looking up style properties
Otherwise, the validation may happen vey automatically some time during
the style property and that will most likely cause a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=756338
2015-10-10 23:23:34 +02:00
Matthias Clasen
d930ea7c1f style context: Avoid a compiler warning 2015-10-03 22:42:12 -04:00
Matthias Clasen
598e17018c style context: Formatting fixes 2015-10-03 21:38:20 -04:00
Matthias Clasen
506fe61938 Fix gtk_style_context_list_classes
The function was always returning NULL.
2015-10-03 17:37:34 -04:00
Matthias Clasen
3c54fbd3ac Use stupid quotes instead of dumb quotes
Following a similar change in GLib a while ago.

'bla' may by stupid, but it looks less dumb than `bla'.
2015-09-23 07:01:16 -04:00
Matthias Clasen
5dcbbc6736 style context: Trivial refactor
Use g_set_object for setting the frame clock.
2015-09-23 07:01:14 -04:00
Christian Hergert
c1691a4964 stylecontext: add opaque background helper
This new private API, _gtk_style_context_is_background_opaque(), is meant to
be used by internal Gtk+ wigets to optimize fast paths for cases where
applicable. One such use would be to use a CAIRO_CONTENT_COLOR surface
instead of CAIRO_CONTENT_COLOR_ALPHA.

https://bugzilla.gnome.org/show_bug.cgi?id=754658
2015-09-13 13:41:19 -07:00
Garrett Regier
6118893a4e stylecontext: Fix list_classes() after optimization
Otherwise a junk value is returned.
2015-09-11 09:48:38 -07:00
Garrett Regier
41b386cd6a cssnode: Optimize listing of classes
Avoid creating the GList of strings when the GQuarks
will just be determined again. Instead have
gtk_style_context_list_classes() do it specifically.
2015-09-11 18:26:11 +02:00
Benjamin Otte
9020b5bd17 stylecontext: Remove line that is a no-op
Creating the transient node will already copy the widget type. So
copying again will not do anything.
2015-09-07 14:33:35 +02:00
Matthias Clasen
4c376d1a9c style context: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
2015-09-06 17:11:36 -04:00
Paolo Borelli
1eb1481bdf css: support text-decoration-style
The support is limited to underline single, double and wavy, which
is what pango has today.
2015-07-06 20:06:20 +02:00
Paolo Borelli
a57e6731c4 css: support text-decoration-color 2015-07-06 00:04:06 +02:00
Paolo Borelli
384df61c90 css: add support for text-decoration-line 2015-07-06 00:04:06 +02:00
Paolo Borelli
a19331f231 label: add support for CSS letter-spacing property
Support letter-spacing CSS property on GtkLabel.
Reftest is included.
2015-07-06 00:04:05 +02:00
Cosimo Cecchi
a1e80d99d2 stylecontext: deprecate gtk_style_context_set_background()
Nothing in GTK calls it anymore.
2015-07-01 16:09:23 -07:00
Benjamin Otte
fe51ac273c stylecontext: Change fallback behavior on state mismatch
For functions that take state flags as an argument we need to special
case the situation where the passed in flags don't match the current
state.

Previously we would create a copy of the style info, change its state
and do the lookup from there.

Now that GtkCssNode has replaced style infos, this doesn't work as well
anymore as copying a GtkCssNode is not possible.
However, unike style infos, GtkCssNodes are instant-apply, so we don't
need to copy anymore, we can just change the state of the node.

This causes some invalidations to be queued, but we can take that
performance hit as this is fallback code.

https://bugzilla.redhat.com/show_bug.cgi?id=1228852
2015-06-15 04:36:47 +02:00
Benjamin Otte
3e5280ae4d stylecontext: Clear style property more frequently
We want to clear the style property cache whenever things change in the
tree, not as we previously did only when those changes actually lead to
a different CSS style.
2015-04-27 19:17:03 +02:00
Benjamin Otte
ec57c6c10b csspathnode: Handle context going away
Sometimes path nodes can survive longer than the style context that
created them. Don't crash in those cases.

Fixes startup of mutter.

Testcase included.

https://bugzilla.gnome.org/show_bug.cgi?id=746407
2015-03-18 18:24:45 +01:00
Benjamin Otte
776d99ac51 stylecontext: Call get_style(), not create_style()
We want to ensure that the style is created properly.

This also allows making the create_Style() function private.
2015-03-18 15:23:32 +01:00
Benjamin Otte
399df06d19 stylecontext: Refactor gtk_style_context_invalidate()
There's no need anymore to recreate styles, nodes do that automagically
now.

This allows making gtk_css_node_set_style() private.
2015-03-18 15:23:32 +01:00
Benjamin Otte
2ec26cd9b5 cssnode: Move style context function to only user 2015-03-18 15:23:32 +01:00
Benjamin Otte
cadf6a9d3c cssnode: Add gtk_css_node_invalidate_style_provider()
This function not just invalidates the current node, but also all
children.
2015-03-18 15:23:32 +01:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +01:00
Benjamin Otte
b92fe2fa85 widget: Add gtk_widget_get_css_node()
and replace gtk_style_context_get_root() with it.
2015-03-18 15:23:31 +01:00
Benjamin Otte
ffb410f11e widget: Create the CssNode
... and pass it to the style context instead of having the style context
create it for us.
2015-03-18 15:23:30 +01:00
Benjamin Otte
efda30c495 stylecontext: Don't queue animate tick callbacks anymore
Instead, just mark nodes permanently as invalid.
2015-03-18 15:23:30 +01:00
Benjamin Otte
219e52f7e1 cssnode: Automatically recreate style on get_style() call
When the style is invalid, redo it.

Make this a vfunc, so the widget nodes can opt out.
2015-03-18 15:23:30 +01:00
Benjamin Otte
c550cf122a stylecontext: Move gtk_style_context_validate() to GtkCssWidgetNode 2015-03-18 15:23:30 +01:00
Benjamin Otte
649edbe2fc stylecontext: Move style creation functions to CssNode code 2015-03-18 15:23:30 +01:00
Benjamin Otte
c4b88e05fd stylecontext: Redo handling of differing state
Instead of passing an "override_state" flag, create a new CssNode just
for this simple lookup.
2015-03-18 15:23:30 +01:00
Benjamin Otte
637a4bda5c stylecontext: Get rid of stylecontext argument
... to a bunch of functions.

This requires a tiny change to the heuristics for the style cache - we
now cache styles when they have the same style provider as their parent
instead of when they have the default provider - but that change doesn't
have any effect in practice.
2015-03-18 15:23:29 +01:00
Benjamin Otte
03ac5f310b cssnode: Add gtk_style_context_get_style_provider()
... and use it when looking up properties.
2015-03-18 15:23:29 +01:00
Benjamin Otte
6dc6af674c stylecontext: Remove children list
It's not needed.
2015-03-18 15:23:29 +01:00
Benjamin Otte
4cc2af2db1 stylecontext: Move validation into GtkCssNode 2015-03-18 15:23:29 +01:00
Benjamin Otte
8e1017db35 stylecontext: Export gtk_style_context_get_root()
.. in the private header. This avoids tiny wrapper functions.
2015-03-18 15:23:29 +01:00
Benjamin Otte
55e68bc2ea cssnode: Track invalid flag
Remove it from GtkStyleContext.
2015-03-18 15:23:29 +01:00
Benjamin Otte
a589f98821 cssnode: Implement refcounting
The parent refs the child, so gtk_css_node_set_parent() adds/removes a
reference.

We should probably refactor this so that we name the function
parent.add(node) instead of node.set_parent(parent) - makes the
refcounting more clear.
2015-03-18 15:23:29 +01:00
Benjamin Otte
721dce73e0 stylecontext: Handle parent in CssNode code
Make CssNode a real tree with a DOM-like API.
2015-03-18 15:23:29 +01:00
Benjamin Otte
8c73799ca8 stylecontext: Move relevant_changes tracking to GtkCssWidgetNode 2015-03-18 15:23:29 +01:00
Benjamin Otte
7bafb63ec3 cssnode: Handle invalidation
Handle invalidation of node inside the CssNode code, don't do it in the
stylecontext.
2015-03-18 15:23:29 +01:00
Benjamin Otte
d79a44c1af stylecontext: Get rid of create_query_path()
Move that functionality into GtkCssNode.
2015-03-18 15:23:29 +01:00
Benjamin Otte
6f99a3cdb0 stylecontext: Change arguments for build_properties
Instead of passing the style declaration, take the node's style
declaration. Add arguments to allow overriding the state for the one
case where this didn't work.
2015-03-18 15:23:29 +01:00
Benjamin Otte
0e3da2f7cf stylecontext: Compute rootness of CssNode
.. instead of passing it as an argument.
2015-03-18 15:23:29 +01:00