From 5f70cacd921b180a48f586b1dd3700ff9c10b818 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 29 Aug 2019 11:35:24 +0900 Subject: [PATCH] edje/textblock: Added edje_textblock_style_get() api. Summary: Now all textblock_style functionality are wrapped under api for easy of optimization. so going forward no one should directly acess the styles from the File . the styles should be acesses by the internal api's provided by edje_textblock_style. Reviewers: Hermet, ali.alzyod, woohyun, kimcinoo Reviewed By: kimcinoo Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9774 --- src/lib/edje/edje_load.c | 21 ++++----------------- src/lib/edje/edje_private.h | 7 ++++++- src/lib/edje/edje_textblock.c | 14 ++++---------- src/lib/edje/edje_textblock_styles.c | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 9c6193a3c1..176cc3bbbc 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -1700,26 +1700,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch if (rp->part->default_desc) { Edje_Part_Description_Text *text; - Edje_Style *stl = NULL; - const char *style; + Evas_Textblock_Style *style = NULL; text = (Edje_Part_Description_Text *)rp->part->default_desc; - style = edje_string_get(&text->text.style); - if (style) - { - Eina_List *l; + style = _edje_textblock_style_get(ed, edje_string_get(&text->text.style)); - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - } - if (stl) - { - if (evas_object_textblock_style_get(rp->object) != stl->style) - evas_object_textblock_style_set(rp->object, stl->style); - } + if (evas_object_textblock_style_get(rp->object) != style) + evas_object_textblock_style_set(rp->object, style); } } _edje_entry_init(ed); diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index a1af62b23b..55ccd4d621 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -2787,12 +2787,17 @@ void _edje_message_queue_process (void); void _edje_message_queue_clear (void); void _edje_message_del (Edje *ed); +// Edje object level textblock style api +Evas_Textblock_Style * _edje_textblock_style_get(Edje *ed, const char *style); void _edje_textblock_styles_add(Edje *ed, Edje_Real_Part *ep); void _edje_textblock_styles_del(Edje *ed, Edje_Part *pt); -void _edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class); + +// Edje File level textblock style api void _edje_textblock_style_all_update(Edje *ed); +void _edje_textblock_style_all_update_text_class(Edje *ed, const char *text_class); void _edje_textblock_style_parse_and_fix(Edje_File *edf); void _edje_textblock_style_cleanup(Edje_File *edf); + Edje_File *_edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed); void _edje_cache_coll_clean(Edje_File *edf); void _edje_cache_coll_flush(Edje_File *edf); diff --git a/src/lib/edje/edje_textblock.c b/src/lib/edje/edje_textblock.c index add799f954..c7e58c3148 100644 --- a/src/lib/edje/edje_textblock.c +++ b/src/lib/edje/edje_textblock.c @@ -434,9 +434,8 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, Evas_Coord tw, th; const char *text = ""; const char *style = ""; - Edje_Style *stl = NULL; + Evas_Textblock_Style *stl = NULL; const char *tmp; - Eina_List *l; if (chosen_desc->text.id_source >= 0) { @@ -484,19 +483,14 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (ep->typedata.text->text) text = ep->typedata.text->text; } - EINA_LIST_FOREACH(ed->file->styles, l, stl) - { - if ((stl->name) && (!strcmp(stl->name, style))) break; - stl = NULL; - } - if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + stl = _edje_textblock_style_get(ed, style); if (stl) { - if (evas_object_textblock_style_get(ep->object) != stl->style) - evas_object_textblock_style_set(ep->object, stl->style); + if (evas_object_textblock_style_get(ep->object) != stl) + evas_object_textblock_style_set(ep->object, stl); // FIXME: need to account for editing if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) { diff --git a/src/lib/edje/edje_textblock_styles.c b/src/lib/edje/edje_textblock_styles.c index f9495f24f6..d9856ba7fb 100644 --- a/src/lib/edje/edje_textblock_styles.c +++ b/src/lib/edje/edje_textblock_styles.c @@ -350,6 +350,31 @@ _edje_textblock_styles_del(Edje *ed, Edje_Part *pt) } } +/* + * returns a evas_textblock style for a given style_string. + * does lazy computation of the evas_textblock_style + * It will compute and cache it if not computed yet and + * will return the final textblock style. + */ +Evas_Textblock_Style * +_edje_textblock_style_get(Edje *ed, const char *style) +{ + if (!style) return NULL; + + Edje_Style *stl = _edje_textblock_style_search(ed, style); + + if (!stl) return NULL; + + /* readonly style naver change */ + if (stl->readonly) return stl->style; + + /* if style is dirty recompute */ + if (!stl->cache) + _edje_textblock_style_update(ed, stl, EINA_FALSE); + + return stl->style; +} + /* * Finds all the styles having text class tag as text_class and * updates them.