Benjamin Otte
151294576d
cssprovider: Refactor code to have a gtk_css_ruleset_matches()
2011-05-18 22:17:58 +02:00
Benjamin Otte
71c748b47e
cssprovider: Rename "SelectorStyleInfo" to "Ruleset"
...
No code changes, just clarification of the name
2011-05-18 22:17:58 +02:00
Benjamin Otte
b37f9fdf81
css: Implement inherit properties
...
Huge performance hit (slows down things roughly by a factor of 3), but
necessary for CSS conformance and for implementing "inherit" and
percentages.
2011-05-18 22:17:58 +02:00
Benjamin Otte
25c396409c
reftests: Check style property order
...
Ensure that style properties are read in the correct order, by having a
property twice with vastly different values.
2011-05-18 22:17:58 +02:00
Benjamin Otte
c1dc3e9372
css: Refactor code to do property lookups earlier
...
We want to ook up the property in the CSS parser, so we can do fancy
things with it. We currently don't but we want to later.
2011-05-18 22:17:57 +02:00
Benjamin Otte
82399bf457
styleproperties: Speed up by not optimizing
...
g_quark_try_string() takes a lock and then does a hashtable lookup. So
just using a string hash table for properties is faster.
2011-05-18 22:17:57 +02:00
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