Commit Graph

59 Commits

Author SHA1 Message Date
Timm Bäder
77e0d360ed Add pure and const annotations to various functions 2020-01-26 18:21:07 +01:00
Matthias Clasen
a5530caec3 Actually turn of css value accounting
We need an #undef here. While doing so, make sure
it compiles without warnings when disabled.
2020-01-18 14:30:23 -05:00
Timm Bäder
e448fc41f3 cssnumbervalue: Move early-out code to GtkCssValue
These checks make sense for all css values.
2020-01-18 08:49:52 +01:00
Timm Bäder
7c75ea376f cssvalue: Improve css value accounting output
And make it fully optional behind an #ifdef.
2020-01-18 08:49:52 +01:00
Timm Bäder
ba08f5e67d cssvalue: Don't call compute() for already computed css values
As per the previous commit, this is unnecessary.

Even with the small amount of css values we mark as is_computed, we
already skip computing over 60% of them like this during the startup of
the widget factory.
2020-01-18 08:49:51 +01:00
Timm Bäder
31aa5a0e53 cssvalue: Add is_computed flag
When a css value has "child" css values (e.g. a linear gradient has
several color stop css values) which are all computed (won't change when
compute() is called on them), we want to skip computing the entire
subtree.

Since css values are immutable, we can set the is_computed flag at
construct time.

Since GtkCssValue instances are 0-initialized in _gtk_css_value_alloc,
the default for is_computed it FALSE. This commit only sets it to TRUE
in a few cases, such as various "none" singleton values which will never
change. Later commits will refine this and set it for more values.
2020-01-18 08:49:51 +01:00
Matthias Clasen
741e12012d dump css value stats 2020-01-18 08:49:51 +01:00
Timm Bäder
caaa3f8200 cssvalue: Remove typechecks
This path is more than hot and those type checks ruin any kind of real
life profiling.
2018-05-19 10:18:50 +02:00
Benjamin Otte
3322599e99 css: Introduce the idea of dynamic values
Dynamic values are values that change their contents with the current
(monotonic) time.

This just introduces the GtkCssValue API for it.
2018-03-16 06:04:43 +01:00
Benjamin Otte
e8053622eb gtk: Fix debug build
It seems I didn't have debug builds enabled and forgot some
return_if_fail()s when doing the last patch.
2017-10-31 06:10:26 +01:00
Benjamin Otte
83fb7a649f css: Merge GtkStyleProviderPrivate into GtkStyleProvider
This is just lots of renaming.

The interface remains private, so the public API does not change, apart
from removing the definition of the Interface object to avoid
subclassing.
2017-10-31 04:33:54 +01:00
Benjamin Otte
93eec3e52f css: Implement transitions for numbers of different units
We now can transition from 10px to 100%.

Note that this requires a teensy tiny hack in
gtk_css_value_transition(), but so be it.
2016-02-13 04:49:08 +01:00
Matthias Clasen
0042f9b414 Fix a comment 2015-12-28 22:37:33 -05:00
Matthias Clasen
9546ce798b css value: No need for atomic refcounting
We are all in one thread anyway.
2015-09-12 12:50:38 -04:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +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
572f46067f cssstyle: Rename GtkCssComputedValues => GtkCssStyle
This is literally just renaming of the object (and the associated source
files). No other changes are in there.
2015-01-07 14:26:46 +01:00
William Jon McCann
5dd751f006 docs: don't use ulink. use markdown instead 2014-02-04 18:53:51 -05:00
Alexander Larsson
af2c40bd54 css: Add a scale argument to css-value compute vfunc
We need to be able to compute different GtkCssImage values
depending on the scale, and we need this at compute time so that
we don't need to read any images other than the scale in used (to
e.g. calculate the image size). GtkStyleProviderPrivate is shared
for all style contexts, so its not right.
2013-07-03 14:39:25 +02:00
Alexander Larsson
afc1a143a4 css: Use internal return_if_fail in some commonly called code
These are internal apis, and any external issues should have been
caught by checks at public API points. We use the internal checks
here because these checks show up in a non-neglible way on profiles.
2012-12-04 20:16:44 +01: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
7cf2adfec4 cssvalue: Always consider values equal to themselves 2012-09-17 20:39:13 +02:00
Benjamin Otte
e3fc081c5d cssvalue: Pass property ID to transition function
This is to allow animating arrays properly. I'm not really thrilled
about this solution (we leak propertys into the values again...), but
it's the best I can come up with - I prefer it to having N different
array types...
2012-09-03 12:54:14 +02:00
Benjamin Otte
0e2f35ed88 css: Introduce dependencies for value computations
When values are computed, they might depend on various other values and
we need to track this so we can update the values when those other
values change. This is the first step in making that happen.

This patch does not do any dependency tracking at all, instead it uses
GTK_CSS_DEPENDS_ON_EVERYTHING as a sort of FIXME.
2012-08-28 15:42:23 +02:00
Benjamin Otte
6dc3113edc cssstyleproperty: Get rid of unused API
Both _gtk_css_style_property_print_value() and
_gtk_css_style_property_compute_value() aren't necessary anymore and are
replaced by _gtk_css_value_print() and _gtk_css_value_comptue()
respectively.
2012-08-28 15:40:57 +02:00
Benjamin Otte
9b4ed66218 css: Pass property_id to compute function
This is a reorganization of how value computing should be done.
Previously the GtkCssStyleProperty.compute vfunc was supposed to take
care of special cases when it needed those for computation. However,
this proved to be very complicated in cases where values were nested and
only the last value (of a common type) needed to be special cased.

A common example for this was the fallback handling for unresolvable
colors.

Now, we pass the property's ID along with all compute functions so we
can do the special casing where it's necessary.
Note that no actual changes happen in this commit. This will happen in
follow-ups.
2012-08-28 15:40:56 +02:00
Benjamin Otte
9b953829fb css: Introduce _gtk_css_value_compute()
This commit is essentially a large reorganization. Instead of all value
subtypes having their own compute function, there is the general
_gtk_css_value_compute() function that then calls a vfunc on the
subtype.
2012-08-28 15:40:56 +02:00
Benjamin Otte
40283e7c27 cssvalue: Split out old value handling to new typed value
... and Make this new value be a real GValue, as we don't need to save
performance for these anymore (it's just used for custom properties).
And I'd rather have code work for all values then be optimized for no
reason.
2012-04-17 08:59:20 +02:00
Benjamin Otte
56f79fecce cssvalue: Add a border value
.. and parse border-image-slice with it.
2012-04-17 08:59:18 +02:00
Benjamin Otte
cfc6462730 cssvalue: Add a cssvalue for background-size 2012-04-17 08:59:18 +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
5377169ef3 cssvalue: Add a value for background-position 2012-04-17 08:59:18 +02:00
Benjamin Otte
aed7600425 cssvalue: Add a css value for engines 2012-04-17 08:59:18 +02:00
Benjamin Otte
edbc8e4f57 cssvalue: Add a value for border-radius corner properties
... and convert those properties to this value.
2012-04-17 08:59:18 +02:00
Benjamin Otte
8ad8a4febf cssvalue: Add _gtk_css_value_to_string()
This is a tiny wrapper around _gtk_css_value_print().
It's intended for usage in gdb and printf debugging.
2012-04-17 08:59:16 +02:00
Benjamin Otte
1a9dfab825 cssvalue: Add _gtk_css_value_transition()
Returns a value that transitions between start and end or %NULL if the
values cannot be transitioned.

So far, all implementations but numbers and rgba return NULL.
2012-04-17 08:59:15 +02:00
Benjamin Otte
bf92f2f7ac cssvalue: Do a hacky conversion of font-size to a number value
Just store the value as px for now.

The font-size property needs a complete makeover anyway.
2012-04-17 08:59:15 +02:00
Benjamin Otte
7c75611bc2 cssvalue: Add a custom value for strings 2012-04-17 08:59:15 +02:00
Benjamin Otte
8c49cd97a7 cssvalue: Add a cssvalue for images 2012-04-17 08:59:14 +02:00
Benjamin Otte
d63b11e56b cssvalue: Add enum values for the pango enums
And fix the parser to conform to the CSS spec while at it.
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
da40ba431d cssvalue: Remove unused function 2012-04-17 08:59:13 +02:00
Benjamin Otte
ccd443796c shadow: Make this a GtkCssValue 2012-04-17 08:59:13 +02:00
Benjamin Otte
a33df2d1d6 cssvalue: Split number values into their own class 2012-04-17 08:59:13 +02:00
Benjamin Otte
bc9060a591 styleproperty: Make gtk_style_property_register() not be valist
Instead, make the caller create a GtkCssValue in advance.
2012-04-17 08:59:12 +02:00
Benjamin Otte
ffe50c3b67 cssvalue: Add _gtk_css_value_equal()
For now, we return FALSE for all default css values, so this is not very
useful.

I also think of this as an optimization equal, not a guaranteed equal,
because we don't even have a notion of what "equal" means.

For example, for background-repeat, "repeat, repeat" and "repeat"
are functionally equivalent. But the cssvalue has no idea that it's used
for background-repeat.
As a more complicated example, "repeat, no-repeat" and "repeat" are
equal to what one sees as long as there's only one image listed
background-image-source. But once you start transition'ing to an image
with 2 sources, it's different...
2012-04-17 08:59:12 +02:00
Benjamin Otte
9b7640b898 styleproperty: Make _gtk_style_property_parse_value() return a CssValue
Also split out initial/inherit handling into a custom GtkCssValue class.
2012-04-17 08:59:11 +02:00
Benjamin Otte
df45983fcb cssvalue: Remove _gtk_css_value_new_take_gvalue()
Having two constructors from GValues complicates refactorings, so I'd
rather not have them.
2012-04-17 08:59:11 +02:00
Benjamin Otte
8e3e3d582f cssvalue: Get rid of unused functions 2012-04-17 08:59:11 +02:00
Benjamin Otte
58e4fdf911 styleproperty: Make print_func take a GtkCssValue
Also, constify GtkCssValue getters, so we can pass a const GtkCssValue
to the print_func.
2012-04-17 08:59:11 +02:00