Fix multi-item <select> on desktop builds
authorAntonio Gomes <a1.gomes@samsung.com>
Thu, 16 Jul 2015 20:06:36 +0000 (16:06 -0400)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
There is a couple of small issues on the current implementation
of multi-item selects (read <select multiple="">...</select>)
when tested on desktop builds.

Patch basically:

* make Tizen-specific the assumption that 'elm_genlist_item_index_get'
  starts iterating from index '1'. This is really the case on GBS
  builds, but not on desktop builds.
  Looking at the public docs and EFL code, there is nothing about it.
  Also, on desktop builds, it was causing menuitems to be persisted in
  the wrong index when closing and opening a <select multiple=""> popups.

* change the insertion logic of selected menuitems into their container
  so that indexes are always sorted.
  Each menuitem in a select has a corresponding index.
  Active menuitem's indexes are stored in an array, and values
  vary from 0 to n-1, where 'n' is the number of menuitems.
  When an item is selected, its index used to be inserted unsorted,
  at the end of the array. On desktop builds, this was confusing the
  "compareChangedItems" function and causing index lookups to fail.

Test: WCS/select_picker_test.html
Reviewed by: DONGJUN KiM, arno renevier

Change-Id: I97faccb6ed627ed81473155610a2115333975381
Signed-off-by: Antonio Gomes <a1.gomes@samsung.com>
tizen_src/ewk/efl_integration/browser/selectpicker/popup_picker.cc

index f961f42..d8c300b 100644 (file)
@@ -100,14 +100,16 @@ void menuItemActivated(void* data, Evas_Object* obj, void* event_info) {
   Popup_Picker* picker = static_cast<Popup_Picker*>(data);
   Elm_Object_Item* selected = static_cast<Elm_Object_Item*>(event_info);
   int index = elm_genlist_item_index_get(selected);
+#if defined(OS_TIZEN)
   // elm_genlist_item_index_get iterrate starting from 1
   if (index > 0)
     index--;
+#endif
 
   if (picker->multiSelect) {
     int pos = eina_inarray_search(picker->changedList, &index, compareChangedItems);
     if (pos == -1)
-      eina_inarray_push(picker->changedList, &index);
+      eina_inarray_insert_sorted(picker->changedList, &index, compareChangedItems);
     else
       eina_inarray_remove(picker->changedList, &index);
   }
@@ -120,13 +122,16 @@ void menuItemDeactivated(void* data, Evas_Object* obj, void* event_info) {
   Elm_Object_Item* deselectedItem = static_cast<Elm_Object_Item*>(event_info);
 
   int deselectedIndex = elm_genlist_item_index_get(deselectedItem);
+#if defined(OS_TIZEN)
   // elm_genlist_item_index_get iterrate starting from 1
   if (deselectedIndex > 0)
     deselectedIndex--;
+#endif
+
   int pos = eina_inarray_search(picker->changedList, &deselectedIndex, compareChangedItems);
 
   if (pos == -1)
-    eina_inarray_push(picker->changedList, &deselectedIndex);
+    eina_inarray_insert_sorted(picker->changedList, &deselectedIndex, compareChangedItems);
   else
     eina_inarray_remove(picker->changedList, &deselectedIndex);