evas: Apply the last character's advance for width calculation
authorYoungbok Shin <youngb.shin@samsung.com>
Fri, 7 Oct 2016 07:29:28 +0000 (16:29 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 17 Nov 2016 07:54:17 +0000 (16:54 +0900)
@tizen_fix

Change-Id: I6729c05478efea3993f003e9cf3fb66ceb1d2bd9

src/lib/evas/canvas/evas_object_text.c
src/lib/evas/canvas/evas_object_textblock.c

index 019a633..5e55f9f 100644 (file)
 #define COL_OBJECT(obj, sub) ARGB_JOIN(obj->sub->color.a, obj->sub->color.r, obj->sub->color.g, obj->sub->color.b)
 #define COL_JOIN(o, sub, color) ARGB_JOIN(o->sub.color.a, o->sub.color.r, o->sub.color.g, o->sub.color.b)
 
+/* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation */
+#define EVAS_TEXT_ITEM_SIZE(it) \
+   ((it->w > it->adv) ? it->w : it->adv)
+/* END */
+
+
 /* private magic number for text objects */
 static const char o_type[] = "text";
 
@@ -795,14 +801,24 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t
                   script_len -= run_len;
                   len -= run_len;
 
+                  /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
                   if (it->w > 0)
                     last_it = it;
+                   */
+                  if ((it->w > 0) || (it->adv > 0))
+                    last_it = it;
+                  /* END */
                }
           }
 
         width = advance;
+        /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
         if (last_it)
           width += last_it->w - last_it->adv;
+         */
+        if (last_it && (last_it->w > last_it->adv))
+          width += last_it->w - last_it->adv;
+        /* END */
      }
    o->last_computed.width_without_ellipsis = width;
 
@@ -831,7 +847,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t
                   start_ellip_it = _layout_ellipsis_item_new(obj, o);
                }
              o->last_computed.ellipsis_start = start_ellip_it;
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
              ellip_frame -= start_ellip_it->w;
+              */
+             ellip_frame -= EVAS_TEXT_ITEM_SIZE(start_ellip_it);
+             /* END */
           }
         if (o->cur.ellipsis != 1)
           {
@@ -848,6 +868,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t
                }
              o->last_computed.ellipsis_end = end_ellip_it;
              ellip_frame -= end_ellip_it->w;
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
+             ellip_frame -= end_ellip_it->w;
+              */
+             ellip_frame -= EVAS_TEXT_ITEM_SIZE(end_ellip_it);
+             /* END */
           }
 
         /* The point where we should start from, going for the full
@@ -858,7 +883,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t
              Evas_Object_Text_Item *itr = o->items;
              advance = 0;
 
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
              while (itr && (advance + l + r + itr->w < ellipsis_coord))
+              */
+             while (itr && (advance + l + r + EVAS_TEXT_ITEM_SIZE(itr) < ellipsis_coord))
+             /* END */
                {
                   Eina_Inlist *itrn = EINA_INLIST_GET(itr)->next;
                   if ((itr != start_ellip_it) && (itr != end_ellip_it))
@@ -907,7 +936,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t
                {
                   if (itr != end_ellip_it) /* was start_ellip_it */
                     {
+                       /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
                        if (advance + l + r + itr->w >= ellip_frame)
+                        */
+                       if (advance + l + r + EVAS_TEXT_ITEM_SIZE(itr) >= ellip_frame)
+                       /* END */
                          {
                             break;
                          }
index c9c5b37..363617f 100644 (file)
@@ -111,6 +111,14 @@ static const char o_type[] = "textblock";
     ((ch) == _PARAGRAPH_SEPARATOR))
 /* END */
 
+/* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation */
+#define EVAS_TEXTBLOCK_ITEM_SIZE(it) \
+   ((it->w > it->adv) ? it->w : it->adv)
+
+#define EVAS_TEXTBLOCK_TEXT_ITEM_SIZE(ti) \
+   ((ti->parent.w > ti->parent.adv) ? ti->parent.w : ti->parent.adv)
+/* END */
+
 #ifdef CRI
 #undef CRI
 #endif
@@ -3616,7 +3624,12 @@ loop_advance:
         it->x = x;
         x += it->adv + obs_adv;
 
+        /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
         if ((it->w > 0) && ((it->x + it->w) > c->ln->w)) c->ln->w = it->x + it->w;
+         */
+        if ((it->x + EVAS_TEXTBLOCK_ITEM_SIZE(it)) > c->ln->w)
+          c->ln->w = it->x + EVAS_TEXTBLOCK_ITEM_SIZE(it);
+        /* END */
      }
 
    /* clear obstacle info for this line */
@@ -4847,7 +4860,11 @@ _layout_handle_ellipsis(Ctxt *c, Evas_Object_Textblock_Item *it, Eina_List *i)
    last_it = it;
 
    save_cx = c->x;
+   /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
    c->w -= ellip_ti->parent.w;
+    */
+   c->w -= EVAS_TEXTBLOCK_TEXT_ITEM_SIZE(ellip_ti);
+   /* END */
 
    /* If there is no enough space for ellipsis item, remove all of items */
    if (c->w <= 0)
@@ -4914,9 +4931,15 @@ _layout_handle_ellipsis(Ctxt *c, Evas_Object_Textblock_Item *it, Eina_List *i)
              /* We need to renew ellipsis item.
               * Because, base format is changed to last_it.
               * We can't reuse it. */
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
              c->w += ellip_ti->parent.w;
              ellip_ti = _layout_ellipsis_item_new(c, last_it);
              c->w -= ellip_ti->parent.w;
+              */
+             c->w += EVAS_TEXTBLOCK_TEXT_ITEM_SIZE(ellip_ti);
+             ellip_ti = _layout_ellipsis_item_new(c, last_it);
+             c->w -= EVAS_TEXTBLOCK_TEXT_ITEM_SIZE(ellip_ti);
+             /* END */
              c->x -= last_it->adv;
              if (c->x < 0)
                c->x = 0;
@@ -4925,7 +4948,11 @@ _layout_handle_ellipsis(Ctxt *c, Evas_Object_Textblock_Item *it, Eina_List *i)
      }
 
    c->x = save_cx;
+   /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
    c->w += ellip_ti->parent.w;
+    */
+   c->w += EVAS_TEXTBLOCK_TEXT_ITEM_SIZE(ellip_ti);
+   /* END */
    /* If we should add this item, do it */
    if (last_it == it)
      {
@@ -4976,12 +5003,22 @@ _calc_items_width(Ctxt *c)
    EINA_LIST_FOREACH(c->par->logical_items, i, it)
      {
         w += it->adv;
+        /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
         last_it = it;
+         */
+        if ((it->w > 0) || (it->adv > 0))
+          last_it = it;
+        /* END */
      }
 
    //reaching this point when it is the last item
+   /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
    if (last_it)
       w += last_it->w - last_it->adv;
+    */
+   if (last_it && (last_it->w > last_it->adv))
+      w += last_it->w - last_it->adv;
+   /* END */
    return w;
 }
 
@@ -5304,12 +5341,22 @@ _layout_par(Ctxt *c)
              EINA_INLIST_FOREACH(c->ln->items, vis_it)
                {
                   needed_w += vis_it->adv;
+                  /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
                   if (vis_it->w > 0)
                     last_it = vis_it;
+                   */
+                  if ((vis_it->w > 0) || (vis_it->adv > 0))
+                    last_it = vis_it;
+                  /* END */
                }
 
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
              if (last_it)
                needed_w += last_it->w - last_it->adv;
+              */
+             if (last_it && (last_it->w > last_it->adv))
+               needed_w += last_it->w - last_it->adv;
+             /* END */
 
              /* Restore */
              c->ln->items = (Evas_Object_Textblock_Item *)
@@ -5319,7 +5366,13 @@ _layout_par(Ctxt *c)
         else
 #endif
           {
+             /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
              needed_w = c->x + it->w;
+              */
+             needed_w = c->x + it->adv;
+             if (it->w > it->adv)
+               needed_w += it->w - it->adv;
+             /* END */
           }
         /* END */
 
@@ -12551,13 +12604,23 @@ loop_advance:
         *w += it->adv;
 
         /* Update visible last item in the logical order */
+        /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
         if (!is_bidi && (it->w > 0))
            last_it = it;
+         */
+        if (!is_bidi && ((it->w > 0) || (it->adv > 0)))
+          last_it = it;
+        /* END */
      }
 
    /* rectify width of line using the last item */
+   /* TIZEN_ONLY(20161007): Apply the last character's advance for width calculation
    if (last_it)
       *w += last_it->w - last_it->adv;
+    */
+   if (last_it && (last_it->w > last_it->adv))
+     *w += last_it->w - last_it->adv;
+   /* END */
 }
 
 /* FIXME: doc */