Commit Graph

27355 Commits

Author SHA1 Message Date
Benjamin Otte
4c92fb2b5d styleproperties: Speed up style_property_lookup()
Use the already existing bsearch version instead of iterating the array
manually.
2011-05-18 22:17:57 +02:00
Benjamin Otte
beba515243 styleproperties: Use the pspec as the hash table key
The code used the quarked name before, but when we already have the
pspec we want to have a lookup that does not involve quarking. And
lookup is equally fast if we only have the name.
2011-05-18 22:17:57 +02:00
Benjamin Otte
d6f0042773 css: Make _gtk_css_selector_matches() take a path length
This will be necessary when handling inherit.
2011-05-18 22:17:57 +02:00
Benjamin Otte
08e83ca66b cssprovider: Simplify code
Don't go through an intermediate array when matching styles.
2011-05-18 22:17:57 +02:00
Benjamin Otte
f04f943708 styleproperties: Mark "color" and "font" as inherit
Keeping it identical to CSS 2.1 again
2011-05-18 22:17:57 +02:00
Benjamin Otte
9bfd3d2eec API: Add API to set style properties to be inherit
The API is not used anywhere yet.
2011-05-18 22:17:57 +02:00
Benjamin Otte
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
Benjamin Otte
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
Benjamin Otte
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
Benjamin Otte
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
Benjamin Otte
806c804271 reftests: Add a test that checks that * matches regions 2011-05-18 22:17:56 +02:00
Benjamin Otte
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
Benjamin Otte
b8eac1e130 reftests: Add a check for matching regions only once 2011-05-18 22:17:56 +02:00
Benjamin Otte
710caeb512 tests: Add a test for enum values 2011-05-18 22:17:56 +02:00
Benjamin Otte
619d344d8d css: Raised SYNTAX error when enum value can't be parsed 2011-05-18 22:17:56 +02:00
Benjamin Otte
8ca799cc39 reftests: Add a test for matching by class 2011-05-18 22:17:56 +02:00
Benjamin Otte
78de3e8180 reftests: Add a test for matching by name 2011-05-18 22:17:56 +02:00
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