Commit Graph

112 Commits

Author SHA1 Message Date
Youngbok Shin 73c39bcf12 Evas textblock: fix wrong hyphenation issues with non UTF8 encoded dictionary
Summary:
hnj_hyphen_hyphenate2() needs properly encoded text based on the given
dictionary. Each dictionary contains its encoding information at the head
of file. So, text will be converted to proper encoding before calling
the function. It fixes T3221.
@fix

Test Plan: Included in Evas test suite.

Reviewers: z-wony, tasn, woohyun, herdsman, Blackmole, minudf

Subscribers: zmike, stefan_schmidt, raster, cedric, jpeg

Tags: #efl

Maniphest Tasks: T3221

Differential Revision: https://phab.enlightenment.org/D3863
2018-05-06 12:01:41 +03:00
Youngbok Shin c33ef15d5d evas textblock: fix double free issue from user style push/pop and free
Summary: The Textblock Style which is created for user style was managed
application side.  It is created and free'd from application - outside
of Evas Textblock.  Recently, evas_object_textblock_style_user_push/pop
start to call efl_canvas_text_style_set() instead of legacy code. The
problem is efl_canvas_text_style_set() is always going to call free()
when a style is going to be deleted.  It makes conflicts(double free
issue) with application which is used to call
evas_textblock_style_free().  So, the issue will be fixed by this patch.

The patch also revise push/pop/peek code to make clean and avoid
meaningless calculation/events.

@fix

Test Plan:
A test case is Included in this patch.
The test case try to trigger double free.

Reviewers: herdsman, raster, cedric

Subscribers: zmike, woohyun

Tags: #efl

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

Committer's note: formatted commit summary (80 width).
2018-05-06 12:01:41 +03:00
Xavi Artigas 55bd097a3d Efl.Gfx.Entity (from Efl.Gfx)
Ref https://phab.enlightenment.org/T6847

Reviewed-by: Cedric Bail <cedric@osg.samsung.com>
2018-04-24 09:03:32 -07:00
Mike Blumenkrantz 624925fe6e tests: move to using checked fixtures for all test suites
individual tests should not need to explicitly call init/shutdown functions
in most cases, and many did not properly do this anyway

see followup commit which resolves some issues with eina tests

ref T6813
ref T6811

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:26 +02:00
Mike Blumenkrantz adc601aca2 tests: add instrumentation to existing tests to find slow tests
efl_check.h must be included and the EFL_START/END_TEST macros must be
used in place of normal START/END_TEST macros

timing is enabled when TIMING_ENABLED is set
https://phab.enlightenment.org/w/improve_tests/

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:25 +02:00
Daniel Hirt 4a905a22a4 Canvas image: add Efl.Canvas.Text.Factory + use in Ui.Text
This interface has a simple 'create' method to create Efl.Canvas.Object
given a key.
This is used higher-up in Ui.Text in the next commit.

Ui text: add ability to set item factories

Added API to set an item factory object.
This is similar to the previous item providers (that worked with
callbacks).

You instantiate a factory object and set it on the Ui.Text object.
Each factory implements the "create" method from
Efl.Canvas.Text.Item_Factory.

This also includes 3 public factories (Image, Emoticon and Fallback):
  - Image factory: creates images from added entries (key strings)
  - Emoticon factory: creates emoticons by querying the theme
  - Fallback: creates image, then falls back to emoticon

If no factory is set, then the fallback (internal) factory is used.

See the added "Ui.text Item Factory" test in elementary_test for an
example of usage.

@feature
2018-01-18 10:20:28 -08:00
Carsten Haitzler e30fb6945e fix evas test suite to now init both ecore and evas.... correctly.
see c8dcc4327b803e9b8ad2a0985e756c924946c442 - basicall evas depends
on ecore these days... thus requires ecore be initted THEN evas. ...
which in theory is an abi break for those using evas and ONLY evas
long ago from when efl was separate... but it''s how we're building
these days.

@fix
2018-01-05 02:34:16 +09:00
Daniel Hirt 45d3614345 Canvas text: fix width calculation with style effects
There are multiple places in the code where both the padded item's
width and the maximum style padding (at the edges) are accounted for.
For the sake of making calculations for wrapping/ellipsis we should
only use the maximum style padding.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-11-10 10:29:49 -08:00
Daniel Hirt 0725ff620b Canvas text: update style pad when no format nodes are present
This updates the style pad even if there are no format nodes.
An example of this is having a default style set to the object.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-11-10 10:29:44 -08:00
Youngbok Shin a386597ad9 evas textblock: handle ellipsis when text's height exceed its area by "br"
Summary:
Textblock's ellipsis feature only worked when text's width exceeds its area.
So, it didn't work when text's height exceeds its area by "br" tags.
This patch will do ellipsis when only ellipsis=1.0 is set.
@fix

Test Plan: make check

Reviewers: herdsman, raster, cedric, jpeg, sohyun

Reviewed By: raster

Subscribers: woohyun

Differential Revision: https://phab.enlightenment.org/D5412
2017-11-06 11:29:43 +09:00
Jean-Philippe Andre 4c634ed78e efl: Use Eina.Size2D for Efl.Gfx.size
Big patch as a lot of things call or reimplement size_set. Hopefully I
got it right... fingers crossed.
2017-09-18 13:34:50 +09:00
Daniel Hirt 048dcc3263 Canvas text: fix non-dirty paragraph width calculation
Follow-up fix for 1624417d91.
Changed for a max comparison, rather than just assigning the line's
width.
Also, added a test case.

Fixes T5939

@fix
2017-08-29 17:07:15 +03:00
Daniel Hirt 4923945f81 Text: move Annotation type to Efl.Text.Annotate namespace 2017-07-17 17:38:28 +03:00
Daniel Hirt d5f781da2b Efl text: replace all usages of cursor handle to same type
Changes cursor handle name from 'Efl.Text.Cursor.Cursor_Data' to
'Efl.Text.Cursor.Cursor'.
Also, replace all usages of Efl_Canvas_Text_Cursor
with Efl_Text_Cursor_Cursor as the handle for the cursor.
2017-07-17 16:51:45 +03:00
Jean-Philippe Andre e8b35c779e evas: Add a test case with a custom font
The font is **ugly** and was created with birdfont. Its license
shall be anything EFL requires (public domain in the ttf file).
2017-07-11 16:21:29 +09:00
Youngbok Shin f29dfe2789 evas textblock: fix evas test suite build errors
Summary:
Fix build errors caused by recent patches for Text cursor.
@fix

Test Plan: run "make check"

Reviewers: herdsman, jpeg, raster

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D4957
2017-06-12 16:31:04 +03:00
Daniel Hirt 49b838c448 Canvas text cursor: move to Efl.Canvas.Text namespace
Originally it was its own object.
There are some valid claims that there is no justification for it to
remain an object.
Furthermore, it's apparent that it added little benefit: changes of
each cursors, in practice, triggered a query for all objects of the
same textblock. There wasn't real advantage to have a finer resolution
of controlling the cursors with their own events.

This ports back a lot of code, and changes a lot of other code in the
higher-up widgets, such as Efl.Ui.Text and co.

The usage was replaces from:
  efl_canvas_text_cursor_char_next(cur_obj)
to
  efl_canvas_text_cursor_char_next(text_obj, cur_obj)
that is, it is an operations on the TEXT OBJECT, rather than on the
(now removed) cursor object.

So, one less efl object to worry about now.
Hopefully, the port went smooth.
2017-06-11 23:58:52 +03:00
Daniel Hirt 1624417d91 Evas textblock: fix width calculation of non-dirty paragraphs
This reverts commit 0a28cb97af, as the
addressed issue was still occurring.
Non-dirty paragraphs were not considered when recalculating the
formatted width of the text.
This could easily be reproduced with two paragraphs, getting the width,
and then updating only the second paragraph.

Added a test case.

@fix
2017-05-23 13:26:32 +03:00
Daniel Hirt 2d44738fae Canvas text: fix ellipsis RTL handling
First, fixing ellipsis text positions: ellipsis items should be assigned the
text positions of the omitted text (while maintaining the formatting of the
last visual item). In the case where an entire item was rejected, it
will be assigned that item's text position. If an item was split, it will be
assigned the text position of the split portion.
The BiDi reorder code relies on properly-assigned text positions.

Second, fixing ellipsis handling: the width calc was only considering the
ellipsis item's width. However, if the ellipsis is placed as e.g. the first
visual item (such as in RTL cases), its advance value should've be considered,
instead.

Thanks Youngbok Shin for the test case and information.

@fix
2016-08-31 16:23:32 +03:00
Daniel Hirt 0d9ddc4514 Canvas text: fix range geometry calculation for RTL
Fixes T3627.

@fix
2016-07-31 10:33:30 +03:00
Daniel Hirt 0c23985626 Canvas text: fix corner case in range geometry calc
The trivial case of [pos,pos] (i.e. range of length 0) didn't work if there is a
format item in 'pos'.
The condition was fixed to not include such items. The reason it was not
apparent for text items is that these have further handling in the rest of the
code and would've been disposed of.

@fix
2016-07-11 16:39:51 +00:00
Youngbok Shin 64e0dc341d Evas textblock: Apply scale factor to <linesize>, <linegap> formats
Summary:
Font size is scaled according to scale factor.
The linesize, linegap formats also have to be scaled properly.
@fix

Test Plan:
Test cases are included.
Run "make check"

Reviewers: woohyun, Jieun, tasn, herdsman

Reviewed By: tasn

Subscribers: raster, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3688
2016-07-11 17:57:40 +09:00
Daniel Hirt 06fd1566ea Canvas text cursor: fix bug after code port
Fixes T4005.
Also, unified repeated code and added a test for multiple cursors.
2016-07-03 14:39:45 +00:00
Daniel Hirt dbbb4bf8ad Canvas text: revert new behavior on text append
This was discussed and still wasn't decided whether this is required to be
supported internally.
The reason for this revert is that the behavior still needs tweaking to work
just right along with the legacy behavior.
2016-06-21 10:40:48 +00:00
Daniel Hirt c9744965c0 Canvas test: remove style test for now 2016-06-16 19:15:20 +01:00
Daniel Hirt ed512ea49e Canvas Text: continue porting api and fixup bugs
Also: This merges style user and normal style into a list with precedence. This
allows for more flexibility while keeping the API clean.

@feature
2016-06-16 19:15:20 +01:00
Tom Hacohen c297ff4115 Canvas text cursor: introduce this new object
The text cursor is now an eo object. Consult the efl_canvas_text_cursor.eo file
for the API.

@feature
2016-06-16 19:15:20 +01:00
Daniel Hirt 3a6c648d28 Canvas text: introduce new text object
The implementation depends on creating different code paths from the now-legacy
behavior of text appending.

The annotation system introduced in this commit replaces the current way of
applying formats on text.
Up until now it has been quite a hassle for the user to control the formats, as
it required keeping track of the format positions with an opener and closer
formats almost every time (with the exception of own-closing formats).

The combination of Efl.Text API along with the Efl.Canvas.Text annotation API
essentially replaces the capabilities of the old format.

There is additional annotation API to allow more control, so be sure to check
the documentation/.eo files and the wiki page of Efl.Canvas.Text.

The style API now accepts actual strings of format style. There is not longer
need to instantiate as style with style_new() followed later by style_free().

@feature
2016-06-16 19:15:20 +01:00
Youngbok Shin f4f9753c20 Evas: Add API to reinit the language and use it in elementary.
Summary:
evas_common_language_from_locale_* functions kept static pointers
inside of its functions. Once these function was called, it was never reset.
It made big problems for harfbuzz and hyphenation. Also, Elementary
provides elm_language_set() API. Then we need to support it fully.
@fix

Test Plan: Test case for hyphenation is included in Evas test suite.

Reviewers: raster, tasn, herdsman, woohyun, z-wony, Blackmole, minudf

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3864
2016-04-08 11:24:32 +01:00
Jiwon Kim c23283944b Evas textblock: fix null-derefernce in _style_match_tag()
Summary:
add null check in _style_match_tag()
if evas_object_textblock_text_markup_set() is called with markup text before setting style,
segmentation fault is occurred in _style_match_tag()
@fix

Test Plan:
Insert this situation to test suite
 -> test id : evas_textblock_simple

Test for without this patch:
 1. apply patch just "src/tests/evas/evas_test_textblock.c" partially.
 2. $make check

Test for with this patch:
 1. apply this patch completely (2 files)
 2. $make check

Reviewers: id213sin, herdsman

Subscribers: Blackmole, cedric, jpeg

Projects: #efl

Differential Revision: https://phab.enlightenment.org/D3818
2016-03-24 10:17:57 +02:00
Daniel Hirt 4013dccda6 Evas font: fix width calc in last_up_to_pos
Width calculations should consider the x_bear. This has been leading to
inconsistent results between wrapping calculation during layout and the
final formatted size.

Also, we should stop our walk only when exceeding 'x', so changed "<="
to "<".

@fix
2016-03-23 15:31:20 +02:00
Tom Hacohen 84fd52921e Evas textblock tests: Fix wrong test suite tests.
The tests were assuming that textblock returns a sanitised utf8 string.
This is not always correct, because textblock may cache and return the
set utf8 markup if the text hasn't changed since the last set.
2016-02-26 09:36:44 +00:00
Vincent Torri 71f0fb98f0 Test rework #20: Evas 2016-02-16 12:41:06 +00:00
Tom Hacohen bcbf5df8b3 Evas textblock: Disable hyphenation tests when hyphenation is disabled. 2016-02-12 12:21:06 +00:00
Youngbok Shin 3252e3bf78 Evas Textblock: Fix ellipsis when textblock is resized to formatted h.
Summary:
it->h is sum of max ascent and max descent. It shouldn't be used
when handle ellipsis. Because, Evas Textblock uses these values for
each lines differently according to its location.
(start, end, else, single)
So, for handling ellipsis exactly, it has to be fixed.

Test Plan: A test case is included in Evas Test suite.

Reviewers: woohyun, tasn, herdsman

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3475
2016-01-04 15:12:10 +00:00
Subodh Kumar 43f50dc7db Evas textblock: Use width of item format to position cursor.
Summary:
Use width of item format to position cursor.

Sometimes it becomes very difficult to
position cursor over item and selection
becomes very difficult as we position the
cursor once the input X coord reached end of the item,
like one attached in the test plan. So this patch
decides over 50% of item width for X coord reaches
to position it at start or end.

@ix

Test Plan:
Attached setup shows how difficult to position cursor at the end when clicked
over item and selection is also very difficult. Consider such case in mobile
device, its becomes impossible to position cursor at the end and selection is
too much difficult.

{F27036}

Also added test cases in evas test suite

Reviewers: herdsman, tasn

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3390
2015-12-17 12:00:23 +00:00
Youngbok Shin fcba96384f Evas Textblock: Fix NULL dereferencing issue
Summary:
Even if the given two cursor is NULL, it shouldn't be crashed.
@fix

Test Plan:
Test case included in Evas test suite.
Run "make check".

Reviewers: herdsman, tasn

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3422
2015-12-13 17:15:10 +02:00
Daniel Hirt 58bfa4b328 Evas textblock: add missing test fonts
evas_suite was failing for people that didn't have malayalam fonts
installed in their system. Obviously, we should provide it in the test
suite.

Added malayalam font (from http://www.indlinux.org/) to the
TestFont.eet, along with the license README.

Fixes T2908.

@fix
2015-12-10 09:57:39 +02:00
Daniel Hirt 7e8e392db6 Evas textblock: improve and fix line range rectangles
The line range rectangles geometries needed a bit of adjusting. I
started out with fixing T2648. In order to fill the gap between the end
of the line and the margins, the geometry of the last line's character
was used. I am not really sure why. Anyway, we have the line geometry,
so I replaced it with that.

Then, it led me to do some alignment checks, and indeed alignment cases
were not treated. For instance, an LTR paragraph could have a line
aligned with a value greater than 0.0. That means that we should fill
the gap from the left of the line, if it was the last line in a
multi-line selection. The inverse case is for RTL.

I think it now works as it should. Will see if the selection logic is
missing some more stuff once I come up with more example cases.

Fixes T2648.

@fix
2015-12-08 17:19:18 +02:00
Daniel Hirt 1d48dd90b2 Evas textblock: fix evas_textblock_cursor_line_set
The line_set function should set the cursor to the first logical
position in the line. We can't use the first text position of the
first item in the line, due to BiDi considerations (the line may be
reordered). I've split evas_textblock_cursor_line_char_first to avoid
code duplication, as it already handles these cases.

@fix
2015-12-07 18:21:00 +02:00
Cedric BAIL 11ac6b145d evas: fix double free.
The ownership of this list and its content belong to the iterator. This code
was actively double freeing and our test suite doesn't crash or have any issue...
Well actually it was complaining that the list had error, but due to our other
false positive test that do trigger eina log, we continuously ignored this error.

NOTE: The fact that the test rely also on the container of the iterator instead
of the iterator itself is not that great to. I kind of feel bad now for having
allowed access to the container. We should have been able to allow changing the
logic to generate those rectangle step after step instead of in one go. Now this
seems difficult.
2015-12-02 12:30:34 -08:00
Daniel Hirt 59e9e2ddc8 Evas textblock: fix height on line wrapping
Line advance should finalize the line with its last item, and not the
item we're currently wrapping. This fixes T1583, where some line
wrapping cases would look different than their equivalent <ps>
versions.

@fix
2015-12-02 15:06:32 +02:00
Youngbok Shin 809d8fdafe Evas Textblock: Fix text disappear issue when text is made up with multiple items.
Summary:
Text is disappearing when we resize a singleline Evas Textblock with ellipsis.
It is happened by putting a Text item at logical_items list without considering about logical position.
It is only happended the text is made up with multiple items.
@fix

Test Plan:
1. Run elementary_test
2. Click Label Ellipsis
3. Resize the window dynamically and see the result.

Reviewers: woohyun, tasn, herdsman

Subscribers: jpeg, subodh6129, shilpasingh, cedric

Maniphest Tasks: T2709

Differential Revision: https://phab.enlightenment.org/D3022
2015-12-02 09:52:01 +02:00
Daniel Hirt a7b0b13c43 Evas textblock: add hyphenation tests 2015-11-24 14:31:29 +02:00
Youngbok Shin a9b4be11e1 Evas object: Add paragraph_direciton APIs
Summary:
It adds evas_object_paragraph_direction_set, get APIs.
The APIs set or get paragraph direction to/from the given object.
It changes BiDi calculations and affect the direction and aligning of text.
It doesn't have any effect to text without Fribidi library.

The default paragraph direction is EVAS_BIDI_DIRECTION_INHERIT.
If dir is EVAS_BIDI_DIRECTION_INHERIT, paragraph direction is changed
according to smart parent object. If there is no smart parent object,
paragraph direction works as EVAS_BIDI_DIRECTION_NEUTRAL.

@feature

Test Plan:
Test cases included to the following files.
- evas_test_textblock.c
- evas_test_text.c
- evas_test_object_smart.c

Run "make check".

Reviewers: woohyun, raster, herdsman, tasn

Subscribers: c, raster, cedric

Differential Revision: https://phab.enlightenment.org/D1690
2015-11-19 11:43:39 +00:00
Daniel Hirt d6e0d902cf Evas textblock: fix bad deletion in test case
No need to delete this object. It is already being deleted when the
textblock is freed at the end of the test.
2015-11-17 16:22:02 +02:00
Minwoo, Lee c196422e63 evas textblock: fixed ascent/descent calculation
Summary:
If textblock has linegap and multi language, ascent/descent calculation is
incorrect.
In _layout_format_ascent_descent_adjust(), descent is accumulated.
(for example, for a line gap of 50, the first line gap is more than 100)

Test Plan:
Textblock has "linegap=50" and multi language (ex.
        "This is a test suite for line gap -
        ഈ ലൈൻ വിടവ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ഒരു പരീക്ഷണ വെയര് ")
Added test suite in evas_test_textblock.c file.

Reviewers: tasn

Subscribers: subodh6129, cedric

Differential Revision: https://phab.enlightenment.org/D3311
2015-11-13 12:27:59 +00:00
Daniel Hirt 74ad947ded Evas textblock: Clear unused paragraphs
This fixes a scenario in which paragraphs in the current layout still
store visual lines from the previous layout. This is possible if the
text uses an ellipsis format, allowing the layout work to stop at a
certain paragraph. This inconsistency affects some query functions that
consider lines which may be irrelevant in the current layout.

Test Case: see added test case to evas_suite.

@fix
2015-07-14 16:04:40 +03:00
Daniel Hirt e8afd5241c Evas Textblock: Add obstacle objects feature
Summary:
Introducing a new feature for Evas Textblock. This allows the layout to
wrap around other evas objects.
The following API is added:
 - obstacle_add
 - obstacle_del
 - obstacle_update
Evas objects can now serve as textblock obstacles, if positioned and
visible on the text area. The text will wrap around the obstacles
according to the wrapping mode set to it.

This also modifies the current wrapping code to handle obstacle wrap
points as well. The wrap index query function is modified so that
forward-scanning (specific cases) may be disabled when treating
obstacle wrap point.

RTL text is currently unsupported by this feature.
Consult added docs and example for usage.

@feature

Test Plan: Evas example and test in evas_suite are provided with this.

Reviewers: tasn

Subscribers: raster, JackDanielZ, cedric

Differential Revision: https://phab.enlightenment.org/D2405
2015-07-01 16:24:31 +01:00
Daniel Hirt 0de8ebbb3a Evas textblock: Fix infinite loop case
This fixes a case with wrapping, where the text has a mixture of 'none'
and 'word' wrapping modes, and the layout function decides to
roll-back a few items.
The test case is added to the evas_suite.
This might not be a common case, or even a case we had defined a proper
behavior to, but since it causes an infinite loop, it needs to be fixed.

@fix
2015-06-29 16:43:49 +03:00