jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0735f6aa612476a9f126747269cb3761b9e9aeba

commit 0735f6aa612476a9f126747269cb3761b9e9aeba
Author: Youngbok Shin <[email protected]>
Date:   Tue Jul 4 13:53:59 2017 +0900

    edje: support legacy Textblock calculation logic for 1.18 edje file
    
    Summary:
    From EFL 1.19, Edje Textblock calculation logic was fixed according to
    Edje documents. But, it broke old edje files which ignored text.min
    option for minimum width. Even if the old edje files were wrong,
    we need to support them as discussed from T5548.
    
    Also, this patch will change default efl_version to 1.18 from 1.19.
    So, without efl_version property, edje file will run on the legacy logic.
    
    Fixes T5548
    
    Test Plan: Turn on/off presentation mode in Enlightenment.
    
    Reviewers: herdsman, cedric, jpeg, zmike, raster
    
    Subscribers: stefan_schmidt
    
    Maniphest Tasks: T5548
    
    Differential Revision: https://phab.enlightenment.org/D4967
    
    Adjusted by @jpeg
---
 src/bin/edje/edje_cc.c          |   6 +-
 src/bin/edje/edje_cc_handlers.c |   6 +
 src/bin/edje/edje_cc_out.c      |  12 +
 src/lib/edje/edje_cache.c       |   2 +-
 src/lib/edje/edje_calc.c        | 655 +++++++++++++++++++++++-----------------
 src/lib/edje/edje_private.h     |   1 +
 src/lib/edje/edje_util.c        | 113 +++++--
 7 files changed, 496 insertions(+), 299 deletions(-)

diff --git a/src/bin/edje/edje_cc.c b/src/bin/edje/edje_cc.c
index 9c0ce0187b..64c1e6df18 100644
--- a/src/bin/edje/edje_cc.c
+++ b/src/bin/edje/edje_cc.c
@@ -402,11 +402,11 @@ main(int argc, char **argv)
     * which was used for developing a edje file.
     * It is useful if Edje(or other EFL libs) need to keep
     * backward compatibility.
-    * efl_version was added just after EFL 1.19.
-    * Thus, 1.19 will be default.
+    * efl_version was added to fix backward compatibility issue caused from 
EFL 1.19.
+    * Thus, 1.18 will be default.
     */
    edje_file->efl_version.major = 1;
-   edje_file->efl_version.minor = 19;
+   edje_file->efl_version.minor = 18;
    edje_file->base_scale = FROM_INT(1);
 
    source_edd();
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 8908ec69c8..415f778280 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -11134,6 +11134,9 @@ 
st_collections_group_parts_part_description_text_min(void)
 
    ed->text.min_x = parse_bool(0);
    ed->text.min_y = parse_bool(1);
+
+   if (current_part->type == EDJE_PART_TYPE_TEXTBLOCK)
+     edje_file->has_textblock_min_max = EINA_TRUE;
 }
 
 /**
@@ -11168,6 +11171,9 @@ 
st_collections_group_parts_part_description_text_max(void)
 
    ed->text.max_x = parse_bool(0);
    ed->text.max_y = parse_bool(1);
+
+   if (current_part->type == EDJE_PART_TYPE_TEXTBLOCK)
+     edje_file->has_textblock_min_max = EINA_TRUE;
 }
 
 /**
diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c
index 367b266e78..08465b5269 100644
--- a/src/bin/edje/edje_cc_out.c
+++ b/src/bin/edje/edje_cc_out.c
@@ -2672,6 +2672,18 @@ data_write(void)
        exit(-1);
      }
 
+   if ((edje_file->efl_version.major <= 1) && (edje_file->efl_version.minor <= 
18)
+       && edje_file->has_textblock_min_max)
+     {
+        WRN("This EDC file was designed for EFL 1.18. Until 1.19, EFL used an "
+            "invalid calculation mechanism for textblock parts, where the 
value "
+            "of text min/max was not properly taken into account. You might "
+            "want to consider adding \"efl_version: %d %d;\" in your EDC "
+            "\"collections\" block, and then check the sizing for all 
textblock "
+            "parts that specify text min/max values.",
+            EFL_VERSION_MAJOR, EFL_VERSION_MINOR);
+     }
+
    check_groups(ef);
 
    ecore_thread_max_set(ecore_thread_max_get() * 2);
diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c
index 7607156c32..22414df4e9 100644
--- a/src/lib/edje/edje_cache.c
+++ b/src/lib/edje/edje_cache.c
@@ -358,7 +358,7 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t 
mtime, Eina_Bool coll
    if ((edf->efl_version.major == 0) && (edf->efl_version.minor == 0))
      {
         edf->efl_version.major = 1;
-        edf->efl_version.minor = 19;
+        edf->efl_version.minor = 18;
      }
 
    edf->path = eina_stringshare_add(eina_file_filename_get(f));
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index 47e918cdcc..fdae32a975 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -1467,6 +1467,369 @@ 
_edje_part_recalc_single_textblock_scale_range_adjust(Edje_Part_Description_Text
    return scale;
 }
 
+/*
+ * Legacy function for min/max calculation of textblock part.
+ * It can't calculate min/max properly in many cases.
+ *
+ * To keep backward compatibility, it will be used for old version of EDJ 
files.
+ * You can't see proper min/max result accroding to documents with this 
function.
+ */
+static void
+_edje_part_recalc_single_textblock_min_max_calc_legacy(Edje_Real_Part *ep,
+                                                       
Edje_Part_Description_Text *chosen_desc,
+                                                       Edje_Calc_Params 
*params,
+                                                       int *minw, int *minh,
+                                                       int *maxw, int *maxh)
+{
+   Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
+
+   /* Legacy code for Textblock min/max calculation */
+   if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
+     {
+        int mw = 0, mh = 0;
+
+        tw = th = 0;
+        if (!chosen_desc->text.min_x)
+          {
+             efl_gfx_size_set(ep->object, TO_INT(params->eval.w), 
TO_INT(params->eval.h));
+             efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
+          }
+        else
+          evas_object_textblock_size_native_get(ep->object, &tw, &th);
+        evas_object_textblock_style_insets_get(ep->object, &ins_l,
+                                               &ins_r, &ins_t, &ins_b);
+        mw = ins_l + tw + ins_r;
+        mh = ins_t + th + ins_b;
+        if (minw && chosen_desc->text.min_x)
+          {
+             if (mw > *minw) *minw = mw;
+          }
+        if (minh && chosen_desc->text.min_y)
+          {
+             if (mh > *minh) *minh = mh;
+          }
+     }
+
+   if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
+     {
+        int mw = 0, mh = 0;
+
+        tw = th = 0;
+        if (!chosen_desc->text.max_x)
+          {
+             efl_gfx_size_set(ep->object, TO_INT(params->eval.w), 
TO_INT(params->eval.h));
+             efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
+          }
+        else
+          evas_object_textblock_size_native_get(ep->object, &tw, &th);
+        evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
+                                               &ins_t, &ins_b);
+        mw = ins_l + tw + ins_r;
+        mh = ins_t + th + ins_b;
+        if (maxw && chosen_desc->text.max_x)
+          {
+             if (mw > *maxw) *maxw = mw;
+             if (minw && (*maxw < *minw)) *maxw = *minw;
+          }
+        if (maxh && chosen_desc->text.max_y)
+          {
+             if (mh > *maxh) *maxh = mh;
+             if (minh && (*maxh < *minh)) *maxh = *minh;
+          }
+     }
+}
+
+static void
+_edje_part_recalc_single_textblock_min_max_calc(Edje_Real_Part *ep,
+                                                Edje_Part_Description_Text 
*chosen_desc,
+                                                Edje_Calc_Params *params,
+                                                int *minw, int *minh,
+                                                int *maxw, int *maxh)
+{
+   Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
+   Evas_Coord min_calc_w = 0, min_calc_h = 0;
+
+   /* min_calc_* values need to save calculated minumum size
+    * for maximum size calculation */
+   if (minw) min_calc_w = *minw;
+   if (minh) min_calc_h = *minh;
+
+   if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
+     {
+        evas_object_textblock_style_insets_get(ep->object, &ins_l,
+                                               &ins_r, &ins_t, &ins_b);
+
+        tw = th = 0;
+        if (!chosen_desc->text.min_x)
+          {
+             /* text.min: 0 1
+              * text.max: X X */
+             int temp_h = TO_INT(params->eval.h);
+             int temp_w = TO_INT(params->eval.w);
+
+             if (min_calc_w > temp_w)
+               temp_w = min_calc_w;
+             if ((!chosen_desc->text.max_x) &&
+                 maxw && (*maxw > -1) && (*maxw < temp_w))
+               temp_w = *maxw;
+
+             if (chosen_desc->text.max_y)
+               {
+                  /* text.min: 0 1
+                   * text.max: X 1 */
+                  temp_h = INT_MAX / 10000;
+               }
+             else if (maxh && (*maxh > TO_INT(params->eval.h)))
+               {
+                  /* text.min: 0 1
+                   * text.max: X 0
+                   * And there is a limit for height. */
+                  temp_h = *maxh;
+               }
+
+             /* If base width for calculation is 0,
+              * don't get meaningless height for multiline */
+             if (temp_w > 0)
+               {
+                  efl_gfx_size_set(ep->object, temp_w, temp_h);
+                  efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
+
+                  tw += ins_l + ins_r;
+                  th += ins_t + ins_b;
+               }
+             else
+               {
+                  efl_canvas_text_size_native_get(ep->object, NULL, &th);
+
+                  th += ins_t + ins_b;
+               }
+          }
+        else
+          {
+             /* text.min: 1 X
+              * text.max: X X */
+             if (chosen_desc->text.min_y && (!chosen_desc->text.max_x) &&
+                 maxw && (*maxw > -1))
+               {
+                  /* text.min: 1 1
+                   * text.max: 0 X */
+                  int temp_w, temp_h;
+
+                  temp_w = *maxw;
+                  temp_h = INT_MAX / 10000;
+
+                  if (min_calc_w > temp_w)
+                    temp_w = min_calc_w;
+
+                  if ((!chosen_desc->text.max_y) && maxh && (*maxh > -1))
+                    {
+                       /* text.min: 1 1
+                        * text.max: 0 0
+                        * There is limit for height. */
+                       temp_h = *maxh;
+                    }
+
+                  efl_gfx_size_set(ep->object, temp_w, temp_h);
+                  efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
+
+                  tw += ins_l + ins_r;
+                  th += ins_t + ins_b;
+
+                  /* If base width for calculation is 0,
+                   * don't get meaningless height for multiline */
+                  if (temp_w <= 0)
+                    {
+                       efl_canvas_text_size_native_get(ep->object, NULL, &th);
+
+                       th += ins_t + ins_b;
+                    }
+               }
+             else
+               {
+                  /* text.min: 1 X
+                   * text.max: 1 X
+                   * Or,
+                   * text.min: 1 X
+                   * text.max: 0 X without max width.
+                   * It is a singleline Textblock. */
+                  efl_canvas_text_size_native_get(ep->object, &tw, &th);
+
+                  tw += ins_l + ins_r;
+                  th += ins_t + ins_b;
+
+                  if (!chosen_desc->text.max_x &&
+                      (maxw && (*maxw > -1) && (*maxw < tw)))
+                    {
+                       /* text.min: 1 0
+                        * text.max: 0 X */
+                       tw = *maxw;
+                    }
+               }
+          }
+
+        if (tw > min_calc_w) min_calc_w = tw;
+        if (th > min_calc_h) min_calc_h = th;
+        if (chosen_desc->text.min_x && minw) *minw = min_calc_w;
+        if (chosen_desc->text.min_y && minh) *minh = min_calc_h;
+     }
+
+   if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
+     {
+        evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r,
+                                               &ins_t, &ins_b);
+
+        tw = th = 0;
+        if (!chosen_desc->text.max_x)
+          {
+             /* text.min: X X
+              * text.max: 0 1 */
+             int temp_w, temp_h;
+
+             if (chosen_desc->text.min_y)
+               {
+                  /* text.min: X 1
+                   * text.max: 0 1
+                   * Already calculated in text for height. */
+                  tw = TO_INT(params->eval.w);
+                  if (min_calc_w > tw)
+                    tw = min_calc_w;
+
+                  th = min_calc_h;
+               }
+             else
+               {
+                  /* text.min: X 0
+                   * text.max: 0 1 */
+                  temp_w = TO_INT(params->eval.w);
+                  temp_h = TO_INT(params->eval.h);
+
+                  if (min_calc_w > temp_w)
+                    temp_w = min_calc_w;
+                  if (maxw && (*maxw > -1) && (*maxw < temp_w))
+                    temp_w = *maxw;
+                  if (min_calc_h > temp_h)
+                    temp_h = min_calc_h;
+
+                  /* If base width for calculation is 0,
+                   * don't get meaningless height for multiline */
+                  if (temp_w > 0)
+                    {
+                       efl_gfx_size_set(ep->object, temp_w, temp_h);
+                       efl_canvas_text_size_formatted_get(ep->object, &tw, 
&th);
+
+                       tw += ins_l + ins_r;
+                       th += ins_t + ins_b;
+                    }
+                  else
+                    {
+                       efl_canvas_text_size_native_get(ep->object, NULL, &th);
+
+                       th += ins_t + ins_b;
+                    }
+               }
+          }
+        else
+          {
+             /* text.max: 1 X */
+             if (chosen_desc->text.min_x)
+               {
+                  /* text.min: 1 X
+                   * text.max: 1 X
+                   * Singleline. */
+                  efl_canvas_text_size_native_get(ep->object, &tw, &th);
+
+                  tw += ins_l + ins_r;
+                  th += ins_t + ins_b;
+               }
+             else
+               {
+                  /* text.min: 0 X
+                   * text.max: 1 X */
+                  if (chosen_desc->text.max_y)
+                    {
+                       /* text.min: 0 X
+                        * text.max: 1 1 */
+                       int temp_w, temp_h;
+
+                       temp_w = TO_INT(params->eval.w);
+                       temp_h = TO_INT(params->eval.h);
+
+                       if (min_calc_w > temp_w)
+                         temp_w = min_calc_w;
+                       if (min_calc_h > temp_h)
+                         temp_h = min_calc_h;
+
+                       if (chosen_desc->text.min_y)
+                         {
+                            /* text.min: 0 1
+                             * text.max: 1 1
+                             * There is no need to calculate it again. */
+                            tw = min_calc_w;
+                            th = min_calc_h;
+                         }
+                       else
+                         {
+                            /* text.min: 0 0
+                             * text.max: 1 1 */
+
+                            efl_gfx_size_set(ep->object, temp_w, temp_h);
+                            efl_canvas_text_size_formatted_get(ep->object, 
&tw, &th);
+
+                            tw += ins_l + ins_r;
+                            th += ins_t + ins_b;
+
+                            /* If base width for calculation is 0,
+                             * don't get meaningless height for multiline */
+                            if (temp_w <= 0)
+                              {
+                                 efl_canvas_text_size_native_get(ep->object, 
NULL, &th);
+
+                                 th += ins_t + ins_b;
+                              }
+                         }
+                    }
+                  else
+                    {
+                       /* text.min: 0 X
+                        * text.max: 1 0 */
+                       int temp_w, temp_h;
+
+                       temp_w = TO_INT(params->eval.w);
+                       if (min_calc_w > temp_w)
+                         temp_w = min_calc_w;
+
+                       efl_gfx_size_get(ep->object, NULL, &temp_h);
+                       efl_gfx_size_set(ep->object, temp_w, temp_h);
+                       efl_canvas_text_size_formatted_get(ep->object, &tw, 
&th);
+
+                       tw += ins_l + ins_r;
+                       th += ins_t + ins_b;
+
+                       /* If base width for calculation is 0,
+                        * don't get meaningless height for multiline */
+                       if (temp_w <= 0)
+                         {
+                            efl_canvas_text_size_native_get(ep->object, NULL, 
&th);
+
+                            th += ins_t + ins_b;
+                         }
+                    }
+               }
+          }
+
+        if (maxw && chosen_desc->text.max_x)
+          {
+             if (tw > *maxw) *maxw = tw;
+             if (minw && (*maxw < *minw)) *maxw = *minw;
+          }
+        if (maxh && chosen_desc->text.max_y)
+          {
+             if (th > *maxh) *maxh = th;
+             if (minh && (*maxh < *minh)) *maxh = *minh;
+          }
+     }
+}
+
 static void
 _edje_part_recalc_single_textblock(FLOAT_T sc,
                                    Edje *ed,
@@ -1476,20 +1839,13 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
                                    int *minw, int *minh,
                                    int *maxw, int *maxh)
 {
-   int min_calc_w = 0, min_calc_h = 0;
-
    if ((ep->type != EDJE_RP_TYPE_TEXT) ||
        (!ep->typedata.text))
      return;
 
-   /* min_calc_* values need to save calculated minumum size
-    * for maximum size calculation */
-   if (minw) min_calc_w = *minw;
-   if (minh) min_calc_h = *minh;
-
    if (chosen_desc)
      {
-        Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
+        Evas_Coord tw, th;
         const char *text = "";
         const char *style = "";
         Edje_Style *stl = NULL;
@@ -1629,279 +1985,22 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
                {
                   evas_object_textblock_text_markup_set(ep->object, text);
                }
-             if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
-               {
-                  evas_object_textblock_style_insets_get(ep->object, &ins_l,
-                                                         &ins_r, &ins_t, 
&ins_b);
-
-                  tw = th = 0;
-                  if (!chosen_desc->text.min_x)
-                    {
-                       /* text.min: 0 1
-                        * text.max: X X */
-                       int temp_h = TO_INT(params->eval.h);
-                       int temp_w = TO_INT(params->eval.w);
 
-                       if (min_calc_w > temp_w)
-                         temp_w = min_calc_w;
-                       if ((!chosen_desc->text.max_x) &&
-                           maxw && (*maxw > -1) && (*maxw < temp_w))
-                         temp_w = *maxw;
-
-                       if (chosen_desc->text.max_y)
-                         {
-                            /* text.min: 0 1
-                             * text.max: X 1 */
-                            temp_h = INT_MAX / 10000;
-                         }
-                       else if (maxh && (*maxh > TO_INT(params->eval.h)))
-                         {
-                            /* text.min: 0 1
-                             * text.max: X 0
-                             * And there is a limit for height. */
-                            temp_h = *maxh;
-                         }
-
-                       /* If base width for calculation is 0,
-                        * don't get meaningless height for multiline */
-                       if (temp_w > 0)
-                         {
-                            efl_gfx_size_set(ep->object, temp_w, temp_h);
-                            efl_canvas_text_size_formatted_get(ep->object, 
&tw, &th);
-
-                            tw += ins_l + ins_r;
-                            th += ins_t + ins_b;
-                         }
-                       else
-                         {
-                            efl_canvas_text_size_native_get(ep->object, NULL, 
&th);
-
-                            th += ins_t + ins_b;
-                         }
-                    }
-                  else
-                    {
-                       /* text.min: 1 X
-                        * text.max: X X */
-                       if (chosen_desc->text.min_y && 
(!chosen_desc->text.max_x) &&
-                           maxw && (*maxw > -1))
-                         {
-                            /* text.min: 1 1
-                             * text.max: 0 X */
-                            int temp_w, temp_h;
-
-                            temp_w = *maxw;
-                            temp_h = INT_MAX / 10000;
-
-                            if (min_calc_w > temp_w)
-                              temp_w = min_calc_w;
-
-                            if ((!chosen_desc->text.max_y) && maxh && (*maxh > 
-1))
-                              {
-                                 /* text.min: 1 1
-                                  * text.max: 0 0
-                                  * There is limit for height. */
-                                 temp_h = *maxh;
-                              }
-
-                            efl_gfx_size_set(ep->object, temp_w, temp_h);
-                            efl_canvas_text_size_formatted_get(ep->object, 
&tw, &th);
-
-                            tw += ins_l + ins_r;
-                            th += ins_t + ins_b;
-
-                            /* If base width for calculation is 0,
-                             * don't get meaningless height for multiline */
-                            if (temp_w <= 0)
-                              {
-                                 efl_canvas_text_size_native_get(ep->object, 
NULL, &th);
-
-                                 th += ins_t + ins_b;
-                              }
-                         }
-                       else
-                         {
-                            /* text.min: 1 X
-                             * text.max: 1 X
-                             * Or,
-                             * text.min: 1 X
-                             * text.max: 0 X without max width.
-                             * It is a singleline Textblock. */
-                            efl_canvas_text_size_native_get(ep->object, &tw, 
&th);
-
-                            tw += ins_l + ins_r;
-                            th += ins_t + ins_b;
-
-                            if (!chosen_desc->text.max_x &&
-                                (maxw && (*maxw > -1) && (*maxw < tw)))
-                              {
-                                 /* text.min: 1 0
-                                  * text.max: 0 X */
-                                 tw = *maxw;
-                              }
-                         }
-                    }
-
-                  if (tw > min_calc_w) min_calc_w = tw;
-                  if (th > min_calc_h) min_calc_h = th;
-                  if (chosen_desc->text.min_x && minw) *minw = min_calc_w;
-                  if (chosen_desc->text.min_y && minh) *minh = min_calc_h;
+             if ((ed->file->efl_version.major >= 1) && 
(ed->file->efl_version.minor >= 19))
+               {
+                  _edje_part_recalc_single_textblock_min_max_calc(ep,
+                                                                  chosen_desc,
+                                                                  params,
+                                                                  minw, minh,
+                                                                  maxw, maxh);
                }
-
-             if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
+             else
                {
-                  evas_object_textblock_style_insets_get(ep->object, &ins_l, 
&ins_r,
-                                                         &ins_t, &ins_b);
-
-                  tw = th = 0;
-                  if (!chosen_desc->text.max_x)
-                    {
-                       /* text.min: X X
-                        * text.max: 0 1 */
-                       int temp_w, temp_h;
-
-                       if (chosen_desc->text.min_y)
-                         {
-                            /* text.min: X 1
-                             * text.max: 0 1
-                             * Already calculated in text for height. */
-                            tw = TO_INT(params->eval.w);
-                            if (min_calc_w > tw)
-                              tw = min_calc_w;
-
-                            th = min_calc_h;
-                         }
-                       else
-                         {
-                            /* text.min: X 0
-                             * text.max: 0 1 */
-                            temp_w = TO_INT(params->eval.w);
-                            temp_h = TO_INT(params->eval.h);
-
-                            if (min_calc_w > temp_w)
-                              temp_w = min_calc_w;
-                            if (maxw && (*maxw > -1) && (*maxw < temp_w))
-                              temp_w = *maxw;
-                            if (min_calc_h > temp_h)
-                              temp_h = min_calc_h;
-
-                            /* If base width for calculation is 0,
-                             * don't get meaningless height for multiline */
-                            if (temp_w > 0)
-                              {
-                                 efl_gfx_size_set(ep->object, temp_w, temp_h);
-                                 
efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
-
-                                 tw += ins_l + ins_r;
-                                 th += ins_t + ins_b;
-                              }
-                            else
-                              {
-                                 efl_canvas_text_size_native_get(ep->object, 
NULL, &th);
-
-                                 th += ins_t + ins_b;
-                              }
-                         }
-                    }
-                  else
-                    {
-                       /* text.max: 1 X */
-                       if (chosen_desc->text.min_x)
-                         {
-                            /* text.min: 1 X
-                             * text.max: 1 X
-                             * Singleline. */
-                            efl_canvas_text_size_native_get(ep->object, &tw, 
&th);
-
-                            tw += ins_l + ins_r;
-                            th += ins_t + ins_b;
-                         }
-                       else
-                         {
-                            /* text.min: 0 X
-                             * text.max: 1 X */
-                            if (chosen_desc->text.max_y)
-                              {
-                                 /* text.min: 0 X
-                                  * text.max: 1 1 */
-                                 int temp_w, temp_h;
-
-                                 temp_w = TO_INT(params->eval.w);
-                                 temp_h = TO_INT(params->eval.h);
-
-                                 if (min_calc_w > temp_w)
-                                   temp_w = min_calc_w;
-                                 if (min_calc_h > temp_h)
-                                   temp_h = min_calc_h;
-
-                                 if (chosen_desc->text.min_y)
-                                   {
-                                      /* text.min: 0 1
-                                       * text.max: 1 1
-                                       * There is no need to calculate it 
again. */
-                                      tw = min_calc_w;
-                                      th = min_calc_h;
-                                   }
-                                 else
-                                   {
-                                      /* text.min: 0 0
-                                       * text.max: 1 1 */
-
-                                      efl_gfx_size_set(ep->object, temp_w, 
temp_h);
-                                      
efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
-
-                                      tw += ins_l + ins_r;
-                                      th += ins_t + ins_b;
-
-                                      /* If base width for calculation is 0,
-                                       * don't get meaningless height for 
multiline */
-                                      if (temp_w <= 0)
-                                        {
-                                           
efl_canvas_text_size_native_get(ep->object, NULL, &th);
-
-                                           th += ins_t + ins_b;
-                                        }
-                                   }
-                              }
-                            else
-                              {
-                                 /* text.min: 0 X
-                                  * text.max: 1 0 */
-                                 int temp_w, temp_h;
-
-                                 temp_w = TO_INT(params->eval.w);
-                                 if (min_calc_w > temp_w)
-                                   temp_w = min_calc_w;
-
-                                 efl_gfx_size_get(ep->object, NULL, &temp_h);
-                                 efl_gfx_size_set(ep->object, temp_w, temp_h);
-                                 
efl_canvas_text_size_formatted_get(ep->object, &tw, &th);
-
-                                 tw += ins_l + ins_r;
-                                 th += ins_t + ins_b;
-
-                                 /* If base width for calculation is 0,
-                                  * don't get meaningless height for multiline 
*/
-                                 if (temp_w <= 0)
-                                   {
-                                      
efl_canvas_text_size_native_get(ep->object, NULL, &th);
-
-                                      th += ins_t + ins_b;
-                                   }
-                              }
-                         }
-                    }
-
-                  if (maxw && chosen_desc->text.max_x)
-                    {
-                       if (tw > *maxw) *maxw = tw;
-                       if (minw && (*maxw < *minw)) *maxw = *minw;
-                    }
-                  if (maxh && chosen_desc->text.max_y)
-                    {
-                       if (th > *maxh) *maxh = th;
-                       if (minh && (*maxh < *minh)) *maxh = *minh;
-                    }
+                  _edje_part_recalc_single_textblock_min_max_calc_legacy(ep,
+                                                                         
chosen_desc,
+                                                                         
params,
+                                                                         minw, 
minh,
+                                                                         maxw, 
maxh);
                }
           }
 
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 1868f7625d..f7c5d46f8e 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -605,6 +605,7 @@ struct _Edje_File
    unsigned char                   allocated_strings : 1;
    unsigned char                   dangling : 1;
    unsigned char                   warning : 1;
+   unsigned char                   has_textblock_min_max : 1;
 };
 
 struct _Edje_Style
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index 7fd145c85b..601661336f 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3233,6 +3233,10 @@ _edje_object_size_min_restricted_calc(Eo *obj 
EINA_UNUSED, Edje *ed, Evas_Coord
    Eina_Bool repeat_w, repeat_h;
    Eina_Bool reset_max = EINA_TRUE;
    Edje_Real_Part *pep = NULL;
+   /* Only for legacy calculation logic */
+   Evas_Coord ins_l, ins_r;
+   Eina_Bool has_fixed_tb;
+   Eina_Bool legacy_calc;
 
    if ((!ed) || (!ed->collection))
      {
@@ -3241,6 +3245,20 @@ _edje_object_size_min_restricted_calc(Eo *obj 
EINA_UNUSED, Edje *ed, Evas_Coord
         return;
      }
 
+   /*
+    * It decides a calculation logic according to efl_version of Edje file.
+    * There was wrong/special consideration for Textblock parts.
+    * Becasue of that, Textblock parts can have minimum size according to its 
text contents
+    * even if there is [text.min: 0 0]. It made people confused.
+    *
+    * To keep backward compatibility, legacy_calc will be used for old version 
of EDJ files.
+    * With enabling legacy_calc, You can't see proper min/max result accroding 
to documents.
+    */
+   if (!ed->file || ((ed->file->efl_version.major >= 1) && 
(ed->file->efl_version.minor >= 19)))
+     legacy_calc = EINA_FALSE;
+   else
+     legacy_calc = EINA_TRUE;
+
    //Simulate object minimum size.
    ed->calc_only = EINA_TRUE;
 
@@ -3276,6 +3294,8 @@ again:
           }
 
         pep = NULL;
+        /* Only for legacy calculation logic */
+        has_fixed_tb = EINA_TRUE;
 
         //for parts
         for (i = 0; i < ed->table_parts_size; i++)
@@ -3288,21 +3308,61 @@ again:
              int over_w = (ep->w - ep->req.w);
              int over_h = (ep->h - ep->req.h);
 
+             /* Only for legacy calculation logic */
+             Eina_Bool skip_h = EINA_FALSE;
+
              //width
-             if ((!ep->chosen_description->fixed.w) &&
-                 (over_w > max_over_w))
+             if (!ep->chosen_description->fixed.w)
                {
-                  max_over_w = over_w;
-                  repeat_w = EINA_TRUE;
-                  pep = ep;
+                  if ((legacy_calc) && (ep->part->type == 
EDJE_PART_TYPE_TEXTBLOCK))
+                    {
+                       //We care textblock width size specially.
+                       Evas_Coord tb_mw;
+                       evas_object_textblock_size_formatted_get(ep->object,
+                                                                &tb_mw, NULL);
+                       evas_object_textblock_style_insets_get(ep->object, 
&ins_l, &ins_r, NULL, NULL);
+                       tb_mw = ins_l + tb_mw + ins_r;
+                       tb_mw -= ep->req.w;
+                       if (tb_mw > over_w) over_w = tb_mw;
+                       has_fixed_tb = EINA_FALSE;
+                    }
+
+                  if (over_w > max_over_w)
+                    {
+                       max_over_w = over_w;
+                       repeat_w = EINA_TRUE;
+                       pep = ep;
+
+                       /* Only for legacy calculation logic */
+                       skip_h = EINA_TRUE;
+                    }
                }
              //height
-             if ((!ep->chosen_description->fixed.h) &&
-                 (over_h > max_over_h))
+             if (!ep->chosen_description->fixed.h)
                {
-                  max_over_h = over_h;
-                  repeat_h = EINA_TRUE;
-                  pep = ep;
+                  if (legacy_calc)
+                    {
+                       if ((ep->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
+                           ((Edje_Part_Description_Text 
*)ep->chosen_description)->text.min_x ||
+                           !skip_h)
+                         {
+                            if (over_h > max_over_h)
+                              {
+                                 max_over_h = over_h;
+                                 repeat_h = EINA_TRUE;
+                                 pep = ep;
+                              }
+                         }
+
+                       if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
+                         has_fixed_tb = EINA_FALSE;
+                    }
+                  else if (over_h > max_over_h)
+                    {
+                       max_over_h = over_h;
+                       repeat_h = EINA_TRUE;
+                       pep = ep;
+                    }
                }
           }
         if (repeat_w)
@@ -3322,14 +3382,32 @@ again:
 
         if (reset_max && (calc_count > CALC_COUNT_LIMIT))
           {
-             /* We should possibly avoid all of this if in this case, but in
-              * the meanwhile, just doing this. */
-             if (pep)
-               ERR("file %s, group %s has a non-fixed part '%s'. Adding 
'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.",
-                   ed->path, ed->group, pep->part->name);
+             if (legacy_calc)
+               {
+                  /* Only print it if we have a non-fixed textblock.
+                   * We should possibly avoid all of this if in this case, but 
in
+                   * the meanwhile, just doing this. */
+                  if (!has_fixed_tb)
+                    {
+                       if (pep)
+                         ERR("file %s, group %s has a non-fixed part '%s'. 
Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty 
part.",
+                             ed->path, ed->group, pep->part->name);
+                       else
+                         ERR("file %s, group %s runs infinite minimum 
calculation loops.Continuing discarding faulty parts.",
+                             ed->path, ed->group);
+                    }
+               }
              else
-               ERR("file %s, group %s runs infinite minimum calculation 
loops.Continuing discarding faulty parts.",
-                   ed->path, ed->group);
+               {
+                  /* We should possibly avoid all of this if in this case, but 
in
+                   * the meanwhile, just doing this. */
+                  if (pep)
+                    ERR("file %s, group %s has a non-fixed part '%s'. Adding 
'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.",
+                        ed->path, ed->group, pep->part->name);
+                  else
+                    ERR("file %s, group %s runs infinite minimum calculation 
loops.Continuing discarding faulty parts.",
+                        ed->path, ed->group);
+               }
 
              reset_max = EINA_FALSE;
              goto again;
@@ -3345,6 +3423,7 @@ again:
 
    ed->w = orig_w;
    ed->h = orig_h;
+
    ed->dirty = EINA_TRUE;
 #ifdef EDJE_CALC_CACHE
    ed->all_part_change = EINA_TRUE;

-- 


Reply via email to