Commit Graph

67 Commits

Author SHA1 Message Date
Benjamin Otte
1cd9396154 css: Review error messages
... and move them from _gtk_css_parser_error() to the proper new error
message.
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
7f99c1e588 cssparser: Split integer gettig into has/consume functions
We can't try to get an integer because ultimately integer getters
support the same shenanigans that numbers and percentages do with calc()
and whatnot.
2019-04-12 19:34:28 +02:00
Benjamin Otte
5f3e5a0406 cssparser: Add gtk_css_parser_try_delim()
For parsing single code point delimiters. Also port calc() to use this.
2019-04-12 19:34:28 +02:00
Benjamin Otte
23080d47b5 cssparser: Get rid of _gtk_css_parser_try_double()
Use gtk_css_parser_consume_number() everywhere instead.
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
dce8c11b07 cssparser: Drop _gtk_css_parser_has_prefix()
Replace it with has_ident/has_function. The old function is a typical
string matching API, not a tokenizing one.
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
dbdb81f411 cssparser: Add gtk_css_parser_consume_ident()
And use it to fix the palette parser.
2019-04-12 19:34:28 +02:00
Benjamin Otte
d99ae4b6c2 cross-fade: Use gtk_css_parser_consume_any()
.. and gtk_css_parser_consume_function().

gtk_css_parser_consume_any() is a new function that implements the CSS
spec's any combinator ||.
2019-04-12 19:34:28 +02:00
Benjamin Otte
753ad64cbc cssparser: Introduce gtk_css_parser_consume_function()
This is a vfunc-based function parser.
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
76fb80f46c cssparser: Introduce gtk_css_parser_try_ident()
... and gtk_css_parser_has_function().
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
Benjamin Otte
d9ef734458 cssparser: Simplify
Remove the uint parser (and use the int parser in the one user of it).

And avoid unnecessarily going through a macro.
2019-03-22 19:55:34 +01:00
Benjamin Otte
73760e5835 cssparser: Remove unused functions 2019-03-22 19:55:34 +01:00
Timm Bäder
7f4b7c48e8 cssparser: Make _gtk_css_parser_try a macro
We almost always pass a constant string to it, so use a macro and try to
trick the compiler into evaluating the 2(!) strlen() calls at compile
time.
2019-01-29 05:03:26 +01:00
Benjamin Otte
4ac3f916d0 css: Parse hex colors with alpha value
The CSS color spec version 4 introduces this, support has hit Safari,
Chrome and Firefox, so this looks like a feature that's here to stay.

https://drafts.csswg.org/css-color/#hex-notation
2018-03-02 02:00:24 +01:00
Timm Bäder
9ef700b161 css parser: Reuse one GString
Instead of creating a new one for every ident, name and string, just
create one GString and reuse it. This means the GString we keep around
will grow to the maximum size of any ident, name or string we parse,
which is still not terribly large.
2018-01-02 08:10:06 +01:00
Matthias Clasen
a08e2b5692 Drop code parsing deprecated forms of url
We no longer allow whitespace between url and (.
2017-09-17 17:01:29 -04: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
3056d793a4 cssparser: Make _gtk_css_parser_has_number() a bit smarter
Previously we just checked the first character. And if that was a "-" as
in "-gtk-some-special-value", we assumed it was a number. Which it
clearly wasn't.

Test included
2016-02-23 04:22:19 +01:00
Benjamin Otte
b246d55472 css: Turn number values into a virtual type
GtkCssNumberValue is now a base class for numbers.

Actual numbers are now implemented in GtkCssDimensionValue. The name is
borrowed from the CSS spec, so there.
2016-02-13 04:49:07 +01:00
Benjamin Otte
0e7691c12e css: Add rem unit
Good luck, Lapo.
2016-02-04 19:37:44 +01: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
b90802f7e4 css: Actually break at end of the string
Introduced in 65c4c1555d.

Found by gnome-continuous running the testsuite.

Includes fixing a broken test in the testsuite.
2014-05-22 02:13:49 +02:00
Benjamin Otte
65c4c1555d css: Fix printing code for CSS strings and idents
It used to infloop on special characters.
2014-05-05 15:48:02 +02:00
Benjamin Otte
b356d81410 css: Split out a common function
It's used in two places already, and Iwant to use it in a third one.
2014-05-05 15:48:02 +02:00
Marcus Kraßmann
7f3595a6be cssparser: Don't detect /*/ as a comment 2012-11-28 21:11:48 +01:00
Benjamin Otte
12683da8f7 gtk: Make functions static that don't need to be non-static
Also remove the starting underscore from function names where
appropriate, as those functions are static now and not exported anymore.

This is part of a bunch of fixes for gcc complaining about
-Wmissing-declarations.
2012-10-02 19:32:51 +02:00
Benjamin Otte
c69e30d65a cssparser: Don't use a free'd string in error messages 2012-09-17 20:39:11 +02:00
Benjamin Otte
e1317268a3 cssparser: Change APIs that work with files
Now that we keep track of the parser's file, we don't require it to be
passed anymore.
2012-05-11 16:42:12 +02:00
Benjamin Otte
a65780902a cssparser: Keep track of the file 2012-05-11 16:42:11 +02:00
Benjamin Otte
1223d53a82 cssparser: Move symbolic color parser to gtksymboliccolor.c 2012-04-17 08:59:19 +02:00
Benjamin Otte
dcd54e20d1 css: Remove GtkCssNumber
It's completely replaced by GtkCssNumberValue now.
2012-04-17 08:59:19 +02:00
Benjamin Otte
662d6787f3 css: Add <time> type to css number stuff 2012-04-17 08:59:16 +02:00
Benjamin Otte
b0e764000f cssparser: Use _gtk_css_parser_error_full() 2012-04-17 08:59:12 +02:00
Benjamin Otte
e7acdec220 cssparser: Add _gtk_css_parser_error_full() 2012-04-17 08:59:11 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Benjamin Otte
0c140daff2 css: Implement support for angles 2012-02-02 03:14:00 +01:00
Benjamin Otte
893807bee0 css: Add GtkCssNumber 2012-02-02 03:14:00 +01:00
Alexander Larsson
e46971306a Ensure we can load images via resource:// uris from CSS 2012-01-16 14:19:19 +01:00
Cosimo Cecchi
e0efeba27e parser: remove unused _gtk_css_parser_read_uri()
It's not used anymore now.
2012-01-13 18:09:30 -05:00
Cosimo Cecchi
d1f3fe4342 parser: remove a duplicate copy of gtk_css_parse_url()
Move the function to gtkcssparser.c and use it in both places.
2012-01-13 17:55:53 -05:00
Paolo Borelli
fee09e726f Introduce _gtk_css_parser_try_length
This starts to introduce the proper API abstraction for when we will
support different units
2012-01-09 18:37:58 +01:00