summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadoslaw Cybulski <r.cybulski@partner.samsung.com>2018-02-02 08:53:42 +0100
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>2018-02-02 09:05:13 +0100
commitcc2e43cc4b34c4816ac13d5edaa62907e737fa86 (patch)
treef8ad0767270986372618187e84bbc21609b71b48
parentd4fcff7ed43bf5b4e6e44767c9f9a1acf5535137 (diff)
elm: fix for invalid attribute matching
Summary: Fixes invalid attribute matching in at-spi's collection interface's GetMatches*** functions. Reviewers: stanluk Reviewed By: stanluk Subscribers: lukasz.stanislawski, cedric Differential Revision: https://phab.enlightenment.org/D5774
-rw-r--r--src/lib/elementary/elm_atspi_bridge.c92
1 files changed, 72 insertions, 20 deletions
diff --git a/src/lib/elementary/elm_atspi_bridge.c b/src/lib/elementary/elm_atspi_bridge.c
index 09ea6a1693..8d5cfe7fdf 100644
--- a/src/lib/elementary/elm_atspi_bridge.c
+++ b/src/lib/elementary/elm_atspi_bridge.c
@@ -16,6 +16,7 @@
16#include "atspi/atspi-constants.h" 16#include "atspi/atspi-constants.h"
17 17
18#include <stdint.h> 18#include <stdint.h>
19#include <assert.h>
19#include <Elementary.h> 20#include <Elementary.h>
20#include "elm_priv.h" 21#include "elm_priv.h"
21 22
@@ -2640,26 +2641,82 @@ _collection_match_roles_lookup(Eo *obj, struct collection_match_rule *rule)
2640} 2641}
2641 2642
2642static Eina_Bool 2643static Eina_Bool
2643_collection_match_attributes_helper(Eina_List *obj_attribs, Eina_List *attribs, Eina_Bool compare, Eina_Bool ret_if_compare, Eina_Bool ret_default) 2644_collection_match_attributes_helper(Eina_List *obj_attribs, Eina_List *attribs, AtspiCollectionMatchType mode)
2644{ 2645{
2645 Eina_List *l, *l2; 2646 Eina_List *l, *l2;
2646 Efl_Access_Attribute *attr, *attr2; 2647 Efl_Access_Attribute *attr, *attr2;
2648 Eina_Bool obj_empty = eina_list_count(obj_attribs) == 0;
2649 Eina_Bool empty = eina_list_count(attribs) == 0;
2647 2650
2651 switch (mode)
2652 {
2653 case ATSPI_Collection_MATCH_ANY:
2654 if (empty || obj_empty) return EINA_FALSE;
2655 break;
2656 case ATSPI_Collection_MATCH_ALL:
2657 if (empty) return EINA_TRUE;
2658 if (obj_empty) return EINA_FALSE;
2659 break;
2660 case ATSPI_Collection_MATCH_NONE:
2661 if (empty || obj_empty) return EINA_TRUE;
2662 break;
2663 case ATSPI_Collection_MATCH_EMPTY:
2664 if (empty && obj_empty) return EINA_TRUE;
2665 if (empty || obj_empty) return EINA_FALSE;
2666 break;
2667 case ATSPI_Collection_MATCH_INVALID:
2668 case ATSPI_Collection_MATCH_LAST_DEFINED:
2669 assert(0);
2670 break;
2671 }
2648 EINA_LIST_FOREACH(attribs, l, attr) 2672 EINA_LIST_FOREACH(attribs, l, attr)
2649 { 2673 {
2650 EINA_LIST_FOREACH(obj_attribs, l2, attr2) 2674 Eina_Bool found = EINA_FALSE;
2651 { 2675 EINA_LIST_FOREACH(obj_attribs, l2, attr2)
2652 if ((attr->key && attr2->key && 2676 {
2653 attr->value && attr2->value && 2677 Eina_Bool compare = (attr->key && attr2->key &&
2654 !strcmp(attr->key, attr2->key) && 2678 attr->value && attr2->value &&
2655 !strcmp(attr->value, attr2->value)) == compare) 2679 !strcmp(attr->key, attr2->key) &&
2656 { 2680 !strcmp(attr->value, attr2->value));
2657 return ret_if_compare; 2681 if (compare)
2658 } 2682 {
2659 } 2683 found = EINA_TRUE;
2684 break;
2685 }
2686 }
2687 switch (mode)
2688 {
2689 case ATSPI_Collection_MATCH_EMPTY:
2690 case ATSPI_Collection_MATCH_ALL:
2691 if (!found) return EINA_FALSE;
2692 break;
2693 case ATSPI_Collection_MATCH_ANY:
2694 if (found) return EINA_TRUE;
2695 break;
2696 case ATSPI_Collection_MATCH_NONE:
2697 if (found) return EINA_FALSE;
2698 break;
2699 case ATSPI_Collection_MATCH_INVALID:
2700 case ATSPI_Collection_MATCH_LAST_DEFINED:
2701 assert(0);
2702 break;
2703 }
2660 } 2704 }
2661 2705
2662 return ret_default; 2706 switch (mode)
2707 {
2708 case ATSPI_Collection_MATCH_EMPTY:
2709 case ATSPI_Collection_MATCH_ALL:
2710 case ATSPI_Collection_MATCH_NONE:
2711 return EINA_TRUE;
2712 case ATSPI_Collection_MATCH_ANY:
2713 return EINA_FALSE;
2714 case ATSPI_Collection_MATCH_INVALID:
2715 case ATSPI_Collection_MATCH_LAST_DEFINED:
2716 assert(0);
2717 break;
2718 }
2719 return EINA_FALSE;
2663} 2720}
2664 2721
2665static Eina_Bool 2722static Eina_Bool
@@ -2676,18 +2733,13 @@ _collection_match_attributes_lookup(Eo *obj, struct collection_match_rule *rule)
2676 ret = EINA_TRUE; 2733 ret = EINA_TRUE;
2677 break; 2734 break;
2678 case ATSPI_Collection_MATCH_ALL: 2735 case ATSPI_Collection_MATCH_ALL:
2679 ret = _collection_match_attributes_helper(
2680 obj_attribs, rule->attributes, EINA_FALSE, EINA_FALSE, EINA_TRUE);
2681 break;
2682 case ATSPI_Collection_MATCH_ANY: 2736 case ATSPI_Collection_MATCH_ANY:
2683 ret = _collection_match_attributes_helper(
2684 obj_attribs, rule->attributes, EINA_TRUE, EINA_TRUE, EINA_FALSE);
2685 break;
2686 case ATSPI_Collection_MATCH_NONE: 2737 case ATSPI_Collection_MATCH_NONE:
2687 ret = _collection_match_attributes_helper( 2738 case ATSPI_Collection_MATCH_EMPTY:
2688 obj_attribs, rule->attributes, EINA_TRUE, EINA_FALSE, EINA_TRUE); 2739 ret = _collection_match_attributes_helper(obj_attribs, rule->attributes, rule->attributematchtype);
2689 break; 2740 break;
2690 default: 2741 default:
2742 DBG("invalid match type");
2691 break; 2743 break;
2692 } 2744 }
2693 2745