summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2014-09-26 13:14:20 +0100
committerTom Hacohen <tom@stosb.com>2014-09-26 13:20:14 +0100
commita4d716d1c0ea5470f319413d82e915798ce9600e (patch)
tree2aae9830d7fae136902cc6fafb0e7a37179b4b6e
parent3c021572dbb36bc45bb31e8cbb0df1f7f5aaebfd (diff)
Evas Textblock: Fix bad empty line add on wrapping
Summary: In some cases of char or word wrapping, an empty line might be accidentally added at the end of the paragraph. That line contains no items. Of course, this line should not exist. One outcome of this is that it causes wrong height values of the paragraph, when the finalizing code uses the _layout_last_line_max_descent_adjust_calc, which in turn looks at that empty line to calculate the descent values. @fix Test Plan: Char-wrap and word-wrap tests to test suite included in this revision. Reviewers: tasn Subscribers: JackDanielZ, cedric Projects: #efl Differential Revision: https://phab.enlightenment.org/D1444
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c13
-rw-r--r--src/tests/evas/evas_test_textblock.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 520761d9ee..2ca3ffbf74 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -4892,8 +4892,12 @@ _layout_par(Ctxt *c)
4892 wrap -= it->text_pos; /* Cut here */ 4892 wrap -= it->text_pos; /* Cut here */
4893 } 4893 }
4894 } 4894 }
4895 4895 if ((wrap >= 0) && ((size_t) wrap == it_len))
4896 if (wrap > 0) 4896 {
4897 /* Can happen if this is the last word in the paragraph */
4898 adv_line = 0;
4899 }
4900 else if (wrap > 0)
4897 { 4901 {
4898 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT) 4902 if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
4899 { 4903 {
@@ -4914,6 +4918,11 @@ _layout_par(Ctxt *c)
4914 redo_item = 1; 4918 redo_item = 1;
4915 _layout_line_advance(c, it->format); 4919 _layout_line_advance(c, it->format);
4916 } 4920 }
4921 else // (wrap < 0)
4922 {
4923 /* avoid line advance if there is no wrapping point */
4924 adv_line = 0;
4925 }
4917 /* Reset wrap */ 4926 /* Reset wrap */
4918 wrap = -1; 4927 wrap = -1;
4919 } 4928 }
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 3b49eb98f4..464ebc534f 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -1654,6 +1654,19 @@ START_TEST(evas_textblock_wrapping)
1654 } 1654 }
1655 fail_if(w != bw); 1655 fail_if(w != bw);
1656 1656
1657 /* Verify that no empty line is added */
1658 evas_object_textblock_text_markup_set(tb, "<wrap=word>Hello</wrap>");
1659 evas_object_textblock_size_native_get(tb, NULL, &nh);
1660 evas_object_resize(tb, 0, 1000);
1661 evas_object_textblock_size_formatted_get(tb, NULL, &h);
1662 ck_assert_int_eq(nh, h);
1663
1664 evas_object_textblock_text_markup_set(tb, "<wrap=char>a</wrap>");
1665 evas_object_textblock_size_native_get(tb, NULL, &nh);
1666 evas_object_resize(tb, 0, 1000);
1667 evas_object_textblock_size_formatted_get(tb, NULL, &h);
1668 ck_assert_int_eq(nh, h);
1669
1657 /* Word wrap */ 1670 /* Word wrap */
1658 evas_object_textblock_text_markup_set(tb, "aaaaaa"); 1671 evas_object_textblock_text_markup_set(tb, "aaaaaa");
1659 evas_object_textblock_size_formatted_get(tb, &bw, &bh); 1672 evas_object_textblock_size_formatted_get(tb, &bw, &bh);