Commit Graph

60280 Commits

Author SHA1 Message Date
Timm Bäder
fc2d05ee38 cssimageradial: Use array + length instead of GArray
This makes sense since we're not going to change the (amount of) colors
after parsing.
2020-01-18 08:49:51 +01:00
Timm Bäder
00aa4f0597 cssimagelinear: Use count+array for the color stops, not GArray
This makse sense but will also make later changes to GtkCssImageLinear
simpler.
2020-01-18 08:49:51 +01:00
Timm Bäder
3401150cca cssimagefallback: Don't compute new image if only a color is set
Themes might use e.g. image(red), which is a constant value and will
never change. In that case, the fallback image has ->color set, but not
->images. If that's the case and the computed color is the same as
the one we already have, just return the already existing image.
2020-01-18 08:49:51 +01:00
Timm Bäder
67991ed0f4 Remove GtkCssRgbaValue
The differenciation between a literal color value and an RGBA value
caused problems in various situations. Just treat the two the same but
don't allow access to the rgba value of a non-literal color value.

This gets rid of around 1.6k rgba values in the widget-factory.
2020-01-18 08:49:51 +01:00
Matthias Clasen
741e12012d dump css value stats 2020-01-18 08:49:51 +01:00
Timm Bäder
91aa60b210 csssshadwovalue: Remove unused function prototype 2020-01-18 08:49:51 +01:00
Timm Bäder
e31c0898e5 cssnumbervalue: Add early-outs to transition code
we don't need to do the calculation at all if the progress is 0 or 1
anyway.

We also sometimes transition from 0 to 0 etc., so we can short-circuit
that as well by doing the fast pointer-equality check and relying on the
singletons.
2020-01-18 08:49:51 +01:00
Timm Bäder
1f2f2777e1 csscornervalue: Accept other values if x == y
Most corners are square, so x == y. In that case, just accept either of
them. This makes the corner value unnecessary.

In fact none of the corner values in the widget-factory are needed, so
this spares us around 500 corner value allocations.

css value stats before:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

and after:

GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
SUM: 7872

8428 to 7872 is a 556 reduction (6.5%)

asdf
2020-01-18 08:49:51 +01:00
Timm Bäder
9cb2fe5cac cssarrayvalue: Don't allocate memory when parsing array values
We probably won't find CSS with more than 128 values in array.
2020-01-18 08:49:51 +01:00
Timm Bäder
8d15efba8f cssarrayvalue: Allow calling array API on non-arrays
Just allow calling _get_nth() and _get_n_values() on every kind of css
value. This way we can allow all values in places where only array
values would be allowed before.

This spares us around 1000 array values in the widget factory.

css value stats before:

GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 1130
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
SUM: 9415

and after:

GtkCssBgSizeValue: 23
GtkCssIdentValue: 25
GtkCssPositionValue: 81
GtkCssCornerValue: 556
GtkCssArrayValue: 143
GtkCssStringValue: 33
GtkCssPaletteValue: 29
GtkCssImageValue: 2765
GtkCssColorValue: 1452
GtkCssFilterValue: 3
GtkCssRgbaValue: 1092
GtkCssShadowValue: 708
GtkCssEaseValue: 33
GtkCssBorderValue: 2
GtkCssTransformValue: 11
GtkCssDimensionValue: 882
GtkCssShadowsValue: 584
SUM: 8428

9415 to 8428 is a 987 reduction (10.4%)
2020-01-18 08:49:51 +01:00
Timm Bäder
1200fe2daf cssvalue: Add type names for all classes
This is important to have for debugging and e.g. to print statistics for
the individual css value types
2020-01-18 08:49:51 +01:00
Timm Bäder
515a527b27 csscolorvalue: Compute alpha/shade/mix of color literals directly
The values of these are never gonna change so we can as well create
literal color values from the resulting colors instead.
2020-01-18 08:49:51 +01:00
Timm Bäder
06dbde22a0 csscolorvalue: Don't resolve literal color values 2020-01-18 08:49:51 +01:00
Matthias Clasen
c21280e455 Merge branch 'adwaita-performance' into 'master'
Adwaita: Remove wildcards

Closes #2380

See merge request GNOME/gtk!1330
2020-01-18 06:43:11 +00:00
Matthias Clasen
0d9a7fe089 Adwaita: Remove wildcards
Selectors like *:disabled or *:link have bad performance
implications, since they cause all styles to be recomputed
when the state of the window changes. Replace these by a
list of the elements that are actually affected.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2380
2020-01-18 01:30:02 -05:00
Matthias Clasen
03883b8b1a Merge branch 'matthiasc/css-change-tracking-4' into 'master'
Improve change computation

See merge request GNOME/gtk!1327
2020-01-18 05:41:26 +00:00
Matthias Clasen
f28cd6cea9 Remove the widget-factory test again
This was failing in ci, in hard to track down ways.
2020-01-18 00:27:52 -05:00
Matthias Clasen
b8b90fefd8 change tests: Update test output
Some of these test cases involve :not, and thus are affected
by our now correct handling of it for change computation.

All of them are affected by the window now being visible.
2020-01-17 23:47:34 -05:00
Matthias Clasen
b4a9cf2bfb Remove no longer needed code
We no longer use superset or any matchers to find changes.
2020-01-17 23:47:34 -05:00
Matthias Clasen
2a919a4d4f Go back to the tree for computing change 2020-01-17 23:47:34 -05:00
Matthias Clasen
b2775d9bdd Redo the way we compute change
Instead of expecting a superset matcher, call
gtk_css_selector_match_for_change while walking the tree with the
original matcher. This fixes the handling of :not while determining
changes.
2020-01-17 23:47:34 -05:00
Matthias Clasen
d0a8a717ef Bring back the reserved bit 2020-01-17 23:47:34 -05:00
Matthias Clasen
7d72703d54 Revert "Remove no longer used code"
This reverts commit 105acfe908.
2020-01-17 23:47:34 -05:00
Matthias Clasen
8ecd4e87e3 Add testcases for css change flags
Add various tests for the change flag computation that
we do in the css selector tree.

test1: Just test the basic machinery of this test
test2: Trigger every change flag at least once
test3: Test that multiple states combine as expected
test4: Test negations (known to produce wrong results)
test5: Test a complex selector (not producing the expected
       output atm)
widget-factory.ui:
       The real thing: widget-factory+Adwaita. Note that
       this expedts to be run with GSETTINGS_BACKEND=memory

Note that test4 checks the wrong results that we currently
produce for selectors involving :not. It will have to be
updated when we fix the handling of :not. The widget-factory.ui
testcase will certainly also be affected.
2020-01-17 23:47:34 -05:00
Matthias Clasen
9de31929d6 Add a test for css change flags 2020-01-17 23:47:34 -05:00
Matthias Clasen
b41bba07fa Add a way to dump css node change values
Add a GTK_STYLE_CONTEXT_PRINT_SHOW_CHANGE flag that
tells gtk_style_context_to_string to include the
change values of nodes in the output. This will
help debugging css change tracking.
2020-01-17 23:47:34 -05:00
Matthias Clasen
0f694b8beb style tests: Update expected output
The printing of css nodes has changed, and the window
is visible now.
2020-01-17 23:47:34 -05:00
Matthias Clasen
7b1ab8fb8b style tests: Show the window
Not doing so somewhat defeats the point that we want
to verify the regular styles, not some weird initial
conditions.
2020-01-17 23:47:34 -05:00
Matthias Clasen
d9b1a1ebb1 style tests: Clean up --generate support
Reshuffle things so we don't call gtk_test_init() when --generate
is passed, to avoid polluting the output with test spew.
2020-01-17 23:47:34 -05:00
Matthias Clasen
d4f3979896 node tests: Update expected output
The printing of css nodes has changed and the
window is visible now.
2020-01-17 23:47:34 -05:00
Matthias Clasen
2e7cb6019f node tests: Show the window
This avoids using default styles.
2020-01-17 23:47:34 -05:00
Matthias Clasen
f1fce5253e node tests: Clean up --generate support
Reshuffle things so we don't call gtk_test_init() when --generate
is passed, to avoid polluting the output with test spew.
2020-01-17 23:47:34 -05:00
Matthias Clasen
81b65eadcb Add an Empty theme for tests 2020-01-17 23:47:34 -05:00
Matthias Clasen
1e7705c08e cssnode: Fix a corner case in style computation
When we recomputed the change flags, and the style
did not change, we still need to replace the style
object, since it holds the new change flags.
2020-01-17 23:47:34 -05:00
Matthias Clasen
cc3cf581ab cssnodedeclaration: Make print output deterministic
This was depending on the memory order of quarks, which
is not a good fit for tests that depend on this output.
2020-01-17 23:47:34 -05:00
Matthias Clasen
6e09c5cee8 Quiet compiler warnings in release builds 2020-01-17 23:47:34 -05:00
Matthias Clasen
69fb3648b2 Tweak the file transfer portal _again_
This is a neverending story. I was seeing problems in tests where
the nested mainloop was picking up unrelated timeouts.

Break down and make this async. This changes the ordering in which
the (de)serializers are registered. If this is causing issues, we
can introduce priorities or something else.
2020-01-17 23:46:37 -05:00
Matthias Clasen
23f84e3a3d Merge branch 'gtk-fix-gesture-get-center' into 'master'
gtkgesture: Fix gtk_gesture_get_bounding_box_center() for touchpads

Closes #2316

See merge request GNOME/gtk!1257
2020-01-17 21:59:33 +00:00
Yariv Barkan
1a9b1f38a4 demo: Use pinch translation in the gestures demo
Add the pinch translation offset to the pinch gesture demo. That allows
moving the square around in addition to the already-supported rotate and
zoom.
2020-01-17 22:34:48 +02:00
Yariv Barkan
00a488a5b5 gtkgesture: Fix get-center for touchpad gestures
Touchpad gestures have only a single event sequence. The current
'center' of the gesture is the starting point + accumulated deltas.
Update gtk_gesture_get_bounding_box_center() accordingly.
2020-01-17 22:34:48 +02:00
Matthias Clasen
26c4c28068 Fix a few bugs in the css change flag definition
These were found by the new change flag tests.
2020-01-17 11:26:50 -05:00
Timm Bäder
da2e184639 Merge branch 'fix-imwayland-cursor' into 'master'
imwayland: Fix get_preedit_string cursor position (GTK4)

Closes #2383

See merge request GNOME/gtk!1328
2020-01-17 09:24:48 +00:00
xdavidwu
9576222b47
imwayland: Fix get_preedit_string cursor position
GtkIMContext get_preedit_string should return cursor position counted
in characters, but cursor_begin here is counted in bytes. This add the
missing conversion.
2020-01-17 16:16:13 +08:00
Matthias Clasen
7738a05bd2 Merge branch 'matthiasc/css-change-tracking-3' into 'master'
Preliminary css matcher work

See merge request GNOME/gtk!1326
2020-01-17 00:38:04 +00:00
Matthias Clasen
93b5b487ae cssmatcher: Change get_state to has_state
This matches all the other vfuncs, and it gets us
out of keeping several big state flag enumerations
in sync.

Update all callers.
2020-01-16 19:24:43 -05:00
Matthias Clasen
7588655a42 Allow printing css matchers
This can help in debugging css matching.
2020-01-16 19:11:21 -05:00
Matthias Clasen
007713c0ba css: Add a matcher type enum
For now, this just replaces the is_any boolean
by a type field in the class. It will be used in
future commits.
2020-01-16 19:11:21 -05:00
Matthias Clasen
f0c1c3349f css: Simplify the superset matcher
We use the superset matcher in exactly one place,
so there is no need for the generality of allowing
to ignore different aspects. Just hardcode the one
case we need: ignoring everything except for name,
id and class.
2020-01-16 19:11:08 -05:00
Matthias Clasen
0dba6e5759 Cosmetic change
Update comments for name changes that happened long ago.
2020-01-16 19:10:03 -05:00
Matthias Clasen
60cd7cd96c css: Fix the ANY matcher state list
The ANY and matcher was not, in fact, matching any state,
since the list of states was not up-to-date.

The same fix applies to the superset matcher as well.
2020-01-16 19:09:19 -05:00