Commit Graph

256 Commits

Author SHA1 Message Date
Benjamin Otte
11d0f9e408 css: Make color lookup handle dependencies 2012-08-28 15:42:24 +02:00
Benjamin Otte
8ff08e7c5e stylecontext: Update computed values when dependencies change
This fixes the longstanding bug where GTK would not update styles when
parent styles would change.

https://bugzilla.gnome.org/show_bug.cgi?id=672046
2012-08-28 15:42:24 +02:00
Benjamin Otte
a770f0c3eb stylecontext: Refactor some code
This just changes the arguments passed to build_properties() and moves
that function around in the source file. No functional changes are
happening.
2012-08-28 15:42:24 +02:00
Benjamin Otte
1d7b23845f css: Pass relevant properties to css lookup code
This is not used yet in this patch.
2012-08-28 15:42:24 +02:00
Benjamin Otte
8874a06ba0 stylecontext: Compute correct changes
... in the case where no change of the DOM tree actually happened.

We don't do anything yet with that information, this patch just
correctly computes it.
2012-08-28 15:42:24 +02:00
Benjamin Otte
5d2acb1fe9 stylecontext: Split out a function for simplicity 2012-08-28 15:42:23 +02:00
Benjamin Otte
2cb9dac14c stylecontext: Pass the changes in the parent to validation function
This way, inherited properties can be updated.
2012-08-28 15:42:23 +02:00
Cosimo Cecchi
b80d935b95 stylecontext: pass down the requested change type to invalidation
<Company>: cosimoc: yes, that totally makes sense
<Company>: looks like a copy/paste error from when i factored out that
           function
2012-06-13 17:04:47 -04:00
Matthias Clasen
8742f6f09c Clarify the gtk_style_context_add_provider docs
https://bugzilla.gnome.org/show_bug.cgi?id=643490
2012-05-26 12:24:13 -04:00
Benjamin Otte
f51c9d4154 stylecontext: Make queue_invalidate() always work
Handle both the case where a widget is set and also the case where a
widget path is set.
2012-05-08 03:58:23 +02:00
Benjamin Otte
0743cef50d stylecontext: Disallow adding/removing GtkSettings style providers
Adding "system" providers like the GtkSettings object shouldn't be
allowed at all, so ensure that it indeed is not.
2012-05-02 17:04:49 +02:00
Benjamin Otte
793748eadd debug: Add GTK_DEBUG=no-css-cache
See inline comments for what it does. Its main use is figuring out if
something has been caused by GTK's caching of CSS properties or if it's
a different problem.
2012-05-02 02:00:11 +02:00
Benjamin Otte
b4195cb408 cssmatcher: Handle case of empty widget path
This is tested by the stylecontext test, but doesn't appear in practice.
2012-05-01 03:13:02 +02:00
Benjamin Otte
04c85a5b3b container: Redo style validation handling
Instead of using 1 global queue for both resizes and style validation,
use 2 queues. This makes the code a lot simpler and fixes a bug where we
could accidentally stop restylying for very delayed restyles.
2012-04-17 08:59:23 +02:00
Benjamin Otte
35e36b9fe5 stylecontext: Avoid style_context_save() calls
Introduce style_data_lookup_for_state() that does this.
2012-04-17 08:59:23 +02:00
Benjamin Otte
2179580c8e stylecontext: Pull all the animation code together
We now animate the core style information (see comment in
gtk_style_context_save()). A lot of widgets save + set custom style
classes/states during drawing and so can't be animated. It does work for
labels, menus and buttons though.
2012-04-17 08:59:23 +02:00
Benjamin Otte
60eff87d08 stylecontext: Shuffle around code
This has two goals:

1) Move invalidation code out of a nested if branch. Invalidation is
actually the most important thing this function does.

2) Have the changes bitmask available. It will needed for invalidate
calls to children later.
2012-04-17 08:59:22 +02:00
Benjamin Otte
42d2430498 stylecontext: Add style_info_set_data()
.. to take care of the refcounting properly.
2012-04-17 08:59:22 +02:00
Benjamin Otte
b8c72a0bdb stylecontext: Make StyleInfo keep the next pointer 2012-04-17 08:59:22 +02:00
Benjamin Otte
deefb64661 stylecontext: Make StyleData refcounted
This is needed for animations where we want to keep a custom StyleData
for animations.
2012-04-17 08:59:22 +02:00
Benjamin Otte
fe89e710ea stylecontext: Add public API to stop animations
... and use it.

Of course, there still are no animations, so we don't turn anything off
yet.
2012-04-17 08:59:22 +02:00
Benjamin Otte
a240808824 stylecontext: Add an animating framework
The design principles were:

- synchronized
If multiple style contexts are animating, they should all do an
animation step at the same time.

- degrades well
Even when there's thousands of style contexts all animating at the same
time, the animation steps don't starve the CPU. This is achieved by
making sure the timeout is really fast. It just sets a bunch of flags.

- no hidden bottlenecks
Turning animatability on or off on a style context is O(1).

So far it is unused.
2012-04-17 08:59:22 +02:00
Benjamin Otte
b6594d1ac9 stylecontext: Don't queue a resize when none is needed 2012-04-17 08:59:22 +02:00
Benjamin Otte
e2f89c0c6a stylecontext: Listen to the new changed signal 2012-04-17 08:59:21 +02:00
Benjamin Otte
29fbfcb8f5 stylecontext: Pass time to style_context_validate()
This way, we can ensure that every style context uses the same timestamp
for whatever they do.
2012-04-17 08:59:21 +02:00
Benjamin Otte
aaedc7b67f stylecontext: Compute if things changed before invalidating
This is only a small performance boost by itself, but it's necessary
for animations, so we need it.

Benchmark numbers for my Glade benchmark for interested people:
        GTK 3.4.0    last commit  this commit
Raleigh
  real  0m41.879s    0m10.176s    0m9.900s
  user  0m41.394s    0m9.895s     0m9.628s
  sys   0m0.111s     0m0.096s     0m0.102s

Adwaita                                        (*)
  real  0m51.049s    0m13.432s    0m14.848s    0m12.253s
  user  0m50.487s    0m13.034s    0m13.218s    0m11.927s
  sys   0m0.117s     0m0.151s     0m0.147s     0m0.107s

Ambiance (patched to not use private GTK APIs)
  real  0m52.167s    0m13.115s    0m13.117s    0m12.944s
  user  0m51.576s    0m12.739s    0m12.768s    0m12.651s
  sys   0m0.119s     0m0.137s     0m0.136s     0m0.118s

(*) Adwaita and unico currently use custom properties, and
_gtk_css_value_compare() for custom properties always returns FALSE,
which makes this optimization never trigger. So I modified
_gtk_css_value_compare() to return TRUE for these properties instead and
reran the benchmark. Those are the numbers.
2012-04-17 08:59:21 +02:00
Benjamin Otte
33f111a47c widget: Don't cache widget paths all the time
Add an internal API that allows GtkStyleContext to create a widget path
for the widget and with that bypassing gtk_widget_get_path() and that
  function caching the path.
2012-04-17 08:59:21 +02:00
Benjamin Otte
6ac754cdd1 stylecontext: Remove theming_engine cache variable
Instead, look up the variable upon use. This is more correct (for when
the engine changes due to save/restore() shenanigans.

And it removes code that doesn't use the standard code paths.
2012-04-17 08:59:21 +02:00
Benjamin Otte
3ddb104302 stylecontext: Split out a function 2012-04-17 08:59:20 +02:00
Benjamin Otte
0111b9d507 symboliccolor: Treat it as a CssValue
.. now that it is one.
2012-04-17 08:59:20 +02:00
Benjamin Otte
83be7e5dbd symboliccolor: Pass the current color to the resolve function
This way, we can resolve things like
  mix (currentColor, &otherColor);
and therefore parse currentColor as a regular color.
2012-04-17 08:59:19 +02:00
Benjamin Otte
04c5fdaca6 css: Remove old animation code
Deprecate public API where appropriate and make it no-ops.
Remove all calls to it.
Get rid of the 'transition' css property.

For now, this means spinners don't animate anymore.
2012-04-17 08:59:19 +02:00
Benjamin Otte
f785f7177c cssvalue: Add a custom value for repeats
In particular, that's background-repeat and border-image-repeat.

Also, fix up the border-image shorthand to allow any order.
2012-04-17 08:59:18 +02:00
Benjamin Otte
580b5e4a83 stylecontext: Don't queue_resize() all the time
When a parent style context exists, there's no need to queue_resize() on
the widget, because the parent widget will call
gtk_style_context_validate() on us and _then_ we can call queue_resize()
if we have to.
2012-04-17 08:59:17 +02:00
Benjamin Otte
a360e77a7b css: Remove _gtk_css_computed_values_get_value_by_name()
Now that we use an enum for the IDs, we don't need that function
anymore.
2012-04-17 08:59:16 +02:00
Benjamin Otte
31565139ba stylecontext: Convert _gtk_style_context_peek_property()
Take the property id instead of the name.
2012-04-17 08:59:15 +02:00
Benjamin Otte
40982eabbb stylecontext: Keep the main style data around until revalidation 2012-04-17 08:59:15 +02:00
Benjamin Otte
751187aa0c stylecontext: Keep per-styleinfo data
Instead of having one global data structure, keep it per style info.
This means that we can do special tricks on the "global" style data.
2012-04-17 08:59:14 +02:00
Benjamin Otte
a737adadf8 stylecontext: Make style_data_lookup() not take a state anymore
Instead, use the current state of the style context.
2012-04-17 08:59:14 +02:00
Benjamin Otte
58b6d492b8 cssvalue: Add a custom RGBA value
Note: custom CSS properties still use the default GtkCssValue and always
will.
So there is a difference in css values used between those, even though
they both carry a GdkRGBA payload.
2012-04-17 08:59:14 +02:00
Benjamin Otte
a33df2d1d6 cssvalue: Split number values into their own class 2012-04-17 08:59:13 +02:00
Benjamin Otte
5ac9ba714a styleproperty: Make _gtk_style_property_query() take a GValue
... and don't make it return a GtkCssValue. We want to use this for
compat with the old GValue APIs after all...
2012-04-17 08:59:11 +02:00
Benjamin Otte
d5a2392cc7 stylecontext: Don't clear cache when only state changes
This takes more memory, but changes to backdrop or active state are
quite expensive otherwise.
2012-04-17 08:59:11 +02:00
Benjamin Otte
585a1fae4f stylecontext: Really queue style changes
Instead of instantly applying a new style, just mark the context as
invalid. Only apply the new style at layout time.
2012-04-17 08:59:10 +02:00
Benjamin Otte
eb537b60f4 stylecontext: Optimize the common case of "style didn't change" 2012-04-17 08:59:10 +02:00
Benjamin Otte
198cf93f0f stylecontext: On failure, exit the loop, don't try again
Because we will fail again. And then we try again. And then we fail
again. Ad infinitum.
2012-04-17 08:59:09 +02:00
Benjamin Otte
15be680540 stylecontext: Invalidate when setting classes/state/regions
... and nobody has called style_context_save().
2012-04-17 08:59:09 +02:00
Benjamin Otte
44d49c900d stylecontext: Use _gtk_style_context_queue_invalidate() on self 2012-04-17 08:59:09 +02:00
Benjamin Otte
39ff874a11 stylecontext: Introduce _gtk_style_context_queue_invalidate()
This is for only queueing invalidations instead of doing a full
invalidation cycle.
2012-04-17 08:59:09 +02:00
Benjamin Otte
1a51ea3ea3 stylecontext: Keep track of children 2012-04-17 08:59:09 +02:00