Commit Graph

27849 Commits

Author SHA1 Message Date
8605a2a10a cssprovider: Speed up gtk_widget_style_get() property lookups
Previously we got the list of all matching rules and then iterated it to
find the first one that had the property. Now we look while matching
rules, so we don't lookup rules that we don't need.
2011-05-18 22:17:57 +02:00
d3c60cc89c css: Don't query type for regions
Regions are regions and don't match by type.
2011-05-18 22:17:57 +02:00
1400644069 reftests: Add a test ensuring selectors don't match children
Previously, the selector "Foo" would not only match Foo widgets, but
also all widgets that are descendants of Foo.
2011-05-18 22:17:57 +02:00
f3ed498c5b reftests: Add a test for descendant CSS selectors match
In widget hierarchy like "Foo Bar Bar Baz", we want the selector "Foo >
Bar Baz" to match, because it matches the elements 1, 2 and 4.
Previously, the selector only matches the Bar at position 3 and then
failed because it wasn't preceded by a Foo.
2011-05-18 22:17:56 +02:00
806c804271 reftests: Add a test that checks that * matches regions 2011-05-18 22:17:56 +02:00
dda83e2f98 reftests: Unset background-image in CSS of test
Otherwise the test screws up when it's set
2011-05-18 22:17:56 +02:00
b8eac1e130 reftests: Add a check for matching regions only once 2011-05-18 22:17:56 +02:00
710caeb512 tests: Add a test for enum values 2011-05-18 22:17:56 +02:00
619d344d8d css: Raised SYNTAX error when enum value can't be parsed 2011-05-18 22:17:56 +02:00
8ca799cc39 reftests: Add a test for matching by class 2011-05-18 22:17:56 +02:00
78de3e8180 reftests: Add a test for matching by name 2011-05-18 22:17:56 +02:00
269fe0f347 reftests: Add a test for matching by subtype 2011-05-18 22:17:56 +02:00
90caef4abe reftests: Add test to check that matching by type works 2011-05-18 22:17:56 +02:00
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
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
e875c619ef css: No more special code for regions
Just treat regions the same as elements.
2011-05-18 22:17:55 +02:00
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
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
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
dd78ab5a2f tests: Add test that ensures we properly parse the color red 2011-05-18 22:17:55 +02:00
42fb004dfc tests: Add another parsing test from the css spec 2011-05-18 22:17:55 +02:00
3f07482b10 tests: Add parsing test from the css spec 2011-05-18 22:17:55 +02:00
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
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
058bbb2aec tests: Add a test for importing nonexistant files 2011-05-18 21:58:47 +02:00
c7ef2225b7 tests: Add tests for cyclic imports 2011-05-18 21:58:47 +02:00
427c97a635 tests: Add test for recursively importing an identical file 2011-05-18 21:58:46 +02:00
e1dda3d03f cssprovider: Don't hardcode strings anymore 2011-05-18 21:58:46 +02:00
cec2875d36 cssprovider: Add support for strings 2011-05-18 21:58:46 +02:00
2a0ac6d102 cssprovider: Parse strings as identifiers when parsing property values 2011-05-18 21:58:46 +02:00
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
22492a37c1 cssprovider: Allow storing the parent stylesheet 2011-05-18 21:58:46 +02:00
286b5b9b72 cssprovider: Don't fail if an import doesn't work 2011-05-18 21:58:46 +02:00
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
b0d3078aa7 cssprovider: Make @import use the new load_internal() func 2011-05-18 21:58:46 +02:00
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
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
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
da52175013 cssprovider: Add a load_internal function that all loads chain to 2011-05-18 21:58:46 +02:00
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
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
84ba8255fc cssprovider: Move properties to scanner constructor
So we can set them in one place.
2011-05-18 21:58:46 +02:00
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
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
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
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
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
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
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
f3bb815517 cssprovider: Use scanner variable instead of priv->scanner 2011-05-18 21:58:45 +02:00