Commit Graph

534 Commits

Author SHA1 Message Date
Matthias Clasen
f5865b125e Add profiler marks around css selector tree building
This is a big part of theme loading, and worth
showing in traces.
2020-01-23 10:29:22 -05:00
Matthias Clasen
0fe9643728 css: Add a profiler mark around theme loading
This is also time spent before the first frame.
2020-01-22 23:44:01 -05:00
Matthias Clasen
55cfeccfd2 css: Go back to clearing out selectors
Now that we use the selector tree for change computation
again, we don't need the ruleset selectors anymore.
Bring back the code that cleans them out.
2020-01-18 23:06:25 -05:00
Matthias Clasen
2a919a4d4f Go back to the tree for computing change 2020-01-17 23:47:34 -05:00
Matthias Clasen
f0c1c3349f css: Simplify the superset matcher
We use the superset matcher in exactly one place,
so there is no need for the generality of allowing
to ignore different aspects. Just hardcode the one
case we need: ignoring everything except for name,
id and class.
2020-01-16 19:11:08 -05:00
Matthias Clasen
1caf197a0d css: Don't got to the selector tree for change
The tree is optimized for mimizing the decisions, and is built ahead-of-time.
That prevents us from taking advantage of the information in the matcher when
collecting changes.

So, instead do what we used to do for verification: Use the selector tree
for finding the superset matches, then just walk the rulesets to collect
the changes.

Since we are now recomputing the change masks much less frequently, this
slightly less optimized way of computing them is not a problem, and will
let us compute better results in the future, by improving the superset
matcher to be more precise.
2020-01-16 17:20:45 -05:00
Matthias Clasen
0a49726c73 cssprovider: Keep selectors around
Don't remove selectors from the rulsets after
creating the selector tree. We want to use them
in future commits.
2020-01-16 17:17:07 -05:00
Matthias Clasen
cb88de5938 css: Drop unsused bitmasks
GtkCssProvider was maintaining bitmasks for the
set properties in each ruleset. The masks are never
used, so drop them.
2020-01-14 18:32:05 -05:00
Benjamin Otte
7523a3f2f2 cssprovider: Don't add empty rulesets
This change was lost during the parser changes, but the newly added test
exposes it.

And fix the expected error, the syntax has changed.
2019-11-23 19:02:36 +01:00
Timm Bäder
b29c30c9d5 cssprovider: Remove unused member from GtkCssScanner 2019-09-09 17:36:24 +02:00
Timm Bäder
d8df197489 cssprovider: Don't lookup on empty css providers
This should not have a huge performance impact, but debugging is easier
if we don't lookup in empty css providers.
2019-09-09 17:36:24 +02:00
Timm Bäder
ecad4743bd csslookup: Remove 'missing' bitmask
It's almost never useful to have a bitmask here, since it's only used
for the intersection case in gtk_css_style_provider_lookup. However,
even if that returns true, we still need to check every single style
property for being set again in the look afterwards.

Just remove the bitmask.
2019-09-09 17:36:24 +02:00
Timm Bäder
3073e65851 cssprovider: Fix compilation wth VERIFY_TREE set 2019-09-09 17:36:24 +02:00
Timm Bäder
a77f8e886b cssprovider: Fix a memory leak in load_internal
We create a new GBytes but never unref it.
2019-07-06 09:50:07 +02:00
Matthias Clasen
c31eadc3a1 css provider: Make not subclassable
Part of being more explicit about what
we allow to be subclassed and what not.
2019-05-19 18:41:33 +00:00
Benjamin Otte
0886ade182 cssparser: Make gsk_renderer_consume_url() return a string
We don't want to return a GFile because GFile can't handle can't deal
with data: urls.
That makes the code a bit more complicated that doesn't deal with those
URLs, but it makes the other code actually work.

GtkCssImageUrl also now decodes data urls immediately instead of only at
the first load. So don't use data urls if you care about performance.
2019-05-12 17:28:19 +02:00
Matthias Clasen
f2e197a389 css provider: Stop mentioning key themes
We no longer do this.
2019-05-09 14:53:32 +00:00
Matthias Clasen
d91f04eefd Correct theme loading docs
The docs were failing to mention the VARIANT.
2019-05-08 14:47:08 +00:00
Matthias Clasen
a86160265a css provider: Remove outdated version check
When looking for versioned theme files, we were
looking for directories names gtk-4.x for x
bigger than 14, which mades sense for GTK 3,
but we are starting out at 0 again, so remove
this check.
2019-05-08 14:33:23 +00:00
Benjamin Otte
1aa1610611 cssprovider: Export correct API
gtk_css_provider_get_named() is the old GTK3 style API to load themes.

Instead, export the function we currently use,
gtk_css_provider_load_named().

As a side effect we allow people to load a theme as often as they want
without conflicting with GTK's theme.
2019-04-18 02:26:04 +02:00
Benjamin Otte
24cc721bc6 cssprovider: Mark whole @import statement on import error 2019-04-12 19:34:28 +02:00
Benjamin Otte
2e0a56665a css: Move gtkcsssection.[ch] into gtk/css 2019-04-12 19:34:28 +02:00
Benjamin Otte
37671d2bd0 cssprovider: Redo error emission
Emit all errors via the parser, don't try to have a custom error
handling machinery.

The only exception is the initial file load error - we need to do that
one directly, because there is no parser.
2019-04-12 19:34:28 +02:00
Benjamin Otte
04d24b7cd2 csssection: Make printing functions public 2019-04-12 19:34:28 +02:00
Benjamin Otte
085d34cbb0 cssprovider: Advance parser to start of declaration
This way, the block will reference the right location.
2019-04-12 19:34:28 +02:00
Benjamin Otte
46143492a2 cssprovider: Change section handling
Instead of building a full tree of sections that then nobody cares
about, just create sections as necessary for when we use it in the
inspector.
2019-04-12 19:34:28 +02:00
Benjamin Otte
2fb202187c css: Remove GtkCssSectionType
It's unused.
2019-04-12 19:34:28 +02:00
Benjamin Otte
207c0b32b4 csssection: Redo constructors
Remove the unused one and rename the old one to new_from_parser().
2019-04-12 19:34:28 +02:00
Benjamin Otte
e0a01ba174 css: Redo for new parser
This commit is still way too big, but I couldn't make it smaller.

It transitions the old CSS parser to the new parser. CSS parsing is now
tokenized, everything else is probably still buggy.
2019-04-12 19:34:28 +02:00
Benjamin Otte
607502ef43 cssparser: Add gtk_css_parser_consume_url()
Another slight renaming and semantics change.
2019-04-12 19:34:28 +02:00
Benjamin Otte
acddc317da cssparser: Add gtk_css_parser_resolve_url()
Another slight change of semantics and naming for the new parser.
2019-04-12 19:34:28 +02:00
Benjamin Otte
f0d2f99239 cssparser: Add gtk_css_parser_consume_string()
Well, just rename _gtk_css_parser_read_string() for the new semantics,
but this sounds cooler.
2019-04-12 19:34:28 +02:00
Benjamin Otte
e7b9ecc99a cssparser: Add gtk_css_parser_try_at_keyword() 2019-04-12 19:34:28 +02:00
Benjamin Otte
7ccec19501 parser: Get rid of _gtk_css_parser_is_eof()
Use gtk_css_parser_has_token() instead.
2019-04-12 19:34:28 +02:00
Benjamin Otte
3fb44ae651 cssparser: Add gtk_css_parser_try_token() 2019-04-12 19:34:28 +02:00
Benjamin Otte
684b6459f1 cssparser: Get rid of _gtk_css_parser_begins_with()
Replace it with calls to gtk_css_parser_has_token().
2019-04-12 19:34:28 +02:00
Benjamin Otte
904a9d0c98 parser: Add gtk_css_parser_has_token()
This is ithe first step towards converting the parsing code to use
tokens. For now, the topken type is just a magic enum value that only
works as-needed.
2019-04-12 19:34:28 +02:00
Benjamin Otte
a938c14d11 build: Add gtk-css static library
This library is meant to be the new CSS library that gets used from GDK,
GSK and GTK for string printing and parsing.

As a first step, move GtkCssProviderError into it.

While doing so, split it into GtkCssParserError (for critical problems)
and GtkCssParserWarning (for non-critical problems).
2019-04-12 19:34:28 +02:00
Matthias Clasen
96fa1fb5c1 Drop key themes
These were an abuse of css, and not very successful
as a concept. We are going to replace bindings with
a new way of doing customizable shortcuts.
2019-02-21 12:22:50 -05:00
Alberts Muktupāvels
7a8f5ca970 gtkcssprovider: remove gtk_css_provider_get_default
This function is unused since cdc6e82720 commit and does not
contain fallback style.

https://gitlab.gnome.org/GNOME/gtk/issues/1226
2018-07-19 19:25:17 +03:00
Timm Bäder
aa32fc1708 cssprovider: Remove priv pointer 2018-02-13 18:48:44 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Benjamin Otte
452f2f0394 cssprovider: Use g_file_load_bytes()
This way, we get a special no-copy case for resources.

https://bugzilla.gnome.org/show_bug.cgi?id=790270
2018-02-05 17:22:56 +01:00
Matthias Clasen
d005109133 Drop unused gtkcssstylefuncs.c
Clean up all the places where the header was still
included needlessly.
2017-11-30 18:46:54 -05:00
Daniel Boles
6f54e1fc6d CssProvider: Fix doc of min theme version loaded
The code shows that we only load back to 4.0, but this still said 3.0.
2017-11-08 09:22:49 +00:00
Daniel Boles
6a9c14b2fa CssProvider: Use consistent theme name placeholder
commit 475d916eb9 added various paths that
use theme-name for this, but the existing path already used THEME, with
a subsequent description referring to the latter. So use that everywhere
2017-11-08 09:22:46 +00: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
9151e0b9f5 stylecontext: Port to use display instead of screen 2017-10-31 03:05:54 +01:00
Matthias Clasen
d1b77fd60f Drop code handling deprecated style properties
We no longer have any deprecated style properties.
2017-09-17 16:59:26 -04:00
Timm Bäder
e36ddfec17 Remove all widget style property code 2017-07-19 21:27:14 -04:00