Commit Graph

475 Commits

Author SHA1 Message Date
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
Benjamin Otte
b9f1f8aa38 stylecontext: Pass cssnode to build_properties 2015-03-18 15:23:29 +01:00
Benjamin Otte
21c3b13596 stylecontext: Simplify a function 2015-03-18 15:23:29 +01:00
Benjamin Otte
40d94fcd38 stylecontext: Remove values cache
The code is confusing the stylecontext=>node transition, so I'll remove
it.

WIth the recent introduction of the parent style cachen, I'm not sure
it's worth it at all. Some crude benchmarking suggests a slight speedup
when removing the cache.

So no guarantees about adding it back later.
2015-03-18 15:23:29 +01:00
Benjamin Otte
e2f6d4db43 cssnode: Split into 3 objects
- GtkCssWidgetNode
  for style contexts owned by a widget
- GtkCssPathNode
  for style contexts using a GtkWidgetPath
- GtkCssTransientNode
  for nodes created with gtk_style_context_save()/restore()
2015-03-18 15:23:29 +01:00
Benjamin Otte
726d8abb7d cssnode: Turn into a GObject
This will allow us to use subclasses.
2015-03-18 15:23:28 +01:00
Benjamin Otte
cf6d9edc12 stylecontext: Turn CssNode accesses into getters/setters
That way we can hide the struct in the source file.
2015-03-18 15:23:28 +01:00
Benjamin Otte
be596f3967 stylecontext: Split out GtkCssNode into own file
The functionality of it is supposed to grow, so better put it in a
custom file early.

This is just a naive split so far, the next patches will split things
further.
2015-03-18 15:23:28 +01:00
Benjamin Otte
181e58e402 iconhelper: Move function from style context into only user 2015-03-12 01:15:38 +01:00
Benjamin Otte
9ec2804775 stylecontext: Store the right style in the cache
Store the newly computed style, not the old and wrong one.

Fixes HighContrast menuitem color sometimes being black-on-black for
selected items.
2015-03-09 23:54:41 +01:00
Emmanuele Bassi
247e62390b docs: Clarify replacement for gtk_style_context_get_background_color()
It seems odd that a getter function for the style context state is
replaced by a rendering call, but it makes sense in context.
2015-03-08 14:29:04 +00:00
Benjamin Otte
b763bb0594 stylecontext: Don't use cache when unsaved
Fixes image-load-from-file reftest
2015-02-10 23:49:40 +01:00
Benjamin Otte
1116914ea0 css: Move scale to GtkStyleProviderPrivate
This way, we can remove it as a separate argument from
gtk_css_value_compute() and allow computation to only depend on one
thing: the style provider.
2015-02-06 11:26:31 +01:00
Benjamin Otte
808bfe0a98 settings: Provide a default style cascade per scale
This guarantees we only create 1 extra style cascade in total for hidpi
and not one per style context.

Style cascades are now nested like this:

GtkSettings root cascade (scale == 1)
 |
 +-- GtkSettings per scale cascade (for any scale, no custom providers)
 |
 +-- GtkStyleContext custom cascade (for any scale, custom providers)

This requires a bunch of care when changing cascade-related properties
inside GtkStyleContext, so that it ends up with a properly setup
cascade, but I think I got those cases right.

The only thing we don't do yet is reverting to a GtkSettings cascade
when the last custom provider is removed from a custom cascade.
2015-02-06 11:26:31 +01:00