Commit Graph

380 Commits

Author SHA1 Message Date
Matthias Clasen
5af2d95bff checkbutton: Add a 'grouped' style class
This will make it easier for themes to style radio buttons
differently from check buttons, since out CSS does not have
:has().

The concrete desire here is to use a different outline for
the focus rectangle.

Update affected tests.

Fixes: #6936
2024-08-17 08:22:54 -04:00
Matthias Clasen
4aea2d2e09 css: Don't pass style variables redundantly
The context->variables field is expected by the resolve code to be
the keyframe variables. That code takes the style variables from
context->style anyway, so no need to pass them as context->variables
too. And crucially, the lookup code treats the keyframes variables
differently to the style variables, since it doesn't expect the
hierarchical structure that comes from parent styles. This change
fixes infinite recursion in variable lookup with css like

:root {
  --a: var(--b);
}

.foo {
  --b: var(--a);
  color: var(--a);
}

Test included.

Fixes: #6881
2024-08-16 11:38:56 -04:00
Matthias Clasen
c9e4abcd3a css: Fix a crash in variables
We were not careful enough when checking for reference cycles.

Fixes: #6935

Test included.
2024-08-15 10:16:47 -04:00
Jeremy Bícha
8ee465c630 testsuite: add more files to test_data 2024-08-06 20:28:58 -04:00
Matthias Clasen
b3451dda04 css: Fix relative font sizes
This regression was introduced in aeac2b54.

We need percentage values to stay non-computed, since we otherwise
fail to compute relative font sizes properly. But we want percentages
not to stick around in relative colors, so tweak things to be more
aggressive with simplication when creating relative color values.

Update affected tests.

Fixes: #6868
2024-07-26 08:45:58 -04:00
Matthias Clasen
960967623a Add css value tests
Add some tests that check the details of calling compute() and
resolve() on number and color values.
2024-07-08 16:47:29 -04:00
Matthias Clasen
168203ab0c css: Fix a font-weight parser test
0 is not a valid font weight.
2024-07-08 16:09:35 -04:00
Matthias Clasen
f2fff53169 testsuite fixes 2024-07-08 16:09:35 -04:00
Matthias Clasen
f74b8f715a css: Fix legacy relative colors
If the color was specified using the legacy rgb(), we must accept
values in the range [0, 255]. But when serializing it as
color(srgb...), we must scale those values to [0, 1].

Update the one affected test.
2024-07-08 16:09:35 -04:00
Matthias Clasen
95c21acec1 css: For color, inherit the used value
When the color property is inherited, don't resolve the inherited
value to find the used value, just inherit the used value of the
parent style.

This is what browsers do, even though the spec says something else.

Update the currentcolor4 style test to reflect these changes.

Fixes: #6833
2024-07-08 14:53:00 -04:00
Matthias Clasen
7f6dce1c22 Add another css style test 2024-07-08 14:53:00 -04:00
Matthias Clasen
657e536941 Add more currentcolor css tests 2024-07-08 13:51:26 -04:00
Matthias Clasen
0cff62335b Fix style variables test
Make the results match what the comments actually say.
2024-06-27 21:03:14 -04:00
Matthias Clasen
e4325e5b2b css: Add more currentcolor style tests
These tests check various situations with inheritance and
currentColor. In particular the caret-color test was not
working correctly before we handled used values explicitly.
2024-06-27 21:03:14 -04:00
Matthias Clasen
cc463d52f6 css: Make palette value resolve used values
Separate out computed and used values for this type.
2024-06-27 20:21:43 -04:00
Matthias Clasen
da41271dd5 css: Parse interpolation for conic gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

This commit fixes preexisting brokenness in conic-gradient parsing
and printing as well, and includes the relevant test changes.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:36 -04:00
Matthias Clasen
5610af1b77 css: Parse interpolation for radial gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:22:27 -04:00
Matthias Clasen
8da70fec91 css: Parse interpolation for linear gradients
Parse things like "in hsl hue longer". For details, see the
CSS Images Module Level 4, https://www.w3.org/TR/css-images-4.

Tests included.

Gradient interpolation color spaces aren't supported for
rendering yet.
2024-06-16 13:21:56 -04:00
Matthias Clasen
763d620a23 css: Parse all supported color spaces
The code parsing interpolation methods hadn't learned about
or latest color space additions. While we're at it, improve
the error reporting a bit.

Tests included.
2024-06-16 13:04:52 -04:00
Matthias Clasen
f024ee1adf Add more tests for css colors 2024-06-11 16:41:22 -04:00
Matthias Clasen
7291a21a85 Merge branch 'wip/alice/css' into 'main'
CSS fixes and more tests

See merge request GNOME/gtk!7345
2024-06-05 20:54:12 +00:00
Alice Mikhaylenko
171bfde133 csscolorvalue: Fix percentage ranges for relative colors
Add tests as well, now that they can be computed at parse time.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
82d1fdb714 csscolorvalue: Resolve relative colors at parse time when possible 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
82b19daa7e csscolorvalue: Don't serialize relative colors as rgb()
Spec says it should be color(srgb).
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
dc1ff3c2e3 csscolorvalue: Fix oklab() percentage range 2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
6602ac5eae testsuite: Fix css tests
There are a bunch of new deprecations, and some tests weren't in
meson.build.
2024-06-06 00:35:52 +04:00
Alice Mikhaylenko
5dab5bf0e9 css: Allow percents in opacity
Add another missing feature from web css. It's nice to be able to use the
same variables in color-mix() and here.
2024-06-06 00:22:19 +04:00
Matthias Clasen
d5e5f47666 css: Add tests for relative colors 2024-06-04 10:47:54 -04:00
Alice Mikhaylenko
48b00f0ac1 testsuite: Add color-mix() tests 2024-06-03 23:59:44 +04:00
Matthias Clasen
60c944bb94 Add tests for color conversion and interpolation
Add some tests for gtk_css_color_convert and
gtk_css_color_interpolate, mostly based on examples
in the spec.
2024-05-31 21:29:49 -04:00
Matthias Clasen
5a85bc691e css: Split off GtkCssColor
Break out a GtkCssColor struct.
2024-05-31 15:51:02 -04:00
Matthias Clasen
3b40d95581 css: Fix currentcolor serialization
According to css specs, the serialization is supposed to be
all lowercase.
2024-05-29 21:45:10 -04:00
Matthias Clasen
15bb77472d css: Add some parser tests for oklab() etc 2024-05-29 12:05:28 -04:00
Alice Mikhaylenko
d51de390ba csscolorvalue: Add color() support
Currently we only have sRGB, so it's a bit redundant, but we'll need this
for color-mix()

Once we have more color spaces, they should be added here (presumably the
enum would be in GDK instead, and instead of GdkRGBA these colors would
have a GdkColor.
2024-05-29 19:28:31 +04:00
Matthias Clasen
1bd208d937 Merge branch 'wip/alice/colors' into 'main'
Add modern rgb() and hsl() syntax

See merge request GNOME/gtk!7278
2024-05-21 14:50:08 +00:00
Alice Mikhaylenko
b70bcd6bfe csscolorvalue: Add modern rgb() and hsl() syntax
Make calc() work in colors too, since we need to support degrees for hsl()
hue anyway and it goes through the same machinery. Make that work for
legacy syntax too, matching the spec.

Ignore missing components/none for now.

Ignore gdk_rgba_parser_parse(), that's also used outside css.
2024-05-21 16:32:52 +04:00
Matthias Clasen
ed889b951b css: Deprecate named colors
Warn for uses of @name colors, since these should be replaced with
CSS variables and custom properties. We don't issue deprecation
warnings for @define-color uses, since we may want to keep these
around in theme CSS for a while, for backwards compatibility.

Update all affected tests.
2024-05-20 16:19:30 -04:00
Matthias Clasen
2aeb80f490 Merge branch 'ccs-math' into 'main'
css: Implement math functions

See merge request GNOME/gtk!7249
2024-05-20 14:40:48 +00:00
Matthias Clasen
a19d0471e9 Merge branch 'css-var-syntax-errors' into 'main'
css: Report some var() syntax errors

See merge request GNOME/gtk!7264
2024-05-20 12:21:18 +00:00
Matthias Clasen
8b653f21cc Drop more underscores
Drop the remaining _'s from css number value apis.
2024-05-19 17:27:37 -04:00
Matthias Clasen
4e6759a126 css: Implement math functions
Implement the functions described in the "Mathematical
Expressions" section of the "CSS Values and Units Module
Level 4" spec, https://www.w3.org/TR/css-values-4/.

Beyond calc(), which we already had, this includes
min(), max(), clamp(),
round(), rem(), mod(),
sin(), cos(), tan(), asin(), acos(), atan(), atan2(),
pow(), sqrt(), hypot(), log(), exp(),
abs(), sign(),
e, pi, infinity and NaN.

Some tests included.
2024-05-19 17:27:37 -04:00
Matthias Clasen
f5d69fa0c5 css: Add some more variables tests
Add a test mixing color expressions with variables, and
empty fallback values.
2024-05-19 16:39:02 -04:00
Matthias Clasen
b60c60f03b css: Report some var() syntax errors
Detect cases such as var(), var(-), var("a") or var(21) early
and report them as syntax errors.

Test included.

Related: #6715
2024-05-19 15:56:26 -04:00
Matthias Clasen
25db645f65 css: Lose some underscores
Drop the _ from all the gtk_css_value apis.
2024-05-15 20:54:43 -04:00
Matthias Clasen
76299396cf testsuite: Improve test-css-parser
Make it so that --generate parse produces output that can be
directly pasted into the ref.css file.
2024-05-13 10:04:28 -04:00
Alice Mikhaylenko
0cd95951e6 testsuite: Add css variables tests 2024-05-10 18:29:48 +04:00
Alice Mikhaylenko
ed35f6f8b8 css: Condense compute parameters into GtkCssComputeContext
That list is getting out of hand, let's make it a struct.
2024-05-10 18:29:47 +04:00
Matthias Clasen
307942e1f7 css: Only compute shorthand values once
When computing a style, only compute the shorthand value once.
2024-05-10 18:29:47 +04:00
Alice Mikhaylenko
e1ac97a185 cssvalue: Pass an extra GtkCssVariableSet to compute()
We'll need this to support variables in @keyframes, since styles will
need to combine their own variables and the ones from the keyframes.

See the next commit, this one is split out to avoid a huge diff.
2024-05-10 18:29:47 +04:00
Georges Basile Stavracas Neto
8ed8f883d1 testsuite: Remove leftover code from meson.build
Performance tests were dropped at 5dd0d39a6b. The 'profiler' option
was renamed to 'sysprof' by commit e915a1aa7f.
2024-05-02 20:28:27 -03:00