Commit Graph

31965 Commits

Author SHA1 Message Date
Benjamin Otte
79238b0d8f cssparser: Add error functions that take locations
... and use them to report better error locations for the warning when
blocks aren't terminated properly.
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
76826cfa2f cssparser: Pass in error locations explicitly
And for the quick function, use the start/end location of the current
token.
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
a475d72d47 cssparser: Improve location APIs
1. Export multiple locations
2. Return the location instead of passing one in
2019-04-12 19:34:28 +02:00
Benjamin Otte
a8f712b09a cssection: Return locations, not numbers
Now that we have GtkCssLocation, actually use it.
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
35f60dc918 csssection: Store a GtkCssLocation 2019-04-12 19:34:28 +02:00
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
de73ac980f css: Use gtk_css_parser_consume_any() for transition shorthand 2019-04-12 19:34:28 +02:00
Benjamin Otte
a31e5f7a8c cssshadow: Use gtk_css_parser_consume_any()
This way, the arguments can now really be speicified in any order.

A new testcase testing all the ordering possibilities has been added.
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
f3db19d694 Resurrect the CSS parser from the tokenizer branch
So far that parser is unused.
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
93b643c44d css: Make font-weight an integer
This conforms to what Pango does and to the CSS4 spec. And it makes the
parsing code easier. So let's go for it.
2019-04-12 19:34:28 +02:00
Benjamin Otte
21616f6e2e cssimagescaled: Use gtk_css_parser_consume_function()
As part of that, adapt the syntax from
  -gtk-scaled( [<image>, <int>?]# )
to
  -gtk-scaled( [<image> <int>?]# )

because the commas should be used to separate distinct elements.

Note that almost nobody specifies the scale anyway.
2019-04-12 19:34:28 +02:00
Benjamin Otte
8157004068 easevalue: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
8d69bda27a cssimagelinear: Use gtk_css_parser_consume_function() 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
28fbcf6abe shorthand: Use gtk_css_parser_try_ident() 2019-04-12 19:34:28 +02:00
Benjamin Otte
1fd339c46f cssimageradial: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
b830bdca37 cssimagefallback: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
45bc4ed321 cssimagerecolor: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
9c862d7736 cross-fade: Make progress optional
Now we accept progress being unset and then dynamically compute it
on-demand.
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
96f9cbcabf cssimage: Make cross-fade() an array
The new spec at https://drafts.csswg.org/css-images-4/#cross-fade-function
allows infinite images to cross-fade and we want to, too.
2019-04-12 19:34:28 +02:00
Benjamin Otte
3597f7e8b1 cssimageicontheme: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
38227dc972 cssfiltervalue: Use gtk_css_parser_consume_function() 2019-04-12 19:34:28 +02:00
Benjamin Otte
aa50e92c65 csstransformvalue: Use gtk_css_parser_consume_function() 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
32e256e5ab css: Split GtkCssLocation into its own file
And make the struct public, so we can use it in signal handlers.
2019-04-12 19:34:28 +02:00
Benjamin Otte
d4d46e8125 csstokenizer: Add gtk_css_token_is_preserved() 2019-04-12 19:34:28 +02:00
Benjamin Otte
661720ef8b tokenizer: Pass error arg to read_token()
Instead of an error vfunc, have the tokenizer vfunc take a GError
argument. Note that even when an error is returned, there is still a
token to be read.
2019-04-12 19:34:28 +02:00
Benjamin Otte
013591d68d css: Add GtkCssTokenizer
This is copied from an old branch of mine.
2019-04-12 19:34:28 +02:00