tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a4d716d1c0ea5470f319413d82e915798ce9600e

commit a4d716d1c0ea5470f319413d82e915798ce9600e
Author: Daniel Hirt <[email protected]>
Date:   Fri Sep 26 13:14:20 2014 +0100

    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
---
 src/lib/evas/canvas/evas_object_textblock.c | 13 +++++++++++--
 src/tests/evas/evas_test_textblock.c        | 13 +++++++++++++
 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 520761d..2ca3ffb 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)
                             wrap -= it->text_pos; /* Cut here */
                          }
                     }
-
-                  if (wrap > 0)
+                  if ((wrap >= 0) && ((size_t) wrap == it_len))
+                    {
+                       /* Can happen if this is the last word in the paragraph 
*/
+                       adv_line = 0;
+                    }
+                  else if (wrap > 0)
                     {
                        if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
                          {
@@ -4914,6 +4918,11 @@ _layout_par(Ctxt *c)
                        redo_item = 1;
                        _layout_line_advance(c, it->format);
                     }
+                  else // (wrap < 0)
+                    {
+                       /* avoid line advance if there is no wrapping point */
+                       adv_line = 0;
+                    }
                   /* Reset wrap */
                   wrap = -1;
                }
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index 3b49eb9..464ebc5 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)
      }
    fail_if(w != bw);
 
+   /* Verify that no empty line is added */
+   evas_object_textblock_text_markup_set(tb, "<wrap=word>Hello</wrap>");
+   evas_object_textblock_size_native_get(tb, NULL, &nh);
+   evas_object_resize(tb, 0, 1000);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_eq(nh, h);
+
+   evas_object_textblock_text_markup_set(tb, "<wrap=char>a</wrap>");
+   evas_object_textblock_size_native_get(tb, NULL, &nh);
+   evas_object_resize(tb, 0, 1000);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_eq(nh, h);
+
    /* Word wrap */
    evas_object_textblock_text_markup_set(tb, "aaaaaa");
    evas_object_textblock_size_formatted_get(tb, &bw, &bh);

-- 


Reply via email to