This is in preparation for calc(), as calc(50% - 5px) is valid CSS
but has 2 units. Instead, add a function to query a value's dimension
(so we can differentiate lengths from numbers) and add a function to
query if the value contains percentages.
The same trick that was applied to _gtk_css_change_for_child in
the previous commit can be applied to _gtk_css_change_for_sibling
as well, and that is what this commit does.
With both functions converted, gtk_css_change_translate is no
longer needed and gets dropped.
The function to translate GtkCssChange enum values to the PARENT
ones is called very frequently. This patch speeds it up tremendously.
The callgrind instruction count for this function in the listbox
demo goes from 108M to 7M.
For now assume that if those flags change for a node, they also changed
for all sibling nodes. This is not strictly true but simplifies
invalidation.
The reason it simplifies invalidation is that when removing or adding a
node, we can just invalidate the first node (for NTH_LAST_CHILD) and the
new node (for NTH_CHILD) and all the other nodes will be invalidated
automatically.
Instead of GTK_CSS_CHANGE_POSITION we now have 4 values:
GTK_CSS_CHANGE_FIRST_CHILD, GTK_CSS_CHANGE_LAST_CHILD,
GTK_CSS_CHANGE_NTH_CHILD and GTK_CSS_CHANGE_NTH_LAST_CHILD
Nobody is using them directly yet.
... and pass it to the API that computes new styles.
A special timestamp of 0 means "please don't animate" and is used when
no frame clock is available for a node.
The design principles were:
- synchronized
If multiple style contexts are animating, they should all do an
animation step at the same time.
- degrades well
Even when there's thousands of style contexts all animating at the same
time, the animation steps don't starve the CPU. This is achieved by
making sure the timeout is really fast. It just sets a bunch of flags.
- no hidden bottlenecks
Turning animatability on or off on a style context is O(1).
So far it is unused.
Also, in places where we're computing a new CssValue based on an
old one, make sure that if nothing changes we're returning a reference
to the old one, rather than creating a new identical instance.
By default, a background image is stretched. Instead, it is worth to
have a tiled background.
This patch allows background surfaces to be repeated or not, and should
be compatible with future extensions and CSS.
https://bugzilla.gnome.org/show_bug.cgi?id=663522