evas_textblock: reduce _evas_textblock_changed calls with markup_text_append
authorAli Alzyod <ali198724@gmail.com>
Mon, 22 Jul 2019 15:25:17 +0000 (15:25 +0000)
committerWonki Kim <wonki_.kim@samsung.com>
Wed, 21 Aug 2019 00:28:14 +0000 (09:28 +0900)
**_evas_textblock_changed** is internal function that mark that the textblock has changed.

When make call for
evas_object_textblock_text_markup_set(txtblock,"This is Line<br>THis is other Line<br>");

Old behaviour:
multible calles for _evas_textblock_changed will happend, for each text/format appended.

New behaviour:
Single call for _evas_textblock_changed will happend.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9376

src/lib/evas/canvas/evas_object_textblock.c

index 52a0578..8fdd332 100644 (file)
@@ -693,6 +693,7 @@ struct _Evas_Object_Textblock
 
    Eina_Bool                           redraw : 1;
    Eina_Bool                           changed : 1;
+   Eina_Bool                           pause_change : 1;
    Eina_Bool                           obstacle_changed : 1;
    Eina_Bool                           content_changed : 1;
    Eina_Bool                           format_changed : 1;
@@ -8334,6 +8335,10 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
    Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
    evas_object_async_block(obj);
    TB_HEAD();
+
+   /* Stop calls for _evas_textblock_changed for each cursor_text_append or cursor_format_append
+    * this should be done once, when markup_prepend finished */
+   o->pause_change = EINA_TRUE;
    if (text)
      {
         char *s, *p;
@@ -8448,6 +8453,7 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
              p++;
           }
      }
+   o->pause_change = EINA_FALSE;
    _evas_textblock_changed(o, eo_obj);
 }
 
@@ -11302,7 +11308,8 @@ _evas_textblock_cursor_text_append(Efl_Text_Cursor_Cursor *cur, const char *_tex
    /* Update all the cursors after our position. */
    _evas_textblock_cursors_update_offset(cur, cur->node, cur->pos, len);
 
-   _evas_textblock_changed(o, cur->obj);
+   if (!o->pause_change)
+     _evas_textblock_changed(o, cur->obj);
    n->dirty = EINA_TRUE;
    free(text);
 
@@ -11652,7 +11659,8 @@ _evas_textblock_cursor_format_append(Efl_Text_Cursor_Cursor *cur,
         o->format_changed = EINA_TRUE;
      }
 
-   _evas_textblock_changed(o, cur->obj);
+   if (!o->pause_change)
+     _evas_textblock_changed(o, cur->obj);
 
    Efl_Text_Cursor_Cursor *ocur = o->cursor;
    if (!ocur->node)