mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 032a3ba018db, It breaks <select> form element interactions (bug 961489, bug 961662)
This commit is contained in:
parent
5fce2fe5f7
commit
e78859a28f
@ -170,25 +170,18 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis
|
|||||||
|
|
||||||
/* Adds to a result value from the lists that can be shown in dialogs.
|
/* Adds to a result value from the lists that can be shown in dialogs.
|
||||||
* Will set the selected value(s) to the button attribute of the
|
* Will set the selected value(s) to the button attribute of the
|
||||||
* object that's passed in. If this is a multi-select dialog, sets a
|
* object that's passed in. If this is a multi-select dialog, can set
|
||||||
* selected attribute to an array of booleans.
|
* the button attribute to an array.
|
||||||
*/
|
*/
|
||||||
private void addListResult(final JSONObject result, int which) {
|
private void addListResult(final JSONObject result, int which) {
|
||||||
try {
|
try {
|
||||||
if (mSelected != null) {
|
if (mSelected != null) {
|
||||||
JSONArray selected = new JSONArray();
|
JSONArray selected = new JSONArray();
|
||||||
for (int i = 0; i < mSelected.length; i++) {
|
for (int i = 0; i < mSelected.length; i++) {
|
||||||
if (mSelected[i]) {
|
selected.put(mSelected[i]);
|
||||||
selected.put(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result.put("list", selected);
|
result.put("button", selected);
|
||||||
} else {
|
} else {
|
||||||
// Mirror the selected array from multi choice for consistency.
|
|
||||||
JSONArray selected = new JSONArray();
|
|
||||||
selected.put(which);
|
|
||||||
result.put("list", selected);
|
|
||||||
// Make the button be the index of the select item.
|
|
||||||
result.put("button", which);
|
result.put("button", which);
|
||||||
}
|
}
|
||||||
} catch(JSONException ex) { }
|
} catch(JSONException ex) { }
|
||||||
@ -229,12 +222,12 @@ public class Prompt implements OnClickListener, OnCancelListener, OnItemClickLis
|
|||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
try {
|
try {
|
||||||
ListView list = mDialog.getListView();
|
ListView list = mDialog.getListView();
|
||||||
addButtonResult(ret, which);
|
|
||||||
addInputValues(ret);
|
|
||||||
|
|
||||||
if (list != null || mSelected != null) {
|
if (list != null || mSelected != null) {
|
||||||
addListResult(ret, which);
|
addListResult(ret, which);
|
||||||
|
} else {
|
||||||
|
addButtonResult(ret, which);
|
||||||
}
|
}
|
||||||
|
addInputValues(ret);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
Log.i(LOGTAG, "Error building return: " + ex);
|
Log.i(LOGTAG, "Error building return: " + ex);
|
||||||
}
|
}
|
||||||
|
@ -37,25 +37,32 @@ var SelectHelper = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.show((function(data) {
|
p.show((function(data) {
|
||||||
let selected = data.list;
|
let selected = data.button;
|
||||||
|
if (selected == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
if (aElement instanceof Ci.nsIDOMXULMenuListElement) {
|
if (aElement instanceof Ci.nsIDOMXULMenuListElement) {
|
||||||
if (aElement.selectedIndex != selected[0]) {
|
if (aElement.selectedIndex != selected) {
|
||||||
aElement.selectedIndex = selected[0];
|
aElement.selectedIndex = selected;
|
||||||
this.fireOnCommand(aElement);
|
this.fireOnCommand(aElement);
|
||||||
}
|
}
|
||||||
} else if (aElement instanceof HTMLSelectElement) {
|
} else if (aElement instanceof HTMLSelectElement) {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
if (!Array.isArray(selected)) {
|
||||||
|
let temp = [];
|
||||||
|
for (let i = 0; i <= list.length; i++) {
|
||||||
|
temp[i] = (i == selected);
|
||||||
|
}
|
||||||
|
selected = temp;
|
||||||
|
}
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
this.forOptions(aElement, function(aNode) {
|
this.forOptions(aElement, function(aNode) {
|
||||||
if (aNode.selected == (selected.indexOf(i) == -1)) {
|
if (aNode.selected != selected[i]) {
|
||||||
changed = true;
|
changed = true;
|
||||||
aNode.selected = false;
|
aNode.selected = selected[i];
|
||||||
} else if (!aNode.selected == (selected.indexOf(i) != -1)) {
|
|
||||||
changed = true;
|
|
||||||
aNode.selected = true;
|
|
||||||
}
|
}
|
||||||
i++;
|
i++
|
||||||
});
|
});
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
|
Loading…
Reference in New Issue
Block a user