Commit Graph

298 Commits

Author SHA1 Message Date
Benjamin Otte
0d253b67f4 css: Make font property a shorthand
... and implement the CSS font properties:
- font-size
- font-style
- font-family
- font-weight
- font-variant

This is the second try at this. The first was backed out previously due
to bugginess. Let's hope this one survives a bit longer.

Also makes the font-family CSS test work again.
2011-06-15 12:52:53 +02:00
Benjamin Otte
3aa73bebea styleproperty: Add border-*-color style properties
And make border-color a shorthand
2011-06-13 15:01:52 +02:00
Benjamin Otte
287069ca3c default theme: Fix menuitem check/radio colors 2011-06-12 23:35:39 +02:00
Benjamin Otte
3712ec71d4 default theme: fix menuitem selections 2011-06-12 23:28:43 +02:00
Benjamin Otte
d7598aabe3 default theme: fix tooltip colors 2011-06-12 23:26:53 +02:00
Cosimo Cecchi
1539ade9d5 cssprovider: add a doc paragraph about box-shadow 2011-06-11 09:29:43 +02:00
Cosimo Cecchi
3d1407a01a border-image: add support for border-image-width too
It's useful to set a slice size != border-width, as backgrounds are
clipped to border-width too.

As slices can be half-transparent and overlap the background,
this would not fill the border box properly if we only use a single
property for specifying the width.

Also, this brings us even closer to CSS3.
2011-06-09 20:01:57 -04:00
Cosimo Cecchi
a2a8d3e8f4 docs: expand the docs for border-image
https://bugzilla.gnome.org/show_bug.cgi?id=651194
2011-06-09 05:51:54 +02:00
Benjamin Otte
2e6bb2a0c9 Revert "css: Make font property a shorthand"
The hack in gtk_style_context_get_font() was causing segfaults in
combobox code. This is not acceptable and I'm not awake enough to fix
it, so just reverting until it's fixed sanely is easiest.

This reverts commit cf6bfbdb17.
2011-06-02 02:31:44 +02:00
Benjamin Otte
a659143d55 docs: There is no font-name style property
It's "font"
2011-06-02 02:03:52 +02:00
Benjamin Otte
fd4ffbb6da styleproperty: Add _gtk_style_property_is_inherit()
And use it instead of gtk_style_param_get_inherit()
2011-06-02 02:03:52 +02:00
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