Moved state information reading before the atspi object name 60/279560/3
authorMaria Bialota <m.bialota@samsung.com>
Thu, 11 Aug 2022 11:35:15 +0000 (13:35 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Thu, 18 Aug 2022 11:26:51 +0000 (13:26 +0200)
Change-Id: I757fec8c4e3025a2249f8b90d15fd55732427eb9

src/reading_composer.c

index 342091a3c5db062702b75cce475f2e6c39243506..1ead1f943598206b1594128e1ce9f9e4244631d1 100644 (file)
@@ -508,6 +508,7 @@ char* reading_composer_description_get(ReadingComposerData *data)
        char *name_from_text_iface = NULL;
        char *state_from_role = NULL;
        AtspiAccessibleReadingMaterial *rm;
+       bool add_disabled_trait = false; /* set to true when states are requested to be read, but the object hasn't got ATSPI "enabled" state */
 
        if (!data)
                return NULL;
@@ -539,6 +540,23 @@ char* reading_composer_description_get(ReadingComposerData *data)
                }
        }
 
+       if (reading_attribute & ACCESSIBLE_READING_INFO_TYPE_STATE) {
+               DEBUG("START : ACCESSIBLE_READING_INFO_TYPE_STATE");
+               state_from_role = generate_state_trait(rm);
+               if (state_from_role && strlen(state_from_role) > 0) {
+                       if (eina_strbuf_length_get(buf))
+                               ESAL(buf, " , ");
+                       ESAL(buf, state_from_role);
+               }
+               if (!STATE_SET_CONTAINS(rm->states, ATSPI_STATE_ENABLED)) {
+                       /* Lack of ATSPI "enabled" state results means the object is disabled. */
+                       /* This should be read at the end of the description, so we keep it for later. */
+                       add_disabled_trait = true;
+               }
+               SCREEN_READER_SAFE_FREE(state_from_role, free);
+               DEBUG("END : ACCESSIBLE_READING_INFO_TYPE_STATE");
+       }
+
        if (reading_attribute & ACCESSIBLE_READING_INFO_TYPE_NAME) {
                DEBUG("START : ACCESSIBLE_READING_INFO_TYPE_NAME");
                name = rm->name;
@@ -584,21 +602,11 @@ char* reading_composer_description_get(ReadingComposerData *data)
                SCREEN_READER_SAFE_FREE(role_name, free);
                DEBUG("END : ACCESSIBLE_READING_INFO_TYPE_ROLE");
        }
-       if (reading_attribute & ACCESSIBLE_READING_INFO_TYPE_STATE) {
-               DEBUG("START : ACCESSIBLE_READING_INFO_TYPE_STATE");
-               state_from_role = generate_state_trait(rm);
-               if (state_from_role && strlen(state_from_role) > 0) {
-                       if (eina_strbuf_length_get(buf))
-                               ESAL(buf, " , ");
-                       ESAL(buf, state_from_role);
-               }
-               if (!STATE_SET_CONTAINS(rm->states, ATSPI_STATE_ENABLED)) {
-                       if (eina_strbuf_length_get(buf))
-                               ESAL(buf, " , ");
-                       ESAL(buf, _("IDS_ACCS_BODY_DISABLED_TTS"));
-               }
-               SCREEN_READER_SAFE_FREE(state_from_role, free);
-               DEBUG("END : ACCESSIBLE_READING_INFO_TYPE_STATE");
+       /* "Disabled" trait should be read at the end of the description */
+       if (add_disabled_trait) {
+               if (eina_strbuf_length_get(buf))
+                       ESAL(buf, " , ");
+               ESAL(buf, _("IDS_ACCS_BODY_DISABLED_TTS"));
        }
 
        DEBUG("RESULT: %s", eina_strbuf_string_get(buf));