From c997214620d80adc0b1794b42a9e79ce856d9df2 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 19 Aug 2019 15:53:18 +0200 Subject: 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. --- atk/atktext.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'atk') 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; -- cgit v1.2.1