Commit Graph

44 Commits

Author SHA1 Message Date
Matthias Clasen
60982265fa css parser: Fix names for blend modes
When the blend modes were ported to use gsk defines, some
dashes were accidentally turned into underscores. It also
turns out that we were expecting 'saturate' instead of
'saturation' as per the css spec. Fix that as well.
2017-03-31 12:48:05 -04:00
Benjamin Otte
45fbc25e5e css: Remove -gtk-icon-effect
-gtk-icon-filter replaces this now.
2016-12-31 02:49:47 +01:00
Benjamin Otte
3e26fadb24 css: Replace custom blend modes with GskBlendMode 2016-12-20 18:01:11 +01:00
Matthias Clasen
45957100b0 Revert a mistaken change
I thought I needed ot rearrange the ordering of the animation-direction
values for the parser, overlooking the fact that we already parse them
backwards to address this very problem.
2016-07-26 00:21:48 -04:00
Matthias Clasen
3c4be3c912 Fix parsing of some css properties
Our property parser stops at the first match when looking for
enums, so we need to order our values so that we don't end up
with prefixes of longer names being found first.

I noticed this when the parser tried to interpret
background-blend-mode: color-burn; as "color, with junk at the end".

It also affects animation-direction, which is also fixed here.
2016-07-03 17:54:19 -04:00
Georges Basile Stavracas Neto
369db4a406 css: add background-blend-mode support
CSS supports blend modes, in which a series of layers are
merged together according to the given operation or set of
operations.

Support for blend modes landed on Cairo, which exposes all
the commons and also the exquisites blend modes available.
Adding support for blend modes, then, is just a matter of
using the available Cairo operations.

This patch adds the background-blend-mode CSS enum property,
and adapts the background rendering code to blend the backgrounds
using the available blend modes when they're set.

https://bugzilla.gnome.org/show_bug.cgi?id=768305
2016-07-03 17:24:47 -04:00
Matthias Clasen
de894f38b5 Fix the build
I forgot to add an include here.
2016-05-01 13:26:35 -04:00
Matthias Clasen
309c6dfaf8 css: Use setters for font size and family
This avoid creating pango font descriptions all the time, when
the gtk-font-name setting hasn't actually changed.
2016-05-01 01:10:59 -04:00
Matt Watson
df08fc91bd css: always get default font size in pixels
Fixes a couple bugs...

 - Pixel font sizes in css would render as point sizes.

 - For em font sizes, where the parent size was set and not default, we would
   incorrectly convert a pixel value from points to pixels.

We'll always grab the default font size in pixels so we don't keep confusing
things.

Worth noting that gtk css font-size will still behave differently than the
web. Pango interprets font-size differently.
2016-04-12 16:58:55 -07:00
Matthias Clasen
0473736499 Fix parsing of font-weight
The parser was turning a 400 into a 200 and a 700 into a 500.
2015-12-20 17:51:47 -05:00
Benjamin Otte
1b835fc7ce css: Leftover renaming gtk-image-effect => icon-effect
The previous renaming commit was incomplete, so here we go again.
2015-12-04 17:44:51 +01:00
Benjamin Otte
a37220109f render: Split out icon-effect apply function 2015-12-04 17:44:51 +01:00
Benjamin Otte
2396265523 css: Rename -gtk-image-effect to -gtk-icon-effect
This is a property for icons, so we should name it as such.
2015-12-02 00:29:31 +01:00
Paolo Borelli
1eb1481bdf css: support text-decoration-style
The support is limited to underline single, double and wavy, which
is what pango has today.
2015-07-06 20:06:20 +02:00
Paolo Borelli
384df61c90 css: add support for text-decoration-line 2015-07-06 00:04:06 +02:00
Matthias Clasen
a14bb5578f css: Silence a clang warning
Clang complains that this check can never be true. Since this
is a argument range check which we do to catch bad input,
convince clang to not complain instead of taking it out.
2015-03-22 15:17:27 -04:00
Benjamin Otte
da25771e58 cssvalue: Remove GtkCssDependencies
They are not used anymore.
2015-03-18 15:23:31 +01:00
Benjamin Otte
295b8aab0c css: Implement animations for font-weight property 2015-02-16 23:57:03 +01:00
Benjamin Otte
0c4a42e629 css: Implement "bolder" and "lighter" font weights 2015-02-16 23:57:03 +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
Emmanuele Bassi
5ad60caa3c css: Implement font-stretch
The font-stretch CSS property is defined in the Level 3 CSS Fonts
module, available at:

  http://dev.w3.org/csswg/css-fonts/#propdef-font-stretch

It allows defining a normal, condensed, or expanded face to the font
description. Pango already supports it, so this is literally just the
CSS parser machinery needed to bridge our CSS to the FontDescription
API.

https://bugzilla.gnome.org/show_bug.cgi?id=735593
2014-08-28 13:41:40 +01:00
Benjamin Otte
b6aecca71c css: Fix animation-direction parsing
We were parsig "alternate-reverse" as "alternate" and then complaining
about the "-reverse" junk at the end of the value.
2014-07-07 20:06:40 +02:00
Benjamin Otte
e012dfab2c Revert "Fix crash"
This reverts commit 024c11dd66.

It's not a crash fix to cause a return_val_if_fail() to happen.
2014-05-22 22:35:39 +02:00
Behdad Esfahbod
024c11dd66 Fix crash 2014-05-22 15:52:01 -04:00
Benjamin Otte
109fcb987b css: Add a -gtk-icon-style property
The values can be:
  "requested" - the style as requested
  "regular"   - use a regular full-color icon
  "symbolic"  - use a symbolic icon

The property defaults to "requested", so no changes should be seen
unless CSS overrides it.
It is also inherited, so that using this CSS
  .toolbar { -gtk-icon-style: symbolic; }
is enough to force the whole toolbar to use symbolic icons.
2014-05-14 04:28:34 +02:00
Cosimo Cecchi
736b350d7a css: Add a GtkCssValue for GtkCssImageEffect
This will allow us to use the CSS machinery to apply a highlight or dim
effect when images are prelit or insensitive.

https://bugzilla.gnome.org/show_bug.cgi?id=705443
2013-08-20 02:50:40 +02: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
1688403ae6 cssvalue: Fix the scaling factors for 'smaller' and 'larger'
They were reversed. Looks like a bad case of copy/paste failure.
2012-12-01 16:27:45 +01:00
Benjamin Otte
5942099f00 cssvalue: Parse font sizes properly
As the last CSS property, font-size now is a proper number (when it's
not a keyword).
2012-12-01 16:27:45 +01:00
Benjamin Otte
891a4ab347 cssvalue: Change order of values
This is necessary so that the (rather stupid) parsing code doesn't parse
"small" and then is happy when it should instead parse "smaller".
2012-12-01 16:27:45 +01:00
Benjamin Otte
a23bc88557 css: Fix dependencies for font lookup
'larger' and 'smaller' depend on the parent value. D'oh.
2012-12-01 16:27:28 +01:00
Benjamin Otte
0d9d576172 css: Add more features to font-size code
We now support the keywords (like xx-small, medium, larger, smaller...)
and I've changed the default value to be "medium".

This required some shuffling of the "get default font size" code. But
all is well now.
2012-12-01 14:00:24 +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
0185e323db cssvalue: Add animation enum properties 2012-09-17 20:39:11 +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
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
Matthias Clasen
f8a7810397 Deal with non-multiple-of-100 font weights
We should not run into an assertion so easily.
2012-06-01 16:15:16 -04: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
4ba9be5b97 cssvalue: Add GtkCssArea to the enum values
... and get rid of its GType.

This makes it non-queryable using gtk_style_context_get() but it used to
be a private struct anyway.
2012-04-17 08:59:15 +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
b65d17dda8 cssvalue: Make border styles be their own value
... and add them via gtkcssenumvalue.[ch] which will be used for all
enums.
2012-04-17 08:59:14 +02:00