textblock: Update visual_pos before calling _size_native_calc_line_finalize.
authorYoungbok Shin <youngb.shin@samsung.com>
Wed, 6 Aug 2014 09:40:02 +0000 (10:40 +0100)
committerTom Hacohen <tom@stosb.com>
Wed, 6 Aug 2014 09:40:02 +0000 (10:40 +0100)
Summary:
In items loop of _size_native_calc_line_finalize,
last_it should be replaced with new item according to position.
But, visual_pos is not prepared and it is always zero in the function.
So, we need to update visual_pos.
And when textblock only has LTR text,
we can replace last_it according to item list sequence.
@fix

Test Plan:
It includes test cases using the following test case.
 1. "i<b>。</b>"
 2. "。<b>i</b>"

Reviewers: seoz, woohyun, sohyun, tasn

Subscribers: raster, herdsman, cedric

Differential Revision: https://phab.enlightenment.org/D859

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

index a3aa98e..8547090 100644 (file)
@@ -10482,6 +10482,7 @@ _size_native_calc_line_finalize(const Evas_Object *eo_obj, Eina_List *items,
 {
    Evas_Object_Textblock_Item *it, *last_it = NULL;
    Eina_List *i;
+   Eina_Bool is_bidi = EINA_FALSE;
 
    it = eina_list_data_get(items);
    *w = 0;
@@ -10505,8 +10506,10 @@ _size_native_calc_line_finalize(const Evas_Object *eo_obj, Eina_List *items,
         /* Add margins. */
         if (it->format)
            *w = it->format->margin.l + it->format->margin.r;
-      }
 
+        if (it->ln && it->ln->par)
+          is_bidi = it->ln->par->is_bidi;
+      }
 
    /* Adjust all the item sizes according to the final line size,
     * and update the x positions of all the items of the line. */
@@ -10539,11 +10542,21 @@ loop_advance:
         *w += it->adv;
 
         /* Only conditional if we have bidi support, otherwise, just set it. */
+        if (it->w > 0)
+          {
 #ifdef BIDI_SUPPORT
-        if (!last_it || (it->visual_pos > last_it->visual_pos))
+             if (is_bidi)
+               {
+                  if (!last_it || (it->visual_pos > last_it->visual_pos))
+                    {
+                       last_it = it;
+                    }
+               }
+             else
 #endif
-          {
-             last_it = it;
+               {
+                  last_it = it;
+               }
           }
      }
 
@@ -10645,6 +10658,7 @@ _evas_textblock_size_native_get(Eo *eo_obj, Evas_Textblock_Data *o, Evas_Coord *
         EINA_INLIST_FOREACH(o->paragraphs, par)
           {
              Evas_Coord tw, th;
+             _layout_paragraph_render(o, par);
              _size_native_calc_paragraph_size(eo_obj, o, par, &position, &tw, &th);
              if (tw > wmax)
                 wmax = tw;
index 76aede3..78d83ef 100644 (file)
@@ -2898,6 +2898,18 @@ START_TEST(evas_textblock_size)
    fail_if((w != nw) || (h != nh));
    fail_if(w <= 0);
 
+   evas_object_textblock_text_markup_set(tb, "i<b>。</b>");
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   evas_object_textblock_size_native_get(tb, &nw, &nh);
+   ck_assert_int_eq(w, nw);
+   ck_assert_int_eq(h, nh);
+
+   evas_object_textblock_text_markup_set(tb, "。<b>i</b>");
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   evas_object_textblock_size_native_get(tb, &nw, &nh);
+   ck_assert_int_eq(w, nw);
+   ck_assert_int_eq(h, nh);
+
    /* This time with margins. */
      {
         Evas_Textblock_Style *newst;