evas_object_textbox: deal with <br> <tab> without closing '/'

This causes many issues because textbox functions deals with <br> <tab> differently depending that user write them with or without '/' at the end (for example <br> vs <br/>)
while most functionaliity are the same (like viewing <br> and <br/> are the same).
cursor dealing with these tags can be differently.
now we will assume <br> <tab> are already have there own closing tag, even if it is missing

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11293
This commit is contained in:
Ali Alzyod 2020-02-05 16:01:52 +00:00 committed by Marcel Hollerbach
parent 269ed1ca34
commit 3560b0f62f
2 changed files with 12 additions and 2 deletions

View File

@ -11809,12 +11809,15 @@ _evas_textblock_node_format_new(Efl_Canvas_Textblock_Data *o, const char *_forma
format_len--; /* We don't care about '/' */
n->own_closer = EINA_TRUE;
}
else if (format_len == 2)
else if (format_len < 4)
{
/* br,ps,tab are already own_closer without '/' */
char tmp[format_len + 1];
strncpy(tmp, format, format_len);
tmp[format_len] = '\0';
if (_IS_PARAGRAPH_SEPARATOR(o, tmp))
if (_IS_PARAGRAPH_SEPARATOR(o, tmp) ||
_IS_LINE_SEPARATOR(tmp) ||
_IS_TAB(tmp))
{
n->own_closer = EINA_TRUE;
}

View File

@ -4777,6 +4777,13 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
ck_assert_int_eq(rect2.y, rect.y);
#endif
//Efl able to deal with br tab without closing tag "/"
efl_text_markup_set(txt, "a<br>a<tab>a");
efl_text_cursor_move(nCur, EFL_TEXT_CURSOR_MOVE_TYPE_FIRST);
efl_text_cursor_move(cur_obj, EFL_TEXT_CURSOR_MOVE_TYPE_LAST);
efl_text_cursor_range_delete(nCur, cur_obj);
ck_assert_str_eq(efl_text_markup_get(txt), "");
END_EFL_CANVAS_TEXTBLOCK_TEST();
}
EFL_END_TEST