Commit Graph

86 Commits

Author SHA1 Message Date
Benjamin Otte
e150ea85bb cssnode: Don't leak the style cache on destruction 2016-01-18 18:06:41 +01:00
Benjamin Otte
c904efef53 cssnode: Redo GTK_DEBUG=no-css-cache
Previously this setting would just invalidate the whole CSS tree and
thereby hopefully avoid all cache usage.

Now, we actually don't cause extra invalidations anymore, but instead
avoid ever inserting anything into the cache when this setting is set.
2016-01-16 23:58:37 +01:00
Benjamin Otte
5d562b6a2a cssnode: Split out the style cache
For now, the split out style cache doesn't cache anything. This is
mostly to make sure that bisections of wrong caching behavior will
bisect down to the commit that actually adds caching.
2016-01-16 23:58:37 +01:00
Matthias Clasen
cfa0884165 Improve formatting of CSS style prints
Add a newline after CSS properties, so things don't run into
each other.
2016-01-03 17:05:16 -05:00
Matthias Clasen
2e921691d9 Redo CSS style printing
Drop the custom style printing implementation in gtkcssnode.c and
instead reuse the existing gtk_css_style_print function, extending
it a bit to suit our needs.

Instead of computing values, just recognize initial values by
having no CSS section. Also do away with the show-initial flag, and
just always filter out initial values. The flag can come back when
it is needed.
2016-01-03 15:36:48 -05:00
Matthias Clasen
0c52eca34c Move node printing to GtkCssNodeDeclaration
The node declaration has all the information we are printing
here (except for visibility). At the same time, redo the format
to print the information in selector format, and indicate
(in)visibility by enclosing the selector in square brackets.
2016-01-03 14:41:43 -05:00
Cosimo Cecchi
dcaffe369f cssnode: fix a compiler warning 2016-01-03 11:25:45 -08:00
Matthias Clasen
68edc47f6a Add a function to dump CSS nodes and styles
Add a gtk_style_context_to_string function that can serialize
a CSS node or tree of nodes, optionally including CSS properties
as well.

This will be useful in writing tests.
2016-01-03 09:19:30 -05:00
Matthias Clasen
6f5b19a0a5 css node: Use g_set_object
Replace unref + assignment + ref combinations by g_set_object_calls.
2015-12-18 16:56:04 -05:00
Benjamin Otte
2e362eafc7 cssnode: Redo first/last-child change tracking
Invisible nodes don't change the first/last-child status of the nodes
after/before them. That means we don't have to just check the state of
the adjacent node when modifying this state, but all their siblings
until we hit a visible node.

The same way, a node is not the first child if it has no previous
sibling, it is the first child if it has no previous visible sibling.
This is important for caching in the global lookup cache.
2015-12-16 19:55:50 +01:00
Matthias Clasen
f2dd4350b2 css node: Warn more
gtk_css_node_insert_before/after can easily create cycles
which later lead to stack overflows. Even if we're not
catching all cycles here, at least we can detect obviously
invalid arguments, such as inserting a node next to itself.
2015-12-15 08:41:16 -05:00
Benjamin Otte
f6606c4f6f cssnode: Clear cache if reusing style
When we reuse styles that didn't change across changes to the source
CSS, make sure we clear the caches. Otherwise child nodes will pick up
styles from the old source CSS.
2015-12-15 01:15:51 +01:00
Benjamin Otte
eb97ef0514 cssnode: Set new style if it's animated
In commit 2c61316677 we avoided emitting
the style-changed signal if no CSS property changed.

Unfortunately, this also caused CSS styles to not be updated when
animations started if those animations did not change any CSS value
immediately. In those cases the animation would just never start.
The obvious example was the spinner.
2015-12-13 16:12:39 +01:00
Benjamin Otte
2c61316677 cssnode: Catch case where a style didn't change
Catch the case where a CSS style did not change and don't emit the
style-changed signal in that case.

This saves not only the emission of the signal, but also doesn't cause
invalidation in child nodes, which would previously get a PARENT_STYLE
2015-12-12 02:16:04 +01:00
Benjamin Otte
971a277419 cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque
object that will compute the changes you are interested in for you.

This simplifies change signal handlers quite a bit and avoids lots of
repeated computation in every signal handler.
2015-12-12 02:16:04 +01:00
Matthias Clasen
9c73603c16 css node: Some more docs 2015-12-06 15:42:13 -05:00
Matthias Clasen
029aad7907 Add more CSS node docs 2015-11-19 14:01:41 -05:00
Matthias Clasen
040723ec2d Trivial: Some doc rewording 2015-11-19 13:40:57 -05:00
Matthias Clasen
2b5d4455b8 Add some CSS node docs
Write up some of the insights from doing the CSS node transition,
so the knowledge is not lost.
2015-11-19 12:56:30 -05:00
Benjamin Otte
0e75fbf39c cssnode: Propagate NTH_LAST_CHILD changes properly
We were just catching the previous sibling before. Now we properly
invalidate all previous siblings (and also all other wiblings, but we
can think about optimizing that later).
2015-11-09 01:48:14 +01:00
Colomban Wendling
f4c30060be cssnode: Fix style updating when the CSS node ID changes
Since 4ebb5781ea ID has a specific value,
while it used to be the same as NAME.  Thus, explicitly list ID as a
radical change just like NAME.

https://bugzilla.gnome.org/show_bug.cgi?id=757397
2015-11-01 02:42:36 +01:00
Colomban Wendling
79a3a7800e cssnode: Fix a typo leading to very poor cache hashing 2015-11-01 02:42:36 +01:00
Matthias Clasen
b7d001e613 Add some api annotations
Nothing is using the /*interned*/ annotations currently,
but if we are doing this, we should be consistent.
2015-10-26 23:39:50 -04:00
Benjamin Otte
24dde6346a API: cssselector: Stop supporting regions
The namespace that belonged to regions is supposed to be used for
CssNode names.
2015-10-22 16:42:46 +02:00
Benjamin Otte
950b1fb65c switch: Port to GtkCssNode
This is a simple port, no code modifications so far other than replacing
gtk_style_context_save() with gtk_style_context_save_to_node().
2015-10-22 16:42:46 +02:00
Benjamin Otte
efff9c8edb cssnode: Add setters/getters for name 2015-10-22 16:35:14 +02:00
Matthias Clasen
29c799a1e7 Use g_object_get_qdata instead of g_object_get_data
This is less expensive.
2015-09-12 12:50:39 -04:00
Matthias Clasen
c8dcb690aa css node: Avoid a duplicate type check 2015-09-12 12:50:39 -04:00
Benjamin Otte
610452dda8 cssnode: Move clear_classes() into the NodeDeclaration
The previous code was crashing when used as the returned classes array
would have been invalid after the first deletion. So if a 2nd class
would be deleted, invalid memory might have been referenced.
2015-09-12 05:27:35 +02: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
Matthias Clasen
3526b08e01 Clean up debug features
Introduce a GTK_DEBUG_CHECK() macro and use it to check for
GTK_DEBUG flags everywhere. Also guard all such places by
2015-09-09 06:32:46 -04:00
Benjamin Otte
f1ca75d181 cssnode: Loosen requirements for style caching
We can actually share :first-child/:last-child related things now,
because we special case them. So the only positions we cannot cache are
nth-child/nth-last-child.

This should take care of a lot of Adwaita's styling.
2015-08-27 17:21:59 +02:00
Benjamin Otte
a7680c68de cssnode: Add gtk_css_node_reverse_children() 2015-07-16 06:15:13 +02:00
Benjamin Otte
6e4f42f97e cssnode: Change API of some functions
gtk_css_node_set_after/before() are now called
gtk_css_node_insert_after/before().

This brings them in line with other similar APIs (ie GtkListStore). And
it allows easier usage of the API (see changes to gtkbox.c).
2015-07-16 06:15:13 +02:00
Benjamin Otte
190f025f74 cssnode: Only queue_validate() when node is visible
This avoids running animations in hidden toplevels.
2015-07-10 21:44:32 +02:00
Benjamin Otte
adcb52e82b cssnode: Only invalidate sibling nodes if changed node is visible 2015-07-10 21:44:32 +02:00
Benjamin Otte
8d3737e4e3 cssnode: Do finer-grained position invalidation
As a side effect, this should fix this bug:

https://bugzilla.gnome.org/show_bug.cgi?id=751910
2015-07-06 15:33:50 +02:00
Benjamin Otte
91fac8b5aa cssnode: Fix position invalidation
The previous code was overly complicated and wrong.
2015-05-30 05:50:31 +02:00
Benjamin Otte
8640bc47b1 cssnode: Add properties 2015-03-18 15:23:33 +01:00
Benjamin Otte
10d39171d9 cssnode: Add a style-changed signal
The signal gets emitted whenever the style needs to be changed.
2015-03-18 15:23:33 +01:00
Benjamin Otte
6988f9b818 cssnode: Add node-added and node-removed signal
This allows monitoring the CSS tree. For now, moving a child to a
different position relative to its siblings while keeping the same
parent will cause a child-added + child-removed emission.
2015-03-18 15:23:33 +01:00
Benjamin Otte
c7fba52a36 cssnode: Track invalid children
We need to properly track if a node needs to propagate invalidation
state information to its children. We didn't do this properly before and
that could lead to us forgetting to invalidate nodes in corner cases.
2015-03-18 15:23:33 +01:00
Benjamin Otte
d785820c53 cssnode: Change the way we invalidate timestamps
Do not propagate the TIMESTAMP change through the node tree, as that
causes lots of uneeded markings of nodes as invalid.

Instead, walk the node tree and find the nodes that have a non-static
style and only invalidate timestamps on those.
2015-03-18 15:23:33 +01:00
Benjamin Otte
759d8dafd9 cssstyle: Add gtk_css_style_is_static()
Gets rid of the need to do

  if (ANIMATED_STYLE() &&
      animated_style_is_static(ANIMATED_STYLE(style))
2015-03-18 15:23:33 +01:00
Benjamin Otte
d9727290cf cssnode: Special-case TIMESTAMP invalidations
Only invalidate timestamps if the node is marked as invalid. We overload
the meaning of "invalid" as "tracks timestamps".

While I don't like the way this is written, it is an important
optimization because 95+% of nodes don't animate so timestamps don't
matter to them. But timestamps are invalidated 60x per second.
2015-03-18 15:23:33 +01:00
Benjamin Otte
68b8f792d6 cssnode: Redo style changed tracking
We don't return a NULL style to mean "no changes" anymore, instead
we check new_style == old_style to mean that.

Make sure the code reflects this, otherwise we'll send
GTK_CSS_CHANGE_PARENT_STYLE invalidations everywhere and screw up
performance.
2015-03-18 15:23:32 +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
092ff983f7 cssnode: Merge the 2 places that compute styles
Now that the widget node recomputes styles on update_style() we can just
call it during validate(). That way, we don't need the widget node to
manually compute its style.
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
6dd19306eb cssnode: Create animated styles by default
... and hardcode transient and path nodes to never create animated
styles.
2015-03-18 15:23:32 +01:00