From be6a4722c0a0d8e49c417704b7365a6d0932f3d0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 19 Feb 2023 04:55:33 +0100 Subject: [PATCH] listview: Measure children only, not self The previous code would include CSS padding/margin/border in the measurement and that is wrong. Until commit a96c75ff02 this was not actually visible, but afterwards listitems were allocated 16px too wide. Test included --- gtk/gtklistview.c | 6 ++-- testsuite/reftests/listview-margin.css | 8 +++++ testsuite/reftests/listview-margin.ref.ui | 32 +++++++++++++++++ testsuite/reftests/listview-margin.ui | 44 +++++++++++++++++++++++ testsuite/reftests/meson.build | 3 ++ 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 testsuite/reftests/listview-margin.css create mode 100644 testsuite/reftests/listview-margin.ref.ui create mode 100644 testsuite/reftests/listview-margin.ui diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c index 792c9d5a6e..f9b7103d63 100644 --- a/gtk/gtklistview.c +++ b/gtk/gtklistview.c @@ -606,9 +606,9 @@ gtk_list_view_size_allocate (GtkWidget *widget, } /* step 1: determine width of the list */ - gtk_widget_measure (widget, opposite_orientation, - -1, - &min, &nat, NULL, NULL); + gtk_list_view_measure_across (widget, opposite_orientation, + -1, + &min, &nat); self->list_width = orientation == GTK_ORIENTATION_VERTICAL ? width : height; if (opposite_scroll_policy == GTK_SCROLL_MINIMUM) self->list_width = MAX (min, self->list_width); diff --git a/testsuite/reftests/listview-margin.css b/testsuite/reftests/listview-margin.css new file mode 100644 index 0000000000..8de8d97250 --- /dev/null +++ b/testsuite/reftests/listview-margin.css @@ -0,0 +1,8 @@ +listview, box { + margin: 50px; + padding: 50px; +} + +row { + all: unset; +} diff --git a/testsuite/reftests/listview-margin.ref.ui b/testsuite/reftests/listview-margin.ref.ui new file mode 100644 index 0000000000..c551b8bb76 --- /dev/null +++ b/testsuite/reftests/listview-margin.ref.ui @@ -0,0 +1,32 @@ + + + + 0 + + + + vertical + + + 1 + One + + + + + 1 + Two + + + + + 1 + Three + + + + + + diff --git a/testsuite/reftests/listview-margin.ui b/testsuite/reftests/listview-margin.ui new file mode 100644 index 0000000000..e72a1e5fec --- /dev/null +++ b/testsuite/reftests/listview-margin.ui @@ -0,0 +1,44 @@ + + + + 0 + + + + + + + + One + Two + Three + + + + + + + + + + + + ]]> + + + + + + diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index b8e0ef0e64..1cc8a4302c 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -446,6 +446,9 @@ testdata = [ 'link-coloring.css', 'link-coloring.ref.ui', 'link-coloring.ui', + 'listview-margin.css', + 'listview-margin.ref.ui', + 'listview-margin.ui', 'listview-with-wrapped-labels.ref.ui', 'listview-with-wrapped-labels.ui', 'marble.xpm',