summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2019-08-19 15:53:18 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-08-20 21:55:17 +0200
commitc997214620d80adc0b1794b42a9e79ce856d9df2 (patch)
treedb6841f33d4962f50a800794b56dbf8e67775a9c
parentd7ba87962aed2e19804bbc1924187258f6a5b616 (diff)
downloadatk-c997214620d80adc0b1794b42a9e79ce856d9df2.tar.gz
Make atk_text_rectangle_union ignore undefined rectangles
atk_text_get_character_extents might return "-1" rectangles for character positions without support for getting an extent. In that case we have to ignore them instead of using -1 values in computations.
-rw-r--r--atk/atktext.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/atk/atktext.c b/atk/atktext.c
index 8f2e498..fbe05ab 100644
--- a/atk/atktext.c
+++ b/atk/atktext.c
@@ -1328,6 +1328,23 @@ atk_text_rectangle_union (AtkTextRectangle *src1,
{
gint dest_x, dest_y;
+ /*
+ * Some invocations of e.g. atk_text_get_character_extents
+ * may return "-1" rectangles for character positions without support for
+ * getting an extent. In that case we have to ignore them instead of using -1
+ * values in computations.
+ */
+ if (src1->width == -1)
+ {
+ *dest = *src2;
+ return;
+ }
+ if (src2->width == -1)
+ {
+ *dest = *src1;
+ return;
+ }
+
dest_x = MIN (src1->x, src2->x);
dest_y = MIN (src1->y, src2->y);
dest->width = MAX (src1->x + src1->width, src2->x + src2->width) - dest_x;