Commit Graph

287 Commits

Author SHA1 Message Date
Benjamin Otte
cf6bfbdb17 css: Make font property a shorthand
... and implement the CSS font properties:
- font-size
- font-style
- font-family
- font-weight
- font-variant
2011-06-02 02:03:52 +02:00
Benjamin Otte
0aa07c6fd6 cssprovider: Remove colors when resetting 2011-06-02 02:03:52 +02:00
Benjamin Otte
d0e1e2b103 css: Move property parsing into styleproperty file
Just shuffles code around for parsing properties.
2011-06-02 02:03:50 +02:00
Benjamin Otte
5a42464547 css: Rename function to _gtk_style_property_parse_value()
... and take an optional style property as argument. This way, we can
allow custom parse functions for properties. The style property needs to
be optional so that we can use it for widget style properties, too.
2011-06-02 02:03:50 +02:00
Benjamin Otte
35488f5846 css: Rename struct variable
I want to add parse_func as something different soon.
2011-06-02 02:03:50 +02:00
Benjamin Otte
3e7f74c456 styleproperty: Change _css_value_to_string()
Name it _gtk_style_property_print_value() and actually pass it the style
property. This way, we can later change it to use custom print functions
for different style properties.
2011-06-02 02:03:50 +02:00
Matthias Clasen
0b9cd78017 Add annotations to gtk_css_provider_load_from_data
https://bugzilla.gnome.org/show_bug.cgi?id=646859
2011-05-31 20:37:43 -04:00
Carlos Garnacho
20433efbfa gtkcssprovider: Free shorthand border GValues in the right place
The call to gtk_border_free() within unpack_border() felt completely
in the wrong place, as the border actually pertains to the GValue
being unpacked. Plus, the GValue itself was also being leaked.
2011-05-30 19:29:22 +02:00
Carlos Garnacho
2c8e01dc80 gtkcssprovider: plug several leaks
In finalize(), clear all rulesets.
In parse_declaration(), Free the GValue under unhandled error situations.
In gtk_css_provider_load_internal(), Do not leak the file contents.
2011-05-30 19:26:28 +02:00
Carlos Garnacho
747dc65c2c gtkcssprovider: Use g_slice_dup() to copy GValues around
GValues stored in GtkCssRulesets are gslice managed, so don't
g_memdup() GValues from shorthand properties. This fixes
memory corruptions when reloading contents in a GtkCssProvider.
2011-05-30 19:13:36 +02:00
Benjamin Otte
7de5a4e08d cssprovider: Don't convert widget style properties to CSS
They are still CSS, so converting them is wrong.
2011-05-23 15:56:09 +02:00
Benjamin Otte
7836df29cb cssprovider: Use right hash table when printing
If the CSS provider had widget style properties, printing them would
crash since 82b340f6f0
2011-05-23 15:56:09 +02:00
Benjamin Otte
21236cf270 style: Make margin a shorthand
... and add the real properties:
- margin-top
- margin-left
- margin-bottom
- margin-right
2011-05-22 05:56:12 +02:00
Benjamin Otte
a35aa96149 style: Make padding a shorthand
... and add the real properties:
- padding-top
- padding-left
- padding-bottom
- padding-right
2011-05-22 05:56:12 +02:00
Benjamin Otte
f5c7cefcca style: Convert border-width to a shorthand
Add the corresponding properties it refers to, too:
- border-top-width
- border-left-width
- border-bottom-width
- border-right-width
2011-05-22 05:56:11 +02:00
Benjamin Otte
42a4bd1c5b style: Add support for shorthand properties
Shorthand properties are basically the same a in CSS. For storage in
style properties or the CSS provider, they are unpacked into the real
values, so it is possible to partially override them.

No properties are yet converted to the new world yet, this is just the
code for supporting them.
2011-05-22 01:25:17 +02:00
Benjamin Otte
73c39f5b16 styleproperties: Add _gtk_style_properties_set_property_by_property()
... as a replacement for _gtk_style_properties_set_property_by_pspec().
We'll need that to handle shorthands.
2011-05-22 01:25:16 +02:00
Benjamin Otte
5eca8f8275 css: Rename gtkcssstrfuncs file to gtkstyleproperty
The idea is to handle the style property registering etc in this file
instead of the styleproperties file. The next commits will move those
files.
2011-05-21 22:49:43 +02:00
Benjamin Otte
548a1302ee cssprovider: Use _gtk_style_property_lookup()
This way we get the actual data node and can use it.
2011-05-21 22:49:43 +02:00
Benjamin Otte
d333911d30 docs: Add missing <row> 2011-05-21 03:41:52 +02:00
Cosimo Cecchi
016f540931 styleproperties: add a "text-shadow" style property
And document its use in the CSS parser gtk-doc.

https://bugzilla.gnome.org/show_bug.cgi?id=649314
2011-05-20 18:44:15 -04:00
Benjamin Otte
a1858c5454 cssprovider: When loading themes, don't pass in an error
We want to parse existing themes as well as possible instead of failing.
And the g_warning() is preserved.
2011-05-18 22:17:59 +02:00
Benjamin Otte
17e3d6f85e cssprovider: Don't propagate deprecation messages to passed-in error
It's an informative message, don't stop parsing the CSS because of it.
2011-05-18 22:17:59 +02:00
Benjamin Otte
d2ef71627b css: Make property parsing functions take a css parser
Instead of reading a string and then passing that in, let the parse
functions use the full power of the parser.
2011-05-18 22:17:59 +02:00
Benjamin Otte
03e84b7ee3 css: Move binding set parsing to strfuncs 2011-05-18 22:17:59 +02:00
Benjamin Otte
8111d99183 cssprovider: Cache if rulesets have inheritable style properties
This provides a huge speedup as we only need to preprocess style
properties when they are indeed inherited. This roughly doubles the
performance of the CSS matcher and brings the time taken by
gtk_css_provider_get_style() from 19% to 7% in my favorite benchmark.
2011-05-18 22:17:58 +02:00
Benjamin Otte
82b340f6f0 cssprovider: Keep two hash tables per ruleset
One for the style properties, one for the widget style properties.
This way we can make one hash table by pspec which means we don't have
to repeat the pspec lookup.
2011-05-18 22:17:58 +02:00
Benjamin Otte
399a439103 cssprovider: Add a new setter for rulesets
We now have set-by-pspec (which is used for normal style properties) and
set-by-name (which is used by widget properties).
2011-05-18 22:17:58 +02:00
Benjamin Otte
0318ab2ce1 cssprovider: Refactor handling of rulesets
Keep rulesets as an on-stack/heap structure instead of allocating all
instances separately.
Also, pass a ruleset to the ruleset parser, so we can make the ruleset
parser do lots of fancy things that might be useful for performance.
2011-05-18 22:17:58 +02:00
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
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
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
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
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
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
e1dda3d03f cssprovider: Don't hardcode strings anymore 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