Commit Graph

276 Commits

Author SHA1 Message Date
Benjamin Otte
6d3b4d9382 stylecontext: Add a flag to force style_updated() emission
This is used in gtk_widget_reset_style() (via GTK_CSS_CHANGE_ANY) now,
and that makes GtkSettings font related changes work again.
2012-11-14 13:25:44 +01:00
Alexander Larsson
55d65571f3 Exit early in gtk_style_context_update_cache codepaths
If lookup->missing is empty we don't need to continue looking.
We short circuit in several places as this can happen
after iteratively makeign lookup->missing smaller.
2012-11-09 10:15:23 +01:00
Benjamin Otte
947fed0961 stylecontext: Fix a memleak 2012-11-08 23:34:30 +01:00
Benjamin Otte
ba88174614 stylecontext: Remove unused function 2012-11-08 23:34:29 +01:00
Benjamin Otte
16677bb85a stylecontext: Don't use bg image in gtk_style_context_set_background()
Old code tried to use the "background-image" proeprty for setting the
default image background. While this used to work in the early days of
GTK3, today it is grossly misleading as the backgronud image may be
resized, repositioned and semi-translucent which causes very weird
artifacts when rendering.

So we use the background-color only instead.
2012-10-31 11:09:10 +01:00
Benjamin Otte
046d004725 gradient: Add a private header file 2012-10-02 14:16:36 +02:00
Benjamin Otte
4943cc4c12 stylecontext: Actually use superset matcher
... when looking up the needed changes.

This is what that matcher was actually written for, but it seems I never
hooked it in.
2012-10-01 14:23:15 +02:00
Benjamin Otte
1454ba15ba css: Huge refactoring to avoid computing wrong values
Here's the shortest description of the bug I can come up with:
When computing values, we have 3 kinds of dependencies:
(1) other properties ("currentColor" or em values)
(2) inherited properties ("inherit")
(3) generic things from the theme (@keyframes or @define-color)
Previously, we passed the GtkStyleContext as an argument, because it
provided these 3 things using:
(1) _gtk_style_context_peek_property()
(2) _gtk_style_context_peek_property(gtk_style_context_get_parent())
(3) context->priv->cascade

However, this makes it impossible to lookup values other than the ones
accessible via _gtk_style_context_peek_property(). And this is exactly
what we are doing in gtk_style_context_update_cache(). So when the cache
updates encountered case (1), they were looking up the values from the
wrong style data.

So this large patch essentially does nothing but replace the
context argument in all compute functions with new arguments for the 3
cases above:
(1) values
(2) parent_values
(3) provider

We apparently have a lot of computing code.
2012-09-28 18:27:49 +02:00
Benjamin Otte
0cc32eae62 symboliccolor: Change prototype of _gtk_symbolic_color_resolve_full()
We can juts pass a GtkStyleProviderPrivate, that one has the vfunc we
want already. So no need to pass vfuncs anymore.
2012-09-28 18:27:49 +02:00
Benjamin Otte
fbb4c61665 stylecontext: Rebuild cached styles with correct classes/regions
Previously, we were using the default classes and regions. That's
obviously wrong.
2012-09-28 18:27:48 +02:00
Benjamin Otte
d74e1b9ac9 stylecontext: Always create animations
Even when there is no current values, do create animations. This ensures
that animations do exist for unmapped widgets when they get mapped
later.
2012-09-17 20:40:01 +02:00
Benjamin Otte
4a281edc87 stylecontext: Only create transitions conditionally
While regular animations should always be created, transitions should
not. This patch allows to express this by passing NULL as the values to
transition from.

It also adds a gtk_style_context_should_create_transitions() function
that returns TRUE when transitions should be created.
2012-09-17 20:40:01 +02:00
Benjamin Otte
7712d41b5e stylecontext: Refactor the way animations are started and stopped
We now create animation objects unconditionally, but we only run the
animation loop when gtk_style_context_should_animate() return TRUE.
2012-09-17 20:40:01 +02:00
Benjamin Otte
13cbd22d17 stylecontext: Clear animations for values kept in cache 2012-09-17 20:40:01 +02:00
Benjamin Otte
37dac2a481 stylecontext: Remove leftover debugging
... that actually was both wrong, a performance failure and has been
there since the original checkin.

Updating the cached style data absolutely does not mean clearing all
cached style data first. There's nothing to update then.
2012-09-17 20:39:14 +02:00
Benjamin Otte
e2cc9f3afc csscomputedvalues: Handle starting animations differently 2012-09-17 20:39:14 +02:00
Benjamin Otte
a7ec3ba53f csscomputedvalues: Get rid of animated values
Merge the animated values code into the computed values code. This
should get rid of various bugs related to animated->computed updating.
2012-09-17 20:39:12 +02:00
Benjamin Otte
229b6fe17a css: Add animation support
This adds the GtkCssAnimation class and the code needed to hook it into
GtkStyleContext. It takes the values out of the CSS "animation"
properties and does animations. See
  http://dev.w3.org/csswg/css3-animations/
for details.

Note that the code for starting and stopping animations with widget
visibility doesn't work yet.
2012-09-17 20:39:12 +02:00
Benjamin Otte
554002028c stylecontext: Provide a function for getting the style provider
This will be necessary for creating the computed values for keyframes.
2012-09-17 20:39:12 +02:00
Cosimo Cecchi
f57778e71e stylecontext: fix a StyleData refleak
We were failing to unref the style data in some code paths.

https://bugzilla.gnome.org/show_bug.cgi?id=683627
2012-09-13 17:00:20 -04:00
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