Replacing comparison between accessible object's pointers with comparison of unique_ids 47/245647/11 accepted/tizen/unified/20201028.123907 submit/tizen/20201020.112528 submit/tizen/20201027.091012
authorLukasz Oleksak <l.oleksak@samsung.com>
Tue, 13 Oct 2020 11:44:31 +0000 (13:44 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Tue, 20 Oct 2020 08:54:49 +0000 (08:54 +0000)
After clearing the cache of AtspiAccessible objects in at-spi2-core which was
introduced by https://review.tizen.org/gerrit/#/c/platform/upstream/at-spi2-core/+/245558/
direct comparison of pointers is not valid anymore.

This patch requires new API: https://review.tizen.org/gerrit/#/c/platform/upstream/at-spi2-core/+/245767/

Change-Id: I89a4616e5e0af3a98cc8eaeef8c144399b70cdb6

src/app_tracker.c
src/flat_navi.c
src/granularity_read.c
src/navigator.c
src/utils.c
src/window_tracker.c

index 1912653857eaa029c936eb27871fc354c577c8a9..0d1a9cd4d67c7ec55fc10e0faa5be19cabdaec65 100644 (file)
@@ -309,7 +309,7 @@ static void _on_atspi_event_cb(AtspiEvent *event, void *user_data)
                        if (event->detail2)
                                _object_needs_scroll_gesture_send(atd, event->source);
                } else {
-                       if (atd->read_timer && atd->prev_highlighted_obj == event->source) {
+                       if (atd->read_timer && atspi_accessible_is_equal(atd->prev_highlighted_obj, event->source)) {
                                gchar *id = atspi_accessible_get_unique_id(atd->prev_highlighted_obj, NULL);
                                DEBUG("Prev highlighted %s lost highlight", id);
                                g_free(id);
@@ -374,7 +374,7 @@ static void _on_atspi_event_cb(AtspiEvent *event, void *user_data)
                                // pop modal
                                DEBUG("Pop modal");
                                timer_reschedule(atd);
-                       } else if (flat_navi_context_current_get(navigator_get_flat_navi_context(atd->view_content_changed_ecd->user_data)) == event->source) {
+                       } else if (atspi_accessible_is_equal(flat_navi_context_current_get(navigator_get_flat_navi_context(atd->view_content_changed_ecd->user_data)), event->source)) {
                                DEBUG("Current highlighted object becomes not-showing");
                                timer_reschedule(atd);
                        }
@@ -406,7 +406,7 @@ static void _on_atspi_event_cb(AtspiEvent *event, void *user_data)
                }
                //On rotation, send the bounds-changed notification to read landscape, portrait view,
                //the width, height is updated based on rotation angle.
-               else if ((role == ATSPI_ROLE_WINDOW) && (event->source == atd->root)) {
+               else if ((role == ATSPI_ROLE_WINDOW) && atspi_accessible_is_equal(event->source, atd->root)) {
                        if (rect) {
                                if (rect->width > rect->height)
                                        SUPPRESS_FORMAT_ERROR(tw_speak(_IGNORE_ON_TV("IDS_ACCS_OPT_LANDSCAPE_VIEW_TTS"), EINA_TRUE));
index 76daf6e8f95ee342a4c1dbdc088d9b4129c7406c..d511822115f111ebfc124f5c13dfda0fec7e2318 100644 (file)
@@ -548,9 +548,9 @@ FlatNaviContextValidity flat_navi_is_valid(FlatNaviContext *context, AtspiAccess
                DEBUG("context is not valid - is null");
        else if (!context->root)
                DEBUG("context is not valid - root is null");
-       else if (new_root != NULL && context->root != new_root)
+       else if (new_root != NULL && !atspi_accessible_is_equal(context->root, new_root))
                DEBUG("context is not valid - root is different");
-       if (!context || !context->root || (new_root != NULL && context->root != new_root))
+       if (!context || !context->root || (new_root != NULL && !atspi_accessible_is_equal(context->root, new_root)))
                return FLAT_NAVI_CONTEXT_NOT_VALID;
 
        object_state st = is_object_showing_and_not_defunct(context->current, "current");
index 466949383e3371d6de2f45aaa3caa67c8800c5d3..16124f23419c320f25681d5f5d3e9437f1932c1e 100644 (file)
@@ -242,7 +242,7 @@ char *granularity_read_text_get(AtspiAccessible *current_obj, Eina_Bool next)
        }
        char *result_text = NULL;
 
-       if (!grd->current_obj || grd->current_obj != current_obj) {
+       if (!grd->current_obj || !atspi_accessible_is_equal(grd->current_obj, current_obj)) {
                granularity_read_text_list_init();
 
                grd->current_obj = current_obj;
index 15524393ba9f4c0c1976ed405f04fa0ead8cf38c..7d36a5302aa6a48239d003397b18acd6826bccf1 100644 (file)
@@ -422,7 +422,8 @@ TIZEN_PROD_STATIC void _current_highlight_object_set(NavigatorData *nd, AtspiAcc
                DEBUG("END");
                return;
        }
-       if (h_type != HIGHLIGHT_POINT_AGAIN && nd->current_obj == obj && _widget_has_state(nd->current_obj, ATSPI_STATE_HIGHLIGHTED)) {
+       if (h_type != HIGHLIGHT_POINT_AGAIN && atspi_accessible_is_equal(nd->current_obj, obj) &&
+                       _widget_has_state(nd->current_obj, ATSPI_STATE_HIGHLIGHTED)) {
                DEBUG("Object already highlighted");
                gchar *name = atspi_accessible_get_name(obj, NULL);
                DEBUG("Object name : %s", name ? name : "name nil");
@@ -512,7 +513,7 @@ void test_debug(AtspiAccessible *current_widget)
                child_iter = atspi_accessible_get_child_at_index(parent, jdx, &err);
                GERROR_CHECK(err)
 
-               if (current_widget == child_iter) {
+               if (atspi_accessible_is_equal(current_widget, child_iter)) {
                        role = atspi_accessible_get_role_name(parent, &err);
                        if (role)
                                DEBUG("Childen found in parent: %s at index: %d\n", role, jdx);
@@ -543,7 +544,7 @@ TIZEN_PROD_STATIC void _window_at_point_check(NavigatorData *nd, int x, int y)
        touched_window_bus_name = atspi_accessible_get_bus_name(touched_window, NULL);
        context_root_bus_name = atspi_accessible_get_bus_name(context_root, NULL);
 
-       if (touched_window && touched_window != context_root &&
+       if (touched_window && !atspi_accessible_is_equal(touched_window, context_root) &&
                        g_strcmp0(touched_window_bus_name, context_root_bus_name)) {
                gchar *id = atspi_accessible_get_unique_id(touched_window, NULL);
                gchar *id2 = atspi_accessible_get_unique_id(context_root, NULL);
@@ -1406,7 +1407,7 @@ _find_scrollable_ancestor_at_xy(int x, int y)
        gchar *name;
        gchar *role;
        // find accessible object with Scrollable interface
-       while (ret && (ret != top_window)) {
+       while (ret && (!atspi_accessible_is_equal(ret, top_window))) {
                name = atspi_accessible_get_name(ret, &err);
                GERROR_CHECK(err)
                role = atspi_accessible_get_role_name(ret, &err);
@@ -1586,8 +1587,8 @@ TIZEN_PROD_STATIC void auto_review_highlight_set(NavigatorData *nd)
                DEBUG("obj == NULL");
                nd->auto_review_on = false;
                return;
-       } else if (obj == (ref = flat_navi_context_last_get(nd->flat_navi_context))) {
-               DEBUG("obj == flat_navi_context_last_get()");
+       } else if (atspi_accessible_is_equal(obj, (ref = flat_navi_context_last_get(nd->flat_navi_context)))) {
+               DEBUG("obj is equal to flat_navi_context_last_get()");
                nd->auto_review_on = false;
        }
 
@@ -2330,7 +2331,7 @@ TIZEN_PROD_STATIC void on_gesture_detected(void *data, const Eldbus_Message *msg
                        if (!_current_highlight_on_keyboard_is(nd))
                                break;
                }
-               if (current_accessible == nd->current_obj)
+               if (atspi_accessible_is_equal(current_accessible, nd->current_obj))
                        _activate_widget(nd);
                else
                        DEBUG("Do not handle gesture, because current object is changed!");
@@ -2537,20 +2538,15 @@ TIZEN_PROD_STATIC void _view_content_changed(AtspiAccessible *root, AtspiRole ro
 
 TIZEN_PROD_STATIC void _new_highlighted_obj_changed(AtspiAccessible *new_highlighted_obj, AtspiRole role, void *user_data)
 {
-       gchar *prev_id, *next_id;
        NavigatorData *nd = user_data;
        if (!nd)  {
                ERROR("Navigator data required!");
                return;
        }
 
-       prev_id = atspi_accessible_get_unique_id(flat_navi_context_current_get(nd->flat_navi_context), NULL);
-       next_id = atspi_accessible_get_unique_id(new_highlighted_obj, NULL);
-       DEBUG("current highlighted obj: %s, new_highlighted obj: %s (role: %d)", prev_id, next_id, role);
-       g_free(prev_id);
-       g_free(next_id);
-
-       if (nd->flat_navi_context && ((nd->current_obj != new_highlighted_obj) || (flat_navi_context_current_get(nd->flat_navi_context) != new_highlighted_obj))) {
+       if (nd->flat_navi_context &&
+               (!atspi_accessible_is_equal(nd->current_obj, new_highlighted_obj) ||
+                !atspi_accessible_is_equal(flat_navi_context_current_get(nd->flat_navi_context), new_highlighted_obj))) {
                /* The application could change highlight directly, in this case
                scrreen reader should call atspi_component_clear_highlight using
                currently highlighted object */
index 870e3025936a941ca10e132c83e55cfeff9e0833..ba90f6996cd845719efd69b4e9f3a0e60e0bcf2a 100644 (file)
@@ -247,4 +247,3 @@ int get_accuracy(double val, int max_accuracy)
        }
        return accuracy;
 }
-
index c790e87c3286ea3ca7eac450326a252e0ffa7fe9..b01206e84b37dda96d3d8a0eb3029d0a86439457 100644 (file)
@@ -180,7 +180,7 @@ static Eina_Bool _is_window_in_stack(WindowTrackerData *wtd, AtspiAccessible *wi
        WindowInfo *wi;
 
        EINA_LIST_FOREACH(wtd->window_infos, l, wi)
-               if(wi && wi->window == window) return EINA_TRUE;
+               if(wi && atspi_accessible_is_equal(wi->window, window)) return EINA_TRUE;
 
        return EINA_FALSE;
 }
@@ -194,7 +194,7 @@ static void _window_append(WindowTrackerData *wtd, AtspiAccessible *window, Eina
        Eina_List *l, *l_prev;
        EINA_LIST_REVERSE_FOREACH_SAFE(wtd->window_infos, l, l_prev, wi) {
                if (!wi) continue;
-               if (wi->window == window) {
+               if (atspi_accessible_is_equal(wi->window, window)) {
                        g_object_unref(wi->window);
                        g_free(wi->rect);
                        g_free(wi);
@@ -256,7 +256,7 @@ static void _window_remove(WindowTrackerData *wtd, AtspiAccessible *window)
        AtspiAccessible *top_window;
 
        top_window = _top_window_get(wtd);
-       remove_from_top = (top_window == window);
+       remove_from_top = atspi_accessible_is_equal(top_window, window);
 
        Eina_Bool window_removed = EINA_FALSE;
        Eina_Bool view_change_need = EINA_FALSE;
@@ -266,7 +266,7 @@ static void _window_remove(WindowTrackerData *wtd, AtspiAccessible *window)
        int removed_index = 0;
        EINA_LIST_REVERSE_FOREACH_SAFE(wtd->window_infos, l, l_prev, wi) {
                if (!wi) continue;
-               if (wi->window == window) {
+               if (atspi_accessible_is_equal(wi->window, window)) {
                        view_change_need = wi->view_change_need;
                        keyboard_window_is = wi->keyboard_window_is;
                        g_object_unref(wi->window);
@@ -279,7 +279,7 @@ static void _window_remove(WindowTrackerData *wtd, AtspiAccessible *window)
                removed_index++;
        }
 
-       if (wtd->subroot && window == wtd->subroot) {
+       if (wtd->subroot && atspi_accessible_is_equal(window, wtd->subroot)) {
                DEBUG("Remove subroot: %p ", wtd->subroot);
                wtd->subroot = NULL;
        }
@@ -598,7 +598,7 @@ WindowActivateInfoType window_tracker_window_activate_info_type_get(WindowTracke
 
        EINA_LIST_REVERSE_FOREACH(wtd->window_infos, l, wi) {
                if (!wi) continue;
-               if (window == wi->window) {
+               if (atspi_accessible_is_equal(window, wi->window)) {
                        return wi->window_activate_info_type;
                }
        }