Benjamin Otte
269fe0f347
reftests: Add a test for matching by subtype
2011-05-18 22:17:56 +02:00
Benjamin Otte
90caef4abe
reftests: Add test to check that matching by type works
2011-05-18 22:17:56 +02:00
Benjamin Otte
174cfff50f
tests: Add a test to ensure we handle unknown pseudo-classes correctly
...
1) We want to throw an unknown value
2) We want to skip the whole rule
2011-05-18 22:17:56 +02:00
Benjamin Otte
e7aa125eb0
tests: Add a test for all selector combination
...
The test contains an error where we complain about a duplicate value for
":hover:hover"
2011-05-18 22:17:56 +02:00
Benjamin Otte
e875c619ef
css: No more special code for regions
...
Just treat regions the same as elements.
2011-05-18 22:17:55 +02:00
Benjamin Otte
fc88b0f47c
css: Rewrite selectors
...
Selectors now go into their own C file. The new selectors are modeled a
lot closer to the CSS spec. In particular the specificity computation
matches CSS 2.1 exactly.
For details about the why, see also:
http://mail.gnome.org/archives/gtk-devel-list/2011-May/msg00061.html
https://bugzilla.gnome.org/show_bug.cgi?id=649798
2011-05-18 22:17:55 +02:00
Benjamin Otte
4e2d3f5d18
cssprovider: Remove a bunch of commented-out code
...
The code was only kept for reference while writing the new parser, it's
not necessary anhymore.
2011-05-18 22:17:55 +02:00
Benjamin Otte
ce44c95ce8
tests: Be more verbose in error messages.
...
Also, it makes it easier to copy/paste diffs from the message log...
2011-05-18 22:17:55 +02:00
Benjamin Otte
dd78ab5a2f
tests: Add test that ensures we properly parse the color red
2011-05-18 22:17:55 +02:00
Benjamin Otte
42fb004dfc
tests: Add another parsing test from the css spec
2011-05-18 22:17:55 +02:00
Benjamin Otte
3f07482b10
tests: Add parsing test from the css spec
2011-05-18 22:17:55 +02:00
Benjamin Otte
2b807e574d
tests: Make the parser fail without assertions
...
Use the new g_test_fail() function. This way, the testsuite usually
doesn't crash, but actually finishes.
2011-05-18 22:17:55 +02:00
Benjamin Otte
7ccb9db79e
css: Rewrite the parser
...
Instead of relying on GScanner and its idea of syntax, code up a parser
that obeys the CSS spec.
This also has the great side effect of reporting correct line numbers
and positions.
Also included is a reorganization of the returned error values. Instead
of error values describing what type of syntax error was returned, the
code just returns SYNTAX_ERROR. Other messages exist for when actual
values don't work or when errors shouldn't be fatal due to backwards
compatibility.
2011-05-18 22:17:55 +02:00
Benjamin Otte
058bbb2aec
tests: Add a test for importing nonexistant files
2011-05-18 21:58:47 +02:00
Benjamin Otte
c7ef2225b7
tests: Add tests for cyclic imports
2011-05-18 21:58:47 +02:00
Benjamin Otte
427c97a635
tests: Add test for recursively importing an identical file
2011-05-18 21:58:46 +02:00
Benjamin Otte
e1dda3d03f
cssprovider: Don't hardcode strings anymore
2011-05-18 21:58:46 +02:00
Benjamin Otte
cec2875d36
cssprovider: Add support for strings
2011-05-18 21:58:46 +02:00
Benjamin Otte
2a0ac6d102
cssprovider: Parse strings as identifiers when parsing property values
2011-05-18 21:58:46 +02:00
Benjamin Otte
6b66efe873
cssprovider: Add recursion checks for @import
...
This is pretty important, because otherwise recursions cause crashes.
And if you accidentally change your theme to one that crashes on load,
all your gonna SEGV and then on reboot, gdm tries to load the theme...
2011-05-18 21:58:46 +02:00
Benjamin Otte
22492a37c1
cssprovider: Allow storing the parent stylesheet
2011-05-18 21:58:46 +02:00
Benjamin Otte
286b5b9b72
cssprovider: Don't fail if an import doesn't work
2011-05-18 21:58:46 +02:00
Benjamin Otte
d6c6a0bcc0
cssprovider: Reimplement gtk_css_provider_load_from_path()
...
Call gtk_css_provider_load_from_file() instead of the internal function.
This has two advantages:
1) It simplifies the code a lot
2) It gets rid of GMappedFile usage. GMappedFile does not work
everywhere, so this is finally portable.
2011-05-18 21:58:46 +02:00
Benjamin Otte
b0d3078aa7
cssprovider: Make @import use the new load_internal() func
2011-05-18 21:58:46 +02:00
Benjamin Otte
a183375b94
cssprovider: Make load_internal() load the contents
...
This way, we achieve two things:
1) We can unify file loading to one location
2) We can emit the error from file loading using the parsing-error
signal. This is very useful for @import handling in particular.
2011-05-18 21:58:46 +02:00
Benjamin Otte
5bedc822ec
cssprovider: Introduce gtk_css_provider_take_error_full()
...
Emits the error without the need for a scanner. Also simplifies
gtk_css_provider_take_error() because we now can assert an available
scanner at all times.
2011-05-18 21:58:46 +02:00
Benjamin Otte
f937d0275a
cssprovider: More error handling into load_internal()
...
Now the parsing functions starting at parse_stylesheet() don't have to
care about errors anymore.
2011-05-18 21:58:46 +02:00
Benjamin Otte
da52175013
cssprovider: Add a load_internal function that all loads chain to
2011-05-18 21:58:46 +02:00
Benjamin Otte
77b40f2dcd
tests: Order files by name before adding them as tests
...
Ensures that the order of tests is not dependant on your hard disk.
2011-05-18 21:58:46 +02:00
Benjamin Otte
5cf6a8a23f
cssprovider: Keep base url in the scanner
...
And provide a nice function to query it. Simplifies a bunch of code.
2011-05-18 21:58:46 +02:00
Benjamin Otte
84ba8255fc
cssprovider: Move properties to scanner constructor
...
So we can set them in one place.
2011-05-18 21:58:46 +02:00
Benjamin Otte
2de4f71586
cssprovider: Don't store scanner in the struct
...
Instead, create scanners whenever we actually parse stuff.
2011-05-18 21:58:46 +02:00
Benjamin Otte
5c940f2bd4
cssprovider: Get rid of gtk_css_provider_reset_parser()
...
Instead call gtk_css_scanner_reset(). There is nothing else we could
need to do.
2011-05-18 21:58:45 +02:00
Benjamin Otte
607846879e
cssprovider: Keep track of passed in error differently
...
Instead of having an error member in the CSS provider's private struct,
connect a signal handler when an error is passed in. This has two
advantages:
1) It makes the code clearer as we don't have to keep track of an error
member anywhere.
2) It causes a non-emission of the g_warning() when an error was passed
in, because it only triggers when no signal handlers are connected.
So we get identical behavior to GTK 3.0 where warnings where only
emitted when no error was passed in.
2011-05-18 21:58:45 +02:00
Benjamin Otte
8fb6fdd3e7
cssprovider: Do error handling differently
...
Instead of aborting a parse whenever we encounter an error, parse to the
end. But if a GError was passed in, reset the provider completely as if
nothing had been parsed.
2011-05-18 21:58:45 +02:00
Benjamin Otte
992ee6a203
cssprovider: Emit a g_warning() when a css file is erroneous
...
... and no other error handler is active. See the source code comment
for the reasoning.
2011-05-18 21:58:45 +02:00
Benjamin Otte
2d75dd2fdf
cssprovider: No need to restore after @import parsing
...
With the recent changes, this just resets the error, and we don't the
error reset from subfile parsing.
2011-05-18 21:58:45 +02:00
Benjamin Otte
3e146b468b
cssprovider: Store current properties and selectors in scanner
...
They don't belong in the css provider
2011-05-18 21:58:45 +02:00
Benjamin Otte
f3bb815517
cssprovider: Use scanner variable instead of priv->scanner
2011-05-18 21:58:45 +02:00
Benjamin Otte
d85cbfe157
cssprovider: Pass scanner argument explicitly to error functions
2011-05-18 21:58:45 +02:00
Benjamin Otte
5bc2ae1a91
cssprovider: Update the scope modifying functions
...
Make them take the scanner as an argument, as that's what gets changed,
not the CssProvider.
2011-05-18 21:58:45 +02:00
Benjamin Otte
83ebc91dce
cssprovider: track state in the scanner
...
This way, we don't have to do magic copies when we create a new scanner
for a subfile.
2011-05-18 21:58:45 +02:00
Benjamin Otte
740f2458bf
cssprovider: Add a private structure to the scanner
...
So far, it's unused
2011-05-18 21:58:45 +02:00
Benjamin Otte
073d75a880
cssprovider: Add a custom gtk_css_scanner_destroy() function
...
So far, it does nothing
2011-05-18 21:58:45 +02:00
Benjamin Otte
5ca9f25523
cssprovider: Pass the scanner explicitly to parse_stylesheet()
...
This is the first step in decoupling the scanner from the provider.
2011-05-18 21:58:45 +02:00
Benjamin Otte
318a3af96e
cssprovider: No need to set user data anymore
2011-05-18 21:58:45 +02:00
Benjamin Otte
796d593cc1
tests: Make css-parser test take files as argument
...
Takes the css files to be tested as argument and runs with it.
2011-05-18 21:58:45 +02:00
Benjamin Otte
1f4b09b2fb
tests: Add a test for border parsing
2011-05-18 21:58:45 +02:00
Benjamin Otte
195589feac
tests: Add new test checking weird behavior for declarations
2011-05-18 21:58:44 +02:00
Benjamin Otte
cb8a595a65
cssprovider: Clean up declaration parser to conform to more tests
...
The tests will follow with the next commits
2011-05-18 21:58:44 +02:00