Evas textblock: fix height on line wrapping
authorDaniel Hirt <daniel.hirt@samsung.com>
Wed, 2 Dec 2015 12:37:58 +0000 (14:37 +0200)
committerDaniel Hirt <daniel.hirt@samsung.com>
Wed, 2 Dec 2015 13:06:32 +0000 (15:06 +0200)
Line advance should finalize the line with its last item, and not the
item we're currently wrapping. This fixes T1583, where some line
wrapping cases would look different than their equivalent <ps>
versions.

@fix

src/lib/evas/canvas/evas_object_textblock.c
src/tests/evas/evas_test_textblock.c

index 879659c..30cfb91 100644 (file)
@@ -3642,6 +3642,8 @@ loop_advance:
 static void
 _layout_line_advance(Ctxt *c, Evas_Object_Textblock_Format *fmt)
 {
+   Evas_Object_Textblock_Format *last_fmt = fmt;
+
    if (c->hyphen_ti)
      {
         c->ln->items = (Evas_Object_Textblock_Item *)
@@ -3652,7 +3654,11 @@ _layout_line_advance(Ctxt *c, Evas_Object_Textblock_Format *fmt)
            eina_list_append(c->o->hyphen_items, c->hyphen_ti);
         c->hyphen_ti = NULL;
      }
-   _layout_line_finalize(c, fmt);
+   if (c->ln->items)
+     {
+        last_fmt = _ITEM(EINA_INLIST_GET(c->ln->items)->last)->format;
+     }
+   _layout_line_finalize(c, last_fmt);
    _layout_line_new(c, fmt);
 }
 
index ad16793..a14f599 100644 (file)
@@ -2162,6 +2162,15 @@ START_TEST(evas_textblock_wrapping)
         ck_assert_int_eq(bret, ret);
      }
 
+   /* Check that line wrap produces the same height values as paragraph break */
+   evas_object_resize(tb, 1, 100);
+   evas_object_textblock_text_markup_set(tb, "<wrap=word>hello world");
+   evas_object_textblock_size_formatted_get(tb, NULL, &bh);
+   evas_object_textblock_text_markup_set(tb, "hello<ps>world");
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+
+   ck_assert_int_eq(bh, h);
+
    END_TB_TEST();
 }
 END_TEST