Commit Graph

36 Commits

Author SHA1 Message Date
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
Matthias Clasen
d3727817ff Drop support for one-stop gradients
These have been deprecated for a while. Time to make this an
error for GTK+ 4.
2017-09-17 16:53:02 -04:00
Benjamin Otte
6055028c96 snapshot: Rename append APIs
Instead of having gtk_snapshot_append_foo_node(), just have
gtk_snapshot_append_foo(). Nobody needs to know that this internally
uses nodes.
2017-01-13 04:46:09 +01:00
Alexander Larsson
c00f8dce9f GtkSnapshot: Always use int for the translation
We already take ints when setting the translation, so it can't
currently take any other values. Additionally, I was seeing large
costs in int -> double -> int for the rects in
gtk_snapshot_clips_rect(), as all callers really are ints (widget
allocations) and the clip region is int-based.

This change completely cleared a 2% rectangle_init_from_graphene from
the profile and is likely to have nice performance effects elsewhere
too.
2017-01-11 16:14:03 +01:00
Alexander Larsson
65ad2541d7 Snapshot: Only record names if inspector is recording
Otherwise we do a lot of allocations and vprintf calls which are
not used.
2017-01-11 10:22:40 +01:00
Benjamin Otte
599cc995f3 css: Handle repeating gradients with only one offset
Example:
  repeating-linear-gradient(red 50%, blue 50%)

Those gradients in Firefox draw a solid image of the last color, so do
the same here.
2016-12-26 17:22:01 +01:00
Chun-wei Fan
23edff1606 gtkcssimagelinear.c: Avoid VLAs
VLAs are not supported by Visual Studio and possibly other compilers that
are supported by GTK+-3.90+, and probably never will be, although it is a
C99 specification, and it became optional for C11.  It is also not a part
of the newer compiler requirements that are listed out for GTK+-3.90.x.

There exist concerns about the implementation of VLAs in compilers that
support them as well, so change it to a g_newa() approach.

https://bugzilla.gnome.org/show_bug.cgi?id=773299
2016-12-22 08:40:32 +08:00
Benjamin Otte
e8cd71228a gsk: Implement linear gradient render nodes 2016-12-20 18:01:11 +01:00
Benjamin Otte
519af3f91d cssimage: Warn if gradients only have 1 color stop
GTK <= 3.20 allowed that but the CSS spec and borwsers do not.
We might want to just remove that feature, but for now, we just warn.
2016-04-18 20:52:35 +02: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
7b301fcece linear-gradient: Remove the hack using NUMBER
Instead, add a "side" member to the struct that keeps sides explicitly.
2016-02-13 04:49:07 +01:00
Matthias Clasen
a7e2a9d8d3 Don't interpolate between keywords
Transitioning between linear gradients like
linear-gradient(to top, yellow, green) and
linear-gradient(to left, yellow, green) was yielding
nonsensical results, with the gradient line jumping around
wildly. Fix this by falling back to stupid image interpolation
for these cases.
2016-01-07 16:13:26 -05:00
Matthias Clasen
3c54fbd3ac Use stupid quotes instead of dumb quotes
Following a similar change in GLib a while ago.

'bla' may by stupid, but it looks less dumb than `bla'.
2015-09-23 07:01:16 -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
9474215a43 cssimage: Fix angle computation for gradients to corners 2015-01-08 19:30:59 +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
0bd76a855c cssimage: Add forgotten line
That line was already missing in the initial commit it seems.
2013-05-28 15:24:04 +02:00
Benjamin Otte
3cb6ae3df3 cssimage: Use GtkCssColorValue 2012-11-08 23:34:29 +01:00
Benjamin Otte
0bfbf39306 cssimage: Implement some equal functions 2012-11-01 12:27:31 +01:00
Benjamin Otte
588ee411ad cssimage: Fix gradient start/end computation
This computation is only supposed to happen for repeating gradients, not
for all of them.
2012-10-06 15:56:08 -04:00
Benjamin Otte
03f5ff20de cssimage: Add transition code for linear-gradient()
This ensures feature-parity with the CSS spec and the -gtk-gradient()
notation.
2012-10-02 19:32:52 +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
e1a1432bd3 cssimage: Implement dependencies for images 2012-08-28 15:42:25 +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
09f9fd42b4 css: Fold color value computation into gtksymboliccolor.c
This gets rid of the public function
_gtk_css_rgba_value_compute_from_symbolic().
The fallback is now handled using a switch statement instead of letting
the caller pass the function.
2012-08-28 15:40:56 +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
c9f01ffb43 cssimage: No need to pass base file anymore
The file is now part of the GtkCssParser
2012-05-11 16:42:12 +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
1223d53a82 cssparser: Move symbolic color parser to gtksymboliccolor.c 2012-04-17 08:59:19 +02:00
Benjamin Otte
1b69f1d7c2 linear-gradient: Convert from GtkCssNumber to GtkCssValue 2012-04-17 08:59:19 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Benjamin Otte
811e848832 css: Implement repeating linear gradients 2012-02-02 03:14:00 +01:00
Benjamin Otte
5df9b0188a css: Implement CSS 3 linear-gradient() syntax 2012-02-02 03:14:00 +01:00