efl_ui_widget: child_can_focus is not needed anymore
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Wed, 27 Feb 2019 19:01:16 +0000 (14:01 -0500)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:36 +0000 (20:49 +0900)
summary_:
pd->logical.child_count is a counter where focusable children do
register themself in the parent if they can be focused or not. With this
we don't need the updating of this internal flag nor the flag itself anymore.

Depends on D8027

Reviewers: woohyun, cedric, Jaehyun_Cho, zmike, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D8030

src/lib/elementary/efl_ui_widget.c
src/lib/elementary/elm_widget.h

index 58c68ad..bce4a66 100644 (file)
@@ -234,7 +234,7 @@ static inline Eina_Bool
 _is_focusable(Evas_Object *obj)
 {
    API_ENTRY return EINA_FALSE;
-   return sd->can_focus || (sd->child_can_focus);
+   return sd->can_focus || (sd->logical.child_count > 0);
 }
 
 static inline Eina_Bool
@@ -1555,23 +1555,6 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
         efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj));
 
         _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
-
-        /* update child focusable-ness on self and parents, now that a
-         * focusable child got in */
-        if (!sd->child_can_focus && (_is_focusable(sobj)))
-          {
-             Elm_Widget_Smart_Data *sdp = sd;
-
-             sdp->child_can_focus = EINA_TRUE;
-             while (sdp->parent_obj)
-               {
-                  sdp = efl_data_scope_get(sdp->parent_obj, MY_CLASS);
-
-                  if (sdp->child_can_focus) break;
-
-                  sdp->child_can_focus = EINA_TRUE;
-               }
-          }
      }
    else
      {
@@ -1686,6 +1669,7 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
              elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
              elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
           }
+<<<<<<< HEAD
         if ((sd->child_can_focus) && (_is_focusable(sobj)))
           {
              Evas_Object *parent = obj;
@@ -1716,6 +1700,9 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
                }
           }
         if (_elm_atspi_enabled() && !sd->on_destroy)
+=======
+        if (_elm_config->atspi_mode && !sd->on_destroy)
+>>>>>>> 665f8877e9... efl_ui_widget: child_can_focus is not needed anymore
           {
              Efl_Access_Object *aparent;
              aparent = efl_provider_find(efl_parent_get(sobj), EFL_ACCESS_OBJECT_MIXIN);
@@ -1832,45 +1819,10 @@ _efl_ui_widget_focus_allow_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can
    sd->can_focus = can_focus;
    if (sd->can_focus)
      {
-        /* update child_can_focus of parents */
-        Evas_Object *o = obj;
-
-        for (;;)
-          {
-             o = elm_widget_parent_get(o);
-             if (!o) break;
-             ELM_WIDGET_DATA_GET(o, sdp);
-             if (!sdp || sdp->child_can_focus) break;
-             sdp->child_can_focus = EINA_TRUE;
-          }
-
         efl_event_callback_array_add(obj, focus_callbacks(), NULL);
      }
    else
      {
-        // update child_can_focus of parents */
-        Evas_Object *parent = elm_widget_parent_get(obj);
-        while (parent)
-          {
-             const Eina_List *l;
-             Evas_Object *subobj;
-
-             ELM_WIDGET_DATA_GET(parent, sdp);
-
-             sdp->child_can_focus = EINA_FALSE;
-             EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
-               {
-                  if (_is_focusable(subobj))
-                    {
-                       sdp->child_can_focus = EINA_TRUE;
-                       break;
-                    }
-               }
-             /* break again, child_can_focus went back to
-              * original value */
-             if (sdp->child_can_focus) break;
-             parent = sdp->parent_obj;
-          }
         efl_event_callback_array_del(obj, focus_callbacks(), NULL);
      }
      if (efl_finalized_get(obj))
@@ -1889,7 +1841,7 @@ elm_widget_child_can_focus_get(const Eo *obj)
    Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
    if (!sd) return EINA_FALSE;
 
-   return sd->child_can_focus;
+   return sd->logical.child_count > 0;
 }
 
 /**
index aa024b1..2700357 100644 (file)
@@ -414,7 +414,6 @@ typedef struct _Elm_Widget_Smart_Data
    Eina_Bool                     scroll_y_locked : 1;
 
    Eina_Bool                     can_focus : 1;
-   Eina_Bool                     child_can_focus : 1;
    Eina_Bool                     focused : 1;
    Eina_Bool                     top_win_focused : 1;
    Eina_Bool                     tree_unfocusable : 1;