Commit Graph

18 Commits

Author SHA1 Message Date
Timm Bäder
352c9ba42a dimensionvalue: Add gtk_css_{dimension,corner}_value_is_zero()
We can usually omit computations when the dimension value ends up being
zero anyway.
2020-01-26 18:21:07 +01:00
Timm Bäder
1f2f2777e1 csscornervalue: Accept other values if x == y
Most corners are square, so x == y. In that case, just accept either of
them. This makes the corner value unnecessary.

In fact none of the corner values in the widget-factory are needed, so
this spares us around 500 corner value allocations.

css value stats before:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

and after:

GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
SUM: 7872

8428 to 7872 is a 556 reduction (6.5%)

asdf
2020-01-18 08:49:51 +01:00
Timm Bäder
1200fe2daf cssvalue: Add type names for all classes
This is important to have for debugging and e.g. to print statistics for
the individual css value types
2020-01-18 08:49:51 +01: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
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
fb47a8d714 css: Remove deprecated number-as-pixels compatibility
Previously, for compatibility with GTK 3.0, we allowed specifying
numbers without units and interpreted them as pixels, even when the CSS
specification didn't.

Remove that now that we can break API.
2017-01-18 04:13:56 +01:00
Benjamin Otte
a52ecd2be6 css: Add gtk_css_number_value_can_parse()
Use it instead of _gtk_css_parser_has_number().

We need that once we introduce calc() support.
2016-02-13 04:49:08 +01: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
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
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
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
012526241a cssvalue: First step of proper dependency tracking
Instead of using the EVERYTHING aka FIXME value for tdependencies,
actually compute the dependencies in a bunch of simple cases.
2012-08-28 15:42:24 +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
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
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